Skip to content

fix(wsl): Settings CLI status, CLI repair, interop health and link checks never boot a stopped distro (E9) - #35412

Merged
nwparker merged 3 commits into
mainfrom
nwparker/e9-cli-interop-gate
Oct 29, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/e9-cli-interop-gate

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​220 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​192
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​145 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78

ELI5

Some background features ran commands inside a WSL distro, or looked at files in it, without checking whether it was running. Doing either starts a stopped distro. Opening Settings, a startup repair, a health check after another distro stopped, and drawing file links in a chat could all start a distro the user had shut down. Now each of them checks first, and leaves a stopped distro alone.

What Changed

  • Settings → CLI, WSL row (cli:getWslInstallStatus): opening Settings takes a settled running read. If the distro is stopped, the row shows "WSL (X) is not running. Refresh to start it and check the CLI." This reuses the existing refreshable wsl_unreachable state. The refresh button passes wakeWslDistro, which runs the read as a user act and may start the distro.
  • Startup CLI repair (reconcileManagedWslCliRegistrations): before each distro's repair spawns, it does a settled per-distro read (isWslDistroRunning). A distro that is stopping, or that stopped while earlier repairs ran, is deferred through the existing deferUntilWslDistroRunning instead of being restarted.
  • Interop health monitor: checks triggered by a stop no longer trust the stop event's running list, which can still name a distro that is stopping. Every check takes a settled read, and takes it again right before the root repair script.
  • Chat file-link and terminal-hover existence (shell:pathsExist): a \\wsl.localhost\<distro> path goes through guardWslUncPathAccess. A stopped distro is refused rather than statted. The native-chat link checker already treats a refusal as "unverifiable" and retries at 2, 10 and 30 s, so links aren't marked missing. Host paths and running distros are unchanged.
  • Stacked on fix(wsl): background preflight and agent detection never boot a stopped WSL distro (E9) #35411, which adds the shared helper src/main/wsl/wsl-background-exec-gate.ts. Review and merge fix(wsl): background preflight and agent detection never boot a stopped WSL distro (E9) #35411 first.
  • wsl:isAvailable (P6) stays ungated, with a code comment saying so. It runs wsl --exec /bin/true in the default distro only when wsl --status reports a missing WSL2 kernel, so a rare broken setup is the only case that can start a stopped distro.

Why

This covers rule E9, audit items P3, P4, P5 and G3. Each path either spawned wsl -d or touched UNC with no running check, or relied on an unsettled running list. Every fix reuses the existing settled-read and user-act primitives instead of adding a new gate. P6 is left ungated on purpose: it fires only on a missing kernel, and gating it would need an injected check to avoid an import cycle.

Linked Issue

Internal E9 audit (P3, P4, P5, G3). No public issue.

Visual Proof

N/A. The WSL CLI row reuses its existing "unsupported / refresh" layout with new detail text. Nothing else in the UI changes.

Testing

  • src/main/ipc/cli.test.ts: opening Settings with a stopped distro returns the refreshable status and never builds an installer; the refresh-button wake reads the status; a running distro reads as before.

  • src/main/cli/wsl-cli-registration-reconciliation.test.ts: a distro listed as running that a settled read finds stopped is deferred, and its repair never spawns.

  • src/main/wsl/wsl-interop-health.test.ts: when a stop event names a distro that a settled read finds stopping, nothing is probed. If the distro stops between the probe and the repair, no root repair runs.

  • New src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts: a stopped distro's UNC path is refused without a stat; host paths and running distros still get answers.

  • With the four source files reverted, all of the new cases fail. Most interop cases also fail on the changed dependency shape.

  • Load rule:

    • pnpm tc and pnpm run typecheck:ci pass.
    • Touched tests pass, except packaged-cli-assets.test.ts. That file fails the same way on a tree without this change.
    • pnpm run check:code-quality:changed passes.
    • Anti-slop oxlint (exit 0) and the ast-grep gates pass.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Flag-off: this changes behavior with ORCA_INTERNAL_WSL_HOSTS unset. For shipping Windows users with WSL:

  • Opening Settings no longer starts the default distro.
  • Startup CLI repair and interop health no longer restart a distro that is stopping.
  • Chat links into a stopped distro are no longer statted.

User-risk:

  • A stopped distro's Settings CLI row says "not running" until the user clicks refresh.
  • A chat link into a stopped distro stays in its "checking" state until the distro runs.
  • A CLI repair or interop check skipped for a stopping distro runs the next time it is used, through the existing deferral or the 5 s post-terminal check.

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: unaffected. shell:pathsExist is local-only, and SSH uses fs:pathsExist / the runtime.
  • Folder workspaces: the same UNC gate applies.
  • Remote wire: wakeWslDistro exists only on desktop IPC.

Status

Ready for review, stacked on #35411. This supersedes #35395.

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 28, 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 3 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
  • 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: 15197dc3-91d4-4def-92e7-2e00c30015e9
Commits

