You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(wsl-host): chat and text generation never run a Windows-side agent CLI on a WSL host - #34590
When a WSL distro has no Claude or Codex installed but Windows does, Orca's server inside the distro could start the Windows copy. WSL adds the Windows PATH to the end of the distro's PATH, and an npm-installed claude on Windows comes with a shell script that WSL can run. After this PR, a chat on a WSL host with no Linux install says the agent isn't installed instead of running Windows' copy. Chat-name and commit-message generation get the same treatment.
What Changed
All of this reuses the existing Windows-drive stripping in src/main/ipc/wsl-guest-windows-drive-path.ts. It finds the drive mounts by type in /proc/mounts (drvfs, 9p, virtiofs), so a custom automount root works, and it is gated on isWslHostOrcadProcess, meaning ORCA_WSL_ORCAD_HOST=1 inside a WSL guest.
Chat programs (Claude, Codex, ACP agents, Pi). They all resolve their stock program through resolveStructuredAgentCommand. That already stripped the drive entries, but when nothing native was found it returned the bare name, and the spawn's own PATH search then found the Windows shim anyway. A new helper, resolveGuestNativeProgram, tells "missing everywhere" apart from "only a Windows copy". In the second case the chat refuses before anything spawns, with the existing cliMissing reason ("Claude wasn't found on the computer running this chat…"). There's no wire change, and the existing refresh-on-miss retry also covers it, so a WSL install made since the last shell read is still found. The agent's own child keeps its full PATH, so its tools can still use interop (code, explorer.exe).
Text generation (chat names, commit messages, model discovery). These run claude -p / codex as one-shot children. On a WSL host those children get a PATH without drive entries, so a missing CLI fails as "not found" instead of starting the Windows copy.
src/main/codex-cli/command.ts.resolveClaudeCommand / resolveCodexCommand serve the account command process, version probes, Codex login, hook-hash lookup, index heal and backfill, and the rate-limit fetcher. They now use the same native-only resolution. On a WSL host, a Windows-only copy resolves to a path under /proc that can never exist. A bare name would be found again by the spawn's own PATH search, so it isn't returned. Each caller then takes the missing-CLI path it already has: spawn ENOENT, no fingerprint, no version. A CLI missing everywhere stays a bare name, as before. Nothing changes off a WSL host.
Sign-in and usage wording. Codex sign-in and the Codex usage probe used to say "Codex CLI found but could not run — Node.js may not be in your PATH" for a Windows-only copy. Claude sign-in showed the raw spawn /proc/… ENOENT. All three now say " is installed only on Windows, not in this WSL distro. Install it inside the distro." The usage probe also marks it unavailable. A Windows-only answer is never cached in the Claude account command, so a Claude installed in WSL afterwards is used on the next call. The helpers live in codex-cli/windows-only-agent-cli.ts, kept apart from ./command, which many tests mock whole. The Codex usage-probe errors gain a trailing period, so they match sign-in.
Terminals and user commands are untouched.
Model and command listings. Claude, Codex, ACP and Pi listing probes resolve through the same chat resolvers, and text-generation model discovery goes through the same spawn as text generation, so both fixes cover them.
Lane. With the guest claude removed, the lane asserts that the decoy never runs and that the probe recorded no errors. It also asserts that a chat create and send on that host returns cliMissing.
Before: on #34551's lane run, all four distros ran the Windows-side claude. On this PR's first lane run, which only filtered the shared resolvers, the decoy still ran, as claude -p --output-format text --model sonnet …. That was text generation spawning the bare name. The receipt also showed orcad had ORCA_WSL_ORCAD_HOST, WSL_DISTRO_NAME, WSL_INTEROP and the WSLInterop binfmt, so the gate itself was on.
Why
The missing piece wasn't the PATH filter. It was the bare-name fallback and the text-generation spawn. Refusing with cliMissing keeps the wire unchanged and gives the user the existing install guidance. Stripping PATH from the long-running chat child was rejected because it would break interop tools the agent legitimately runs.
Release note
On a WSL host, a Claude or Codex installed only on Windows is now reported as not found, instead of Orca running the Windows CLI.
Linked Issue
N/A (maintainer).
Visual Proof
N/A: no UI change; the existing cliMissing copy is shown.
Testing
src/main/ipc/wsl-guest-native-program.test.ts covers four things:
a WSL install beats a Windows copy;
only a Windows copy gives null;
a program missing everywhere stays as its bare name;
with no drive mounts, resolution is unchanged.
It also covers the spawn env, and pins the gate off on macOS, the Windows desktop, native Linux and SSH-host orcad.
structured-agent-command-resolution-wsl-host.test.ts: Claude, Codex and Pi refuse with cliMissing, and a shell refresh then finds a new WSL install.
New *-windows-only.test.ts files:
Claude sign-in gets the WSL wording;
a Windows-only answer isn't reused, so the next call spawns the new WSL install;
Codex sign-in gets the WSL wording, not "Node.js may not be in your PATH";
the usage probe reports the WSL wording as unavailable.
command-guest-path.test.ts:
a WSL install wins over the Windows copy;
a Windows-only copy reads as not installed;
a CLI missing everywhere and hosts other than WSL resolve as before;
each kind of caller fails cleanly on the Windows-only path: nothing on disk, a spawn gives ENOENT, and a version probe gives null.
pnpm tc, pnpm run typecheck:ci, check:code-quality:changed, ratchets and oxlint pass, as do the touched suites (657 tests).
This PR's WSL orcad E2E lane run is the real-distro proof. On 89e1d5b, ubuntu and fedora passed: the decoy never ran and the chat refused with cliMissing. On debian the decoy never ran either, but the chat failed with a plain spawn claude ENOENT. Debian's /etc/profile resets PATH for login shells, so the chat's PATH never showed the Windows copy, and the CLI simply counted as missing. The lane now accepts either refusal; the decoy must never run on any distro.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
User risk: limited to WSL-host orcad. A WSL host exists only with ORCA_INTERNAL_WSL_HOSTS, and everything here is inert without Windows drive mounts, so the desktop, native Linux, macOS and SSH hosts are unchanged.
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
Rebased onto main after #34551 merged. Follow-ups I'm not doing here:
The cliMissing copy says "the computer running this chat" rather than naming the distro. Naming it would need a new reason or parameter, which needs a compatibility plan for older clients.
Terminal agent launches type the command into the user's shell, so a Windows-only install still runs there. That is the user's shell behaving as it does in their own terminal, so it is left alone.
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)
nwparker
changed the title
fix(wsl-host): never resolve a Windows-side claude or codex on a WSL host
fix(wsl-host): chat and text generation never run a Windows-side agent CLI on a WSL host
Oct 27, 2026
Guest-native command resolution filters Windows-drive paths when WSL drive mounts are supplied. CLI wrappers use a Windows-only path when guest-native resolution finds no program. Structured agent resolution reports cliMissing and can retry after a shell refresh. Supervised agent launches filter their spawn environment. Claude and Codex handlers classify Windows-only command failures. The WSL chat contract checks that Windows-only chat is refused and that the Windows-side decoy remains unrun.
Priority: Normal
Merge Risk: Low · up to cb54e
WSL launches can still run Windows-side CLIs in certain PATH configurations. Address these edge cases or accept them for follow-up.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: preventing chat and text generation from running Windows-side agent CLIs on WSL hosts.
Description check
The description includes all required sections and provides clear user impact, implementation details, rationale, testing evidence, scope, and compatibility considerations. The maintainer correctly us…
Docstring Coverage
Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description includes all required sections and provides clear user impact, implementation details, rationale, testing evidence, scope, and compatibility considerations. The maintainer correctly uses N/A for the linked issue, and the unchecked local-test items do not make the description incomplete.
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
set -e
printf'%s\n''--- production structured-agent callers ---'forfin \
src/main/claude/claude-structured-child-env.ts \
src/main/pi/rpc-launch-resolution.ts \
src/main/codex/codex-structured-launch-resolution.ts \
src/main/acp/acp-structured-launch-resolution.ts \
src/main/runtime/structured-agent-launch-support.ts \
src/main/runtime/structured-agent-runtime-metadata.ts \
src/main/runtime/workspaces/workspace-process-listing.ts \
src/main/claude/claude-model-catalog-probe.ts \
src/main/codex/codex-model-catalog-probe.ts
doiftest -f "$f";thenprintf'%s\n'"--- $f ---"
nl -ba "$f"| sed -n '1,230p'fidoneprintf'%s\n''--- all non-test structured-agent call contexts ---'
rg -n -C 8 -F --glob '*.ts''resolveStructuredAgentCommand(' src/main -g '!*.test.ts'printf'%s\n''--- mount predicate and path helper ---'
nl -ba src/main/ipc/wsl-guest-windows-drive-path.ts | sed -n '35,115p'printf'%s\n''--- focused guest-path tests ---'
nl -ba src/main/native-chat/structured-agent-command-guest-path.test.ts | sed -n '1,130p'
nl -ba src/main/codex-cli/command-guest-path.test.ts | sed -n '1,100p'
Repository: stablyai/orca
Length of output: 41932
Reject drive-mounted resolver results.
resolveGuestNativeProgram filters pathEnv, but resolveCliCommand also searches install directories derived from homePath. A WSL environment with a drive-mounted HOME can therefore return a Windows-drive CLI, which the current isAbsolute(native) branch accepts.
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.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Supported by static analysis
Script executed:
sed -n '1,170p' src/main/ipc/wsl-guest-windows-drive-path.ts
sed -n '1,220p' src/shared/node-cli-command-resolution.ts
sed -n '35,85p' src/main/native-chat/structured-agent-command-resolution.ts
Repository: stablyai/orca
Length of output: 13952
Filter PATH entries by their resolved location.
withoutWindowsDriveMountDirs compares each PATH entry as text. A directory such as /home/me/bin that is a symlink into a Windows drive mount, such as /mnt/c/..., does not match a mount prefix, so it stays in PATH. The shared resolver then checks candidates with statSync and accessSync, which follow symlinks. For a CLI in that directory, it can return the absolute path /home/me/bin/claude. resolveGuestNativeProgram accepts any absolute result, so the Windows-side CLI is returned instead of null. guestNativeSpawnEnv keeps the same PATH entry, so a text-generation child can also reach the Windows-side CLI.
Compare the resolved directory with the mounts as well as the text:
Suggested fix
-import { existsSync, readFileSync } from 'node:fs'+import { existsSync, readFileSync, realpathSync } from 'node:fs'
+/** Resolve a symlinked PATH entry to its real location; keep the text when resolution fails. */+function resolvedPathDir(dir: string): string {+ if (!isAbsolute(dir)) {+ return dir+ }+ try {+ return realpathSync(dir)+ } catch {+ return dir+ }+}+
export function withoutWindowsDriveMountDirs(pathValue: string, mounts: readonly string[]): string {
if (mounts.length === 0) {
return pathValue
}
return pathValue
.split(':')
- .filter((dir) => !isUnderWindowsDriveMount(dir.replace(/\/+$/, ''), mounts))+ .filter((dir) => {+ const lexical = dir.replace(/\/+$/, '')+ return (+ !isUnderWindowsDriveMount(lexical, mounts) &&+ !isUnderWindowsDriveMount(resolvedPathDir(lexical), mounts)+ )+ })
.join(':')
}
The change belongs in the PATH filter, not in resolveGuestNativeProgram. Removing the entry before resolution lets the resolver find a native copy later on PATH. A post-resolution check would return null even when a native copy exists.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
printf'%s\n''--- resolver helpers ---'
nl -ba src/shared/node-cli-command-resolution.ts | sed -n '45,105p;135,175p;220,265p'printf'%s\n''--- focused native resolver tests ---'
nl -ba src/main/ipc/wsl-guest-native-program.test.ts | sed -n '1,180p'printf'%s\n''--- baseline command and baseline resolver context ---'
git show f4d98b74e32535fb12394a085a0dd01bd9975a97:src/main/codex-cli/command.ts
git show f4d98b74e32535fb12394a085a0dd01bd9975a97:src/shared/node-cli-command-resolution.ts | nl -ba | sed -n '220,265p'printf'%s\n''--- direct resolver call sites relevant to launch ---'
nl -ba src/main/text-generation/source-control-agent-launch.ts | sed -n '60,100p'
nl -ba src/main/claude-accounts/claude-command-process.ts | sed -n '45,75p'
Repository: stablyai/orca
Length of output: 14993
Reject Windows-drive executables reached through symlinks.
If a WSL bin directory contains a symlink to a Windows-drive claude or codex shim, resolveGuestNativeProgram can accept it. The PATH filter checks directory strings, while resolveCliCommand uses statSync and accessSync, which follow the symlink. The wrapper then returns the symlink path instead of the WINDOWS_ONLY_AGENT_CLI_DIR sentinel, so a later spawn can launch the Windows-side CLI.
Resolve the accepted executable before checking its mount. Apply this check to PATH results and fallback installation directories.
This is a narrow gap in the PR’s stated goal, not a regression. The baseline resolver already allowed the same symlink path.
This PR includes the complete terminal launch fix (PR-A):
Changes for terminal launches:
src/main/native-chat/structured-agent-command-resolution.ts: Uses resolveGuestNativeProgram to detect Windows-only copies and reject with cliMissing reason
src/main/native-chat/structured-agent-command-resolution-wsl-host.test.ts: Tests verify terminal launches (claude, codex, pi) refuse with cliMissing when only Windows copy exists
Behavior:
Terminal launches on WSL host with Windows-only CLI: Reject with "installed only on Windows, not in WSL distro"
Note: Attempted to create separate PR-A stacked on this branch but encountered GitHub infrastructure timeout on workflow creation. The complete terminal launch fix is implemented and tested here in PR #34590.
Filter PATH components against the effective child cwd.
guestNativeSpawnEnv(spawnEnv) filters raw PATH components without the child cwd. Because input.binary can be a bare command, withCliRuntimeOnPath leaves this PATH unchanged. A relative component, or an empty component, can therefore resolve against the effective child cwd and launch a Windows-side CLI. Filtering all components can also produce PATH="", which still searches the cwd.
Filter components against launch.cwd ?? process.cwd(). Remove components that resolve under Windows mounts. Preserve safe native entries, including an empty entry when the effective cwd is native. Use a nonempty sentinel only when no entries survive. Keep the existing no-mount behavior that returns PATH unchanged.
This is a narrow, recoverable one-shot CLI-selection failure. Minor severity is proportional.
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: 7a0b4bc9-477d-4efe-ba0f-f7bf562a0a18
Commits
Reviewing files that changed from the base of the PR and between b2c85f3 and cb54ec9.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
On a WSL host (orcad inside WSL with ORCA_WSL_ORCAD_HOST), interactive
terminal agent launches now check if the agent is Windows-only before
typing the command. If only a Windows copy exists, show the same error
message as other spawn paths: "installed only on Windows, not in this
WSL distro." This ensures terminal launches have feature parity with
chat and background agent spawns added in PR #34590.
When an agent is found as an absolute path in the WSL distro, terminal
launches prefer that resolved path over the bare command name, improving
consistency across launch paths.
Desktop, native Linux, macOS, and SSH terminal launches are unchanged —
WSL host path resolution only applies when isWslHostOrcadProcess() returns
true.
Test coverage: 9 tests verify desktop/Linux/macOS/SSH launches remain
unchanged, and WSL host resolution behavior (Windows-only detection,
absolute path preference, bare command fallback).
…34674)
* feat: make WSL host terminal agent launches consistent
On a WSL host (orcad inside WSL with ORCA_WSL_ORCAD_HOST), interactive
terminal agent launches now check if the agent is Windows-only before
typing the command. If only a Windows copy exists, show the same error
message as other spawn paths: "installed only on Windows, not in this
WSL distro." This ensures terminal launches have feature parity with
chat and background agent spawns added in PR #34590.
When an agent is found as an absolute path in the WSL distro, terminal
launches prefer that resolved path over the bare command name, improving
consistency across launch paths.
Desktop, native Linux, macOS, and SSH terminal launches are unchanged —
WSL host path resolution only applies when isWslHostOrcadProcess() returns
true.
Test coverage: 9 tests verify desktop/Linux/macOS/SSH launches remain
unchanged, and WSL host resolution behavior (Windows-only detection,
absolute path preference, bare command fallback).
* fix(wsl-host): refuse Windows-only agent CLIs in terminal launches without touching the terminal env
* fix(wsl-host): launch a native alias binary before refusing a Windows-only agent
* fix(wsl-host): refuse wrapper launches whose required CLI is Windows-only
---------
Co-authored-by: bench <[email protected]>
Co-authored-by: Neil <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When a WSL distro has no Claude or Codex installed but Windows does, Orca's server inside the distro could start the Windows copy. WSL adds the Windows PATH to the end of the distro's PATH, and an npm-installed
claudeon Windows comes with a shell script that WSL can run. After this PR, a chat on a WSL host with no Linux install says the agent isn't installed instead of running Windows' copy. Chat-name and commit-message generation get the same treatment.What Changed
All of this reuses the existing Windows-drive stripping in
src/main/ipc/wsl-guest-windows-drive-path.ts. It finds the drive mounts by type in/proc/mounts(drvfs, 9p, virtiofs), so a custom automount root works, and it is gated onisWslHostOrcadProcess, meaningORCA_WSL_ORCAD_HOST=1inside a WSL guest.resolveStructuredAgentCommand. That already stripped the drive entries, but when nothing native was found it returned the bare name, and the spawn's own PATH search then found the Windows shim anyway. A new helper,resolveGuestNativeProgram, tells "missing everywhere" apart from "only a Windows copy". In the second case the chat refuses before anything spawns, with the existingcliMissingreason ("Claude wasn't found on the computer running this chat…"). There's no wire change, and the existing refresh-on-miss retry also covers it, so a WSL install made since the last shell read is still found. The agent's own child keeps its full PATH, so its tools can still use interop (code,explorer.exe).claude -p/codexas one-shot children. On a WSL host those children get a PATH without drive entries, so a missing CLI fails as "not found" instead of starting the Windows copy.src/main/codex-cli/command.ts.resolveClaudeCommand/resolveCodexCommandserve the account command process, version probes, Codex login, hook-hash lookup, index heal and backfill, and the rate-limit fetcher. They now use the same native-only resolution. On a WSL host, a Windows-only copy resolves to a path under/procthat can never exist. A bare name would be found again by the spawn's own PATH search, so it isn't returned. Each caller then takes the missing-CLI path it already has: spawn ENOENT, no fingerprint, no version. A CLI missing everywhere stays a bare name, as before. Nothing changes off a WSL host.spawn /proc/… ENOENT. All three now say " is installed only on Windows, not in this WSL distro. Install it inside the distro." The usage probe also marks it unavailable. A Windows-only answer is never cached in the Claude account command, so a Claude installed in WSL afterwards is used on the next call. The helpers live incodex-cli/windows-only-agent-cli.ts, kept apart from./command, which many tests mock whole. The Codex usage-probe errors gain a trailing period, so they match sign-in.clauderemoved, the lane asserts that the decoy never runs and that the probe recorded no errors. It also asserts that a chat create and send on that host returnscliMissing.Before: on #34551's lane run, all four distros ran the Windows-side
claude. On this PR's first lane run, which only filtered the shared resolvers, the decoy still ran, asclaude -p --output-format text --model sonnet …. That was text generation spawning the bare name. The receipt also showed orcad hadORCA_WSL_ORCAD_HOST,WSL_DISTRO_NAME,WSL_INTEROPand the WSLInterop binfmt, so the gate itself was on.Why
The missing piece wasn't the PATH filter. It was the bare-name fallback and the text-generation spawn. Refusing with
cliMissingkeeps the wire unchanged and gives the user the existing install guidance. Stripping PATH from the long-running chat child was rejected because it would break interop tools the agent legitimately runs.Release note
On a WSL host, a Claude or Codex installed only on Windows is now reported as not found, instead of Orca running the Windows CLI.
Linked Issue
N/A (maintainer).
Visual Proof
N/A: no UI change; the existing
cliMissingcopy is shown.Testing
src/main/ipc/wsl-guest-native-program.test.tscovers four things:null;It also covers the spawn env, and pins the gate off on macOS, the Windows desktop, native Linux and SSH-host orcad.
structured-agent-command-resolution-wsl-host.test.ts: Claude, Codex and Pi refuse withcliMissing, and a shell refresh then finds a new WSL install.New
*-windows-only.test.tsfiles:command-guest-path.test.ts:pnpm tc,pnpm run typecheck:ci, check:code-quality:changed, ratchets and oxlint pass, as do the touched suites (657 tests).This PR's WSL orcad E2E lane run is the real-distro proof. On 89e1d5b, ubuntu and fedora passed: the decoy never ran and the chat refused with
cliMissing. On debian the decoy never ran either, but the chat failed with a plainspawn claude ENOENT. Debian's/etc/profileresets PATH for login shells, so the chat's PATH never showed the Windows copy, and the CLI simply counted as missing. The lane now accepts either refusal; the decoy must never run on any distro.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
User risk: limited to WSL-host orcad. A WSL host exists only with
ORCA_INTERNAL_WSL_HOSTS, and everything here is inert without Windows drive mounts, so the desktop, native Linux, macOS and SSH hosts are unchanged.Agent skill upstream boundary
Notes
Rebased onto main after #34551 merged. Follow-ups I'm not doing here:
cliMissingcopy says "the computer running this chat" rather than naming the distro. Naming it would need a new reason or parameter, which needs a compatibility plan for older clients.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)