Repository navigation
fix(codex): stop the restart card from parking focus on Restart - #10870
Merged
brennanb2025 merged 1 commit intoJul 27, 2026
Merged
brennanb2025 merged 1 commit into
brennanb2025 merged 1 commit into
Conversation
When a Codex restart notice appears, the card moved keyboard focus to its default "Restart" button. The card is mounted per WORKTREE — Terminal.tsx renders it as a sibling of TabGroupSplitLayout — so `root.parentElement` is the whole worktree surface and shouldFocusMobileDriverAction's xterm branch matches ANY terminal in it. A notice raised for pane A therefore yanked focus out of a different, perfectly healthy pane B that the user was typing in. The focused control was destructive: Restart calls queueCodexPaneRestarts over every stale pty in the worktree, so the next Space or Enter of the user's prose silently restarted those Codex sessions and lost their state — the same class of loss #10757 is about. Focus the role="dialog" root instead, with tabIndex={-1} so it is programmatically focusable but out of the Tab order. The card is still announced (role + aria-live + labelledby/describedby) and Tab from it still reaches Restart and Keep, so keyboard and AT discoverability are preserved; the only thing lost is the ability to fire a session-killing action by accident. shouldFocusMobileDriverAction is untouched, so MobileDriverOverlay's behaviour is unchanged. Both new tests are mutation-proved: restoring restartRef.current?.focus() fails exactly the two of them and leaves the other 11 green. Known residual, deliberately not fixed here: focus still leaves a healthy pane for the dialog. That interrupts typing, but no longer destroys anything, and narrowing the scope to the stale pane needs a DOM-to-ptyId mapping the card does not have today. Refs #10863
brennanb2025
force-pushed
the
brennanb2025/codex-restart-chip-focus
branch
from
July 27, 2026 06:46
e457b28 to
dc88a69
Compare
brennanb2025
merged commit Jul 27, 2026
833dd90
into
brennanb2025/fix-codex-account-switch
1 check 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. Fixes #10863. Found while reviewing #10853 — see "Why now" below.
The bug
When a Codex restart notice appears,
CodexRestartChipmoves keyboard focus to its default Restart button.The card is mounted per worktree:
Terminal.tsx:2146/:2394render it as a sibling ofTabGroupSplitLayout. Soroot.parentElement(CodexRestartChip.tsx:166) is the whole worktree surface, andshouldFocusMobileDriverAction's xterm branch isfocusScope.contains(active)— which matches any terminal in that worktree, not just the stale pane.Verified directly against the helper:
So a notice raised for pane A yanks focus out of pane B — a different, perfectly healthy pane whose input is not blocked (
isCodexPaneStaleis per-pane by design) and which the user may well be typing in.The control that receives focus is destructive.
handleRestartcallsqueueCodexPaneRestarts(staleWorktreePtyIds)over every stale pty in the worktree, so the next Space or Enter in the user's prose silently restarts those Codex sessions and loses their state — the same class of loss #10757 is about.Why now
This is pre-existing, but #10853 is what makes it routine. That PR widens the stale-pane sweep ladder so a notice can first appear up to 35.8s after PTY bind instead of 5.8s. At 5.8s the pane has just appeared and nobody is typing yet; at 35.8s they plausibly are. #10853 is correct and should land — but it converts a rare race into a likely one, so this wants to land alongside it.
Filed separately rather than folded into #10853 to keep that PR to its one-line ladder change.
The fix
Focus the
role="dialog"root instead, withtabIndex={-1}so it is programmatically focusable but out of the Tab order.role="dialog"+aria-live="assertive"+aria-labelledby/aria-describedby.shouldFocusMobileDriverActionis untouched, soMobileDriverOverlay's behaviour is unchanged — that helper's worktree-wide semantics are right for a per-pane overlay whose pane is paused, just not for a worktree-wide card.Verification
Two new tests in
codex-restart-chip.test.ts(happy-dom, real render), both mutation-proved — restoringrestartRef.current?.focus()fails exactly these two and leaves the other 11 green:The second test exists so the fix cannot silently degrade into "never take focus at all".
Gates:
codex-restart-chip+mobile-driver-overlay-focus+mobile-driver-overlay-visibility+codex-restart-notice-lifecycle— 28/28npm run typecheck— exit 0npx oxlinton both touched files — no findingscheck:max-lines-ratchet— OKKnown residual, deliberately not fixed
Focus still leaves a healthy pane for the dialog, which interrupts typing. It no longer destroys anything, which was the severe part. Narrowing the scope to only the stale pane needs a DOM-node-to-ptyId mapping the card does not have today; that is worth doing separately, and per-pane scoping alone would not have been a fix — a correctly scoped focus steal onto a session-killing button is still a session-killing button.
Not verified: no live app run. The DOM structure claim is read from
Terminal.tsx, and the focus-branch claim is proved against the real helper.