Repository navigation
Bridge WSL Codex sessions into runtime home - #7477
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis pull request adds a WSL session bridge module that resolves distro-specific session paths, generates a bash command to hardlink JSONL session files into a managed home, and runs that command through 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6c980d63-01b8-4d66-86d4-16c6591396d2
📒 Files selected for processing (4)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex/wsl-codex-session-bridge.test.tssrc/main/codex/wsl-codex-session-bridge.ts
aa20bb7 to
72d685a
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/codex/wsl-codex-session-bridge.ts (1)
130-132: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the POSIX path utility for Linux-side path joins.
This is runtime path construction; use
node:path/posixinstead of manually joining with/.♻️ Proposed refactor
import { execFile } from 'node:child_process' +import { posix as pathPosix } from 'node:path' @@ function joinLinuxPath(basePath: string, ...segments: string[]): string { - const normalizedBasePath = basePath === '/' ? '' : basePath.replace(/\/+$/, '') - return [normalizedBasePath, ...segments].join('/') + return pathPosix.join(basePath, ...segments) }As per coding guidelines, “Use
path.joinor Electron/Node path utilities for file paths — never assume/or\for cross-platform compatibility”.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b5e196cb-6033-4c7c-bb0f-7c445502a8dd
📒 Files selected for processing (4)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex/wsl-codex-session-bridge.test.tssrc/main/codex/wsl-codex-session-bridge.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/codex-accounts/runtime-home-service.ts
- src/main/codex-accounts/runtime-home-service.test.ts
72d685a to
22045d2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ad95e59a-3ee0-47eb-b90f-284cb7d56eff
📥 Commits
Reviewing files that changed from the base of the PR and between 72d685a and 22045d2b0b6b162aec7eb53d6778c92d0c633b76.
📒 Files selected for processing (4)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex/wsl-codex-session-bridge.test.tssrc/main/codex/wsl-codex-session-bridge.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/codex-accounts/runtime-home-service.ts
22045d2 to
d2c95cd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e262ff09-6a7e-4c22-8e01-3a22251cfae9
📥 Commits
Reviewing files that changed from the base of the PR and between 22045d2b0b6b162aec7eb53d6778c92d0c633b76 and d2c95cdbe19de6a92e0ce13639f7d7b63f920c18.
📒 Files selected for processing (4)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex/wsl-codex-session-bridge.test.tssrc/main/codex/wsl-codex-session-bridge.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/codex-accounts/runtime-home-service.ts
- src/main/codex-accounts/runtime-home-service.test.ts
| const summaryLine = | ||
| stdout | ||
| .split(/\r?\n/) | ||
| .map((line) => line.trim()) | ||
| .filter(Boolean) | ||
| .at(-1) ?? '' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== file outline ==\n'
ast-grep outline src/main/codex/wsl-codex-session-bridge.ts --view expanded || true
printf '\n== relevant source slice ==\n'
sed -n '150,190p' src/main/codex/wsl-codex-session-bridge.ts
printf '\n== package/runtime hints ==\n'
for f in package.json tsconfig.json tsconfig.*.json .eslintrc* eslint.config.*; do
[ -e "$f" ] && { echo "--- $f"; sed -n '1,220p' "$f"; }
done
printf '\n== search for findLast usage and lint rule ==\n'
rg -n "findLast|prefer-array-find|target|lib|node18|es2023" -S . || trueRepository: stablyai/orca
Length of output: 50371
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== relevant source slice ==\n'
sed -n '158,178p' src/main/codex/wsl-codex-session-bridge.ts
printf '\n== package.json (target/runtime hints) ==\n'
sed -n '1,220p' package.json
printf '\n== tsconfig files (lib/target hints) ==\n'
for f in tsconfig.json tsconfig.*.json; do
[ -e "$f" ] && { echo "--- $f"; sed -n '1,220p' "$f"; }
done
printf '\n== eslint config (unicorn rule) ==\n'
for f in .eslintrc* eslint.config.*; do
[ -e "$f" ] && { echo "--- $f"; sed -n '1,260p' "$f"; }
done
printf '\n== direct usage/search for findLast and prefer-array-find ==\n'
rg -n "findLast|prefer-array-find" src package.json tsconfig.json .eslintrc* eslint.config.* -S || trueRepository: stablyai/orca
Length of output: 16300
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== config/tsconfig.node.json ==\n'
sed -n '1,220p' config/tsconfig.node.json
printf '\n== config/tsconfig.tc.cli.json ==\n'
sed -n '1,220p' config/tsconfig.tc.cli.json
printf '\n== config/tsconfig.web.json ==\n'
sed -n '1,220p' config/tsconfig.web.json
printf '\n== package engines / runtime clues ==\n'
rg -n '"engines"|node[:=]|electron[^-]' package.json config -S || trueRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== package.json engines section ==\n'
sed -n '220,260p' package.json
printf '\n== exact lint-related line context ==\n'
sed -n '162,172p' src/main/codex/wsl-codex-session-bridge.ts
printf '\n== search for project Node support declarations ==\n'
rg -n '"node"|node version|Node [0-9]+|Electron [0-9]+' README.md docs config package.json -S || trueRepository: stablyai/orca
Length of output: 50370
Use findLast here filter(Boolean).at(-1) trips unicorn/prefer-array-find; Node 24 supports Array.prototype.findLast, so this can be simplified to findLast(Boolean).
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFile } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
🪛 GitHub Check: verify
[failure] 169-169: unicorn(prefer-array-find)
Prefer find over filtering and accessing the first result.
Sources: Linters/SAST tools, Pipeline failures
d2c95cd to
9eec57b
Compare
Brings in 9 commits: deferred remote catalogs at startup (#7087), owner-aware pane title decision gating the Gemini GPU fallback (#7458), incremental transcript parsing for JSONL agents (#7593), gh rate-limit and git-status spawn-churn fixes (#7595), WSL Codex session bridging (#7477), jump-palette subscription gating (#7558), and the IDE font dropdown fix. Conflict resolutions (our structure, main's semantics): - pty-connection.ts onTitleChange: kept this branch's third parameter and stale-derived-title guard (staleWorkingTitleClear must never feed completion tracking), grafted main's resolvePaneTitleDecision so the display label, GPU policy, and observeTitle all ride the owner-aware decision (#7428/#7447). - App.tsx startup: kept this branch's publishTerminalViewAttributesAtAppStart (hidden-at-launch OSC 10/11 replies) ahead of main's restructured local-first startup; dropped this branch's early ui.get() overlap — main's #7087 now awaits ui.get at effectively the same point, making it redundant. Gates: typecheck clean; 4298 tests across src/main/ipc, src/main/daemon, terminal-pane, pane-manager. The delivery path (ipc/pty.ts, dispatcher, scheduler, snapshots) had no conflicts and no incoming changes. Co-authored-by: Orca <[email protected]>
Summary
sessions/**/*.jsonlfrom the WSL user's real~/.codexinto Orca's per-distro managed runtime home.prepareForCodexLaunch()path after the managed runtime home is materialized, while leaving the host bridge path unchanged.wsl.exe ... bash -lc ....Screenshots
No visual change.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/main/codex/wsl-codex-session-bridge.test.ts src/main/codex/codex-session-bridge.test.ts src/main/codex-accounts/runtime-home-service.test.ts src/shared/wsl-login-shell-command.test.ts-> 105 passed.pnpm run typecheck-> passed.pnpm exec oxlint src/main/codex/wsl-codex-session-bridge.ts src/main/codex/wsl-codex-session-bridge.test.ts src/main/codex-accounts/runtime-home-service.ts src/main/codex-accounts/runtime-home-service.test.ts src/main/codex/codex-session-bridge.ts src/main/codex/codex-session-bridge.test.ts src/shared/wsl-login-shell-command.ts src/shared/wsl-login-shell-command.test.ts-> passed.git diff --check-> passed.Ubuntuwith native/home/jinwoo/.local/bin/codex(codex-cli 0.142.5): a temporary Playwright spec launched Orca, created a real WSL terminal for a WSL-runtime project, assertedCODEX_HOME/ORCA_CODEX_HOMEwere the managed runtime home, waited for the bridged JSONL to appear, verified source and managed target had the same inode with link counts>= 2, and verified the matching.sqlitetarget did not exist.node-pty+@xterm/headlesswithCODEX_HOME=$HOME/.local/share/orca/codex-runtime-home/home;codex resume --all --include-non-interactive --no-alt-screenrenderedResume a previous sessionand showed the unique fake prompt marker from the bridged JSONL.pnpm lint/pnpm test/pnpm buildwere not run locally; focused coverage and touched-file lint above were run for this PR.AI Review Report
CodeRabbit and local review checked the WSL-specific launch path, host-launch regression risk, background dedup behavior, distro resolution, Linux path construction, and noisy shell startup output. Follow-ups applied from review: unmocked
../wslin runtime-home test cleanup, threaded the resolved distro from the materialized runtime home, added a 30swsl.exetimeout, switched Linux path joins topath.posix.join, parsed the last non-empty stdout line for login/profile noise, and replaced the parser'sfilter(...).at(-1)shape with a direct last-match lookup for the merge-ref oxlint rule.Cross-platform compatibility checked: WSL execution remains Windows-gated behind
process.platform === 'win32'; Linux-side hardlinks run inside WSL, not through hostlinkSync; host/macOS/Linux non-WSL launches still use the existing host bridge path; all path building uses existing WSL home resolution pluspath.join/path.posix.join; no UI shortcut, label, or Electron renderer behavior changed.Security Audit
Reviewed command execution, path handling, and data scope. The WSL bridge uses
execFilewith an argv array rather than shelling through host command strings, runs onlywsl.exe -d <distro> -- bash -lc <script>, applies the existing WSL dollar-escape helper, converts managed/system UNC paths to Linux paths before entering WSL, quotes Linux shell paths, and bounds execution with a 30s timeout. The bridge only hardlinks*.jsonlundersessions/; it does not copy, link, or touchstate_5.sqlite,logs_2.sqlite,goals_1.sqlite, ormemories_1.sqlite. No new dependencies, secrets, auth flows, or IPC surfaces were added.Notes
Root Cause
WSL launches returned early from
prepareForCodexLaunch()throughsyncWslRuntimeForCurrentSelection(...), before the existing host-onlystartSystemCodexSessionBridgeInBackground()call. The existing bridge also readsgetSystemCodexHomePath(), which resolves host~/.codex, so no WSL user's~/.codex/sessionswere linked into the WSL managedCODEX_HOME.Fix
The new WSL bridge resolves the already-known per-distro WSL system and managed homes, converts UNC paths to Linux paths, and asks bash inside the distro to hardlink session JSONL files into the managed runtime sessions tree. It does not point
CODEX_HOMEat the user's~/.codex, and it does not copy or touch SQLite databases.Temporary E2E files were not committed, and WSL synthetic session leftovers under the
01900000-0000-7000-8000-*test prefix were removed (syntheticSessionLeftovers=0).