Repository navigation
fix(codex): keep a dismissed restart notice from killing the pane's keyboard - #10802
Merged
brennanb2025 merged 5 commits intoJul 27, 2026
Conversation
…e pane's launch account
Dismissing the Codex restart prompt deleted the notice record, and
`previousAccountLabel` on that record is the renderer's only memory of the
account the pane actually launched under. With it gone, re-selecting the pane's
original account read as a fresh switch and created an inverted notice
{previous: B, next: A} — and since `isCodexPaneStale` treats any notice as
stale, that false notice silently dropped every keystroke in the pane.
Keep the record and mark it `dismissed` instead. Two shared predicates
(`blocksCodexPaneInput`, `awaitsCodexRestartAnswer`) hold the deliberate
asymmetry between the two answered states in one place: a queued restart still
blocks input because the pane runs under the old account until it relaunches,
while a dismissal frees the keyboard immediately because keeping that account is
what the user asked for. A dismissal is not carried across a later switch, so a
genuinely different third account still prompts.
`isCodexPaneStale` consulted the tab-level `tab.ptyId` even when the pane held its own notice record. In a split tab `tab.ptyId` is whichever pane bound last, so a pane the user had answered "Keep old account" for kept a dead keyboard because a sibling still held an unanswered notice — with no prompt of its own to explain it, which is the exact outcome the dismissed marker exists to prevent. The panes drift apart in practice: dismissal forgets the pane's launch record, and a later switch only re-marks panes whose foreground process is Codex right then, so a sibling can pick up a fresh notice while this pane keeps its dismissal. The pane's own record is now the last word; the tab lookup stays as the reconnect-race fallback it was written for, used only when the pane has no record. Also strips `dismissed` when `queueCodexPaneRestarts` sets `restartRequested`, mirroring the strip already in `dismissCodexRestartNotices`. Both queue call sites filter dismissed panes out today, so this is unreachable rather than a live bug, but the combined state resolves as "dismissed wins" in `blocksCodexPaneInput` — input flowing freely in a pane that is still on the old account with a restart queued.
… pane A pane with no notice of its own still fell through to the tab-level `tab.ptyId` check, so in a split tab a plain shell inherited whichever pane bound last. Once that sibling's restart was requested the prompt is gone, so the innocent pane's keyboard went dead with nothing on screen to answer. The fallback is only needed for a pane whose transport has not bound: both transports refuse writes while their pty binding is null (pty-transport sendInput, remote-runtime sendInput gate on it), so the tab's persisted id is the only evidence of which shell that pane will reach. A bound pane's own ptyId is exactly where its keystrokes go, so its own record is authoritative.
Adding a Codex account and reauthenticating the active one both re-mark every live pane with the active account unchanged. Once a dismissed notice survives as launch-account memory, that re-mark rebuilt the record without the marker, resurrecting a prompt the user had answered and re-blocking the pane's keyboard. Carry `dismissed` forward when the target account is the one the dismissal already answered.
Both were added by this PR onto the gate whose false positives silently kill a pane's keyboard, so a wrong mental model here is expensive. `tab.ptyId` does not name the pane that bound last: `updateTabPtyId` keeps the first binder (`currentTabPtyId ?? nextPtyIds[0]`, "later split-pane spawns must not steal it") and only `clearTabPtyId` demotes it to the last survivor. And a keystroke on an unbound pane does not arm recovery against `tab.ptyId` — `requestTerminalPaneRecovery` targets `ptyIdsByTabId[tabId][0]`, which diverges from `tab.ptyId` in split tabs. The reasoning the fixes rest on is unchanged: `tab.ptyId` holds *some sibling's* id rather than this pane's, which is what makes it wrong to gate a bound pane on. Comments only — no behavior change.
brennanb2025
merged commit Jul 27, 2026
34e179e
into
brennanb2025/fix-codex-account-switch
4 checks passed
brennanb2025
added a commit
that referenced
this pull request
Jul 28, 2026
…count switch (#10770) Fixes #10757. Switching Codex accounts broke three ways, all rooted in the self-contained per-account CODEX_HOME from #9501. HISTORY DISAPPEARED. Codex's own /resume picker only lists rollouts under the launch CODEX_HOME, and nothing bridged history into a per-account home — only the AI Vault's discovery scan knew about the other homes. Every other Orca-visible home's rollouts are now hardlinked in, on selection and again at launch, so one physical log is listed everywhere. THE RESTART PANEL STUCK. A queued restart was only drained by a mounted TerminalPane, but the prompt covered every stale pane in the worktree including parked and cold-deferred tabs. Requesting a restart now answers the prompt immediately while the pane keeps its pending restart, and a pane drains it when its reconnected PTY binds. PANES STAYED ON THE OLD ACCOUNT. CODEX_HOME is fixed in a shell's environment at spawn and the daemon keeps those shells alive across app restarts, while the restart notices are renderer state and are discarded. Each PTY's launch account is now recorded on disk and compared against the current selection at startup. Also merged in: #10802 (a dismissed notice no longer kills the pane's keyboard), #10803 (the sweep arms on real PTY binds, and launcher Codex panes are no longer filtered out by Windows deepest-process reporting), #10804 (a resume-pinned pane now says which account it is on), #10870 (the restart card no longer parks focus on its destructive Restart button), #10853 (the retry ladder is widened past the Windows worst case). Six independent reviews found real defects in every original PR, several of them dead-keyboard bugs and three introduced by the fix for another defect in the same loop. Live QA on macOS covered every PR; Windows was validated three times. WINDOWS: pass 1 found two defects that made the stale-account fix a no-op there (the sweep fired before any PTY was bound and never retried; launcher panes were filtered out). Pass 3 at the merged head: the prompt appears on its own after a restart — warm ~3.7-4.2s, cold ~21s needing rung 4, so #10853's widening was load-bearing rather than precautionary; an ordinary sentence typed into a healthy pane while another pane's card is up reaches that pane and kills nothing; a pane running vim after exiting Codex gets no card, still none 45s later. auth.json byte-identical across every pass. KNOWN GAPS, stated rather than implied: #10804 is unverified on Windows (auto-resume could not be manufactured there); cross-volume Windows is untested and expected to yield no bridged history (EXDEV, and Codex ignores symlinked rollouts); a cold-parked pane never binds so the sweep never covers it; the subagent-deepest launcher shape could not be reproduced on Windows, so that branch is fixture-verified only; WSL passed isolation but the resume mechanism is host-lane only. A host-account switch also marks and mutes live SSH remote panes — confirmed pre-existing on main by two independent QA runs — tracked separately in #10992. Related pre-existing defect filed as #10863.
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…count switch (stablyai#10770) Fixes stablyai#10757. Switching Codex accounts broke three ways, all rooted in the self-contained per-account CODEX_HOME from stablyai#9501. HISTORY DISAPPEARED. Codex's own /resume picker only lists rollouts under the launch CODEX_HOME, and nothing bridged history into a per-account home — only the AI Vault's discovery scan knew about the other homes. Every other Orca-visible home's rollouts are now hardlinked in, on selection and again at launch, so one physical log is listed everywhere. THE RESTART PANEL STUCK. A queued restart was only drained by a mounted TerminalPane, but the prompt covered every stale pane in the worktree including parked and cold-deferred tabs. Requesting a restart now answers the prompt immediately while the pane keeps its pending restart, and a pane drains it when its reconnected PTY binds. PANES STAYED ON THE OLD ACCOUNT. CODEX_HOME is fixed in a shell's environment at spawn and the daemon keeps those shells alive across app restarts, while the restart notices are renderer state and are discarded. Each PTY's launch account is now recorded on disk and compared against the current selection at startup. Also merged in: stablyai#10802 (a dismissed notice no longer kills the pane's keyboard), stablyai#10803 (the sweep arms on real PTY binds, and launcher Codex panes are no longer filtered out by Windows deepest-process reporting), stablyai#10804 (a resume-pinned pane now says which account it is on), stablyai#10870 (the restart card no longer parks focus on its destructive Restart button), stablyai#10853 (the retry ladder is widened past the Windows worst case). Six independent reviews found real defects in every original PR, several of them dead-keyboard bugs and three introduced by the fix for another defect in the same loop. Live QA on macOS covered every PR; Windows was validated three times. WINDOWS: pass 1 found two defects that made the stale-account fix a no-op there (the sweep fired before any PTY was bound and never retried; launcher panes were filtered out). Pass 3 at the merged head: the prompt appears on its own after a restart — warm ~3.7-4.2s, cold ~21s needing rung 4, so stablyai#10853's widening was load-bearing rather than precautionary; an ordinary sentence typed into a healthy pane while another pane's card is up reaches that pane and kills nothing; a pane running vim after exiting Codex gets no card, still none 45s later. auth.json byte-identical across every pass. KNOWN GAPS, stated rather than implied: stablyai#10804 is unverified on Windows (auto-resume could not be manufactured there); cross-volume Windows is untested and expected to yield no bridged history (EXDEV, and Codex ignores symlinked rollouts); a cold-parked pane never binds so the sweep never covers it; the subagent-deepest launcher shape could not be reproduced on Windows, so that branch is fixture-verified only; WSL passed isolation but the resume mechanism is host-lane only. A host-account switch also marks and mutes live SSH remote panes — confirmed pre-existing on main by two independent QA runs — tracked separately in stablyai#10992. Related pre-existing defect filed as stablyai#10863.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #10770 — base is
brennanb2025/fix-codex-account-switch, notmain.Root cause
isCodexPaneStale(pty-connection.ts:819, consumed at the pane'sonDatahandler) treats any Codex restart notice on a pty as "stale" and makes the handler return early — while a notice exists, every keystroke in that pane is silently dropped. That's deliberate: don't let work run under the wrong account. But it means any wrong notice state is a terminal that ignores typing.Dismissing the prompt ("Keep old account") called
clearCodexRestartNotice, which deletes the notice record.previousAccountLabelon that record is the renderer's only memory of the account the pane actually launched under, and it's whatmarkCodexRestartNoticesuses for its A → B → A collapse (terminals.ts, "a live Codex pane keeps its original launch account until it actually restarts"). With the record gone, re-selecting the pane's original account A read as a fresh switch:The prompt then reads "Codex is still signed in as B. Restart this session to use A" with the labels backwards, and — because a notice exists — the pane's keyboard goes dead.
Verified myself, and confirmed pre-existing on
origin/main. I did not take the report on faith: I wrote the repro against the store before touching anything and watched it produce{previousAccountLabel: "[email protected]", nextAccountLabel: "[email protected]"}.origin/main(fd7ebe3) carries a byte-identicalmarkCodexRestartNoticescollapse, a byte-identicalclearCodexRestartNotice, and a byte-identicalisCodexPaneStale, so the bug reproduces there too. #10770 does not introduce it — its startup sweep, which re-raises notices at launch, makes wrong notice state much more reachable.The fix
A
dismissed?: truemarker onCodexRestartNotice, so a dismissal is remembered rather than erasing the pane's launch-account memory. New store actiondismissCodexRestartNotices(ptyIds)marks instead of deleting.clearCodexRestartNoticeis deliberately left alone: its other caller (TerminalPane.tsx:1596) fires when the pane actually relaunches, and there the record must genuinely die — the pane now runs under the new account, so its launch memory has to reset. Conflating the two would suppress a legitimate later prompt. There's a regression test for exactly that.Two shared predicates in the new
codex-restart-notice-state.tskeep the asymmetry between the two answered states in one place, honoured by every consumer:restartRequesteddismissedJustification for the input gate.
restartRequestedmeans the user asked for a restart but the pane hasn't relaunched yet — it is still running under the old account, so letting keystrokes through would run work under the wrong account, which is the entire reason the gate exists.dismissedmeans the user explicitly chose to keep that account: there is no wrong-account hazard left, and leaving the terminal dead would punish them for answering the prompt. A dismissal that kills the keyboard is the worst possible outcome, so the keyboard comes back immediately.Consumers updated:
isCodexPaneStale(both the live-pty path and the tab-id reconnect fallback),collectStalePtyIdsForTabs(CodexRestartChip.tsx),summarizeCodexRestartStatus(status bar), plusselectCodexRestartInputs— that selector gated on "any notice exists", which would now leave every mounted chip permanently subscribed to pty-lifecycle churn after a single dismissal, so it gates on "any unanswered notice" instead.A dismissal is not carried across a later switch. It answered "keep A instead of B", which says nothing about a later C. Switching to a genuinely different third account rebuilds the notice as
{previous: A, next: C}— correct labels, taken from the surviving launch memory — and prompts. Over-suppressing here would silently strand the pane on A. (restartRequestedis carried over, since a queued restart relaunches under whatever is selected when it runs; that behaviour is unchanged.)Durability across app restart composes with #10770 rather than duplicating it. The two layers are doing different jobs: the renderer marker is in-session memory and the input unblock;
codexAccounts:forgetStalePanesdrops the on-disk launch record so the startup sweep doesn't re-raise. Dismissal still calls both. No change to the main-process registry.Mutation proof
Five targeted mutations, each reverting one part of the fix and re-running. Every one produced failures — no test passes with or without the production change:
blocksCodexPaneInputignoresdismissedawaitsCodexRestartAnswerignoresdismissedmarkCodexRestartNoticescarriesdismissedforward (over-suppression)dismissCodexRestartNoticesdeletes the record (the original bug)blocksCodexPaneInputalso excludesrestartRequestedMutation 5 matters: it proves the "restart requested still blocks input" test is discriminating rather than passing incidentally.
Acceptance
pty-connectioninput-gate tests (mutation 1).codex-stale-pane-accounts.test.ts("stops reporting a pane the user chose to keep"), which uses a discriminating second pane; the chip test assertsforgetStalePanesis still called on dismiss.Gates
All run and clean:
tsc× 3 (node,tc.cli,tc.web),oxlint(exit 0, no warnings in touched files),check-max-lines-ratchet(no new bypasses, nomax-linesdisables added). Targeted suites 523 passed; wider sweep ofcomponents/status-bar,components/terminal-pane,store/,main/codex— 5529 passed, 0 failed.Not verified
forgetStalePanesdeletes the on-disk launch record outright, a pane that was dismissed and then survives an app restart has no launch-account memory on disk. A later switch in the new session will prompt it with whatever account was active at that moment aspreviousAccountLabel, which may not be the account it truly launched under. The prompt itself is still correct — the pane genuinely is stale — only the label can be wrong. Fixing that means teaching the main-process registry about dismissal instead of forgetting, which is fix(codex): keep history, restarts, and account identity across an account switch #10770's contract and out of scope here.Review addendum (independent review, 4 rounds)
Four rounds of independent review ran against this branch; rounds 1–3 each found real defects, round 4 came back clean. Five commits were added on top of the original fix. Every fix below was mutation-proved twice — once by the agent that wrote it, once independently re-run by the reviewer (revert the production hunk → confirm the new test fails → restore → confirm it passes).
f01251a6daisCodexPaneStalefell through to the tab-level check even when the pane's own record wasdismissed. In a split tab, a dismissed pane beside a sibling holding a blocking notice kept a dead keyboard with no prompt — the exact outcome this PR exists to prevent.sendInput0 calls)f01251a6daqueueCodexPaneRestartsdid not stripdismissedwhiledismissCodexRestartNoticesstrippedrestartRequested.{dismissed, restartRequested}resolved as "dismissed wins" → input flowing in a pane with a restart queued, still on the old account. Unreachable via today's UI (both call sites filter throughawaitsCodexRestartAnswer); landed as a state-model invariant, not a live bug.2e9f584a93tab.ptyId's block. Worst case: a plain shell split beside a Codex pane whose restart was already requested — the prompt is off-screen (awaitsCodexRestartAnswerfalse), so an innocent pane went silently mute with nothing to answer. Thetab.ptyIdfallback now runs only whenpanePtyIdis null.e576362f58markCodexRestartNoticesdroppeddismissedon every re-mark.AccountsPane.tsxre-marks live panes with the selection unchanged foradding(unconditional) andreauth:<activeId>, and the A→B→A collapse does not fire (it comparesexisting.previousAccountLabel, still A, againstnext: B). So routine token reauth resurrected an answered prompt and re-muted the pane.dismissednow carries forward iffexisting.nextAccountLabel === notice.nextAccountLabel.841c7882a8tab.ptyIdis the first binder, not the last; unbound-pane recovery targetsptyIdsByTabId[tabId][0], nottab.ptyId). Comments only — the reasoning the fixes rest on ("some sibling's id, not this pane's") is unchanged.Correction to the original description above
This is now only true for a genuinely different target account. D4 changed it: a dismissal is carried forward when the incoming target equals the one the dismissal already answered, so adding an account or reauthing the active one cannot resurrect it. A real third account C still reopens the prompt, and the A→B→A collapse still runs first and deletes the record outright.
Verified state-model invariant
{dismissed, restartRequested}is unreachable, re-derived after D4 across all four writers of the map:dismissstripsrestartRequested;queuestripsdismissed;markonly ever propagates flags fromexisting, so it cannot manufacture the pair from a single-flag record; thesetTabPtyIdmigration copies verbatim. This matters because that shape would let input flow in a pane still on the old account.Gates
npm run typecheckexit 0 (all 3 projects) ·oxlintexit 0 · 513 passed across the 5 touched suites · 2231 passed across all ofstore/+status-bar/· nomax-linesdisables added (the two in the touched files are pre-existing onmain).Not verified
getLiveCodexSessionPtyIds— the gate on whether a pane gets a notice at all — was not verified.Scope note on #10757
This PR owns the "Keep old account" half only. Lost
/resumehistory is PR #10801's territory and is not addressed here; the stuck restart panel and the across-restart stranding are largely base PR #10770 (ed40982db0,1818553aa6). Reading this PR as closing #10757 on its own would be wrong.Follow-ups (out of scope, not committed)
previousAccountLabel === nextAccountLabelcollapse swallows thereauth:<active>mark for panes with no existing record, so a pane on a stale token is never offered a restart even thoughshouldPromptRestartintends it. Pre-existing on base; shares a root cause with D4.forgetStalePanesdeletes the registry entry and only PTY spawn re-records it, so a dismissed pane that later switches to a third account and survives an app restart may be mislabelled — or not surfaced at all. fix(codex): keep history, restarts, and account identity across an account switch #10770's contract.restartRequestedpane whose restart never runs (tab parked indefinitely) stays input-blocked with no prompt on screen and no way to reopen it — both surfaces filterrestartRequestedout. Pre-existing on base.