Repository navigation
fix(codex): launch WSL accounts from direct homes - #16504
Conversation
Electron UI validation (macOS, isolated profile)Isolated Orca dev instance for this worktree. No product code changed. Instance identity
Visible evidenceLanding (empty isolated profile) Settings → AI Provider Accounts → Codex
Settings search Settings → Agents → Codex command override Usage popover (quota from system Codex home) Usage → Manage Accounts… Backing IPC/store{"accounts":[],"activeAccountId":null,"activeAccountIdsByRuntime":{"host":null,"wsl":{}},"systemDefault":{"hasAuth":true,"authKind":"oauth","email":"[email protected]"}}Settings: Residual gaps (not exercised)
This validates the host system-default Codex account-home / quota UI on the PR worktree. Direct WSL launch-home behavior still needs a Windows/WSL host. |
PR review statusStatus: PASS WITH RISK — land after CI completes. Review completed on the PR worktree with the required readiness passes, focused performance/reliability review, and cross-platform checks.
No scope-expanding product changes were made. |
Review status update — Windows high-spec validation
The remaining gap is therefore environment/tooling coverage of the WSL-specific UI paths (distro/account-home selection, direct-home launch, pane retention, and legacy drain). No additional product changes were made while addressing this validation gap. |
CI noteThe current GitHub run also has an unrelated flaky failure in |
Windows high-spec retryRetried the orchestrated Grok/Electron validation after the runtime recovery. The Windows high-spec runtime is reachable, but the remote WSL environment still has no |
ebea84e to
14e33f5
Compare
740bef3 to
dc57877
Compare
The apply script validated the source hash and then re-read it with cp, so a legacy pane rotating in that window put bytes freshness never judged over a valid account home. Codex rewrites auth.json in place, so that read can be torn. Covers it by running the real guest script under sh with a sha256sum shim that rotates the source between the two reads; without the guard it exits 0.
dc57877 to
a327198
Compare
📝 WalkthroughWalkthroughThe change replaces shared WSL runtime-home materialization with direct managed or system homes. It adds a per-distro legacy authentication drain that validates, promotes, removes, and marks legacy auth. The drain now handles credential files and protects against torn reads. WSL auth reads run in one bounded guest process. WSL pane attribution now identifies legacy, account, direct-home, and shared-home routes. Tests cover drain outcomes, concurrent triggers, authentication rotation, direct-home launches, session bridging, refreshes, restarts, and account switching. Merge Risk: 🟡 Moderate · up to This PR redirects WSL sessions and quota reads to selected account homes or the distro system home while draining legacy credentials. Merge readiness remains moderate because cleanup can remove a recoverable credential prematurely, and stale host paths can cause credentials or sessions to use the wrong WSL home; owner follow-up is needed before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the main changes and lists verification steps, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue, Visual Proof, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Complete the required template sections. Add the issue reference after "Fixes #"; provide the required Visual Proof entry or state "N/A" with a reason; document testing platforms and check the applicable testing items; complete AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. Expand the summary into explicit ELI5, What Changed, and Why sections.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97c7c83d-eab2-4a57-a8d3-9476e23f12b8
📒 Files selected for processing (11)
src/main/codex-accounts/legacy-wsl-runtime-auth-drain-apply-script.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-accounts/runtime-home-wsl-managed-accounts.test.tssrc/main/codex-accounts/runtime-home-wsl-session-bridge.test.tssrc/main/codex-accounts/runtime-home-wsl-system-default.test.tssrc/main/codex/codex-pane-account-registry.tssrc/main/codex/codex-pane-launch-account.test.tssrc/main/codex/codex-pane-launch-account.tssrc/main/codex/codex-stale-pane-accounts.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| if [ "$8" = 1 ]; then | ||
| [ "$(hash_file "$source_auth")" = "$5" ] || exit 40 | ||
| rm -- "$source_auth" | ||
| printf '%s\n' '{"completed":true}' > "$temporary_marker" | ||
| chmod 600 "$temporary_marker" | ||
| mv -f -- "$temporary_marker" "$3" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Synchronize destination auth before legacy cleanup.
When $7 is 0, the target hash is checked only at Line 226. If Codex then fails during an in-place target rewrite, Lines 250-254 remove the last complete auth file and prevent later recovery with the completion marker. Retain the legacy source until the destination writer uses atomic replacement or participates in a shared lock.
| const accounts = this.store.getSettings().codexManagedAccounts.filter((account) => { | ||
| const parsedHome = parseWslUncPath(account.managedHomePath) | ||
| return parsedHome?.distro.toLowerCase() === distro.toLowerCase() | ||
| }) | ||
| const authReads = new Map<string, WslCodexAuthRead>() | ||
| for (const account of accounts) { | ||
| const parsedHome = parseWslUncPath(account.managedHomePath) | ||
| if (parsedHome) { | ||
| try { | ||
| authReads.set(account.id, await readWslCodexAuth(distro, parsedHome.linuxPath)) | ||
| } catch { | ||
| authReads.set(account.id, { kind: 'unreadable' }) | ||
| } | ||
| } | ||
| } | ||
| const match = this.findManagedAccountForRuntimeAuth(runtimeAuthContents, undefined, { | ||
| accounts, | ||
| authReads | ||
| }) | ||
| if (match.kind === 'ambiguous') { | ||
| return null | ||
| } | ||
| if (match.kind === 'matched') { | ||
| const parsedHome = parseWslUncPath(match.account.managedHomePath) | ||
| if (!parsedHome || parsedHome.distro.toLowerCase() !== distro.toLowerCase()) { | ||
| return null | ||
| } | ||
| return { | ||
| authContents: match.managedAuthContents, | ||
| linuxHomePath: parsedHome.linuxPath |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify whether persisted/migrated WSL accounts can carry a Linux home separately
# from a UNC managedHomePath.
rg -n -C 4 'wslLinuxHomePath|managedHomeRuntime|managedHomePath' srcRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- relevant symbols ---'
rg -n -C 3 --glob '*.ts' \
'interface CodexManagedAccount|type CodexManagedAccount|wslLinuxHomePath|parseWslUncPath|resolveLegacyWslAuthDestination|getWslCodexHomePathForSelection' \
src/main src/shared 2>/dev/null
printf '%s\n' '--- reviewed method ---'
sed -n '1040,1180p' src/main/codex-accounts/runtime-home-service.tsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- runtime selection and destination code ---'
sed -n '1045,1168p' src/main/codex-accounts/runtime-home-service.ts
printf '%s\n' '--- production WSL account metadata usage ---'
rg -n --glob '!*.test.ts' --glob '!*.spec.ts' \
'wslLinuxHomePath|managedHomeRuntime|wslDistro' src/main src/shared
printf '%s\n' '--- account type and applicable convention ---'
cat src/shared/managed-account-types.ts
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.mdRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- WSL account creation and persistence ---'
sed -n '810,865p' src/main/codex-accounts/service.ts
sed -n '1215,1275p' src/main/codex-accounts/service.ts
sed -n '1415,1440p' src/main/codex-accounts/service.ts
printf '%s\n' '--- WSL account fixtures with runtime markers ---'
rg -n -B 8 -A 12 --glob '*.test.ts' \
"managedHomeRuntime: 'wsl'" src/main/codex-accounts
printf '%s\n' '--- relevant repository convention ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.mdRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- WSL runtime tests around legacy path handling ---'
sed -n '430,545p' src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts
printf '%s\n' '--- all production construction sites for WSL managed homes ---'
rg -n -C 5 --glob '!*.test.ts' --glob '!*.spec.ts' \
'managedHomePath:|managedHomeRuntime: .wsl.|wslLinuxHomePath =' \
src/main/codex-accounts src/shared/managed-account-types.ts
printf '%s\n' '--- account normalization and migration references ---'
rg -n -C 4 --glob '!*.test.ts' --glob '!*.spec.ts' \
'codexManagedAccounts|managedHomePath|wslLinuxHomePath' \
src/main/store src/main/settings src/shared 2>/dev/null || trueRepository: stablyai/orca
Length of output: 24911
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- destination result and account matching ---'
sed -n '1123,1215p' src/main/codex-accounts/runtime-home-service.ts
rg -n -C 6 \
'function findManagedAccountForRuntimeAuth|findManagedAccountForRuntimeAuth|function readWslCodexAuth|readWslCodexAuth|startLegacyWslRuntimeAuthDrain' \
src/main/codex-accounts src/mainRepository: stablyai/orca
Length of output: 27663
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '32,112p' src/main/codex-accounts/legacy-wsl-runtime-auth-drain.tsRepository: stablyai/orca
Length of output: 2761
Use WSL metadata for legacy destination resolution. getWslCodexHomePathForSelection accepts WSL accounts without a WSL UNC managedHomePath, but resolveLegacyWslAuthDestination excludes them before matching credentials. The drain then returns pending and does not promote refreshed credentials. Use wslDistro and wslLinuxHomePath.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 24db8012-f05a-41f1-bd09-b6fe803649db
📒 Files selected for processing (5)
src/main/codex-accounts/legacy-wsl-runtime-auth-drain-apply-script.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-accounts/wsl-codex-auth-batch-reader.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| source_credentials="$legacy_home/.credentials.json" | ||
| target_credentials="$target_home/.credentials.json" | ||
| if [ -f "$source_credentials" ] && [ ! -e "$target_credentials" ] && [ ! -L "$target_credentials" ]; then | ||
| [ "$9" != missing ] || exit 43 | ||
| [ "$(hash_file "$source_credentials")" = "$9" ] || exit 43 | ||
| cp -- "$source_credentials" "$temporary_credentials" | ||
| chmod 600 "$temporary_credentials" | ||
| [ "$(hash_file "$temporary_credentials")" = "$9" ] || exit 43 | ||
| [ "$(hash_file "$source_credentials")" = "$9" ] || exit 43 | ||
| mv -n -- "$temporary_credentials" "$target_credentials" | ||
| elif [ "$9" = missing ] && [ ! -e "$target_credentials" ] && [ ! -L "$target_credentials" ]; then | ||
| [ ! -e "$source_credentials" ] && [ ! -L "$source_credentials" ] || exit 43 |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Remove verified legacy credentials before completion.
When the last pane exits, Line 289 removes only auth.json; .credentials.json remains after the marker is written. Verify $9 again during finalization, then remove the source credentials. If it changed, exit 43 and retry.
Windows Electron validation (HEAD
|
Review statusCompleted the requested review session for STA-4606 stage 3 at
Verification completed:
CI status:
Residual QA gap: the isolated Windows profile did not contain a managed WSL account, so the managed-account-home variant was not live exercised. The native WSL home path and launched Codex environment were exercised successfully. The branch is clean, pushed, and matches the PR head SHA above. |
…-wsl-mirror-removal-stage-3
* fix(codex): launch WSL accounts from direct homes * fix(codex): coalesce WSL auth drains and validate distro homes * fix(codex): preserve legacy WSL account home metadata * fix(codex): retain marked WSL home compatibility * fix(codex): verify the bytes the WSL drain promotes, not an earlier read The apply script validated the source hash and then re-read it with cp, so a legacy pane rotating in that window put bytes freshness never judged over a valid account home. Codex rewrites auth.json in place, so that read can be torn. Covers it by running the real guest script under sh with a sha256sum shim that rotates the source between the two reads; without the guard it exits 0. * fix(codex): harden WSL auth drain races
…tor(codex): remove WSL runtime mirror machinery" (#16722) This reverts commit ebcd637 (#16504) and dependent commit 673842d (#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.
* fix(codex): launch WSL accounts from direct homes * fix(codex): coalesce WSL auth drains and validate distro homes * fix(codex): preserve legacy WSL account home metadata * fix(codex): retain marked WSL home compatibility * fix(codex): verify the bytes the WSL drain promotes, not an earlier read The apply script validated the source hash and then re-read it with cp, so a legacy pane rotating in that window put bytes freshness never judged over a valid account home. Codex rewrites auth.json in place, so that read can be torn. Covers it by running the real guest script under sh with a sha256sum shim that rotates the source between the two reads; without the guard it exits 0. * fix(codex): harden WSL auth drain races (cherry picked from commit ebcd637)
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722) This reverts commit ebcd637 (stablyai#16504) and dependent commit 673842d (stablyai#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users. (cherry picked from commit 9c01e09)
* fix(codex): launch WSL accounts from direct homes * fix(codex): coalesce WSL auth drains and validate distro homes * fix(codex): preserve legacy WSL account home metadata * fix(codex): retain marked WSL home compatibility * fix(codex): verify the bytes the WSL drain promotes, not an earlier read The apply script validated the source hash and then re-read it with cp, so a legacy pane rotating in that window put bytes freshness never judged over a valid account home. Codex rewrites auth.json in place, so that read can be torn. Covers it by running the real guest script under sh with a sha256sum shim that rotates the source between the two reads; without the guard it exits 0. * fix(codex): harden WSL auth drain races
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722) This reverts commit 35c6098 (stablyai#16504) and dependent commit bf956ae (stablyai#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.









Summary
Verification
src/main/codex,src/main/codex-accounts, andsrc/main/agent-hookssuitespnpm typechecknode config/scripts/check-changed-code-quality.mjs