Repository navigation
fix(codex): widen the stale-pane sweep retry ladder past the Windows worst case - #10853
Conversation
…worst case Live Windows 11 validation of #10770 measured bind -> notice at 5140ms, 3959ms and 4064ms across three runs: the third and final rung is what raised the card every time, with essentially zero margin. macOS resolved on the first rung and left ~3.3s unused. A slower box, more panes, or a colder daemon reattach pushes past the last rung, and the sweep then has nothing left to fire — no card, and the pane silently keeps running the old account, which is the exact bug #10770 exists to fix. Adds two tail rungs, so the ladder reaches 15.8s and 35.8s from bind instead of ending at 5.8s. The fast early rungs are untouched, so macOS still resolves in under a second. Still bounded: five attempts and then the pane is dropped, never an interval or a poll.
The bounded-ladder test asserted only that inspectProcess ran 5 times within a 120s window. A sixth rung at 200s passes that unchanged — the count cannot tell "the ladder terminated" from "the next rung moved past the window", which is exactly the polling-loop property the test is named for. Assert the fake-timer queue is empty instead. Mutation-proved: passes as-is, and a sixth rung at 200_000 fails it with `expected 1 to be +0` while leaving the call-count assertion green.
Review: LAND-READYReviewed against the correct base ( The five things I was asked to judge1. Cumulative arithmetic — CONFIRMED. Not just read; measured with an instrumented copy of the module. Rungs fire at 300ms / 1.8s / 5.8s / 15.8s / 35.8s, with 2. Still bounded — CONFIRMED. Deterministic across 10/10 runs. The attempt counter, not the clock, is the bound, so the catch path ( 3. Per-PTY rung independence — NOT regressed. 4. The 35.8s tail is safe against stale targets.
5. Mutation proof — REPRODUCED exactly. Reverting to One thing I changed (944b7ce, test-only)
On the rebind interaction — I was wrong, and the PR is better than I thoughtI flagged that a mid-ladder rebind of the same ptyId consumes a rung rather than extending the ladder (
At
|
c460de6
into
brennanb2025/fix-codex-account-switch
Post-merge Windows validation: the widening was load-bearing, not precautionaryValidated on Windows 11 at Warm renderer restart (daemon already up, panes rebind fast) — the method used for the original
Essentially unchanged from the pre-fix numbers (3,959 / 4,064 / 5,140 ms). Still resolved by rung 3 Cold full restart (quit Orca entirely; daemon reattaches ~14 panes):
Bind is consistently ~6.1–6.6s, so bind → card is ~21 seconds — past rung 3 (5.8s), resolved by What that meansUnder the old three-rung ladder the cold-restart card would not have appeared at all. This change The original 3,959–5,140 ms figures were all warm-reload measurements, which is why they looked Caveats
|
…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.
…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.
Stacked on #10770. Ladder only — no change to the bind signal, the eligibility predicate, or the queue mechanics.
The problem
Live Windows 11 validation of #10770 measured store-visible PTY bind → notice raised:
The ladder was
SWEEP_ATTEMPT_DELAYS_MS = [300, 1500, 4000], i.e. attempts at 300ms / 1800ms / 5800ms from bind. On Windows the final rung is what produced the card in all three runs — rungs 1 and 2 never won. macOS by comparison resolved on the first rung in ~0.66s, leaving ~3.3s of ladder unused.So Windows consumes the entire ladder with essentially zero margin. A slower box, more panes, or a colder daemon reattach and the last attempt also misses — at which point there is no further rung,
queueNextRungdrops the pane, and the card never appears. The user stays on the old account unaware, which is precisely the bug #10770 exists to fix. The failure mode when the ladder exhausts is "no card", never a dead keyboard, so this is a coverage problem, not a safety one.The change
Cumulative attempt times from bind:
Justification against the measurements:
queueNextRungfindsundefinedand deletes the pane's attempt state. It is not interval-based and cannot become a polling loop, which the constant's comment calls out explicitly.Per-PTY rungs stay per-PTY:
queue/takeDuePtyIdsare untouched, so the rung-collapse fix from the earlier review round is not regressed. The sweep still stops for a notified pane (notifiedPtyIds) and for a dismissed one (forgetStaleCodexPanesdrops the launch record, solistStalePanesstops reporting it) — a longer tail cannot resurrect either.Verification
Mutation-proof of the new tail. Reverting the constant to
[300, 1500, 4000]with the tests unchanged fails exactly the two tests that assert the tail:The new test drives a pane inconclusive through the first three rungs and asserts the notice is still raised on the fourth — the exact silent-failure scenario the Windows data points at. The bounded-ladder test now advances 120s (well past the 35.8s ceiling) so it pins the ceiling rather than the clock.
Per-PTY independence test passes unchanged —
spends a pane its full retry ladder even when another pane binds laterstill asserts 2 then 3 inspects forpty-1at t=3310/6310, which the longer ladder does not perturb. Only its stale "its 3 attempts" comment was reworded.Gates, all green on this branch:
npm run typecheck(node + tc.cli + tc.web) — exit 0, 0 errorsnpx oxlint— exit 0, no findings in touched filescheck:max-lines-ratchet— OK, no new bypassescodex-stale-pane-sweep.test.ts+codex-session-restart.test.ts— 33/33pty-connection.test.ts(the sweep's only caller) — 484/484Known-noise on the validation box, unrelated to this change: Node 26 vs the repo-pinned 24 fails ~41 renderer tests (browser-pane/markup, right-sidebar, sidebar) on clean checkouts, and
verify:localization-coverageexits 1 on 6 pre-existing Ghostty strings.