fix(orchestration): leave a hook row a newer terminal in the pane owns

This commit is contained in:
Jinwoo-H
2026-11-10 20:27:45 -05:00
parent c7fd3bd361
commit c733d18eb7
2 changed files with 12 additions and 2 deletions
@@ -72,6 +72,7 @@ describe('worker terminal recovery after a crash', () => {
hasPty: () => false,
listProcesses: async () => []
})
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: recovery calls only this notifier method.
runtime.setNotifier({ resolveLegacyWorkerTerminalRecovery: vi.fn() } as never)
await expect(runtime.reconcileLegacyWorkerTerminals()).resolves.toMatchObject({
@@ -78,8 +78,17 @@ export abstract class LegacyWorkerTerminalSurface extends OrcaRuntimeWithRestore
if (pty && this.paneOfPty(pty).tabId === candidate.tabId) {
forgetPtySurface(this.terminalIdentity, pty)
}
// Why: an exit this run never saw leaves the pane's restored hook row holding the conversation.
this.reconcileAgentStatusForEndedProcessFn?.([candidate.paneKey])
// Why: an exit this run never saw leaves the pane's restored hook row holding the conversation;
// a newer terminal already in the pane owns that row.
const paneTakenOver =
(leaf?.ptyId && leaf.ptyId !== candidate.ptyId) ||
[...this.ptysById.values()].some(
(other) =>
other.ptyId !== candidate.ptyId && this.paneOfPty(other).paneKey === candidate.paneKey
)
if (!paneTakenOver) {
this.reconcileAgentStatusForEndedProcessFn?.([candidate.paneKey])
}
this.notifier?.resolveLegacyWorkerTerminalRecovery?.(
candidate.paneKey,
'rolled_back',