Repository navigation
Conversation
…stopped distro (E9) Several checks ran `wsl -d <distro>` in the background: - Source-control preflight, forced on every window focus. - Agent detection on mount. - The Settings WSL-CLI status read. The startup CLI repair and the interop health monitor trusted a running list that can still name a stopping distro. The health monitor also probed on every stop event with no check at all. Preflight and detection now refuse a stopped distro with the gate's "not running" error, which callers show and retry, so a stopped distro never caches as "no agents". The CLI status read reports the distro is not running. CLI repair and interop health use a settled running list.
[Medium impact] The changes affect several Windows workflows that inspect or maintain WSL distros. Fix the explicit-launch regression and the two gaps in stopped-distro checks before merging. Findings
SummaryThis PR adds running-state checks before background WSL preflight, agent detection, CLI status, startup repair, and interop checks.
|
| // Detection runs on mount: a stopped distro is unverifiable, never "no agents" and never booted. | ||
| const wsl = getPreflightWslTarget(host.context) | ||
| if (wsl) { | ||
| await assertPreflightWslDistroRunning(wsl) |
There was a problem hiding this comment.
Explicit WSL launches can fail
detectProjectLaunchContext also calls this helper, so the new background gate can reject an intentional issue/PR launch when its distro is stopped. launchWorkItemDirect starts detection before its setup checks, converts a rejection to null, and cancels the launch with an unavailable-agent message. Keep the gate for background detection, but let the explicit launch path start its selected distro.
| const distro = target.distro?.trim() || (await listWslDistrosAsync())[0] | ||
| if (distro) { | ||
| await assertWslUncPathRunning('', distro) |
There was a problem hiding this comment.
Unknown default bypasses the gate
listWslDistrosAsync returns an empty list after a failed lookup, including during its retry delay. This helper then returns without checking anything. With { wslDefault: true }, the following commands still omit a distro name and run in WSL's default distro, so a temporary lookup failure can let a background check start a stopped distro. Reject as unverifiable when the default cannot be resolved.
| export async function listSettledRunningWslDistros(): Promise<string[]> { | ||
| const distros = await listRunningWslDistrosAsync({ requireConfirmed: true }) | ||
| return distros.filter((distro) => wasWslDistroLastSeenRunningSettled(distro)) |
There was a problem hiding this comment.
This filter depends on mayHaveStoppedAt, but its stop listener is registered only by settledWslRunningReadAnchor. Neither new caller invokes that helper. If startup repair or interop health runs before another caller registers the listener, a stop seen by the running-list cache goes unrecorded. A later list that names the distro during its stop window then passes this filter, allowing a probe or repair to restart it. Initialize stop tracking before reading the running list.
| if (distro && (await blockedWslDistroForPath('', distro))) { | ||
| return stoppedWslCliStatus(distro) |
There was a problem hiding this comment.
Unknown state appears as stopped
blockedWslDistroForPath also returns a value when WSL's running-list checks fail. This condition therefore gives a running but temporarily unreachable distro the false message “is not running.” Check the returned state and use an unknown/unreachable message for unverifiable, rather than sending users to open a terminal unnecessarily.
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 5

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:
c9be7b1e-e538-43ce-acd5-9f7b94c5d597
Files selected for processing: 15-
src/main/cli/wsl-cli-registration-reconciliation.tssrc/main/cli/wsl-cli-status.tssrc/main/ipc/cli.test.tssrc/main/ipc/cli.tssrc/main/ipc/preflight-agent-detection.test.tssrc/main/ipc/preflight-host-cli-status.test.tssrc/main/preflight/agent-detection.tssrc/main/preflight/preflight-wsl-running-gate.tssrc/main/preflight/preflight-wsl-stopped-distro.test.tssrc/main/preflight/workspace-agent-detection.test.tssrc/main/preflight/workspace-agent-detection.tssrc/main/wsl-background-distro-gate.tssrc/main/wsl-settled-running-list.test.tssrc/main/wsl/wsl-interop-health.test.tssrc/main/wsl/wsl-interop-health.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.
-
| // Never boot stopped distros for background repair; defer until they run. | ||
| const running = new Set( | ||
| (await (options.listRunningDistros ?? listConfirmedRunningWslDistros)()).map((distro) => | ||
| (await (options.listRunningDistros ?? listSettledRunningWslDistrosOrNone)()).map((distro) => |
There was a problem hiding this comment.
Schedule a settled retry when this lookup defers a running distro.
If a candidate is running but its observation falls inside the stop-settle window, this lookup excludes it. The observation occurs before deferUntilWslDistroRunning registers the task, so its settle-probe scheduler has no task to schedule. Reconciliation then waits for an unrelated observation or wake, leaving the managed launcher unrepaired. Schedule a post-settle probe when registering this deferral. (raw.githubusercontent.com)
| if (distro && (await blockedWslDistroForPath('', distro))) { | ||
| return stoppedWslCliStatus(distro) |
There was a problem hiding this comment.
Distinguish an unverifiable distro from a stopped distro.
blockedWslDistroForPath also returns a block when running-state discovery fails. This branch then tells users that the distro is not running and asks them to start it, even when its state is unknown. Return unreachableWslCliStatus for unverifiable and reserve stoppedWslCliStatus for stopped. (raw.githubusercontent.com)
| */ | ||
| export async function assertPreflightWslDistroRunning(target: WslPreflightTarget): Promise<void> { | ||
| // No distro named means wsl.exe's default, which a probe would boot just the same. | ||
| const distro = target.distro?.trim() || (await listWslDistrosAsync())[0] |
There was a problem hiding this comment.
Resolve and pin the actual default distro.
listWslDistrosAsync retains a nonempty list, but the WSL default can change while Orca runs. After a default change, this gate can check the old distro while the subsequent command, which has no distro argument, starts the new stopped default. Resolve the current default and pass that same name to the command. (raw.githubusercontent.com)
| if (distro) { | ||
| await assertWslUncPathRunning('', distro) | ||
| } |
There was a problem hiding this comment.
Fail closed when the default distro cannot be resolved.
If distro discovery fails without a cached list, it returns []. This branch then skips the assertion, and preflight or agent detection can launch the default distro when a later WSL command succeeds. Return an unverifiable error instead. (raw.githubusercontent.com)
| // The confirmed list that reported the stop also proves this distro is up. | ||
| void this.check(health.name, { confirmRunning: false }) | ||
| // That list may still name a distro that is itself stopping: confirm, settled (E9). | ||
| void this.check(health.name, { confirmRunning: true }) |
There was a problem hiding this comment.
Require a new probe after the stop event.
The stop listener runs while the probe that produced running is still in flight. This check joins that same probe, so it does not independently confirm the distro. If another distro is also stopping but has not been marked stopped, the interop probe can start it again. Request a running-list read anchored after the stop event and its settle window. (raw.githubusercontent.com)
…-end preflight gate test A focus with a native workspace active sends no wake. Ports the real running-list preflight case from #35395 and adds user-act scoping cases.
|
Superseded by #35411 (preflight and agent detection, P1/P2) and #35412 (Settings CLI status, startup CLI repair, interop health, chat-link existence: P3/P4/P5/G3), which is stacked on #35411. I cross-checked them against this PR. The end-to-end preflight running-list test was ported into #35411. The stop-settle concern behind |
…-end preflight gate test A focus with a native workspace active sends no wake. Ports the real running-list preflight case from #35395 and adds user-act scoping cases.
…ed WSL distro (E9) (#35411) * fix(wsl): background preflight and agent detection never boot a stopped WSL distro (E9) Integration checks (git/gh/glab --version and auth status) and agent detection ran inside the focused workspace's WSL distro on every mount, poll and status-bar render, and wsl.exe starts a stopped distro. They now take a settled running read first and refuse (WSL_DISTRO_STOPPED or WSL_DISTRO_UNVERIFIABLE) when it is not running. Window focus/visibility, retry buttons, agent refresh buttons, a runtime choice in Settings and first-run onboarding pass wakeWslDistro, which runs the check as a user act on that distro only. Running distros behave exactly as before. * fix(wsl): a focus wakes only a focused WSL workspace's distro; end-to-end preflight gate test A focus with a native workspace active sends no wake. Ports the real running-list preflight case from #35395 and adds user-act scoping cases. * test(wsl): model the running gate in the preflight RPC suite and cover a stopped distro Windows CI runs the real gate, so the WSL detection case must state that the distro runs. * fix(wsl): an agent refresh click never joins a background refresh it would be refused with Store the wake flag with each in-flight refresh, as preflight.ts does, so a status-bar or Agents refresh click during a mount refresh reaches main as a user act. Note why the RPC project branch stays ungated. * fix(wsl): a refused background check waits for the distro, and an agent picker wakes it A preflight or agent detection refused for a stopped WSL distro was final: once the distro came up, nothing re-ran it, so the tab-bar + menu offered no WSL agents (real-WSL golden). Now a refusal is deferred until the distro is next confirmed running (deferUntilWslDistroRunning), and main tells renderers to re-ask. Opening an agent-launch picker (tab-bar +, composer, continuation dialog, source-control action dialog) whose list was refused retries it as a wake, never joining a background probe. * fix(wsl): an open agent picker wakes a refused list once, and never retries real failures The picker wake fired whenever the list read 'failed', so a woken probe that failed again (pending -> failed) re-fired it: an endless wsl.exe loop while the picker stayed open, and repeated probes for native failures too. It now fires at most once per open per target, and only when the last probe was an E9 refusal (distro not running/unverifiable), matched by the gate's message. * fix(wsl): forget agent-inventory refusals when the inventory or its project contexts are cleared
Flag-off: Not WSL-host-specific. These checks run on main for any Windows user whose active project, or the default runtime, is a WSL distro, bridge users included. This fixes them flag-off too.
User-risk: Low. While the active WSL distro is stopped:
The explicit "Refresh agents" action, the WSL CLI install/remove buttons and opening a terminal still start the distro.
ELI5
Orca must never start a WSL distro you stopped unless you ask (rule E9). Some background checks did: a "is git/gh installed and signed in?" check that runs every time the window gets focus, a scan for installed agent CLIs, the Settings CLI status, and two startup/health checks. Now they first check that the distro is running and, if it isn't, say so instead of starting it.
What Changed
preflight:check). Before:git/gh/glab --versionandauth statusran inside the active WSL distro on sidebar/landing mount and forced on every window focus, which booted it. After:executePreflightCheckfirst calls the newassertPreflightWslDistroRunning, which uses the settled gateassertWslUncPathRunning. A stopped distro rejects with the existingWslDistroStoppedErrormessage, which the renderer already shows as the preflight error. The check sits inside the shared run, so concurrent callers still collapse onto one probe.preflight:detectAgents, mount). Before: acommand -vloop ran in the distro on mount. After: it refuses the same way. A rejection already marks detection failed and retries; it never caches[].preflight:refreshAgents(the explicit Refresh button) is unchanged.cli:getWslInstallStatus). Before: a status script ran on the default distro on every mount. After: a stopped distro returns the retryablewsl_unreachablestatus with "is not running" copy, through the newstoppedWslCliStatus.listRunningWslDistrosAsync, which still names a distro inside its stop's settle window, and interop health probed every listed distro on each stop event without asking. After: both use a newlistSettledRunningWslDistros(wsl-background-distro-gate.ts), and interop health confirms before probing on stop events too.Why
wsl-availability's--exec /bin/truefallback is not gated. It runs only on missing-WSL2-kernel machines and gates whether a WSL terminal can open at all. Gating it could stop WSL1 users from opening a terminal in a stopped distro.Linked Issue
Internal WSL tracker, E9 audit (/tmp/fanout/wsl-exec-audit.md, rows P1–P5).
Visual Proof
N/A: no new UI. The existing preflight-error and CLI-unreachable states show the new copy.
Testing
New tests, each failing with its source fix reverted (checked):
preflight-wsl-stopped-distro.test.ts(real gate, mockedwsl.exe, win32): a focus-forced preflight and an on-mount agent detection both refuse a stopped distro without running anything in it.cli.test.ts: a Settings status read of a stopped distro returns "is not running" and never constructs the installer.wsl-interop-health.test.ts: a distro the stop event's list still names, but the settled list doesn't, is not probed. The existing stop-path case now expects the confirming read.wsl-settled-running-list.test.ts: a distro inside its stop settle window is dropped, then listed again once it settles.The existing preflight tests now mock the gate, because they test what preflight does once a distro runs. One race test now waits for the stale probes before flipping phase, since the running check comes first.
Suites: preflight, ipc/preflight, cli, ipc/cli, wsl, and the background-distro gate pass, except
packaged-cli-assets, whose two tests also fail on an exact main baseline here.Load rule:
pnpm tc,typecheck:ci, oxlint, the anti-slop lint, oxfmt,check:code-quality:changed, and the ast-grep gates.Review
Agent skill upstream boundary
Notes
getPreflightWslTargetis null.preflight.checkare unaffected.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)