Skip to content

Bridge WSL Codex sessions into runtime home - #7477

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/codex-home-wsl
Jul 6, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/codex-home-wsl

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a WSL-side Codex session bridge that runs inside the selected distro and hardlinks only sessions/**/*.jsonl from the WSL user's real ~/.codex into Orca's per-distro managed runtime home.
  • Start that bridge from the WSL prepareForCodexLaunch() path after the managed runtime home is materialized, while leaving the host bridge path unchanged.
  • Reuse Orca's existing WSL argv dollar-escape helper so Linux-side shell variables survive 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.
  • Added WSL bridge unit coverage and WSL runtime-home integration regressions, including distro resolution, JSONL-only bridging, existing-target handling, profile/login stdout before the JSON summary, and background dedup cleanup.
  • Full WSL E2E proof on Ubuntu with 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, asserted CODEX_HOME/ORCA_CODEX_HOME were 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 .sqlite target did not exist.
  • Codex picker proof: the same E2E flow ran native WSL Codex under node-pty + @xterm/headless with CODEX_HOME=$HOME/.local/share/orca/codex-runtime-home/home; codex resume --all --include-non-interactive --no-alt-screen rendered Resume a previous session and showed the unique fake prompt marker from the bridged JSONL.
  • Full pnpm lint / pnpm test / pnpm build were 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 ../wsl in runtime-home test cleanup, threaded the resolved distro from the materialized runtime home, added a 30s wsl.exe timeout, switched Linux path joins to path.posix.join, parsed the last non-empty stdout line for login/profile noise, and replaced the parser's filter(...).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 host linkSync; host/macOS/Linux non-WSL launches still use the existing host bridge path; all path building uses existing WSL home resolution plus path.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 execFile with an argv array rather than shelling through host command strings, runs only wsl.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 *.jsonl under sessions/; it does not copy, link, or touch state_5.sqlite, logs_2.sqlite, goals_1.sqlite, or memories_1.sqlite. No new dependencies, secrets, auth flows, or IPC surfaces were added.

Notes

Root Cause

WSL launches returned early from prepareForCodexLaunch() through syncWslRuntimeForCurrentSelection(...), before the existing host-only startSystemCodexSessionBridgeInBackground() call. The existing bridge also reads getSystemCodexHomePath(), which resolves host ~/.codex, so no WSL user's ~/.codex/sessions were linked into the WSL managed CODEX_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_HOME at 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).

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This 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 wsl.exe with background task deduplication. CodexRuntimeHomeService now starts the bridge during WSL launch preparation, and new tests cover the bridge logic and the runtime-home integration.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately captures the main change: adding a WSL Codex session bridge into the runtime home flow.
Description check ✅ Passed The description follows the template and includes summary, screenshots, testing, AI review, security audit, and notes with cross-platform coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6c980d63-01b8-4d66-86d4-16c6591396d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa8589 and aa20bb7.

📒 Files selected for processing (4)
  • src/main/codex-accounts/runtime-home-service.test.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex/wsl-codex-session-bridge.test.ts
  • src/main/codex/wsl-codex-session-bridge.ts

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-home-wsl branch from aa20bb7 to 72d685a Compare July 6, 2026 03:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/codex/wsl-codex-session-bridge.ts (1)

130-132: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the POSIX path utility for Linux-side path joins.

This is runtime path construction; use node:path/posix instead 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.join or 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

📥 Commits

Reviewing files that changed from the base of the PR and between aa20bb7 and 72d685a.

📒 Files selected for processing (4)
  • src/main/codex-accounts/runtime-home-service.test.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex/wsl-codex-session-bridge.test.ts
  • src/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

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-home-wsl branch from 72d685a to 22045d2 Compare July 6, 2026 20:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex/wsl-codex-session-bridge.test.ts
  • src/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

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-home-wsl branch from 22045d2 to d2c95cd Compare July 6, 2026 21:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex/wsl-codex-session-bridge.test.ts
  • src/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

Comment on lines +165 to +170
const summaryLine =
stdout
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
.at(-1) ?? ''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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 . || true

Repository: 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 || true

Repository: 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 || true

Repository: 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 || true

Repository: 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

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/codex-home-wsl branch from d2c95cd to 9eec57b Compare July 6, 2026 22:00
@Jinwoo-H
Jinwoo-H merged commit 377bde3 into main Jul 6, 2026
1 check passed
Jinwoo-H added a commit that referenced this pull request Jul 6, 2026
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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant