Repository navigation
fix(codex): keep the stale-pane prompt when two accounts share a label - #11228
Conversation
The startup sweep asks main which panes are stale, and main answers by account id. The renderer then threw that away: it resolved both ids to labels and let the store's A -> B -> A collapse compare the strings. Two accounts can share a label — doAddAccount has no duplicate-email check, so one OpenAI login used in two ChatGPT workspaces gives both the same email, and a failed roster read collapses every account to 'Codex account'. Either way the notice was deleted for a pane that really is running under the account the user switched away from. The sweep then made it permanent: it marked every stale pane notified, including the ones whose notice had just been dropped, and a notified pane is suppressed for the rest of the session. Relaunching cleared the set but the deletion recurred, so the prompt never came back and the pane kept running on the other account's auth.json and quota, silently. Carry the account ids into the notice and decide on them, falling back to labels only for callers that have none; report which panes were left holding a notice so a dropped one cannot claim suppression. The prompt also names the ChatGPT workspace when that is what tells two same-email accounts apart, which is what the two duplicated getCodexAccountLabel copies now share.
Greptile SummaryThis PR fixes a compound bug where two Codex accounts sharing the same email label (or a failed roster read collapsing every account to
Confidence Score: 4/5Safe to merge. The fix is scoped, well-tested at multiple levels, and the two changed invariants (id-based comparison, return-value-gated suppression) are both explicitly exercised by fail-first tests. When two accounts sharing an email both lack a workspaceLabel, resolveCodexRestartPromptAccountLabel returns the bare email for both, so the prompt reads 'switch from x@y to x@y'. The fix is that the prompt now reliably appears — the id comparison sees through the label collision — but the text still can't distinguish the two accounts in this edge case. This is an acknowledged limitation rather than a regression, and the id-based identity logic is correct throughout. Files Needing Attention: No files require special attention. The sweep-level test added to codex-stale-pane-sweep.test.ts is a good regression guard for the suppression logic.
|
| Filename | Overview |
|---|---|
| src/renderer/src/store/slices/terminals.ts | markCodexRestartNotices now returns ptyIds that kept a notice; collapse and dismissal carry-forward use id-aware comparison. The noticedPtyIds side-effect inside set() matches the existing wasQueued pattern immediately above it. |
| src/renderer/src/store/slices/codex-restart-notice-account-identity.ts | New utility type and isSameCodexRestartNoticeAccount helper; correctly falls back to label comparison only when neither side carries an id. |
| src/renderer/src/lib/codex-session-restart.ts | markRestoredStaleCodexSessionsForRestart now builds notifiedPtyIds from the store's return value rather than the raw stale list; resolveCodexRestartPromptAccountLabel extracted and exported, consolidating the duplicate label logic. |
| src/renderer/src/components/settings/AccountsPane.tsx | Private getCodexAccountLabel removed; previousAccountId/nextAccountId now passed to markLiveCodexSessionsForRestart so the store can compare by id. |
| src/renderer/src/components/status-bar/StatusBar.tsx | Same refactor as AccountsPane; private getCodexAccountLabel dropped, ids forwarded to markLiveCodexSessionsForRestart. |
| src/renderer/src/lib/codex-stale-pane-account-identity.test.ts | New fail-first test file covering the exact regression scenarios: shared email, roster failure, workspace disambiguation, and dropped-notice suppression prevention. |
| src/renderer/src/store/slices/codex-restart-notice-lifecycle.test.ts | Extended with id-vs-label collapse, system-default collapse, dismissal carry-forward, and re-ask-on-third-account cases. |
| src/renderer/src/lib/codex-stale-pane-sweep.test.ts | Existing expectations updated to include new id fields; new case verifies a pane whose notice the store dropped is not suppressed from future sweeps. |
Reviews (1): Last reviewed commit: "fix(codex): keep the stale-pane prompt w..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughCodex restart notices now carry previous and next account IDs alongside labels. Notice lifecycle logic compares IDs when available, handles colliding labels, tracks retained PTYs, and updates dismissal and collapse behavior. Restart-session helpers resolve disambiguated labels and forward account IDs from account switching and stale-pane recovery. Tests cover identity collisions, roster failures, stale-pane retries, dropped notices, and restored-session prompts. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
stablyai#11228) The startup sweep asks main which panes are stale, and main answers by account id. The renderer then threw that away: it resolved both ids to labels and let the store's A -> B -> A collapse compare the strings. Two accounts can share a label — doAddAccount has no duplicate-email check, so one OpenAI login used in two ChatGPT workspaces gives both the same email, and a failed roster read collapses every account to 'Codex account'. Either way the notice was deleted for a pane that really is running under the account the user switched away from. The sweep then made it permanent: it marked every stale pane notified, including the ones whose notice had just been dropped, and a notified pane is suppressed for the rest of the session. Relaunching cleared the set but the deletion recurred, so the prompt never came back and the pane kept running on the other account's auth.json and quota, silently. Carry the account ids into the notice and decide on them, falling back to labels only for callers that have none; report which panes were left holding a notice so a dropped one cannot claim suppression. The prompt also names the ChatGPT workspace when that is what tells two same-email accounts apart, which is what the two duplicated getCodexAccountLabel copies now share.
stablyai#11228) The startup sweep asks main which panes are stale, and main answers by account id. The renderer then threw that away: it resolved both ids to labels and let the store's A -> B -> A collapse compare the strings. Two accounts can share a label — doAddAccount has no duplicate-email check, so one OpenAI login used in two ChatGPT workspaces gives both the same email, and a failed roster read collapses every account to 'Codex account'. Either way the notice was deleted for a pane that really is running under the account the user switched away from. The sweep then made it permanent: it marked every stale pane notified, including the ones whose notice had just been dropped, and a notified pane is suppressed for the rest of the session. Relaunching cleared the set but the deletion recurred, so the prompt never came back and the pane kept running on the other account's auth.json and quota, silently. Carry the account ids into the notice and decide on them, falling back to labels only for callers that have none; report which panes were left holding a notice so a dropped one cannot claim suppression. The prompt also names the ChatGPT workspace when that is what tells two same-email accounts apart, which is what the two duplicated getCodexAccountLabel copies now share.
The bug
A Codex pane that outlives the app is re-prompted at startup by the stale-pane sweep. Main decides staleness authoritatively and by account id (
codex-stale-pane-accounts.ts:record.accountId !== activeAccountId). The renderer then discarded that answer:markRestoredStaleCodexSessionsForRestartresolved both ids to display labels, and the store's A → B → A collapse deleted the notice wheneverpreviousAccountLabel === nextAccountLabel.Two accounts can share a label:
doAddAccounthas no duplicate-email check, and the label is the bare email — so one OpenAI login added under two ChatGPT workspaces produces two accounts that read identically.Codex account.Worse,
notifiedPtyIdswas built unconditionally fromstalePanes, so a pane whose notice had just been deleted still reportednotified: true. The bind sweep adds those to a module-level set thatnotifyCodexPaneBoundForStaleSweepearly-returns on for the rest of the session. The set resets on relaunch, but the deletion recurs — so the prompt never comes back.Consequence: the pane keeps running under the other account's
auth.jsonand quota, with no prompt, on this and every subsequent launch.The fix
Both halves — either one alone leaves the bug reachable:
CodexRestartNoticenow carriespreviousAccountId/nextAccountId, andmarkCodexRestartNoticesdecides the A → B → A collapse (and the dismissal carry-forward) on ids when both sides know them, falling back to labels only for callers that carry none. The restored-stale path passes main's ids straight through; both live-switch call sites already had the ids on hand.markCodexRestartNoticesreturns the ptyIds left holding a notice, and the sweep marksnotifiedfrom that rather than from the stale list.Secondary, and only because the prompt text would otherwise read "switch from x@y to x@y": the prompt label appends the ChatGPT workspace when that is what distinguishes two same-email accounts.
StatusBar.tsxandAccountsPane.tsxheld byte-identical private copies ofgetCodexAccountLabel, used for nothing but these notices; both now call the one shared resolver.Tests
src/renderer/src/lib/codex-stale-pane-account-identity.test.tsis fail-first. On the parent commit, 4 of its 5 cases fail and the regression guard passes:Also added: id-vs-label collapse and dismissal cases in
codex-restart-notice-lifecycle.test.ts, and a sweep-level guard that a pane whose notice the store dropped is still swept on its next bind.Verification
pnpm typecheck(all three projects, after clearing tsbuildinfo) — cleanpnpm lint(oxlint, both code-quality gates, reliability gates, max-lines ratchet, both localization gates) — cleansrc/renderer/src/lib,src/renderer/src/store/slices,src/renderer/src/components,src/main/codex,src/main/codex-accounts— pass, except 41 pre-existinglocalStorage is undefinedfailures in 7 unrelated files (Node 26 vs. the repo's Node 24; none reference the notice code)