Repository navigation
Conversation
…tem default WSL launches bridged only the distro's ~/.codex into the selected account home, so a session started on another managed WSL account was missing after switching (regressed by the direct-home cutover in #16854). Bridge every sibling WSL account home in the distro too, one wsl.exe at a time. Host system-default launches on the real ~/.codex bridged nothing, so sessions from managed accounts disappeared when switching back. Bridge managed host account homes into the real home with the existing account-session bridge, which also heals Codex's thread index. Fixes #18486 Fixes #25000
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
edf637f8-d3bd-41a6-8891-566250c43d65
Files selected for processing: 4-
src/main/codex-accounts/runtime-home-real-home-lane-routing.test.tssrc/main/codex-accounts/runtime-home-service-launch.tssrc/main/codex-accounts/runtime-home-service-managed-home.tssrc/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
| targetCodexHomePath: | ||
| resolveHostCodexSessionSourceHome(this.store.getSettings()) ?? getSystemCodexHomePath(), |
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
set -o pipefail printf '%s\n' '--- diff ---' git diff --find-renames c074ec50da641241e79867cf520cea93e45a919d0 a3cacfb26556809d29235e16982373b82a74b6d0 -- src/main/codex-accounts/runtime-home-service-managed-home.ts src/main/codex-accounts printf '%s\n' '--- target implementation and related symbols ---' rg -n -F --glob '*.ts' -e 'resolveHostCodexSessionSourceHome' -e 'isHostSystemDefaultRealHomeSelected' -e 'prepareForCodexLaunch' -e 'targetCodexHomePath' -e 'codexSessionSourceHome' src/main/codex-accounts src | head -240 printf '%s\n' '--- relevant file excerpts ---' nl -ba src/main/codex-accounts/runtime-home-service-managed-home.ts | sed -n '1,240p' printf '%s\n' '--- selection/launch definitions ---' rg -l -F --glob '*.ts' -e 'isHostSystemDefaultRealHomeSelected' -e 'resolveHostCodexSessionSourceHome' -e 'codexSessionSourceHome' src/main | while read -r f; do echo "### $f"; nl -ba "$f" | sed -n '1,280p'; done printf '%s\n' '--- focused tests ---' rg -n -F --glob '*.{ts,tsx}' -e 'resolveHostCodexSessionSourceHome' -e 'isHostSystemDefaultRealHomeSelected' -e 'startSystemDefaultSessionBridgeForLaunch' -e 'configured source' -e 'session source' src/main/codex-accounts src | head -240
Repository: stablyai/orca
Length of output: 45667
Script executed:
printf '%s\n' '--- launch ---' nl -ba src/main/codex-accounts/runtime-home-service-launch.ts | sed -n '1,190p' printf '%s\n' '--- home routing ---' nl -ba src/main/codex-accounts/runtime-home-service-home-routing.ts | sed -n '1,150p' printf '%s\n' '--- session source resolver ---' nl -ba src/main/codex/codex-session-source-home.ts printf '%s\n' '--- direct consumers of source home ---' nl -ba src/main/startup/main-process-runtime-service.ts | sed -n '95,140p' nl -ba src/main/startup/main-process-account-services.ts | sed -n '35,65p' nl -ba src/main/startup/main-window-core-services.ts | sed -n '75,105p' printf '%s\n' '--- configured source tests ---' nl -ba src/main/codex-accounts/runtime-home-session-migration-pass.test.ts | sed -n '1,180p' nl -ba src/main/codex-accounts/runtime-home-real-home-lane-routing.test.ts | sed -n '1,230p' printf '%s\n' '--- relevant settings declarations ---' rg -n -F --glob '*.{ts,tsx}' -e 'codexSessionSourceHome' -e 'realHomeRoutable' src/shared src/main | head -160
Repository: stablyai/orca
Length of output: 42129
Target the real Codex home for real-home launches.
When the real-home lane is selected, prepareForCodexLaunch() returns null, so CODEX_HOME remains unset and Codex reads the system home. The bridge currently targets the configured history source instead, so managed sessions can remain unavailable from the real home.
🐛 Suggested fix
-
--- "a/src/main/codex-accounts/runtime-home-service-managed-home.ts" +++ "b/src/main/codex-accounts/runtime-home-service-managed-home.ts" @@ -155,8 +155,7 @@ return } void startCodexAccountSessionBridgeInBackground({ - targetCodexHomePath: - resolveHostCodexSessionSourceHome(this.store.getSettings()) ?? getSystemCodexHomePath(), + targetCodexHomePath: getSystemCodexHomePath(), sourceCodexHomePaths }) }
If the configured history home must also contribute existing sessions, include it as a source instead of using it as the target.
Committable suggestion
-
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.Suggested changetargetCodexHomePath: resolveHostCodexSessionSourceHome(this.store.getSettings()) ?? getSystemCodexHomePath(), targetCodexHomePath: getSystemCodexHomePath(),
* fix(codex): keep Codex history across WSL account switches 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). * fix(codex): bridge WSL siblings only into a selected account home, one 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.
… on system default When system default launches Codex on the real ~/.codex, bridge every trusted managed host account home into it so sessions started on a managed account stay resumable after switching back (#25000). Split from #33578 (host half). Needs an owner product decision (#10770 vs #24511).
…h a per-host opt-out (#24511) (#34981) * fix(codex): link managed-account history into the user's own ~/.codex on system default When system default launches Codex on the real ~/.codex, bridge every trusted managed host account home into it so sessions started on a managed account stay resumable after switching back (#25000). Split from #33578 (host half). Needs an owner product decision (#10770 vs #24511). * feat(codex): a per-host opt-out for sharing Codex history across accounts (#24511) Adds codexShareHistoryAcrossAccounts (absent = on, today's #10770 behaviour). Off, the host that launches Codex starts none of its history bridges: system default into the shared runtime home, accounts and ~/.codex into a per-account home, managed accounts into the real ~/.codex, and the WSL distro and sibling accounts into a WSL account home. Turning it off removes nothing already linked. The setting lives in each host's own store, since that host writes the links. Settings → Agents shows it for the selected host: local writes update this app, a paired SSH or WSL host is read and written over settings.get/settings.update. New hosts always publish the key; a host that doesn't is shown as needing an update and is never sent it, because older hosts' strict update schema would reject the call. Strings are localized for all 11 locales. The system-default lane moves into the launch class, keeping managed-home under the line cap. * fix(codex): ~/.codex gets hardlinks or nothing, and a WSL history source is left to the WSL lane The system-default lane wrote into codexSessionSourceHome when set, which can be a \\wsl.localhost path: the background scan would boot a stopped distro over 9P and its cross-volume symlinks are ignored by codex resume. That lane now returns early for a WSL UNC target; the WSL lane owns those homes. Into the user's own ~/.codex the bridge now links with hardlinks only: a failed hardlink (EXDEV across volumes) skips the rollout, counted as skippedFiles, removes any folder it just created, and never falls back to a symlink that codex resume ignores and that would dangle once an account is removed. Bridges between Orca-managed homes keep the symlink fallback. Also: the setting's JSDoc sits above its own field, and Settings search finds the switch (codex, history, share, shared, account; existing localized keys).
Summary (ELI5)
Orca gives each managed Codex account its own
CODEX_HOMEso their logins never collide. To keep "switch account, keep your conversations" working (#10770), Orca hardlinks session files between those homes, because Codex's/resumeandcodex resume <id>only look in their ownCODEX_HOME. Two launch paths had stopped doing that:~/.codexinto the selected account. A session started on account A was missing after switching to account B.~/.codex([Bug]: Codex session disappears after account switch when pane routes from managed home to ~/.codex (macOS 1.4.218) #25000): switching back to "system default" launched Codex on~/.codex, and nothing linked the managed accounts' sessions there, so the folder's session list looked empty.Root cause
runtime-home-service-managed-home.tsstartWslSessionBridgeForLaunchpassed only the distro system home as a source (systemCodexHomePath → runtimeHomePath). The host lane already includes every managed home (getSelfContainedSessionBridgeSourceHomes).runtime-home-service-launch.tsprepareForCodexLaunchreturnednullfor the real-home lane without starting any bridge. Managed-home history flowed from~/.codexbut never back into it.codex resume <id>resolves the rollout by scanning$CODEX_HOME/sessions(codex-rs/rollout/src/list.rs:1512-1529,find_thread_path_by_id_str→ filename fallback). The picker lists indexed threads, which the existing account-session bridge heals throughthread/read.What changed
wsl.exeat a time. The existing bridge script and its in-flight dedupe are unchanged.startCodexAccountSessionBridgeInBackgroundwith target = the host session-source home (~/.codexor the configured source home) and sources = trusted managed host account homes. This reuses its backfill-ready gate and index heal. It is skipped when there are no managed host accounts.Verification (real Windows: win-lowspec, WSL Ubuntu, pinned Codex 0.164.0, isolated USERPROFILE/APPDATA/LOCALAPPDATA/CODEX_HOME, mock Responses server, no API keys)
I drove Orca's real
CodexRuntimeHomeService.prepareForCodexLaunch*on Windows (esbuild bundle of the source, realwsl.exeand bridge script, real Codex app-server for index heal).getWslHomepoints at a temp guest dir, and accounts live under/tmp/agint-codexbridgein the distro.#18486, WSL: a real session was created with
codex execin account A's home, account B was selected, Orca's WSL launch prep ran, and thencodex exec resume <id>ran under B'sCODEX_HOME:codex exec resume <id>from Bthread/resume failed: no rollout found for thread id …#25000, host real-home lane: a real session was created in a managed host account home, system default was selected (no
CODEX_HOMEoverride), Orca's launch prep returnednull(real home), and then:~/.codex/sessions~/.codexstate DB (picker)codex exec resume <id>on~/.codexno rollout found for thread id …pnpm test src/main/codex-accounts/(457 tests),pnpm tc:node, andpnpm run check:code-quality:changedpass.Risk / trade-offs vs main
~/.codexsession list. Hardlinks only, so no extra disk use, and no auth or config is copied. This matches the existing host per-account lane, which already links~/.codexand every sibling account home in. 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. That is a separate product decision.~/.codexhas no state DB yet, the existing gate starts Codex once to create it before linking.wsl.exeruns per launch (N = number of WSL accounts in that distro).codex resume <id>works but the picker's indexed-only view may not list bridged WSL threads. The pane-restart path choosing barecodex(a comment on [Bug]: Regression in 1.4.196: Codex session history no longer bridged between managed accounts #18486) is also not covered.Fixes #18486
Fixes #25000