fix structured activation composition follow-ups

This commit is contained in:
Brennan Benson
2026-08-13 16:07:55 -07:00
parent 57cc51ebd0
commit 023f0dfb42
7 changed files with 17 additions and 12 deletions
@@ -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')
+1 -1
View File
@@ -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')
@@ -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'
})
@@ -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'
}
})
@@ -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')
@@ -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')(
+7 -2
View File
@@ -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)
}
})
}