Skip to content

fix(wsl-host): chat and text generation never run a Windows-side agent CLI on a WSL host - #34590

Merged
nwparker merged 5 commits into
mainfrom
nwparker/wsl-host-agent-cli-guest-path
Oct 28, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/wsl-host-agent-cli-guest-path

Conversation

@nwparker

@nwparker nwparker commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​358
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​224 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​182

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 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
nwparker force-pushed the nwparker/wsl-host-agent-cli-guest-path branch from 75fd9d8 to b557443 Compare October 27, 2026 22:41
@nwparker 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
@nwparker
nwparker force-pushed the nwparker/wsl-host-agent-cli-guest-path branch from b557443 to a916dd0 Compare October 27, 2026 22:42
@nwparker
nwparker changed the base branch from nwparker/wsl-chat-lane-path-discovery to main October 27, 2026 22:42
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

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: Passed 5
Check name Status Explanation
Title check Passed 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 Passed 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 Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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.
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.

❤️ 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: 2


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: 9f72c622-8392-4f08-9d7e-75aed7dd91e0
Commits

Reviewing files that changed from the base of the PR and between 5a29a68 and 89e1d5b.

Files selected for processing: 10
  • src/main/codex-cli/command-guest-path.test.ts
  • src/main/codex-cli/command.ts
  • src/main/ipc/wsl-guest-native-program.test.ts
  • src/main/ipc/wsl-guest-windows-drive-path.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter-errors.ts
  • src/main/native-chat/structured-agent-command-resolution-wsl-host.test.ts
  • src/main/native-chat/structured-agent-command-resolution.ts
  • src/main/text-generation/source-control-agent-launch.ts
  • src/main/wsl/wsl-orcad-chat-windows-decoy.ts
  • src/main/wsl/wsl-orcad-structured-chat-contract.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +116 to +124
