diff --git a/src/main/codex-accounts/runtime-home-service.test.ts b/src/main/codex-accounts/runtime-home-service.test.ts index 966d901f994..770eed0a470 100644 --- a/src/main/codex-accounts/runtime-home-service.test.ts +++ b/src/main/codex-accounts/runtime-home-service.test.ts @@ -2480,7 +2480,7 @@ describe('CodexRuntimeHomeService', () => { '', '[model_providers.codex-lb]', 'base_url = "https://codex-lb.example.test/v1"', - 'env_key = "CODEX_LB_API_KEY"', + 'env_key = "EXAMPLE_GATEWAY_TOKEN"', '' ].join('\n') writeFileSync(canonicalConfigPath, canonicalConfig, 'utf-8') diff --git a/src/main/codex-accounts/service.test.ts b/src/main/codex-accounts/service.test.ts index ec80a01c3be..8d50c1bebe5 100644 --- a/src/main/codex-accounts/service.test.ts +++ b/src/main/codex-accounts/service.test.ts @@ -831,7 +831,7 @@ describe('CodexAccountService config sync', () => { '[model_providers.codex-lb]', 'name = "Codex load balancer"', 'base_url = "https://codex-lb.example.test/v1"', - 'env_key = "CODEX_LB_API_KEY"', + 'env_key = "EXAMPLE_GATEWAY_TOKEN"', '' ].join('\n') writeFileSync(canonicalConfigPath, canonicalConfig, 'utf-8') diff --git a/src/main/codex/codex-structured-child-environment.test.ts b/src/main/codex/codex-structured-child-environment.test.ts index 3aa1982bc89..98e988ec7d5 100644 --- a/src/main/codex/codex-structured-child-environment.test.ts +++ b/src/main/codex/codex-structured-child-environment.test.ts @@ -12,12 +12,12 @@ describe('buildCodexStructuredChildEnvironment', () => { cwd: '/worktree', codexHome: '/pinned/home', resumeThreadId: null, - env: { CODEX_LB_API_KEY: 'shell-exported', CODEX_HOME: '/shell/home' } + env: { EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/shell/home' } }, 'spawn-token' ) ).toEqual({ - CODEX_LB_API_KEY: 'shell-exported', + EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/pinned/home', [CODEX_SPAWN_TOKEN_ENV]: 'spawn-token' }) diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-launch-env.test.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-launch-env.test.ts index 861032a727f..feab90d7b8f 100644 --- a/src/main/native-chat/agent-session-wire/structured-agent-session-launch-env.test.ts +++ b/src/main/native-chat/agent-session-wire/structured-agent-session-launch-env.test.ts @@ -6,12 +6,12 @@ describe('pinnedAgentSessionLaunchEnv', () => { it('layers the pinned account home over the shell environment', async () => { await expect( pinnedAgentSessionLaunchEnv( - async () => ({ CODEX_LB_API_KEY: 'shell-exported', CODEX_HOME: '/shell/home' }), + async () => ({ EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/shell/home' }), hostTestAttachParams(null) ) ).resolves.toEqual({ launchEnv: { - CODEX_LB_API_KEY: 'shell-exported', + EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/home/dev/.codex' } }) diff --git a/src/main/runtime/structured-agent-session-integration.test.ts b/src/main/runtime/structured-agent-session-integration.test.ts index 8fd99002417..eb200020d0f 100644 --- a/src/main/runtime/structured-agent-session-integration.test.ts +++ b/src/main/runtime/structured-agent-session-integration.test.ts @@ -310,7 +310,7 @@ beforeEach(async () => { resolveWorkspacePath: async (workspaceId) => `/repos/${workspaceId}`, resolveCodexCommand: () => '/usr/local/bin/codex', resolveLaunchEnv: async () => ({ - CODEX_LB_API_KEY: 'shell-exported', + EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/shell/home' }), openCodexConnection: codex.openConnection @@ -393,7 +393,7 @@ describe('a structured codex session over agentSession.*', () => { ) expect(created.snapshot.items).toEqual([]) expect(codex.live().launch.env).toMatchObject({ - CODEX_LB_API_KEY: 'shell-exported', + EXAMPLE_GATEWAY_TOKEN: 'shell-exported', CODEX_HOME: '/home/dev/.codex' }) const stream = await subscribe('sub-first-send') diff --git a/src/main/startup/login-shell-environment.test.ts b/src/main/startup/login-shell-environment.test.ts index c91eacee8b0..230623c71a6 100644 --- a/src/main/startup/login-shell-environment.test.ts +++ b/src/main/startup/login-shell-environment.test.ts @@ -40,12 +40,12 @@ describe('resolveLoginShellEnvironment', () => { it('returns variables exported by the profile-loading shell', async () => { const spawner = vi.fn(async () => ({ ...process.env, - CODEX_LB_API_KEY: 'shell-exported' + EXAMPLE_GATEWAY_TOKEN: 'shell-exported' })) await expect( resolveLoginShellEnvironment({ shellOverride: '/bin/zsh', spawner }) - ).resolves.toMatchObject({ CODEX_LB_API_KEY: 'shell-exported' }) + ).resolves.toMatchObject({ EXAMPLE_GATEWAY_TOKEN: 'shell-exported' }) }) it.runIf(process.platform !== 'win32')( diff --git a/src/renderer/src/lib/worktree-activation.ts b/src/renderer/src/lib/worktree-activation.ts index 52b5589294c..35e03db418d 100644 --- a/src/renderer/src/lib/worktree-activation.ts +++ b/src/renderer/src/lib/worktree-activation.ts @@ -267,7 +267,9 @@ export function activateAndRevealFolderWorkspace( !opts?.startup && workspaceHasSleepingAgentSessions(state, workspaceKey) if (shouldGateAutoResume) { void gateWorktreeAgentActivation(workspaceKey).then(() => { - ensureFolderWorkspaceInitialTerminal(folderWorkspace) + if (useAppStore.getState().activeWorktreeId === workspaceKey) { + ensureFolderWorkspaceInitialTerminal(folderWorkspace) + } }) } const primaryTabId = shouldGateAutoResume @@ -351,7 +353,10 @@ export function activateAndRevealWorktree( !hasActivationWork && workspaceHasSleepingAgentSessions(postActivationState, worktreeId) if (shouldGateAutoResume) { void gateWorktreeAgentActivation(worktreeId).then(() => { - ensureWorktreeHasInitialTerminal(useAppStore.getState(), worktreeId) + const currentState = useAppStore.getState() + if (currentState.activeWorktreeId === worktreeId) { + ensureWorktreeHasInitialTerminal(currentState, worktreeId) + } }) }