Skip to content

fix(wsl): put both agent-detection probes on the runner's probe lane - #15907

Closed
nwparker wants to merge 1 commit into
wsl-w3from
wsl-w3-detection
Closed

nwparker wants to merge 1 commit into
wsl-w3from
wsl-w3-detection

Conversation

@nwparker

@nwparker nwparker commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #15903. Allowlist 23 → 21.

ELI5

Two bits of code both ask WSL "is the Claude/Codex CLI installed?" One asks in a way that gets a banner mixed into the answer. The other asks in a way that can't see tools installed via nvm. Both now ask the same, correct way.

Why these two first

They're worth reading together because they make opposite mistakes.

ipc/preflight-wsl-agent-detection.ts:60 ran buildWslLoginShellCommand — the uncaptured variant — and parsed stdout. An interactive login shell runs the distro rc, and stock Ubuntu writes "run a command as administrator" to stdout. Detection was parsing a stream with a banner in front of it.

skills/skill-wsl-provider-detection.ts:13 ran a bare sh -c with no login shell at all, so a codex/claude installed through nvm or mise was never on PATH and read as absent.

Two adjacent paths, opposite causes, neither reviewable against the other. Both are mechanisms for #9725, #7563, #8366 — "agent detection fails while the same command works by hand".

What changes

Both move to lane: 'probe': PATH and HOME come from one cached login-shell probe per distro, and the call itself runs no shell. No banner to strip, no ~/.profile to stall behind.

Also drops a hand-rolled Promise.race timeout in the preflight file. It existed because execFile's timeout doesn't fire if the child wedges before spawn completes; runProcess bounds the child and escalates to SIGKILL, so the race is now redundant rather than merely duplicated.

Proof of no regression

  • preflight-wsl-agent-detection.test.ts rewritten onto the runner mock, plus a regression test that puts Ubuntu-shaped banner noise immediately ahead of the payload and asserts detection still succeeds.
  • skill-wsl-provider-detection.test.ts is new — the file had no unit test at all — asserting the probe lane, which is what makes a PATH-only install visible.
  • Detection now treats a timeout or non-zero exit as "no answer" rather than parsing partial stdout. runProcess resolves on both, so this had to be explicit.
  • 624 tests pass; typecheck and lint clean. The guard accepted both allowlist removals — and it fails on a stale entry, so the count moving is real, not cosmetic.

User-facing trade-offs

None. Both paths get strictly more accurate: the banner can no longer corrupt a result, and an nvm/mise-installed agent is now found where it previously read as missing.

These two sites make opposite mistakes, and neither is reviewable against the
other:

- `preflight-wsl-agent-detection.ts` ran `buildWslLoginShellCommand` -- the
  *uncaptured* variant -- and parsed stdout. An interactive login shell runs the
  distro rc, and stock Ubuntu writes its "run a command as administrator" hint
  to stdout, so detection was parsing a stream with a banner in front of it.
- `skill-wsl-provider-detection.ts` ran a bare `sh -c` with no login shell at
  all, so a codex/claude installed through nvm or mise was never on PATH and
  read as absent.

Both want the same thing: the user's real login PATH, without a shell in the
loop. That is the probe lane -- the PATH comes from one cached login-shell probe
per distro, and no shell runs on the call itself, so there is no banner to strip
and no `~/.profile` to stall behind (#9725, #7563, #8366).

Also removes the hand-rolled Promise.race timeout in the preflight file;
`runProcess` already bounds the child and escalates to SIGKILL.

Allowlist: 23 -> 21.
@nwparker

Copy link
Copy Markdown
Contributor Author

Folded into #15915, which carries the same content plus three rounds of review fixes on one branch that is green on its own. The stacked branches predated those fixes, so each was red in isolation — collapsing was safer than four-way branch surgery.

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