fix(runtime): retire stale pane agent identity

This commit is contained in:
Brennan Benson
2026-08-25 14:14:07 -07:00
parent bcc2471b88
commit 447a03f89a
3 changed files with 33 additions and 1 deletions
@@ -73,4 +73,28 @@ describe('provider reattach launch identity', () => {
launchIncarnationId: null
})
})
it('retires daemon launch identity when the agent command finishes', () => {
const runtime = new OrcaRuntimeService(null)
runtime.registerPty('pty-finished-reattach', WORKTREE_ID, null, {
tabId: TAB_ID,
leafId: LEAF_ID,
incarnationId: INCARNATION_ID,
providerReattachLaunchIdentity: {
incarnationId: INCARNATION_ID,
launchAgent: 'codex'
}
})
runtime.emitDaemonPtyTransientFact('pty-finished-reattach', {
kind: 'command-finished',
exitCode: 0
})
expect(getPty(runtime, 'pty-finished-reattach')).toMatchObject({
launchAgent: null,
launchToken: null,
launchIncarnationId: null
})
})
})
+7
View File
@@ -13330,6 +13330,7 @@ describe('OrcaRuntimeService', () => {
const terminal = await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`, {
command: 'codex',
launchAgent: 'codex',
launchConfig: { agentCommand: 'codex', agentArgs: '', agentEnv: {} }
})
const spawnEnv =
@@ -13346,6 +13347,9 @@ describe('OrcaRuntimeService', () => {
launchToken: spawnEnv.ORCA_AGENT_LAUNCH_TOKEN
})
).toBeDefined()
expect((await runtime.listTerminals()).terminals).toEqual([
expect.objectContaining({ handle: terminal.handle, agentIdentity: 'codex' })
])
runtime.onPtyData('pty-authority', '\x1b]133;D;0\x07', 100)
@@ -13356,6 +13360,9 @@ describe('OrcaRuntimeService', () => {
launchToken: spawnEnv.ORCA_AGENT_LAUNCH_TOKEN
})
).toBeUndefined()
expect((await runtime.listTerminals()).terminals).toEqual([
expect.not.objectContaining({ agentIdentity: expect.anything() })
])
})
it('retires only receipted restored PTY authority on command completion and exit', () => {
+2 -1
View File
@@ -14063,13 +14063,14 @@ export class OrcaRuntimeService {
return
}
const receipt = this.restoredOrchestrationAuthorityByPtyId.get(ptyId)
if (!pty.launchToken && !receipt) {
if (!pty.launchToken && !receipt && !pty.launchAgent) {
return
}
const paneKeys = this.collectPaneKeysForPty(ptyId)
this.restoredOrchestrationAuthorityByPtyId.delete(ptyId)
pty.launchToken = null
pty.launchIncarnationId = null
pty.launchAgent = null
for (const paneKey of paneKeys) {
this.retireAgentHookCompatibilityAuthorityFn?.(paneKey)
}