You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(codex): keep Codex history across WSL account switches - #34968
Orca gives each managed Codex account its own Codex folder (CODEX_HOME) so logins never collide. To keep "switch account, keep your conversations" working, Orca links session files between those folders. On WSL, a launch only linked the distro's own ~/.codex into the selected account, so a conversation started on account A disappeared from /resume after switching to account B. This PR also links the other WSL accounts in the same distro, so history follows the user across WSL account switches again.
What Changed
startWslSessionBridgeForLaunch (runtime-home-service-managed-home.ts) now bridges the distro's system home plus every other managed WSL account home in the same distro into the selected account's home. Before, it bridged only the system home.
The selected home itself and duplicates are skipped by comparing Linux paths.
Accounts from other distros are excluded: getWslLaunchCodexHomePath returns null for them.
Sources run one at a time through the existing startWslCodexSessionBridgeInBackground. The bridge script, its per-target dedupe, the index-ready gate and the index heal are unchanged.
Test: a regression test that a WSL launch on account B bridges both the system home and sibling account A, and skips the Debian account. It fails on main. I dropped one assertion from the retired-session test: it required a retired session not to reach the selected sibling home, which is exactly the cross-account isolation this PR reverts to the fix(codex): keep history, restarts, and account identity across an account switch #10770 behavior.
This is the WSL half of #33578. The host "system default" half is a separate draft PR, because it changes behavior for every non-WSL user and needs a product decision.
Why
The host per-account launch already uses ~/.codex plus every sibling account home as sources (getSelfContainedSessionBridgeSourceHomes). The WSL launch lost that after the WSL direct-home cutover (#16854), which caused #18486. Reusing the existing per-source WSL bridge keeps the change small. I considered teaching the bridge script to take several sources in one wsl.exe run, but that script is shared with migration and backfill, and its single-source summary drives marker and index-heal bookkeeping. Changing it would be a much larger and riskier diff than this fix needs.
Cost: each WSL Codex launch now runs one bridge per source instead of one: the system home plus each sibling WSL account in that distro. With the typical 1–3 WSL accounts, that is 0–2 extra short wsl.exe runs, each one a find over the source's sessions folder. A Codex thread/read index heal follows only when something new was linked. It all runs in the background after launch preparation and never blocks the pane.
Stopped distros (E9): this never starts a stopped distro. The bridge runs only from finishWslLaunchPreparation, which is reached only from prepareForCodexLaunch for a WSL target. That is a Codex launch (terminal pane, chat or commit-message generation) that starts Codex in that distro anyway. No startup, background, polling or discovery path calls it.
Flag-off: N/A. There is no feature flag. The WSL hosts switch doesn't gate this path: it is the existing Codex managed-account launch for WSL workspaces on Windows.
N/A. This is internal launch preparation and changes no UI. #33578 has a real Windows/WSL check with pinned Codex 0.164.0: on main, codex exec resume <id> from account B fails with "no rollout found"; with this change it resumes from a hardlink of account A's rollout.
Testing
pnpm tc and pnpm run typecheck:ci pass.
pnpm exec oxlint src/main/codex-accounts passes, and so do the anti-slop lint, the ast-grep gates, check:process-host-imports and check:code-quality:changed.
src/main/codex-accounts/ plus src/main/codex/wsl-codex-session-bridge.test.ts pass: 470 tests. One unrelated real-home catalog test timed out once under full-suite load and passed on reruns.
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Windows/WSL only (process.platform === 'win32' guard). macOS, Linux, native Windows and SSH are unchanged. No wire, settings or dependency change.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The WSL launch bridge now uses the system home and eligible managed-account homes as session-history sources for the selected home. It excludes sources with the same normalized Linux path as the target, removes duplicates, and awaits each bridge sequentially. A test covers bridging from the WSL system home and a same-distro sibling account, while excluding an account from another distro.
Priority: Normal
Severity of issue fixed: Medium
Merge Risk: Low · up to 7875c
Switching WSL Codex accounts now restores session history from the system home and sibling accounts in the same distro. Linking of sibling sessions can be delayed when an earlier source has a slow index gate or heal. Launch is not blocked. A new test also uses paths that would fail if run on a Windows host. Neither issue blocks the fix itself, but both are worth addressing.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly identifies the main change: preserving Codex history when users switch between WSL accounts.
Description check
The description is complete and covers the user impact, implementation, rationale, linked issue, testing, scope, risks, and checklist. Visual proof is correctly marked N/A because the change has no UI…
Linked Issues check
The change meets #18486. For a selected WSL account, startWslSessionBridgeForLaunch uses the distro system home and sibling managed account homes as sources. It excludes the selected home and non-ma…
Out of Scope Changes check
The production change is limited to WSL Codex launch bridging. The tests cover sibling sources, the no-selected-account case, and concurrent launches. The change does not add host system-default behav…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check
Explanation
The description is complete and covers the user impact, implementation, rationale, linked issue, testing, scope, risks, and checklist. Visual proof is correctly marked N/A because the change has no UI impact. The Review and AI Disclosure sections are empty, but these omissions are non-critical.
Full details: Linked Issues check
Explanation
The change meets #18486. For a selected WSL account, startWslSessionBridgeForLaunch uses the distro system home and sibling managed account homes as sources. It excludes the selected home and non-matching distro homes. It runs one bridge per source. The regression test verifies account B receives the system home and account A sources, and the concurrency test prevents duplicate bridge loops. The existing bridge performs the session linking required for codex resume.
Full details: Out of Scope Changes check
Explanation
The production change is limited to WSL Codex launch bridging. The tests cover sibling sources, the no-selected-account case, and concurrent launches. The change does not add host system-default behavior, UI changes, dependencies, or unrelated platform behavior.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
set -o pipefail
printf'%s\n''--- managed-home header and bridge method ---'
nl -ba src/main/codex-accounts/runtime-home-service-managed-home.ts | sed -n '1,310p'printf'%s\n''--- selection helpers ---'
nl -ba src/main/codex-accounts/runtime-selection.ts | sed -n '1,155p'
Repository: stablyai/orca
Length of output: 19058
Restrict managed-account sources to managed-account targets.
When no WSL account is selected, getWslCodexHomePathForSelection returns the distro system home. Launch preparation passes that path to the bridge as its target, while startWslSessionBridgeForLaunch still adds managed-account homes from the distro as sources. The bridge then links those session files into the system home.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Supported by static analysis
Script executed:
sed -n '1,200p' src/main/codex/wsl-codex-session-bridge.ts
sed -n '255,290p' src/main/codex-accounts/runtime-home-service-managed-home.ts
Repository: stablyai/orca
Length of output: 8689
Let each source finish linking before index work delays the next source.
startWslSessionBridgeForLaunch awaits each startWslCodexSessionBridgeInBackground call before it starts the next source. The returned promise settles only after the index-ready gate, the file linking, and the index heal all finish. When the target home's index is not yet complete, the gate can wait up to 15 minutes. A long heal for an earlier source can also delay linking for every later source, including the sibling-account sessions this change adds for account-switch /resume.
Launch itself is not blocked, because the loop runs inside an unawaited async function. The delay affects only the sibling-account links.
Serialize the file-link steps where order matters. Start the index-gate and heal work without making the next source's file linking wait for it. This likely requires splitting the link step from the index step in src/main/codex/wsl-codex-session-bridge.ts.
Bridge the distro's system home and every sibling managed WSL account home in
the same distro into the selected account's home at launch, so a session
started on account A is resumable after switching to account B (#18486).
Split from #33578 (WSL half only).
…e loop per home
System default's own ~/.codex in the distro gets no sibling sources, so the
#24511 product decision stays out of this change. Concurrent launches join the
loop already bridging a target home. Restores #16854's drain-target assertion
with the launch bridge mocked.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Supported by static analysis
Script executed:
sed -n 1,160p src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts
rg -n "getWslManagedHomeIdentity|wslLinuxHomePath" src/main/codex-accounts/*.ts | head -40
rg -n "windows-latest|runs-on" .github/workflows | head -30
sed -n 1,80p src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts
Repository: stablyai/orca
Length of output: 15445
Script executed:
set -eu
printf'%s\n''--- runtime-home-service-wsl-core.ts ---'
nl -ba src/main/codex-accounts/runtime-home-service-wsl-core.ts | sed -n '1,180p'printf'%s\n''--- parseWslUncPath and related path helpers ---'
rg -n -F --glob '*.ts' -e 'parseWslUncPath' -e 'getWslManagedHomeIdentity' -e 'wslLinuxHomePath' src/main src/shared | head -120
printf'%s\n''--- sibling bridge test with line numbers ---'
nl -ba src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts | sed -n '1,180p'printf'%s\n''--- session bridge fixture blocks ---'
nl -ba src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts | sed -n '200,330p'
nl -ba src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts | sed -n '420,490p'printf'%s\n''--- test scripts and Windows CI references ---'
rg -n -F --glob 'package.json' -e '"test' -e 'vitest'.
rg -n -F --glob '.github/workflows/*' -e 'runtime-home-wsl-sibling-bridge' -e 'codex-accounts' -e 'windows-2022' -e 'windows-latest' -e 'pnpm test' -e 'vitest'.
Repository: stablyai/orca
Length of output: 41900
Script executed:
set -u
printf'%s\n''--- shared WSL path parser ---'
nl -ba src/shared/wsl-paths.ts | sed -n '1,75p'printf'%s\n''--- runtime-home service launch and sibling bridge flow ---'
rg -n -F --glob 'src/main/codex-accounts/*.ts' -e 'prepareForCodexLaunch' -e 'startWslCodexSessionBridgeInBackground' -e 'getWslManagedHomeIdentity' -e 'getWslManagedHomePath'printf'%s\n''--- runtime-home service implementation ---'
nl -ba src/main/codex-accounts/runtime-home-service.ts | sed -n '1,260p'printf'%s\n''--- test harness path setup ---'
rg -n -F -- 'userDataDir' src/main/codex-accounts/runtime-home-service-test-harness.ts
nl -ba src/main/codex-accounts/runtime-home-service-test-harness.ts | sed -n '1,150p'printf'%s\n''--- Windows workflow and test selection ---'forfin .github/workflows/*.yml .github/workflows/*.yaml;do
[ -f"$f" ] ||continueif grep -n -E 'windows|runs-on|pnpm (test|tc)|vitest|codex-accounts'"$f">/tmp/workflow-matches 2>/dev/null;thenecho"### $f"
cat /tmp/workflow-matches
fidone
Repository: stablyai/orca
Length of output: 41214
Script executed:
set -eu
printf'%s\n''--- launch methods ---'
nl -ba src/main/codex-accounts/runtime-home-service-launch.ts | sed -n '1,145p'printf'%s\n''--- managed-home bridge methods ---'
nl -ba src/main/codex-accounts/runtime-home-service-managed-home.ts | sed -n '1,120p'
nl -ba src/main/codex-accounts/runtime-home-service-managed-home.ts | sed -n '255,305p'printf'%s\n''--- WSL runtime-home methods ---'
nl -ba src/main/codex-accounts/runtime-home-service-wsl.ts | sed -n '1,125p'printf'%s\n''--- WSL home helper ---'
nl -ba src/main/wsl.ts | sed -n '1,75p'printf'%s\n''--- exact Windows CI test commands ---'
nl -ba .github/workflows/preflight-cli-platforms.yml | sed -n '24,60p'
nl -ba .github/workflows/zcode-credential-contract.yml | sed -n '25,105p'
nl -ba .github/workflows/zcode-transcript-contract.yml | sed -n '20,50p'
Repository: stablyai/orca
Length of output: 32691
Script executed:
set -eu
printf'%s\n''--- WSL system-home helper ---'
rg -n -F --glob 'src/main/codex-accounts/*.ts' -e 'getWslSystemCodexHomePath' -e 'finishWslLaunchPreparation'
nl -ba src/main/codex-accounts/runtime-home-service-wsl.ts | sed -n '125,230p'printf'%s\n''--- finish launch preparation and bridge entry ---'
nl -ba src/main/codex-accounts/runtime-home-service-managed-home.ts | sed -n '205,270p'
Repository: stablyai/orca
Length of output: 6247
Use WSL-shaped paths in the fixtures.
On Windows, join(...) creates drive paths, but getWslManagedHomeIdentity requires POSIX wslLinuxHomePath values or WSL UNC paths. The selected account is rejected, so prepareForCodexLaunch returns the system WSL home instead of selectedHome, and the expected sibling bridge calls are not made.
Use explicit POSIX Linux paths and WSL UNC paths for the fixtures, then update the assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Orca gives each managed Codex account its own Codex folder (
CODEX_HOME) so logins never collide. To keep "switch account, keep your conversations" working, Orca links session files between those folders. On WSL, a launch only linked the distro's own~/.codexinto the selected account, so a conversation started on account A disappeared from/resumeafter switching to account B. This PR also links the other WSL accounts in the same distro, so history follows the user across WSL account switches again.What Changed
startWslSessionBridgeForLaunch(runtime-home-service-managed-home.ts) now bridges the distro's system home plus every other managed WSL account home in the same distro into the selected account's home. Before, it bridged only the system home.getWslLaunchCodexHomePathreturns null for them.startWslCodexSessionBridgeInBackground. The bridge script, its per-target dedupe, the index-ready gate and the index heal are unchanged.This is the WSL half of #33578. The host "system default" half is a separate draft PR, because it changes behavior for every non-WSL user and needs a product decision.
Why
The host per-account launch already uses
~/.codexplus every sibling account home as sources (getSelfContainedSessionBridgeSourceHomes). The WSL launch lost that after the WSL direct-home cutover (#16854), which caused #18486. Reusing the existing per-source WSL bridge keeps the change small. I considered teaching the bridge script to take several sources in onewsl.exerun, but that script is shared with migration and backfill, and its single-source summary drives marker and index-heal bookkeeping. Changing it would be a much larger and riskier diff than this fix needs.Cost: each WSL Codex launch now runs one bridge per source instead of one: the system home plus each sibling WSL account in that distro. With the typical 1–3 WSL accounts, that is 0–2 extra short
wsl.exeruns, each one afindover the source'ssessionsfolder. A Codexthread/readindex heal follows only when something new was linked. It all runs in the background after launch preparation and never blocks the pane.Stopped distros (E9): this never starts a stopped distro. The bridge runs only from
finishWslLaunchPreparation, which is reached only fromprepareForCodexLaunchfor a WSL target. That is a Codex launch (terminal pane, chat or commit-message generation) that starts Codex in that distro anyway. No startup, background, polling or discovery path calls it./resume. That restores the intended fix(codex): keep history, restarts, and account identity across an account switch #10770 behavior and matches the host lane. Files are hardlinked inside the distro, so there is no extra disk use and no auth or config is copied. Users who want strict per-account isolation ([Bug]: Codex session bridge shares history across all managed accounts with no opt-out or per-account scope #24511) still have no switch, as on the host today. It's the one session-restore-visible change here.Linked Issue
Fixes #18486. Split from #33578.
Visual Proof
N/A. This is internal launch preparation and changes no UI. #33578 has a real Windows/WSL check with pinned Codex 0.164.0: on main,
codex exec resume <id>from account B fails with "no rollout found"; with this change it resumes from a hardlink of account A's rollout.Testing
pnpm tcandpnpm run typecheck:cipass.pnpm exec oxlint src/main/codex-accountspasses, and so do the anti-slop lint, the ast-grep gates,check:process-host-importsandcheck:code-quality:changed.src/main/codex-accounts/plussrc/main/codex/wsl-codex-session-bridge.test.tspass: 470 tests. One unrelated real-home catalog test timed out once under full-suite load and passed on reruns.codex resume <id>works but the picker's indexed-only view may not list them.AI Disclosure
Review
Agent skill upstream boundary
Notes
Windows/WSL only (
process.platform === 'win32'guard). macOS, Linux, native Windows and SSH are unchanged. No wire, settings or dependency change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)