Reviewing files that changed from the base of the PR and between 0654de9 and 5440f5d.

Files selected for processing: 18
  • src/main/cli/wsl-cli-registration-reconciliation.test.ts
  • src/main/cli/wsl-cli-registration-reconciliation.ts
  • src/main/cli/wsl-cli-status.ts
  • src/main/ipc/cli.test.ts
  • src/main/ipc/cli.ts
  • src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts
  • src/main/ipc/shell.ts
  • src/main/wsl-availability.ts
  • src/main/wsl/wsl-interop-health.test.ts
  • src/main/wsl/wsl-interop-health.ts
  • src/preload/api/cli-bridge.ts
  • src/preload/api/cli-install-api.ts
  • src/preload/api/shell-api.ts
  • src/preload/api/shell-bridge.ts
  • src/renderer/src/components/settings/WslCliRegistration.tsx
  • src/renderer/src/components/terminal-pane/terminal-path-existence-batch.test.ts
  • src/renderer/src/components/terminal-pane/terminal-path-existence-batch.ts
  • src/shared/path-existence-batch.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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The changes affect several WSL workflows on Windows, from Settings and background checks to local file links.

The PR should wait until the two existing stale-running-answer findings are fixed.

Findings

  1. P1 Settings restarts stopped distros ▶
  2. P1 Health checks reuse old answers ▶

Summary

This PR adds running-state checks before background WSL work and makes Settings refresh an explicit action that may start a distro.

  • Opening Settings leaves a stopped WSL distro alone.
  • Startup CLI repair waits for each WSL distro to be running.
  • Interop health checks only probe WSL distros that are running.
  • File-link checks leave stopped WSL paths untouched.

Reviews (8) · Last reviewed commit: "fix(wsl): shell:pathsExist refuses only ..." · Reviewed by Greptile

): Promise<BlockedWslDistro | null> {
const target = await resolveWslExecDistro(distro)
// No distro named and none listed: wsl.exe has nothing to start.
return target ? blockedWslDistroForPath('', target) : null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Settings restarts stopped distros

blockedWslDistroForExec reuses the UNC gate's 60-second running lease. If a probe names Ubuntu and the user then stops it outside Orca, opening Settings during that lease can reuse the old answer and call getStatus(), starting Ubuntu again. Take a fresh settled read for background command checks instead of using the file-access lease.

Comment on lines +89 to +90
// The stop's list can still name a distro that is stopping too; check() takes a settled read (E9).
void this.check(health.name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Health checks reuse old answers

Stop-triggered checks can reuse the exact running list that triggered them. The cache calls stop listeners before clearing inFlightProbe. When Ubuntu has no recorded stop, isWslDistroRunning passes no time boundary and joins that same probe. If the list still names Ubuntu while it stops, the health check accepts the old answer and can restart Ubuntu with its guest probe. Require a running-list probe started after the stop event for this path.

Comment thread src/main/ipc/shell.ts Resolved
@nwparker
nwparker force-pushed the nwparker/e9-cli-interop-gate branch from b13c031 to e58fd78 Compare October 28, 2026 22:26
@nwparker
nwparker changed the base branch from main to nwparker/e9-preflight-gate October 28, 2026 22:26
@nwparker
nwparker force-pushed the nwparker/e9-cli-interop-gate branch 2 times, most recently from 3e4e0de to 2277e45 Compare October 28, 2026 22:57
@nwparker
nwparker force-pushed the nwparker/e9-cli-interop-gate branch from 2277e45 to c80c5f6 Compare October 28, 2026 23:29
@nwparker
nwparker force-pushed the nwparker/e9-preflight-gate branch from 0f1e560 to b4beb56 Compare October 29, 2026 00:29
@nwparker
nwparker force-pushed the nwparker/e9-cli-interop-gate branch 3 times, most recently from c19676e to 7979345 Compare October 29, 2026 00:43
… link checks never boot a stopped distro (E9)

- cli:getWslInstallStatus: opening Settings takes a settled running read and shows a refreshable
  "not running" status instead of starting the distro; the refresh button passes wakeWslDistro.
- Startup CLI repair re-reads each listed distro (settled) right before its repair spawns and
  defers it otherwise, so a distro stopping mid fan-out is not restarted.
- Interop health: stop-triggered checks no longer trust the stop event's list; every check takes a
  settled read, and again before the root repair.
- shell:pathsExist (chat link and terminal hover existence) refuses a stopped distro's UNC path
  instead of statting it; callers already retry an unverifiable answer.
…t the whole batch

One UNC path in a stopped distro no longer fails the host paths checked with it; the renderer
treats that path alone as unverifiable and retries it.
@nwparker
nwparker force-pushed the nwparker/e9-cli-interop-gate branch from 7979345 to 5440f5d Compare October 29, 2026 01:09
@nwparker
nwparker changed the base branch from nwparker/e9-preflight-gate to main October 29, 2026 01:09
@nwparker
nwparker merged commit 3a68805 into main Oct 29, 2026
67 of 94 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