if (mounts.length === 0) {
return resolve(command, options)
}
const native = resolve(command, {
...options,
pathEnv: guestNativePathEnv(options.pathEnv, mounts)
})
if (isAbsolute(native)) {
return native

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '106,130p' src/main/ipc/wsl-guest-windows-drive-path.ts
rg -n 'resolveGuestNativeProgram|resolveCliCommand|versionManager|pathEnv' src/shared/node-cli-command-resolution.ts src/main/native-chat/structured-agent-command-resolution.ts src/main/codex-cli/command.ts

Repository: stablyai/orca

Length of output: 3605


Script executed:

set -e
printf '%s\n' '--- resolver ---'
nl -ba src/shared/node-cli-command-resolution.ts | sed -n '1,330p'
printf '%s\n' '--- all resolver helper call sites ---'
rg -n -F --glob '*.{ts,tsx}' -e 'resolveGuestNativeProgram(' -e 'resolveCliCommand(' -e 'resolveCliCommands(' src
printf '%s\n' '--- focused caller modules ---'
nl -ba src/main/native-chat/structured-agent-command-resolution.ts | sed -n '1,150p'
nl -ba src/main/codex-cli/command.ts | sed -n '1,220p'
printf '%s\n' '--- WSL path helper and focused tests ---'
nl -ba src/main/ipc/wsl-guest-windows-drive-path.ts | sed -n '1,180p'
rg -n -F --glob '*.{ts,tsx}' -e 'wsl-guest-windows-drive-path' -e 'resolveGuestNativeProgram' -e 'guestNativePathEnv' -e 'versionManager' -e 'symlink' src/main src/shared | head -240

Repository: stablyai/orca

Length of output: 42365


Script executed:

set -e
printf '%s\n' '--- structured command resolution ---'
nl -ba src/main/native-chat/structured-agent-command-resolution.ts | sed -n '19,135p'
printf '%s\n' '--- structured command resolution callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'resolveStructuredAgentCommand(' -e 'resolveStructuredAgentCommandWith' -e 'resolveAgainAfterRefreshOnMissingProgram' src/main
printf '%s\n' '--- codex command module ---'
nl -ba src/main/codex-cli/command.ts | sed -n '1,180p'
printf '%s\n' '--- codex command callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'resolveCodexCommand(' -e 'resolveCodexCommands(' -e 'resolveCodexCommandFor' -e 'resolveGuestNativeAgentCommand(' src/main src/cli
printf '%s\n' '--- focused WSL helper tests ---'
nl -ba src/main/ipc/wsl-guest-native-program.test.ts | sed -n '1,180p'
printf '%s\n' '--- focused command-resolution tests ---'
nl -ba src/main/native-chat/structured-agent-command-resolution.test.ts | sed -n '1,180p'
printf '%s\n' '--- base-to-head diff for implicated files ---'
git diff --unified=35 5a29a68ffaecae7aa25fc9ac19b7ac50a2482f34..89e1d5b82bf27f66f7b4ec0dfa04887a0b5d7675 -- src/main/ipc/wsl-guest-windows-drive-path.ts src/shared/node-cli-command-resolution.ts src/main/native-chat/structured-agent-command-resolution.ts src/main/codex-cli/command.ts

Repository: stablyai/orca

Length of output: 40652


Script executed:

set -e
printf '%s\n' '--- production structured-agent callers ---'
for f in \
  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
do
  if test -f "$f"; then
    printf '%s\n' "--- $f ---"
    nl -ba "$f" | sed -n '1,230p'
  fi
done
printf '%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.

Suggested fix
   if (isAbsolute(native)) {
-    return native
+    return isUnderWindowsDriveMount(native, mounts) ? null : native
   }
Committable suggestion

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.

Suggested change
if (mounts.length === 0) {
return resolve(command, options)
}
const native = resolve(command, {
...options,
pathEnv: guestNativePathEnv(options.pathEnv, mounts)
})
if (isAbsolute(native)) {
return native
if (mounts.length === 0) {
return resolve(command, options)
}
const native = resolve(command, {
...options,
pathEnv: guestNativePathEnv(options.pathEnv, mounts)
})
if (isAbsolute(native)) {
return isUnderWindowsDriveMount(native, mounts) ? null : native

Comment on lines +123 to +124
if (isAbsolute(native)) {
return native

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.

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.

@nwparker
nwparker force-pushed the nwparker/wsl-host-agent-cli-guest-path branch from 89e1d5b to b2c85f3 Compare October 27, 2026 23:07

@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
  • 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: 00b67558-42bd-44d2-b0e3-df03d7139e25
Commits

Reviewing files that changed from the base of the PR and between 89e1d5b and b2c85f3.

Files selected for processing: 10
  • src/main/claude-accounts/claude-command-process-windows-only.test.ts
  • src/main/claude-accounts/claude-command-process.ts
  • src/main/codex-accounts/codex-login-session-windows-only.test.ts
  • src/main/codex-accounts/codex-login-session.ts
  • src/main/codex-cli/command.ts
  • src/main/codex-cli/windows-only-agent-cli.test.ts
  • src/main/codex-cli/windows-only-agent-cli.ts
  • src/main/rate-limits/codex-rpc-rate-limit-probe-windows-only.test.ts
  • src/main/rate-limits/codex-rpc-rate-limit-probe.ts
  • src/main/wsl/wsl-orcad-chat-windows-decoy.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment on lines +27 to +28
resolveGuestNativeProgram(name, options, resolveCliCommand, mounts) ??
`${WINDOWS_ONLY_AGENT_CLI_DIR}/${name}`

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

cat src/main/ipc/wsl-guest-windows-drive-path.ts
sed -n '1,60p' src/main/codex-cli/command.ts
rg -n 'realpath|readlink' src/main/ipc/wsl-guest-windows-drive-path.ts src/shared/node-cli-command-resolution.ts

Repository: stablyai/orca

Length of output: 6083


Script executed:

set +e
printf '%s\n' '--- shared resolver declarations and implementation ---'
rg -n -F --glob '*.ts' -e 'export function resolveCliCommand' -e 'function resolveCliCommand' -e 'resolveCliCommand(' -e 'statSync' -e 'accessSync' -e 'realpath' -e 'readlink' src/shared/node-cli-command-resolution.ts src/main src/shared | head -240
printf '%s\n' '--- shared resolver source ---'
sed -n '1,280p' src/shared/node-cli-command-resolution.ts
printf '%s\n' '--- focused references and tests ---'
rg -n -F --glob '*.ts' -e 'resolveGuestNativeProgram' -e 'resolveGuestNativeAgentCommand' -e 'WINDOWS_ONLY_AGENT_CLI_DIR' -e 'resolveCodexCommand' -e 'resolveClaudeCommand' src
printf '%s\n' '--- diff against supplied merge base ---'
git diff --unified=35 f4d98b74e32535fb12394a085a0dd01bd9975a97 b2c85f374a0f1ceb4d416cbe0b69b770f18a9ad2 -- src/main/ipc/wsl-guest-windows-drive-path.ts src/main/codex-cli/command.ts src/shared/node-cli-command-resolution.ts

Repository: stablyai/orca

Length of output: 41948


Script executed:

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.

@buf0-bot

buf0-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

STATUS: PR-A (Terminal Launch Fix) Complete

Head SHA: 9cbfc22

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/ipc/wsl-guest-windows-drive-path.ts: Provides resolveGuestNativeProgram helper
  • 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"
  • Prefers absolute native paths when available
  • Desktop, native Linux, macOS, SSH terminal launches unchanged
  • Gated on ORCA_WSL_ORCAD_HOST=1

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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Filter PATH components against the effective child cwd. · source-control-agent-launch.ts:103

src/main/text-generation/source-control-agent-launch.ts:103
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

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.

Files selected for processing: 4
  • src/main/native-chat/structured-agent-command-guest-path.test.ts
  • src/main/wsl/wsl-orcad-chat-envelope.ts
  • src/main/wsl/wsl-orcad-chat-windows-decoy.ts
  • src/main/wsl/wsl-orcad-structured-chat-contract.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@nwparker
nwparker merged commit e055073 into main Oct 28, 2026
71 of 72 checks passed
nwparker pushed a commit that referenced this pull request Oct 28, 2026
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).
nwparker added a commit that referenced this pull request Oct 28, 2026
…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]>
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