Skip to content

fix(wsl): wake a stopped distro only on the user's own workspace switch or expand - #35867

Merged
nwparker merged 1 commit into
mainfrom
nwparker/e9-edge-triggered-wsl-wake
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/e9-edge-triggered-wsl-wake

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​104
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

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

  • Explorer, opening a workspace:
    • Before: the workspace-open load always passed wakeWslDistro: true.
    • After: it wakes only when 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's workspace-switch-user-act.ts, which notes only real user opens and terminal tab picks, once per switch per consumer.
    • A remount, launch restore or host-loss re-run reads without waking, so a stopped distro is refused instead of started.
  • Explorer, expanded folders:
    • Before: the expanded-dirs effect re-read every expanded folder with an empty or stale cache as a user act, on every run.
    • After: it wakes only for a folder that is newly expanded in the same workspace since the last run. Folders that were already expanded, and a workspace change, never wake.
    • A click on a folder still wakes it directly (useFileExplorerHandlers), as before.
  • Git status:
    • Before: the first poll after each mount woke the distro (a per-mount ref).
    • After: only the first status after a new user switch does, via 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.

  • Red, current main (run 40842920879): about 166 ms after the terminate, the explorer's fs:readDir ran through the user-act wake path on the repo root and src (realpath, then readdir), and the distro was running again.
  • Green for the explorer part, with this change and fix(wsl): a passive restore never starts a stopped WSL distro; its bridge panes wait with Start #35813 (run 40842925396): the Explorer sat visible for 7.5 s after the stop with no UNC touch and no boot.
    • Switching that run's sidebar to Source Control then started the distro through a separate path, a GitHub repository lookup plus the commits list. That one is being attributed and is tracked separately; the commits list is in wsl-e6's follow-up.

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 workspaceKey param and the edge-only expand wake.

Local checks: the right-sidebar suite (287 files) passes, as do pnpm tc, typecheck:ci, check:code-quality:changed and anti-slop oxlint.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH and folder workspaces: unchanged. wakeWslDistro is ignored for non-WSL hosts, and the switch helper is keyed by the store worktree id, folder:<id> for folders.
  • Remote compatibility: renderer only; no wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: d2bb207b-09cb-4162-a575-d75bd229cec9
Commits

Reviewing files that changed from the base of the PR and between f8cf317 and 0c4fd95.

Files selected for processing: 9
  • src/renderer/src/components/right-sidebar/file-explorer-linked-recovery.test.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-stale-retry.test.tsx
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-load-effects-wsl-wake.test.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-load-effects.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-pane-state.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.lifecycle.test.tsx
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.refresh-projection-churn.test.tsx
  • src/renderer/src/components/right-sidebar/useGitStatusPolling.test.ts
  • src/renderer/src/components/right-sidebar/useGitStatusPolling.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[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.

Findings

  1. P1 Old switches still wake WSL ▶
  2. P1 Expanded folders miss WSL startup ▶

Summary

The PR ties explorer and git-status wake requests to recorded user switches and newly expanded folders.

  • Explorer reads wake a stopped WSL distro only after a user action.
  • Git status wakes a stopped WSL distro only after a user workspace switch.

Reviews (1) · Last reviewed commit: "fix(wsl): wake a stopped distro only on ..." · Reviewed by Greptile

Comment on lines +94 to +95
const wake = workspaceKey !== null && takeWorkspaceSwitchWake(workspaceKey, 'explorer')
resetAndLoad(wake ? { wakeWslDistro: true } : undefined)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Old switches still wake WSL

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.

Comment on lines 152 to 155
void loadDir(dirPath, depth, {
wakeWslDistro: true,
...(sameWorkspace && !seen.dirs.has(dirPath) ? { wakeWslDistro: true } : {}),
...(decision === 'reload' ? { force: true } : {})
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

@nwparker
nwparker merged commit 5dde71c into main Oct 29, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant