Repository navigation
fix(claude-accounts): restart WSL Claude panes after an account switch - #31945
Conversation
A Windows host cannot see processes inside WSL, so the foreground gate dropped every WSL pane from the restart set. WSL panes now use the guest's hook status and shell marks, the evidence the execution host owns. Reported-by: Kooooojun
The account-restart resume builder declined every WSL project runtime, so a WSL worktree or a WSL Windows runtime default left no Claude candidate to restart. Keep that guard for Codex only; a WSL Claude launch reads the guest's selected-account pointer.
|
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
|
ELI5
If Claude runs inside WSL on Windows and you switch Claude accounts with "Always restart" turned on, Orca should restart those Claude panes on the new account. It didn't restart them. Now it does.
What Changed
Before: on a Windows host, switching the Claude account left every Claude pane running in WSL on the old account. The toast said "Running sessions keep their account", even with "Always restart" (or "Ask") selected.
After: WSL Claude panes are included in the restart set, the same way host panes are. Each one resumes its own conversation (
claude --resume <id>) on the new account once its current turn ends.Two separate blockers caused this. Each one alone was enough to drop every WSL pane:
src/renderer/src/lib/claude-session-account-move.ts).findMovableClaudeSessionskept a pane only if the Windows process table showed Claude in the foreground. WSL2 guest processes aren't in that table, so a WSL pane only ever showswsl.exe. For a WSL switch, the scan now uses evidence from the execution host instead: the Claude hook status row the guest reports (already required), checked with the existingresolvePaneAgentSessionId. That check drops a pane whose guest shell has signalled, through OSC 133;D, that Claude is back at the prompt. Host panes keep the process check unchanged.src/renderer/src/lib/agent-account-restart-startup.ts).resolveAgentAccountRestartResumeStartupreturned nothing for any project whose runtime resolves to WSL: a\\wsl.localhost\...worktree, or a WSL Windows runtime default. So no Claude candidate was ever built. That guard now applies to Codex only. A WSL Claude relaunch already lands on the selected account: main's spawn path (spawn-preflight.ts→prepareClaudeAuth) sets the selected WSL profile'sCLAUDE_CONFIG_DIRand account pointer. The resume command uses POSIX quoting for the guest shell.The other suspect, matching the transcript path against
wslLinuxAuthPath, turned out to be correct. Registration saves the guestCLAUDE_CONFIG_DIR(…/claude-profiles/<id>/home), and the guest hook reports<that>/projects/…. With Claude made visible to the process gate, the WSL panes matched the right account.Why
The AGENTS.md rule is that the execution host owns agent status. For a WSL pane, the execution host is the guest, and its hooks and shell marks are the only evidence available to a Windows host. A Windows-side
wsl.exeprobe of the guest process table would be a new, slower mechanism. Neither the restart path nor any other agent-status consumer does that today.SSH panes and paired-runtime (server) panes are left out on purpose, as before. A local Claude account switch doesn't change those machines' logins, and the restart executor only respawns local PTYs. That matches how Codex account restarts behave.
Linked Issue
Fixes #31486
Thanks to @Kooooojun for the detailed report, including the
/proc/<pid>/environevidence and the confirmation that a manual resume works.Visual Proof
N/A. No UI changes. The existing toast and restart flow now include WSL panes.
Testing
Automated tests added/updated
I manually tested these changes locally (no WSL machine available; see below)
claude-session-account-move.test.ts: a WSL switch built from the real data shapes: UNCmanagedAuthPath, guestwslLinuxAuthPath, a guest transcript path, a WSL project runtime, and a Windows foreground ofwsl.exewith no confirmation. It fails on main and needs both fixes. A pane that is back at the guest shell (OSC 133;D) is left out.agent-account-restart-startup.test.ts: a Claude resume for a WSL runtime resolved through the real resolver, once from a UNC worktree path and once from a WSL runtime default. Fails on main. The Codex WSL test is unchanged and still passes.The test files that import the changed modules pass (8 files, 110 tests), along with the full local static job.
What was not verified live: there was no Windows + WSL machine, so the end-to-end flow (switch account → WSL pane restarts →
/statusshows the new account) was not run. The main-side account repin for a WSL Claude spawn was confirmed by reading the code, not by running it. The reporter's manual workaround (resuming through Orca's shell wrapper lands on the new account) matches it.Known limitations
resolvePaneAgentSessionIddoesn't strictly reject rows restored after an Orca restart. For arestoredUnconfirmedrow it falls back to the pane's sleeping-session record. An idledonerow restored after a restart counts as live, because only non-terminal states are marked unconfirmed. The outcome is the same: possibly one resume in place on the new account.AI Disclosure
Review
ea60ec5d:Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
No wire or IPC changes, so client/host version mismatches aren't affected. Mobile has no Claude account-switch restart flow. Folder workspaces go through the same lane and runtime resolution as worktrees.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)