Repository navigation
Conversation
|
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 (32)
🚧 Files skipped from review as they are similar to previous changes (32)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughCodex account-switch restarts now repin rollout transcripts into the selected account home and transfer supported thread goals between homes. Resume preparation returns a fresh-session result when repinning fails. Renderer startup builds pane-specific resume commands and propagates account-switch metadata through terminal state, PTY transport, preload, and IPC. Account prompts and localized restart notices now distinguish preserved work from conversations that start fresh. Tests cover filesystem linking, resume outcomes, goal transfer, startup planning, transport retries, and UI messaging. Merge Risk: 🟡 Moderate · up to The PR changes account-switch restarts to resume conversations and transfer goals, but custom-shell terminals may restart with an incorrectly constructed resume command, while invalid budget values may cause the transferred objective to be lost. These bounded correctness issues should be fixed or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/TerminalPane.tsx (1)
1570-1580: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPass
terminalTab.shellOverrideto the restart startup builder.When a resumable Codex pane uses a custom shell, this call generates resume arguments for the default shell. The command can then fail to parse in the tab's actual shell. Pass
terminalTab?.shellOverrideand add it to thehandleRestartCodexPanedependency array.
🧹 Nitpick comments (4)
src/main/codex/codex-thread-goal-transfer.ts (1)
86-91: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winApply the same defensive filtering to
tokenBudgetthatstatusalready receives.Lines 101-103 drop an unrecognized
statusso a rejected field cannot fail the whole transfer and lose the objective.tokenBudgethas no equivalent guard. A negative or fractional value passesNumber.isFiniteand reachesthread/goal/set, which can reject the request and return'failed'.♻️ Proposed guard
- const tokenBudget = record.tokenBudget ?? record.token_budget + const tokenBudget = record.tokenBudget ?? record.token_budget + const usableTokenBudget = + typeof tokenBudget === 'number' && Number.isInteger(tokenBudget) && tokenBudget > 0 return { objective, ...(status ? { status } : {}), - ...(typeof tokenBudget === 'number' && Number.isFinite(tokenBudget) ? { tokenBudget } : {}) + ...(usableTokenBudget ? { tokenBudget } : {}) }src/renderer/src/lib/codex-account-restart-startup.ts (1)
74-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename the shadowing callback parameter.
The
findcallback parameter on Line 75 is namedentry, which shadows the agent-statusentryfrom Line 50. The current logic is correct, but a later edit inside the callback could read the wrongentry.♻️ Proposed rename
- const repo = worktree ? state.repos.find((entry) => entry.id === worktree.repoId) : null + const repo = worktree ? state.repos.find((repoEntry) => repoEntry.id === worktree.repoId) : nullsrc/renderer/src/lib/codex-account-restart-startup.test.ts (1)
88-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a case for the WSL bare relaunch.
The builder returns the bare startup for a resolved WSL runtime. That branch carries the strongest failure mode in the module: a resume argv against a home that does not list the rollout. The suite does not cover it.
Add a test that seeds a Codex session plus a resolved WSL project runtime and asserts
command === 'codex'andresumeProviderSession === undefined.src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts (1)
230-240: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRead all startup fields from
restartStartup.Line 230 takes
commandfromrestartStartup, but Lines 231-233 takestartupCommandDelivery,launchAgent, andcodexAccountSwitchRestartfromCODEX_ACCOUNT_RESTART_STARTUP. The values match today because the builder spreads the const. A later builder change that varies delivery or agent would silently not reach this spawn.♻️ Proposed change
command: restartStartup.command, - startupCommandDelivery: CODEX_ACCOUNT_RESTART_STARTUP.startupCommandDelivery, - launchAgent: CODEX_ACCOUNT_RESTART_STARTUP.launchAgent, - codexAccountSwitchRestart: CODEX_ACCOUNT_RESTART_STARTUP.codexAccountSwitchRestart, + startupCommandDelivery: restartStartup.startupCommandDelivery, + launchAgent: restartStartup.launchAgent, + codexAccountSwitchRestart: restartStartup.codexAccountSwitchRestart,
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 686e155c-3f03-42ac-bcdb-bca4ecd0061b
📥 Commits
Reviewing files that changed from the base of the PR and between e4e54a1 and 09e4b472a2321782029d2bd336ecf98090f678cb.
📒 Files selected for processing (32)
src/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-switch-resume-repin.test.tssrc/main/codex/codex-account-switch-resume-repin.tssrc/main/codex/codex-thread-goal-transfer.test.tssrc/main/codex/codex-thread-goal-transfer.tssrc/main/index.tssrc/main/ipc/pty.tssrc/main/runtime/orca-runtime.tssrc/preload/api/pty-api.tssrc/preload/index.tssrc/renderer/src/components/CodexRestartChip.tsxsrc/renderer/src/components/codex-restart-chip.test.tsxsrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/codex-detached-pane-restart.tssrc/renderer/src/components/terminal-pane/pty-connection-types.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/codex-account-restart-startup.test.tssrc/renderer/src/lib/codex-account-restart-startup.tssrc/renderer/src/lib/codex-session-restart.test.tssrc/renderer/src/lib/codex-session-restart.tssrc/renderer/src/store/slices/terminals.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.
pty:spawn pinned the launch CODEX_HOME to the home owning the session being resumed and never consulted the current selection — right for a cold restore, wrong for an account-switch restart, which shares the path. The pane relaunched under the account the user just left, and a second press only appeared to fix it because the first respawn had not yet registered a session for the pin to find. The restart now declares itself (codexAccountSwitchRestart), resume preparation follows the current selection, the rollout is hardlinked into the selected account's home ahead of the background sweep, and the relaunch runs `codex resume <id>` so the conversation continues. The /goal objective, status and budget travel via thread/goal/get / thread/goal/set; tokens_used and the limit statuses stay behind. Switching to the system default cannot carry the conversation (Orca never writes into ~/.codex), so it switches, starts fresh, and the card says so before the press. Co-Authored-By: Claude Fable 5 <[email protected]>
Review follow-up (PR stablyai#14877): - pass the tab's shellOverride to buildCodexAccountRestartStartup on the mounted restart path, matching the detached driver - skip the symlink-replacement test on Windows, where symlink creation needs elevation or Developer Mode - cover the WSL bare-relaunch branch in the startup builder's suite Co-Authored-By: Claude Fable 5 <[email protected]>
"usage is counted against the account you switch to" reads as existing usage counters and limit statuses moving with the switch. Say "new usage" in the restart notice across all five locales; counters stay put. Co-Authored-By: Claude Fable 5 <[email protected]>
c3bbf84 to
5f3ae17
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
#25485 adapts this PR's explicit conversation resume and selected-account handling to the current terminal modules, together with #24350's atomic pane replacement. Credit to @tonite31 is in the PR body and commit coauthor trailers (including the original AI coauthor). This is a partial integration: the goal-state transfer and settings/copy changes here are not included, so #25485 does not claim to supersede this entire PR. Real Codex A→B→A restarts, conversation continuity, a completed prompt under the selected account, and Ctrl+C were verified in an isolated macOS Electron instance. |
…5485) 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 <[email protected]> Co-authored-by: itisvincent <[email protected]> Co-authored-by: rayim <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
ELI5
You switch Codex to account B and press Restart on the card. The terminal comes back… still on account A. This PR makes that one press actually land on B, keeps your conversation going there (
codex resume), and moves your/goalalong with it. When the conversation can't follow (switching to the system default account), the card says so before you press.What Changed
codexAccountSwitchRestartflag from the renderer throughpty:spawn. The flag survives a failed spawn, a reattach answer, and a rejected admission — it is only spent by a fresh spawn that actually ran the switch path.codex resume <id>instead of a barecodex./goalobjective, status and budget travel viathread/goal/get/thread/goal/set.tokens_usedand the limit statuses stay behind — both were metered against the account being left. (Note: the app-server's status enum is camelCase —usageLimited/budgetLimited— not the snake_case spellings the goals sqlite stores; sending the latter is rejected.)~/.codex), so it switches, starts fresh, and the card copy says so before the user presses.CODEX_HOMEis baked into the shell at spawn).Why
pty:spawnpins the launchCODEX_HOMEto the home that owns the session being resumed, and never consults the current selection. That is correct for a cold restore, where the pane should come back as the account that recorded the conversation. An account-switch restart takes the same path, so it relaunches under the account the user just left.Deterministic repro (two managed accounts, A selected): run Codex in a terminal, exchange one message so a rollout exists, switch the active account to B, press Restart once. The pane comes back on A —
<userData>/codex-pane-accounts.jsonrecords the account each spawn actually launched under, so this is observable without guessing. Pressing Restart a second time usually works, which makes this read as flaky, but that is a timing artifact: the first respawn's shell has not yet registered a session for the pin to find, so the second press falls through to the current selection. Wait long enough and the second press fails too.#12146 covers a different path — it executes restarts for unmounted panes; this PR is about a mounted pane resolving the wrong home.
Linked Issue
Addresses the account-switch restart bug in #12098 (the automatic-rotation feature request in that issue is out of scope here, so no closing keyword).
Visual Proof
The visible change is the card copy and which account the relaunched pane lands on. Before/after copy:
The behavioral proof is the launch-account registry: after one Restart press, the pane's
codex-pane-accounts.jsonentry names the newly selected account, where it previously kept naming the old one. My local screenshots carry personal account emails; happy to attach a redacted screen recording if useful.Testing
Verified live on macOS (codex-cli 0.147): three consecutive account switches each moved the pane on one press, the conversation continued across all three in a single rollout (the model answered a fact memorised before the first switch; 17,152 of 18,083 input tokens served from cache), and the goal row landed in the new account's database with
tokens_usedat 0.Automated:
codex-account-switch-resume-repin.test.ts— resume preparation follows the current selection, only for a declared account-switch restart.codex-thread-goal-transfer.test.ts— which goal fields travel vs. stay, status-name remap, missing-goal and rejected-set paths.codex-account-restart-startup.test.ts— startup command:codex resume <id>vs. freshcodex, system-default fallback.pty-transport-connect-spawn.test.ts— flag lifecycle across failed spawn / reattach / rejected admission / later spawns.codex-restart-chip.test.tsx,codex-session-restart.test.ts,codex-account-session-bridge.test.ts— card copy per target account, restart contract, rollout hardlink into the selected home.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude Code (Claude Fable 5). Live verification on macOS was done by hand.
Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
normalizeRuntimePathForComparisonandgetSpawnArgsForWindows; no new platform-specific behavior outside existing guards.pty:spawnfield is optional, so older renderers simply never send it (same-machine IPC, both sides ship together anyway).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code