Skip to content

fix(orcad): keep Codex status hooks in a managed account home on a WSL host, and list its sessions - #28469

Merged
nwparker merged 5 commits into
mainfrom
nwparker/wsl-e4-codex-managed-homes
Oct 14, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/wsl-e4-codex-managed-homes

Conversation

@nwparker

@nwparker nwparker commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​331 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​330
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​238 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​198

ELI5

When Orca runs inside a WSL distro as its own server (the not-yet-enabled "WSL host"), a terminal that uses a signed-in Codex account (one Orca manages, not the default ~/.codex) never told Orca what Codex was doing. Its past conversations were also missing from AI Vault. Now that server keeps Orca's status hook in that account's Codex folder and lists the folder's conversations.

What Changed

Before: the desktop sends the selected Codex account's in-distro folder (~/.local/share/orca/codex-accounts/<id>/home) as CODEX_HOME when it opens a terminal on the WSL host. The server inside the distro (orcad) passed it straight through. It never put Orca's status hook in that folder, so a Codex pane there reported no status. AI Vault, and looking a transcript up by session id, only searched ~/.codex and Orca's shared folder, so the account's conversations didn't show up.

After:

  • Status hook. orcad recognises a CODEX_HOME that is an Orca-owned account folder: under the account root, with an ownership marker holding the account id. The path is checked as text first, because it comes from the client. Before the terminal starts, orcad keeps Orca's status hook in that folder. It uses the same in-place editor that already maintains ~/.codex, generalised to take any folder (reconcileCodexHookEntriesInHome, sweepRealHomeCodexHook(home)). Only Orca's entry and its approvals change; the account's own hooks and approvals stay. With status hooks turned off, Orca's entry is taken back out. Any other CODEX_HOME is left untouched.
  • Sessions. orcad lists these account folders as extra Codex folders, so AI Vault shows their sessions. The native-chat lookup by session id now searches per-account folders as a separate tier. It runs only after the default folders miss, never when the caller names its own folders, and an error while listing them is skipped. That last part applies on the desktop too, for its own per-account folders.

~/.codex behaviour is unchanged: the wrappers pass the same paths, the same queue key and the same one-time backup as before. Nothing here turns on the WSL host; it stays behind ORCA_INTERNAL_WSL_HOSTS. On SSH hosts there are no such folders, so nothing changes.

Why

The first version reused the desktop's installer for managed account homes. That installer rebuilds a home's hooks from ~/.codex. Review found it would delete hooks and approvals that existed only in the account folder, which the WSL bridge always kept. A "skip if something would be lost" guard was then found racy and still lossy. Editing in place the way ~/.codex is edited matches what the bridge did, reuses code that is already hardened against concurrent saves, and loses nothing.

Linked Issue

Track E step E4 of the internal WSL-host work (no public issue).

Visual Proof

N/A: no UI change. The behaviour is server-side; see Testing for the end-to-end run.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

End-to-end on macOS (POSIX orcad, the same code that runs in a distro): I built orcad, started it with an isolated HOME, paired a client, and created a terminal with CODEX_HOME pointing at a fake account folder. That folder held its own Stop hook and a rollout file.

Check main this branch
pane gets the account CODEX_HOME yes yes
Orca's status hook in the account hooks.json (with Codex's approvals) no yes
account-only user hook kept n/a yes
hook fired from the pane reaches orcad's status store (worktree.ps) n/a yes
AI Vault lists the account session no (timed out) yes
a user CODEX_HOME outside the account root is untouched yes yes

Unit tests:

  • Account folder ownership: lexical rejection, wrong marker, symlink escape, listing.
  • The in-place lane on an account folder: adds next to a user hook and keeps its approval; hooks-off removes only Orca's entry; a second launch is a no-op.
  • The orcad wiring.
  • The resolver tiers: order, caller-named folders, an unlistable folder.

The existing ~/.codex lane suites pass unchanged. Not tested on a real WSL distro with a real managed account: there is no test Codex account. Codex's hook firing was exercised by running the installed hook command inside the pane.

Review

Three adversarial review rounds with a second model. Round 1 and round 2 findings (lost hooks and approvals, a stat on a wire path, by-id lookup, a race in the guard, a desktop mkdir on lookup) are each fixed by the redesign or by a direct fix. Round 3: no MEDIUM/HIGH findings, LOW.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: only paths under the Orca account root, with a matching marker, are edited. The path is checked lexically before any filesystem call.
  • Cross-platform: POSIX-only path forms; this does nothing on a Windows orcad.
  • SSH: no account folders, so no change.
  • Wire compatibility: no change.
  • Performance: the account tier only runs after a lookup misses.

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)

@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 254fc2a7-626d-4734-b999-e3a40465435c
📥 Commits

Reviewing files that changed from the base of the PR and between 8b0fa15 and f82edb3.

📒 Files selected for processing: 15
  • src/main/codex-accounts/guest-codex-account-homes.test.ts
  • src/main/codex-accounts/guest-codex-account-homes.ts
  • src/main/codex/codex-account-home-hook.test.ts
  • src/main/codex/codex-account-home-hook.ts
  • src/main/codex/codex-hook-orca-approvals.ts
  • src/main/codex/codex-hook-trust-cleanup.ts
  • src/main/codex/codex-real-home-hook-install.ts
  • src/main/codex/codex-real-home-hook-sweep.ts
  • src/main/codex/codex-real-home-hooks-json.ts
  • src/main/native-chat/host-readable-transcript-path.ts
  • src/main/native-chat/session-file-resolver-codex-roots.test.ts
  • src/main/native-chat/session-file-resolver.ts
  • src/main/orcad/orcad-codex-account-homes.test.ts
  • src/main/orcad/orcad-codex-account-homes.ts
  • src/main/orcad/orcad-entry.ts
  • 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.

❤️ Share

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

@nwparker
nwparker merged commit 7b915d5 into main Oct 14, 2026
45 checks passed
nwparker added a commit that referenced this pull request Oct 16, 2026
The per-account tier of the session-file resolver listed homes through
getHostCodexHomePathsForSessionDiscovery, which reached the mkdir-ing
getOrcaManagedCodexHomePath. The transcript poll runs every 5 s on a miss, so
users who never used Codex got userData/codex-runtime-home/home created. Use
the path-only resolver for discovery, and skip the per-account ownership
checks while the managed accounts root does not exist.

Follow-up to #28469.
nwparker added a commit that referenced this pull request Oct 16, 2026
…9557)

The per-account tier of the session-file resolver listed homes through
getHostCodexHomePathsForSessionDiscovery, which reached the mkdir-ing
getOrcaManagedCodexHomePath. The transcript poll runs every 5 s on a miss, so
users who never used Codex got userData/codex-runtime-home/home created. Use
the path-only resolver for discovery, and skip the per-account ownership
checks while the managed accounts root does not exist.

Follow-up to #28469.
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