Repository navigation
fix(wsl): never boot a stopped distro to check a folder workspace's path - #35899
Conversation
A background read of a \\wsl.localhost folder workspace's status (sidebar polling, runtime status RPC, a passive terminal restore) stat'ed the folder and booted its stopped distro. The status now reports 'unavailable' without touching it; a passive restore holds with Start; a spawn the user asked for checks the folder as their act, which may start the distro as before.
|
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 4 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 change affects folder checks and terminal restores for Windows WSL workspaces. Fix explicit folder-workspace creation on stopped WSL distros before merging. Findings
SummaryAdds a WSL running-state check before checking local folder-workspace paths.
Acknowledged behavior:
|
| if (await blockedWslDistroForPath(path)) { | ||
| return { path, exists: false, reason: 'unavailable' } |
There was a problem hiding this comment.
When an existing project group's parentPath points into a stopped WSL distro, clicking Create calls folderWorkspaces:create outside runAsWslUserAct. The new gate returns unavailable, so the handler throws before saving the workspace. The composer allows this submission, but an action that previously started the distro and succeeded now fails.
Keep background reads gated, but run explicit create and path-update checks inside the matching distro's runAsWslUserAct, as this PR does for explicit terminal spawns.
…ssively With #35899's folder stat gate, the runtime preflight passes passiveWslRestore = !wslUserAct, so a background start never stats a stopped distro's folder as a user act before the daemon hold.
… distro (#35865) * fix(wsl): main's background terminal starts never start a stopped WSL distro Every start main makes through the runtime controller is background work unless its caller names the user's act (CLI and window creates and splits, paired-client creates and tab opens, agent launches and sessions, conversation resumes). #35813's hold now also holds those fresh and restored starts while the distro is stopped or unverifiable. * fix(wsl): headless Run now starts as the user's act; update create expectations A headless automation's Run now names the user's act through launchAgentTerminal, so it may start a stopped WSL distro; a scheduled run stays background and is held. The paired-client background create expectation now includes wslUserAct. * fix(wsl): main's background start checks a folder workspace's path passively With #35899's folder stat gate, the runtime preflight passes passiveWslRestore = !wslUserAct, so a background start never stats a stopped distro's folder as a user act before the daemon hold.
Flag-off: applies with the flag on or off. It covers folder workspaces whose folder is a
\\wsl.localhostpath on Windows.User-risk: Low. While a folder workspace's distro is stopped, its sidebar row shows the existing muted "folder unavailable" mark instead of booting the distro to look. A restored terminal there waits with Start. A terminal the user opens still starts the distro, as before.
ELI5
Orca checks whether a folder workspace's folder still exists. It does this when drawing the sidebar, answering a status request, and before starting a terminal there. On Windows, simply looking at a folder inside a stopped WSL distro starts that distro. So these background checks could boot WSL when the user never asked for it. Now Orca first asks whether the distro is running. If it isn't, the check answers "unavailable right now" without touching the folder. The exception is when the user is the one asking, for example by opening a terminal.
What Changed
statFolderPathinfolder-workspace-path-status.tsranfs.staton the folder for every caller ofgetFolderWorkspacePathStatus. On a stopped distro, that stat booted it. This affected:folderWorkspaces:getPathStatusIPC);pty:spawnpreflight (assertWorkspaceAcceptsNewPty→assertFolderWorkspacePtyPathUsable). This included a passive restore, because the stat ran before fix(wsl): hold a passive WSL restore before the cwd probe, whichever provider spawns #35895's hold.statFolderPathchecksblockedWslDistroForPathfirst. On a stopped or unverifiable distro, it returns the existing{ exists: false, reason: 'unavailable' }and never stats. It never reports "missing", so nothing treats the folder as deleted. A user act on that distro (runAsWslUserAct) passes the gate.pty:spawnruns no user-act scope today. So the folder check inspawn-cwd.tsnow splits on the request'swslPassiveRestoreflag, which the preflight passes throughassertWorkspaceAcceptsNewPty:runAsWslUserAct, so it may start the distro, exactly as before.wslDistroHoldMessage, so the pane shows fix(wsl): a passive restore never starts a stopped WSL distro; its bridge panes wait with Start #35813's Start card. When the distro runs, the check proceeds as usual.Why
'unavailable', not a new reason. It already exists on the wire, so older clients and remote peers show it unchanged, and it isn't the confirmed-stale (destructive) state.folder_workspace_path_unavailable. The renderer already turns the hold message into the Start card.For review: the runtime's folder-workspace launch scope (
resolveFolderWorkspaceLaunchScope, used by the runtime's terminal create, file sessions and emulator selectors) has no user-act signal. On a stopped distro it now refuses withfolder_workspace_path_unavailableinstead of booting. That is the conservative E9 choice. If a runtime launch should count as a user act, that belongs in a follow-up.Linked Issue
Internal WSL tracker, E9. e9-reviewer found this gap during #35895's review. It existed before #35895, and this PR is independent of it.
Visual Proof
N/A: no new UI. The sidebar reuses the existing "unavailable" mark, and a held pane uses #35813's existing Start card.
Testing
New
spawn-cwd-wsl-stopped-folder.test.ts, on win32 with a mocked running read and a mockedfs.stat. The first three cases fail without the change.getFolderWorkspacePathStatuson a stopped distro returnsunavailableand never stats.assertWorkspaceAcceptsNewPtyis refused with the hold message and never stats.Also run:
the pty, project-groups, session-graph, project-group-controller and repos IPC suites: 1,568 pass;
pnpm tc,typecheck:ci,check:code-quality:changed, the anti-slop lint and the ast-grep gates.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
The gate is a no-op off Windows and for non-WSL paths. SSH folder workspaces take the existing remote branch before it. The running read is cached, so the sidebar polling adds no
wsl.exespawn per row.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)