Repository navigation
Conversation
…ccount After an account switch, a running Claude kept the account it started on (stablyai#19900). The Claude account menu now says how many sessions are still on the old account and offers Move Sessions, the way Codex offers Restart Sessions. Each one reopens its conversation with claude --resume once it is idle, so nothing it was doing, and nothing typed but not sent, is lost. A new setting, off by default, does that on its own for sessions idle for a minute in a tab you are not looking at. A session's account is read from where its transcript lives, and compared by login, so an account served by the System default login, or two folders holding one login, never cause a move. Safe to move is hibernation's own test for a pane it may stop, which this lets take a turn that ended on an error or a Stop: that is how a usage limit ends one. Moves restart only mounted panes and never join the Codex restart queue.
…ting moved sessions The e2e spec seeds two accounts with B selected and a Claude session that started on A, opens the Claude menu from the usage panel, moves the session, and checks that the pane relaunches with claude --resume and that the menu no longer counts it. A moved session reads as the old account until it reports again, so the menu now leaves settled sessions out.
…ll logins apart by organization - Ask the pane's process before a restart, so a Claude inside tmux, or a pane back at the shell, is left alone instead of having its outer terminal restarted. - Report System default's organization with its email, so one email in two organizations stays two logins. - Hold a moved session only until it reports again, so A to B to A to B moves each time. - Forget the account list when reading it fails, and try again, instead of acting on the old one. - Retry a session you asked to move when its pane was not ready, with no store change needed. - Give the setting its own search entry.
…art prompt does A Claude installed through npm runs under node, so a name-only check skipped it. A pane now counts as running Claude when its process is Claude, or when the tab launched Claude and an agent wrapper runs there; tmux, the shell or another program still means leave it alone. The e2e spec launches Orca's stub agent as Claude, so it no longer needs a real claude.
…nly the latest account list - A session whose account was removed is offered a move: no saved login is served from its folder any more, so it cannot be on the selected one. - When account-list replies to a quick A, B, A arrive out of order, only the latest one is kept. - The menu's hint says unsent text holds a move too. - The Claude accounts comment moved with its field, and AccountsPane imports the Claude search catalog directly.
…d keep retrying - After the process check comes back, the session is checked again on fresh state, so text typed or a turn started meanwhile still holds the move. - A process check that failed, or could not see the process, is retried instead of giving up. - Move Sessions pressed while the account list cannot be read is kept, and acted on once it can.
…nd retry when a pane's processes are unreadable After the process check, the session is re-checked against the newest account list and the current setting, so switching back or turning moves off while it waits stops the move. An inspection whose evidence says the process table could not be read is retried, like a failed one.
…nd read Windows panes by child evidence A switch is what usually asks for a new account list, so the old one is dropped as the read starts and nothing moves on it meanwhile. A local pane's inspection is judged by its child-process evidence, as agent completion does: Windows marks the foreground evidence unverifiable on every local answer, which blocked every move there.
… no longer runs Claude A process-table read that failed can leave only the foreground evidence marked unverifiable. A pane that does not read as Claude is now settled only on a verifiable answer, and retried otherwise; a real Claude still moves, on Windows too.
…ts process read failed Off Windows, an inspection whose foreground evidence is unverifiable now counts as unseen, so a cached claude name from a failed read cannot restart a pane Claude already left; the session is retried instead. Windows marks that evidence unverifiable on every local answer, so there the child-process evidence decides, as before.
…ude pane The cached foreground read can flap to the shell for a live agent (stablyai#11064), so a shell in a tab that launched Claude now gets the fresh scan Codex's restart uses; a scan that cannot tell is retried. Panes that are not mounted are skipped before any process read, and a settings save no longer re-reads the accounts unless the selection or the account list changed.
…hell's child A shell reading carries no children, so a Claude the fresh read finds running under node was taken for something else and left on the old account.
…a Claude tab A Codex someone started in a tab that launched Claude was taken for Claude and would have been restarted as claude --resume.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c5e3af42-7a9f-4baf-bba5-65e899f0c688
📒 Files selected for processing: 32
docs/site/content/docs/agents/claude-code.mdxsrc/main/claude-accounts/claude-account-selection.tssrc/main/claude-accounts/claude-account-service.test.tssrc/renderer/src/app-shell/AppBackgroundServices.tsxsrc/renderer/src/components/ClaudeSessionMoveGate.tsxsrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/accounts-claude-search.tssrc/renderer/src/components/settings/accounts-pane-claude-section.tsxsrc/renderer/src/components/settings/accounts-pane-claude-session-moves.test.tsxsrc/renderer/src/components/settings/accounts-pane-claude-session-moves.tsxsrc/renderer/src/components/settings/accounts-search.test.tssrc/renderer/src/components/settings/accounts-search.tssrc/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsxsrc/renderer/src/components/status-bar/claude-session-move-prompt.test.tsxsrc/renderer/src/components/status-bar/claude-session-move-prompt.tsxsrc/renderer/src/components/terminal-pane/pane-account-move-restarts.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-process-exit-actions.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/agent-hibernation-pane-eligibility.tssrc/renderer/src/lib/claude-session-move-coordinator.test.tssrc/renderer/src/lib/claude-session-move-coordinator.tssrc/renderer/src/lib/claude-session-move.test.tssrc/renderer/src/lib/claude-session-move.tssrc/renderer/src/lib/codex-account-restart-startup.test.tssrc/renderer/src/lib/codex-account-restart-startup.tssrc/shared/claude-account-global-settings.tssrc/shared/claude-transcript-account.test.tssrc/shared/claude-transcript-account.tssrc/shared/default-global-settings.tssrc/shared/global-settings-types.tssrc/shared/managed-account-types.tstests/e2e/claude-session-move.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…cted A move restarts the pane and is recorded at once, but a pane that unmounts before the new PTY connects keeps the old one. The record now names the PTY it replaced, so a pane still on it reads as not moved.
|
Closing this in favor of #29898, which landed this morning and covers the same thing with a better UX (the dialog right after the switch, plus Ask / Always restart / Never restart). Thanks @Jinwoo-H. For what it's worth, I ran this approach against two real accounts last night: the first one was at its weekly limit, and after the move the same session id carried on, on the second account, with its history. So restart plus A few edge cases came up in review here. I haven't checked yet whether any of them apply to #29898, but I'm happy to go through them and send small fixes if they do:
I've also hooked #28044's automatic switch into your setting, so an auto-switch asks or restarts the same way a manual one does (details on #28044). |
ELI5
When you switch Claude accounts, the Claudes that are already running stay on the old one. That's by design: each
claudepicks its account folder when it starts. Codex has a "Restart N Sessions" prompt for this. Claude had nothing, so you had to quit each session and resume it yourself.This adds the Claude version. The Claude account menu tells you how many sessions are still on the old account, and Move Sessions reopens each one's conversation on the new account with
claude --resume. There's also an opt-in setting that does it on its own for sessions that are sitting idle.What Changed
Before: after a switch, running Claudes kept the old account until you restarted them by hand.
After:
claude --resume <id>. It picks up the selected account the same way any newclaudedoes.How it decides, briefly:
claude-profiles/<accountId>/home/projects/..., or System default for the user's own folder). That'sclaude-transcript-account.ts, one function, so it can switch to feat(accounts): keep a Claude or Codex agent on its account #28684's per-agent account once that lands.getEligiblePane. It gains one opt-in,allowEndedTurn, so a turn that ended in a failure or a Stop also counts. A usage limit ends a turn that way, and that's the session you most want to move. Hibernation itself is unchanged.isCodexRestartEligiblePane: Claude by name, or node or python under a tab that launched Claude. A Claude inside tmux, a pane that's back at the shell, or another agent started in that tab is left alone. Like the Codex scan, a shell reading in a tab that launched Claude gets a fresh read first (Codex restart card silently skipped when inspectProcess flaps to a shell foreground #11064), and a read that can't tell is tried again later. Panes that aren't mounted are skipped before any process read.handleRestartCodexPanewith an explicit startup), and only for mounted panes. They never joinpendingCodexPaneRestartIds, because its detached path relaunches unmounted panes as Codex.Two refactors keep files under the 300-line cap. The Claude account settings fields moved to
claude-account-global-settings.ts, the wayDeletePrefsdid. The Claude settings-search entries moved toaccounts-claude-search.ts. Main also reports System default's organization next to its email (systemDefaultOrganizationUuid), so one email in two organizations stays two logins.Why
#19900 has the background. @Tauri-EPO confirmed on 1.4.227 that running sessions keep the old account by design now, and asked for something like Codex's restart prompt. @joefour is doing this today with a local hook, and listed what a built-in version has to handle. I went through that list:
Linked Issue
Fixes #19900
Visual Proof
From the real app (headless e2e launch with the stub agent running as Claude). Before this change the menu ended at "Running sessions keep their account."
Testing
tests/e2e/claude-session-move.spec.tsseeds two accounts with B selected and a Claude session that started on A, opens the menu, clicks Move Session, and checks that the pane relaunches with--resumeand drops out of the count.codex-account-switch-dismiss.spec.tsstill passes on the shared restart builder./statusshowed the second login. Then, with the setting on and the tab in the background, switching back moved it again after about a minute. Moving onto an account that's out of credits just brings up Claude's own limit prompt.Ran locally on macOS: the Claude account, hibernation, settings, status-bar, provider-accounts and restart-startup suites, typecheck (node, web, cli), oxlint, oxfmt, the changed-code audit, the max-lines ratchet and the localization checks. One unrelated failure on this machine:
runtime-home-service-per-account-migration.test.tsneedsnode:sqlite, which my local Node doesn't have.Review
cc @nwparker @brennanb2025. @QichangZheng this is the switch-driven half I mentioned on #28684. If step 1 lands first, the account check becomes one line here, and kept agents would be skipped. Happy to rebase onto it.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
systemDefaultOrganizationUuidis an optional field.--mcp-config,--settings) is resumed with Orca's default flags, because Orca has no record of the ones it was given.StopFailuretodoneand drops the error type, so that needs a main-side hook change, and I'd rather do it on top of feat(accounts): keep a Claude or Codex agent on its account #28684.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)