Repository navigation
fix(wsl): hold a daemon-off restore of a stopped WSL distro - #35938
Conversation
[Low impact] The change reaches WSL pane restores routed through the local fallback. The PR appears safe to merge, with a non-blocking suggestion to strengthen the stopped-distro test. Findings
SummaryThe local terminal provider now checks the shared WSL hold before checking the folder or starting a terminal.
Reviews (1) · Last reviewed commit: "fix(wsl): hold a daemon-off restore of a..." · Reviewed by Greptile |
| expect(readWslDistroRunningStateMock).toHaveBeenCalledWith('Ubuntu', { | ||
| retryUnverifiable: true | ||
| }) | ||
| expect(spawnMock).not.toHaveBeenCalled() |
There was a problem hiding this comment.
The stopped-distro test only checks spawnMock, but validateWorkingDirectory can call wslUncDirectoryExistsAsync before the terminal starts. Moving the hold below that check would still pass this test, even though the folder probe could start the stopped distro. Also assert that wslUncDirectoryExistsAsyncMock was not called.
| expect(spawnMock).not.toHaveBeenCalled() | |
| expect(spawnMock).not.toHaveBeenCalled() | |
| expect(wslUncDirectoryExistsAsyncMock).not.toHaveBeenCalled() |
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2

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:
33149bce-7f71-4aa3-b353-d541aa4115d6
Files selected for processing: 2-
src/main/providers/local-pty-provider-windows-shell-launch.test.tssrc/main/providers/local-pty-spawn.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
| } | ||
| throwIfCanceled() | ||
| // Daemon-off (the daemon failed to start) a restore spawns here: same E9 hold as the daemon's. | ||
| await holdPassiveRestoreOfStoppedWslDistro(args, plan.launchWslDistro ?? undefined) |
There was a problem hiding this comment.
Hold WSL launches when the target distro is unknown.
If default-distro discovery fails and no distro is cached, plan.launchWslDistro is null. The hold then returns without checking state, but the planned wsl.exe launch selects the default distro and can start it. Resolve the target before allowing a passive launch, or fail closed when a WSL target cannot be resolved. (raw.githubusercontent.com)
Make the hold responsive to cancellation.
If shutdown cancels a spawn during the distro read, the spawn remains pending until the read and its retry finish. If the hold rejects, it also returns the hold error instead of the cancellation error. Race the shared read against cancellation and preserve cancellation on rejection. (raw.githubusercontent.com)
Based on learnings: check canceled state when an in-flight asynchronous start settles.
Source: Learnings
ELI5
When Orca can't start its background terminal service, it falls back to running terminals itself. On that fallback path, reopening Orca would restart a stopped WSL distro just to restore an old WSL terminal pane, even though the user never asked for it. This PR makes the fallback path wait for the user, the same way the normal path already does.
What Changed
main-process-pty-startup.ts, "STARTUP FAILED — falling back to local PTYs"), or missed the 60-second startup deadline (LOCAL_PTY_STARTUP_FAIL_OPEN_TIMEOUT_MSinfirst-window-startup-services.ts), restored WSL panes went through the local terminal provider. That provider had no stopped-distro check, so it ranwsl.exeand booted the distro.holdPassiveRestoreOfStoppedWslDistro, once the launch plan knows the distro and before anything is spawned. A passive restore or a background start of a stopped distro is held, and the pane shows the existing stopped card with a Start button. Fresh terminals the user opens, and restores of a running distro, behave as before.Why
This reuses the daemon's hold as it is, so both providers apply one rule and the renderer handling stays unchanged. The alternative was to stop restoring WSL panes at all when the daemon is off, but that would also drop panes for distros that are running.
Linked Issue
Internal WSL rewrite, E9 follow-up flagged in review of #35858.
Visual Proof
N/A. The stopped card is unchanged; this only routes the fallback path into it.
Testing
local-pty-provider-windows-shell-launch.test.tshas two new cases:wsl.exeis never spawned. This case fails without the fix.wsl.exeonce the distro reads as running.typecheck:ci, oxlint andcheck:code-quality:changedpass.Platforms: macOS, unit tests with Windows mocked. I haven't run it on a Windows machine.
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)