Files
orca/src/main/persistence/loading-store/replaced-pane-binding.ts
T
40f9e7a3fc fix(codex): resume account switches without blanking the terminal (#25485)
fix(codex): restart account switches without blanking or repinning the pane

Integrate the atomic pane replacement from #24350 and adapt the explicit
conversation resume from #14877. Keep terminal protocol replies flowing
while account notices block user input. Ordinary restores retain provenance.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
Co-authored-by: itisvincent <vincentcgamer@gmail.com>
Co-authored-by: rayim <rayim@fxy.global>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-10-05 01:51:49 -07:00

34 lines
1.3 KiB
TypeScript

import type { WorkspaceSessionState } from '../../../shared/workspace-session-state-types'
import type { RetiredTerminalSurface } from '../../runtime/mobile-session-terminal-retirement'
/** The caller fences the old owner; a restart keeps the pane and removes only its process binding. */
export function clearReplacedPaneBinding(
session: WorkspaceSessionState,
surface: RetiredTerminalSurface
): WorkspaceSessionState {
const layout = session.terminalLayoutsByTabId[surface.parentTabId]
if (!layout || layout.ptyIdsByLeafId?.[surface.leafId] !== surface.ptyId) {
return session
}
const ptyIdsByLeafId = { ...layout.ptyIdsByLeafId }
delete ptyIdsByLeafId[surface.leafId]
const terminalPtyIncarnationsByPaneKey = { ...session.terminalPtyIncarnationsByPaneKey }
delete terminalPtyIncarnationsByPaneKey[`${surface.parentTabId}:${surface.leafId}`]
return {
...session,
terminalPtyIncarnationsByPaneKey,
terminalLayoutsByTabId: {
...session.terminalLayoutsByTabId,
[surface.parentTabId]: { ...layout, ptyIdsByLeafId }
},
tabsByWorktree: {
...session.tabsByWorktree,
[surface.worktreeId]: (session.tabsByWorktree[surface.worktreeId] ?? []).map((tab) =>
tab.id === surface.parentTabId && tab.ptyId === surface.ptyId
? { ...tab, ptyId: null }
: tab
)
}
}
}