Repository navigation
fix(wsl): Settings CLI status, CLI repair, interop health and link checks never boot a stopped distro (E9) - #35412
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
[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. FindingsSummaryThis PR adds running-state checks before background WSL work and makes Settings refresh an explicit action that may start a distro.
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 |
There was a problem hiding this comment.
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.
| // The stop's list can still name a distro that is stopping too; check() takes a settled read (E9). | ||
| void this.check(health.name) |
There was a problem hiding this comment.
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.
b13c031 to
e58fd78
Compare
3e4e0de to
2277e45
Compare
2277e45 to
c80c5f6
Compare
0f1e560 to
b4beb56
Compare
c19676e to
7979345
Compare
… 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.
7979345 to
5440f5d
Compare
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
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 refreshablewsl_unreachablestate. The refresh button passeswakeWslDistro, which runs the read as a user act and may start the distro.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 existingdeferUntilWslDistroRunninginstead of being restarted.shell:pathsExist): a\\wsl.localhost\<distro>path goes throughguardWslUncPathAccess. 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.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 runswsl --exec /bin/truein the default distro only whenwsl --statusreports 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 -dor 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 tcandpnpm run typecheck:cipass.packaged-cli-assets.test.ts. That file fails the same way on a tree without this change.pnpm run check:code-quality:changedpasses.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_HOSTSunset. For shipping Windows users with WSL:User-risk:
Agent skill upstream boundary
Notes
shell:pathsExistis local-only, and SSH usesfs:pathsExist/ the runtime.wakeWslDistroexists only on desktop IPC.Status
Ready for review, stacked on #35411. This supersedes #35395.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)