Skip to content

fix(wsl-host): refuse Windows-only agent CLIs in terminal launches - #34674

Merged
nwparker merged 4 commits into
mainfrom
nwparker/wsl-terminal-agent-launch-native
Oct 28, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/wsl-terminal-agent-launch-native

Conversation

@buf0-bot

@buf0-bot buf0-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​193 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​193
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​97 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​87

ELI5

When Orca runs inside a WSL Linux distro, an agent like Claude or Codex might be installed only on the Windows side. Chat already refuses to start it there. Starting the same agent in a terminal now refuses the same way, instead of quietly running the Windows copy.

What Changed

Before: on a WSL host (Orca's background service running inside the distro, ORCA_WSL_ORCAD_HOST=1), starting an agent in a terminal typed the bare name (claude). If the only copy was the Windows one, the shell found it through the Windows folders WSL adds to PATH (/mnt/c/...) and ran the Windows program against Linux paths.

After:

  • Only a Windows copy exists: the launch is refused with "claude is installed only on Windows, not in this WSL distro. Install it inside the distro. Or set the claude Command setting to a program inside the distro."
  • A copy exists inside the distro: the terminal types its absolute path (quoted for the shell), so a Windows copy earlier in PATH can't win. Launch arguments built into the stock command (for example kiro-cli chat --tui) are kept.
  • Agents with more than one program name (Qoder ships qodercli and qoder) use the first name installed inside the distro. A launch is refused only when no name is installed in the distro and at least one is installed only on Windows.
  • Agents that run another CLI under their own command are refused when that CLI is installed only on Windows: Agent Teams (runs Claude through Orca's CLI) and dsh (needs dsh). The Agent Teams command itself is never rewritten.
  • Found nowhere: unchanged; the shell reports it as before.
  • The terminal's own environment is not touched. PATH keeps its Windows entries, so code ., explorer.exe and other interop still work inside the agent's terminal.

Mechanism: one function, resolveWslHostAgentLaunchInputs (src/main/runtime/wsl-host-agent-terminal-launch.ts), runs on the launch inputs before the startup plan is built. It uses the resolver chat and status already use (resolveGuestNativeAgentCommand with the Windows-only marker). It returns the inputs unchanged, as the same object, when any of these hold:

  • the process is not a WSL host
  • the launch is remote (SSH)
  • the user has set a Command for the agent
  • the launch runs a wrapper rather than the agent's own program (Agent Teams runs Orca's CLI). Wrappers are only checked: refused if the CLI they need exists only on Windows, never rewritten

The resolved path is applied only to this launch's inputs. Settings are never written.

Why

This is the same rule as chat (#34590), and it reuses chat's resolver and marker instead of adding a second copy. The alternative, stripping Windows folders from the whole terminal's PATH, would break interop commands users rely on inside the agent's terminal. Typing the absolute path pins only the agent program.

Known limitation (shared with chat): the lookup uses the PATH of Orca's background service, not the interactive shell's .bashrc. A distro install that only .bashrc adds to PATH is still found when it is in a standard location (nvm, ~/.local/bin, volta, asdf, mise, bun, pnpm). Tests cover nvm and ~/.local/bin. An install in a custom directory added only by .bashrc would be refused. The message tells the user to set the agent's Command setting in that case.

Launch paths not covered here (follow-ups): this PR covers agent terminals created through the runtime's terminal startup. These paths build launch commands separately and still type the bare name on a WSL host: mobile terminal startup (src/main/runtime/terminal/launch/mobile-terminal-startup.ts), the agent session execution path (src/main/runtime/session-construction/agent-session/get-agent-session-execution-namespace.ts), and the resume launch builders (src/shared/tui-agent-resume-startup.ts, src/shared/ai-vault-resume-startup.ts).

Flag-off: with ORCA_WSL_ORCAD_HOST unset (and so with ORCA_INTERNAL_WSL_HOSTS unset), the function returns its input unchanged. Desktop, native Linux, macOS, Windows and SSH terminal launches are unchanged.

User-risk: low. This affects only agent terminals started by a WSL-host Orca. The worst case is the limitation above: a refusal for an agent installed only in a custom .bashrc directory, fixed by setting the Command setting.

Linked Issue

Follow-up to #34590.

Visual Proof

N/A. This changes which program a terminal launch types, or adds a refusal message, on WSL hosts only. Covered by unit tests and a call-site test.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

src/main/runtime/wsl-host-agent-terminal-launch.test.ts (real files, no mocks; a temp directory stands in for the Windows drive mount via the resolver's mounts parameter):

  • Windows-only copy → refusal with the fix-it message
  • distro copy → absolute path, even with a Windows copy earlier in PATH; built-in launch arguments kept
  • Agent Teams with only a Windows Claude → refused; with a distro Claude → command untouched
  • dsh with only a Windows dsh → refused
  • Qoder: qodercli only on Windows, qoder in the distro → launches the distro qoder
  • nvm and ~/.local/bin installs missing from the service PATH → still found
  • found nowhere → inputs unchanged
  • explicit Command setting → untouched, no refusal
  • remote launch or non-WSL host → untouched (same object)
  • full terminal create on a simulated WSL host → types the absolute path, and the terminal env gets no PATH

Checks run: pnpm tc, pnpm run typecheck:ci, touched and adjacent runtime tests (38 passing), pnpm run check:code-quality:changed, anti-slop oxlint, ast-grep scan and flaky-test gates. No WSL distro was booted.

Review

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

SSH: remote launches are skipped explicitly. Folder workspaces: the logic does not depend on git. Wire compatibility: nothing new is exchanged between client and host.

Status

Reworked after safety review. Ready for lead review; not merged.

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)

bench and others added 2 commits October 28, 2026 03:19
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
nwparker force-pushed the nwparker/wsl-terminal-agent-launch-native branch from d0bf7d2 to b020315 Compare October 28, 2026 10:27
@nwparker nwparker changed the title feat: make WSL host terminal agent launches consistent fix(wsl-host): refuse Windows-only agent CLIs in terminal launches Oct 28, 2026
@nwparker

Copy link
Copy Markdown
Contributor

STATUS: safety-review fixes done, rebased on origin/main 478743d. Head b020315. One resolver (resolveGuestNativeAgentCommand fed the raw PATH, plus the WINDOWS_ONLY_AGENT_CLI_DIR marker), so the refusal now fires. It skips explicit Command settings, remote launches and non-WSL hosts, and never writes settings. The terminal env is untouched. The old mocked test is replaced by unmocked tests in wsl-host-agent-terminal-launch.test.ts. Checks: pnpm tc, typecheck:ci, 5 runtime test files (34 tests passing), check:code-quality:changed, anti-slop oxlint, ast-grep scan and gates. Open question: the lookup uses the service PATH, not .bashrc (same as chat; standard install dirs are covered). Not merged.

@nwparker

Copy link
Copy Markdown
Contributor

STATUS: reviewer B's points are in. Head bed0106. (1) Every program name the agent has is now tried in order, and the first one installed in the distro wins. A launch is refused only when no name is installed in the distro and at least one is installed only on Windows. A new test covers Qoder (qodercli only on Windows, qoder in the distro). (2) The PR body now names the launch paths this PR doesn't cover. Checks: pnpm tc, typecheck:ci, 35 runtime tests, check:code-quality:changed, anti-slop oxlint, ast-grep scan and gates. Reviewer A's verdict is still pending. Not merged.

@nwparker

Copy link
Copy Markdown
Contributor

STATUS: reviewer A's extra is in. Head cbeb168. A launch is now refused when a CLI that the agent's command runs is installed only on Windows (Agent Teams needs Claude, dsh needs dsh). The Agent Teams command is never rewritten, including when the headless launch types plain orca. Tests: Windows-only Claude refuses Agent Teams; a distro Claude leaves its command untouched; Windows-only dsh refuses. Checks: pnpm tc, typecheck:ci, 38 runtime tests, check:code-quality:changed, anti-slop oxlint, ast-grep scan and gates. Not merged.

@nwparker
nwparker merged commit 485e1a1 into main Oct 28, 2026
42 checks passed
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