Repository navigation
fix(wsl): wake a stopped distro only on the user's own workspace switch or expand - #35867
Conversation
…ch or expand The explorer's workspace-open read and the first git status woke WSL on every mount, so a remount, launch restore or host loss after the user stopped the distro started it again. Both now wake only when takeWorkspaceSwitchWake reports a new user switch to that workspace, once per switch per consumer; an expanded folder wakes only when it is newly expanded in the same workspace, not when a mount or switch re-runs with the same folders.
|
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 seconds. 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 WSL wake-ups from the renderer's explorer and Git status paths. Fix the delayed wake and expanded-folder startup race before merging. FindingsSummaryThe PR ties explorer and git-status wake requests to recorded user switches and newly expanded folders.
Reviews (1) · Last reviewed commit: "fix(wsl): wake a stopped distro only on ..." · Reviewed by Greptile |
| const wake = workspaceKey !== null && takeWorkspaceSwitchWake(workspaceKey, 'explorer') | ||
| resetAndLoad(wake ? { wakeWslDistro: true } : undefined) |
There was a problem hiding this comment.
Picking a terminal tab records another switch while the workspace stays focused. The explorer leaves it unused because its path has not changed. If the user then stops the distro, an explorer remount consumes that old switch and wakes it again. The new git-status call can likewise consume an old switch on a later poll. Limit wake requests to reads caused by the current action, rather than any unused switch.
| void loadDir(dirPath, depth, { | ||
| wakeWslDistro: true, | ||
| ...(sameWorkspace && !seen.dirs.has(dirPath) ? { wakeWslDistro: true } : {}), | ||
| ...(decision === 'reload' ? { force: true } : {}) | ||
| }) |
There was a problem hiding this comment.
Expanded folders miss WSL startup
On a user switch or first mount, sameWorkspace is false, so already-expanded folders now load without permission to wake WSL. Those reads run alongside the waking root read. The backend checks whether WSL is running without waiting for that read, so a folder can save a stopped-distro error before startup finishes. The root's success does not retry it, and the error check skips it afterward. Wait for the waking root read before loading the already-expanded folders.
ELI5
If you stop a WSL distro while one of its workspaces is open in Orca, Orca can start it again with no action from you. The file explorer and git status treated each re-render, remount or reconnect as if you had just opened the workspace or expanded a folder. Now they only start a stopped distro for your own actions: switching to that workspace, or expanding a folder.
What Changed
wakeWslDistro: true.takeWorkspaceSwitchWake(activeWorktreeId, 'explorer')reports a new user switch to that workspace. That comes from fix(wsl): a passive restore never starts a stopped WSL distro; its bridge panes wait with Start #35813'sworkspace-switch-user-act.ts, which notes only real user opens and terminal tab picks, once per switch per consumer.useFileExplorerHandlers), as before.takeWorkspaceSwitchWake(activeWorktreeId, 'git-status'). Polls, remounts and restores stay gated.Why
Rule E9: only the user's own acts may start a stopped distro. A real-WSL guard reproduced a device report of a distro restarting with its workspace focused and nothing touched.
fs:readDirran through the user-act wake path on the repo root andsrc(realpath, then readdir), and the distro was running again.Consuming a switch once per consumer, rather than remembering "this workspace was opened", closes the hole where an old switch, then a stop, then a remount would wake again. Reusing #35813's helper keeps one definition of a user switch across the explorer, git status and pane restore.
Flag-off: bridge mode is where these reads go over
\\wsl.localhost, so it's the main beneficiary. Host mode uses the same renderer paths.User-risk: after a distro stops, a focused workspace's explorer and git status show the existing "distro is stopped" state instead of restarting it. Switching to the workspace, expanding a folder, Refresh, or opening a terminal still starts it.
Linked Issue
Fixes #
Visual Proof
N/A. No new UI. A stopped distro shows the existing refused or stopped states.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
use-file-explorer-tree-load-effects-wsl-wake.test.ts: mounting doesn't wake, a newly expanded folder wakes, and a remount doesn't wake.file-explorer-stale-retry.test.tsx: only a noted user switch lets the workspace-open read wake, once. A restore, a remount, or a re-open without a new switch reads without waking.useGitStatusPolling.test.ts: the mount's status doesn't wake; after the user switches to the workspace, the next status does.Existing explorer tests updated for the new
workspaceKeyparam and the edge-only expand wake.Local checks: the right-sidebar suite (287 files) passes, as do
pnpm tc,typecheck:ci,check:code-quality:changedand anti-slop oxlint.Review
Agent skill upstream boundary
Notes
wakeWslDistrois ignored for non-WSL hosts, and the switch helper is keyed by the store worktree id,folder:<id>for folders.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)