Skip to content

fix(wsl): background Git and the roots catalog never start a stopped WSL distro (E9) - #34231

Merged
nwparker merged 5 commits into
mainfrom
nwparker/wsl-unc-git-no-boot
Oct 27, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/wsl-unc-git-no-boot

Conversation

@nwparker

@nwparker nwparker commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​508 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​500
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​230 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​163

ELI5

On Windows, running Git for a project inside a stopped WSL Linux starts that Linux again. Orca runs Git in the background all the time: status checks, a merge/rebase badge check every 3 s, branch compare, and listing a project's worktrees. In the verify-15b run, git status hit the project 0.45 s after the distro was stopped. With this change, background Git first asks whether the distro is running and skips the run if it isn't.

Builds on #34222 (merged), which added the shared check this PR reuses.

What Changed

Before: after wsl --terminate, the next background git:status ran through wsl.exe (or read the UNC .git) and booted the distro (684025f run, 02:37:06.45). The 3 s git:conflictOperation poll, git:upstreamStatus, git:branchCompare, the upstream-ref watch, the authorized-roots rebuild that runs on any authorization miss, and worktrees:listDetected could each do the same.

After: for a stopped distro, these refuse instead of running. Source Control shows the error, and the worktree list keeps its rows, marked unavailable. Once the distro runs again, the next poll or scan works as before.

Mechanism: everything goes through assertWslUncPathRunning from #34222, the shared check with the 60 s lease that is reset by a stop signal (with a settle window, and "unverifiable" kept separate from "stopped"). It now also takes the repo's wslDistro, because Git for a host path such as C:\… can still run through wsl.exe in a distro.

  • Git handlers: git:status, git:conflictOperation, git:upstreamStatus, git:branchCompare and git:setStatusUpstreamRefWatch check the requested path before resolving it, so there's no realpath and no roots rebuild. They check the resolved path plus the repo's distro before running Git.

  • Authorized-roots rebuild: listWorktreeRootsWithConcurrency doesn't list a repo whose distro is stopped. The repo's entry stays dirty and is listed on the first rebuild after the distro runs. The repo root itself stays authorized. Its worktree paths are refused until then, which is fine, because touching them would boot the distro anyway.

  • Detected-worktree scan: the check runs inside the shared scan promise, so concurrent callers still join one scan. A refusal goes through the existing scan-failure path: rows are kept and marked unavailable, and the refusal is not cached. A host scan starts and settles on exactly the same ticks as before, because the check only runs when a distro is involved.

  • User acts still start the distro:

    • The active workspace's first git:status after it becomes active carries wakeWslDistro, so a drive-path (C:\…) project whose Git runs through WSL starts its distro from Source Control. Later polls stay gated. There's no separate Source Control Retry for status; re-activating the workspace wakes it again.
    • A user act runs in an async scope that names its distro. Gated work inside it may start that distro and no other. That covers the authorized-roots rebuild an authorization miss triggers, the detected scan, and the Git run. So a wake read of an external worktree (git worktree add outside the workspace folder) on a stopped distro after a relaunch is listed and authorized, instead of failing with access denied.
    • After a user act wakes a distro, background checks stop trusting the earlier "stopped" read and probe again. Without this, they could refuse for up to 60 s.
    • The same applies to every explicit wsl.exe launch for a distro last read as stopped: Git or CLI runs such as commit, push and fetch (noted where the command resolves to wsl.exe), and WSL terminal spawns. Polls right after them read again instead of refusing.
    • The editor's active-tab wake from fix(wsl): background file reads and watches never start a stopped WSL distro (E9) #34222 now fires only when the active tab changes. Effect re-runs driven by git status or conflict-overview views read without waking, so a host repo's poll can't start a distro for a stale WSL tab.
    • Deferred tasks drained inside a user act, and the listeners of a running-list probe started inside one, run outside the user-act scope, so nothing triggered indirectly inherits permission to start a distro.
    • The authorization roots' WSL home probe (getAllowedRoots, which runs wsl.exe when the home is uncached) no longer runs in a stopped distro. Until the distro runs, the root falls back to the unknown-home layout.

Why

The 5e fix (#34200) can only see the distro as stopped if nothing restarts it. The explorer was one booter (#34222) and background Git was the other. Gating at the main-process handlers covers every renderer poll at once: the 60 s safety timer, focus catch-up, watch events and push signals. That's simpler than threading a flag through each scheduler.

Explicit Git actions stay ungated: commit, push, fetch, stage and discard. Those are the user's own acts.

Follow-ups (lows, not in this PR):

  • An explicit Git act on an unlisted external worktree before its workspace is activated still hits "access denied" while the distro is stopped. The act doesn't run in a user-act scope, so the roots rebuild it triggers defers the repo.
  • Host git.exe running over a UNC path (not through wsl.exe) doesn't record a launch, so polls right after it may refuse until the lease or the next stop/wake signal.

Linked Issue

WSL re-write, gate E9 / 5e. Evidence: 684025f run, main.trace git status on \\wsl.localhost\…\p10 at 02:37:06.45.

Visual Proof

N/A: no new UI. Source Control and the worktree list show their existing error and unavailable states.

Testing

  • filesystem-wsl-stopped-distro-git.test.ts: git:status, git:conflictOperation, git:upstreamStatus and git:branchCompare refuse before any realpath or Git run.
  • git-status-upstream-ref-watch-request.test.ts: no Git run in a stopped distro, including one named only by the repo's wslDistro.
  • registered-worktree-root-stopped-distro.test.ts: a rebuild skips the listing, the repo root stays authorized, and the repo is listed once the distro runs.
  • detected-worktree-scan-listing-distro.test.ts: a stopped distro means no Git run and a refusal that isn't cached; the next scan after the distro runs lists it.
  • wsl-unc-access-gate.test.ts: a host path with a distro is gated, and a host path without one never probes. A user act on one distro lets gated work start that distro but not another. After a wake, background reads re-probe instead of trusting the old "stopped".
  • The active workspace's first git:status with wakeWslDistro runs while the distro is stopped, and a later poll is refused. useGitStatusPolling sends the flag on the first status only.
  • The roots rebuild inside a user act on the distro lists the external worktree's repo, and the path is authorized.
  • A wsl.exe launch for a distro last read as stopped makes the next check read again, a launch for a running distro costs no read, and resolveCommand notes the distro of every WSL run.
  • A re-key re-run under the same active tab reads without waking.
  • A stopped distro's uncached home is not probed.
  • Three existing WSL-routing test files now mock the distro as running. Three WSL pruning tests wait for the scan to start instead of one microtask.
  • pnpm tc is clean apart from the two errors already on main. oxlint and check:code-quality:changed pass. The ipc, git, wsl and agent-hooks suites pass (11,092 tests).
  • Not yet re-run on Windows. verify-15b 5e with fix(wsl): background file reads and watches never start a stopped WSL distro (E9) #34222 and this PR is the check.

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

  • User risk: this applies to every Windows user whose projects run Git in WSL, whether through a \\wsl.localhost path or a WSL project runtime. The WSL hosts gate doesn't cover it.
    • If wsl.exe --list --running fails, the shared check re-reads once. If that also fails, background Git for those projects is refused with "WSL didn't answer" until WSL recovers. Source Control shows the error, and worktree rows stay but are marked unavailable.
    • Right after a stop signal, background Git for that distro waits up to 500 ms (the settle window from fix(wsl): background file reads and watches never start a stopped WSL distro (E9) #34222) before its running check.
    • User-initiated Git is unchanged.
  • Probes added per minute of normal use: 0 beyond fix(wsl): background file reads and watches never start a stopped WSL distro (E9) #34222. All callers share the same 60 s lease and the same probe, so the status poll, the 3 s conflict poll and branch compare together add at most 1 wsl.exe --list --running per distro per minute, and only when no other caller made one. Each stop signal adds 1. Host-only projects and non-Windows platforms never probe.
  • Flag-off: not behind the WSL hosts flag. With it off, the behaviour is the same as described above.
  • Cross-platform / SSH: every check returns early off Windows and for host paths without a distro. SSH and remote runtimes are untouched, because their requests return earlier.
  • Folder workspaces: a non-git folder never reaches these Git paths. The detected scan's folder branch is unchanged.
  • Git 2.25 baseline: no Git commands changed.

@nwparker
nwparker force-pushed the nwparker/wsl-unc-no-boot branch from 7a6b516 to cf3a360 Compare October 27, 2026 03:37
@nwparker
nwparker force-pushed the nwparker/wsl-unc-git-no-boot branch 2 times, most recently from f247aa3 to 01a7c1a Compare October 27, 2026 04:08
@nwparker
nwparker changed the base branch from nwparker/wsl-unc-no-boot to main October 27, 2026 04:20
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The changes add WSL distro wake tracking and access checks across Git requests and worktree discovery. Stopped distros can defer root listings or cause background Git requests to reject before path resolution or Git execution. The first status refresh and first visible tab load for a workspace can request a distro wake. Later refreshes and loads omit that option.

Priority: Normal

Merge Risk: Moderate · up to 2b951

Background conflict polling can still start a stopped WSL distro when Git is configured to run in WSL for a host path, which defeats the purpose of this change. A stopped distro can also cause a host workspace directory to be authorized in place of the WSL mirror root. Smaller issues: metadata pruning can be skipped after a refused scan, and a reopened editor panel may fail to read a stale file. Fix the conflict gate and the home fallback before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the user impact, implementation, testing, risks, and platform scope. However, it does not provide an actual linked issue under the required Linked Issue section, and the requi… Add the actual issue reference or URL after “Fixes #” and include the repository’s Checklist section with each applicable item completed or explained. Complete AI Disclosure if required for this contributor.
Docstring Coverage Warning Docstring coverage is 55.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: preventing background Git and roots-catalog operations from starting stopped WSL distributions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the user impact, implementation, testing, risks, and platform scope. However, it does not provide an actual linked issue under the required Linked Issue section, and the required Checklist section is missing.

Resolution

Add the actual issue reference or URL after “Fixes #” and include the repository’s Checklist section with each applicable item completed or explained. Complete AI Disclosure if required for this contributor.

Full details: Docstring Coverage

Explanation

Docstring coverage is 55.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 34 functions across 34 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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.

@nwparker
nwparker force-pushed the nwparker/wsl-unc-git-no-boot branch 2 times, most recently from ce7f60f to e1a6364 Compare October 27, 2026 04:42
…WSL distro

git status ran on the UNC project root 0.45 s after a terminate, next to the
explorer read; either boots the distro. Background Git (status, conflict
operation, upstream status, branch compare, the upstream-ref watch) now asks the
shared running gate first and refuses for a stopped distro, including host
paths whose Git runs through wsl.exe. The authorized-roots rebuild skips a
stopped distro's repo and leaves it dirty, and the detected-worktree scan fails
as unavailable, so rows are kept and the next scan after the distro runs lists it.
… rebuild may start WSL

- Drive-path projects whose Git runs through WSL had no wake path: the active
  workspace's first git:status after it becomes active now passes
  wakeWslDistro, so Source Control starts the distro; later polls stay gated.
- A user act runs in an async scope naming its distro; gated work inside it
  (the authorized-roots rebuild an authorization miss triggers, the detected
  scan, the Git) may start that distro and no other. External worktrees on a
  stopped distro no longer fail a wake read with access denied.
- After a user act wakes a distro, background reads stop trusting the older
  'stopped' read and probe again.
…n tab change; gate the home probe

- Any wsl.exe Git/CLI run (commit, push, fetch) or WSL terminal spawn for a
  distro last read as stopped records that it started, so background reads probe
  again instead of refusing for up to 60 s.
- The active editor tab wakes only when the active tab changes; effect re-runs
  driven by git status or overview views read without waking.
- The authorization roots' WSL home probe no longer runs wsl.exe in a stopped
  distro when the home is uncached.
- The settle window no longer imports the orcad liveness module (it pulled main
  code into the web typecheck); a test pins it to EXIT_SETTLE_MS.
…er act

A user act's async scope could leak into work it triggers indirectly: a drain of
deferred tasks it caused, or listeners of a running-list probe started inside
it. Both now run outside the scope, so only the act's own work may start its
distro.
worktree-logic.ts and wsl-running-distro-cache.ts are also compiled by the web
project, which cannot see main-only modules (AsyncLocalStorage, wsl.exe).
getAllowedRoots now injects the gated home lookup into computeWorkspaceRootWithin,
and the background gate's own cache subscriptions run outside the user-act scope
instead of the cache knowing about it.
@nwparker
nwparker force-pushed the nwparker/wsl-unc-git-no-boot branch from e1a6364 to 2b95128 Compare October 27, 2026 05:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: 1a1d0675-64e4-44ef-abce-37d1e74f4129
Commits

Reviewing files that changed from the base of the PR and between 192f578 and 2b95128.

Files selected for processing: 34
  • src/main/git/command-runner/wsl-command-resolution-launch-note.test.ts
  • src/main/git/command-runner/wsl-command-resolution.ts
  • src/main/ipc/filesystem/filesystem-allowed-roots.ts
  • src/main/ipc/filesystem/filesystem-git-status-handlers.ts
  • src/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.ts
  • src/main/ipc/filesystem/git-remote/compare-handlers.ts
  • src/main/ipc/filesystem/git-remote/sync-handlers.ts
  • src/main/ipc/git-status-upstream-ref-watch-request.test.ts
  • src/main/ipc/git-status-upstream-ref-watch-request.ts
  • src/main/ipc/pty/spawn-execute.ts
  • src/main/ipc/registered-worktree-root-probes.ts
  • src/main/ipc/registered-worktree-root-stopped-distro.test.ts
  • src/main/ipc/registered-worktree-roots-cache.ts
  • src/main/ipc/worktree-logic-wsl.test.ts
  • src/main/ipc/worktree-logic.ts
  • src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts
  • src/main/ipc/worktrees-detected-scan-cache.test.ts
  • src/main/ipc/worktrees-wsl-runtime-routing.test.ts
  • src/main/ipc/worktrees/listing/detected-worktree-scan-cache.ts
  • src/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.ts
  • src/main/wsl-background-distro-gate.ts
  • src/main/wsl/wsl-home-unless-stopped.test.ts
  • src/main/wsl/wsl-home-unless-stopped.ts
  • src/main/wsl/wsl-unc-access-gate.test.ts
  • src/main/wsl/wsl-unc-access-gate.ts
  • src/main/wsl/wsl-user-act-scope.ts
  • src/preload/api/git-bridge.ts
  • src/preload/api/git-inspection-api.ts
  • src/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.overview.test.tsx
  • src/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.ts
  • src/renderer/src/components/right-sidebar/git-status-refresh.ts
  • src/renderer/src/components/right-sidebar/useGitStatusPolling.test.ts
  • src/renderer/src/components/right-sidebar/useGitStatusPolling.ts
  • src/renderer/src/runtime/runtime-git-status-client.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

): Promise<GitConflictOperation> => {
requireReachableGitRoute(getConnectionExecutionHostId(args.connectionId))
// A 3 s poll for inactive worktrees: its UNC reads would boot a stopped WSL distro (E9).
await assertWslUncPathRunning(args.worktreePath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Stability & Availability · Quick win

Check the configured distro before conflict polling.

If a registered Windows host path uses WSL Git, this check sees no UNC distro. detectConflictOperation then receives gitOptions.wslDistro and can launch Git in the stopped distro. Add the resolved-path check with gitOptions.wslDistro, as git:status does. (raw.githubusercontent.com)

As per coding guidelines, “Support macOS, Linux, and Windows.”

Source: Coding guidelines

Comment on lines +103 to +105
await invoke('git:status', { worktreePath: UNC_ROOT, wakeWslDistro: true }).catch(
(error: unknown) => expect(error).not.toBeInstanceOf(WslDistroStoppedError)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Require the waking status request to succeed.

This .catch also accepts access-denied errors and other failures before getStatus runs. The test can therefore pass without showing that the first request reads status. Register an authorized UNC worktree in the fixture, then assert that the request resolves and calls getStatusMock. (raw.githubusercontent.com)

const scan: DetectedWorktreeScan = {
invalidated: false,
promise: listRepoWorktreesForDetectedScan(repo, localWorktreeGitOptions),
promise: listUnlessWslDistroStopped(repo, localWorktreeGitOptions),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

Preserve the prune pass when the WSL gate rejects a scan.

If a stopped distro blocks the first scan, markLocalWorktreeMetadataPruneStarted has already claimed the pass. The rejected scan records no listing fingerprint. The first successful scan does not re-arm the pass when no earlier fingerprint exists, so metadata and lineage pruning wait for another invalidation. Keep the pass due when this gate rejects the listing. (raw.githubusercontent.com)

Comment on lines +7 to +8
if (getCachedWslHome(distro) === undefined && (await blockedWslDistroForPath('', distro))) {
return null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Security & Privacy · Heavy lift

Do not authorize the host fallback when a stopped distro blocks home lookup.

If a WSL repository has no cached home, this branch returns null. computeWorkspaceRootWithin treats null as a failed home lookup and returns an absolute host workspaceDir. getAllowedRoots then authorizes that host directory, although the repository’s mirrored worktrees belong under its WSL home. Keep “distro unavailable” distinct from a failed home lookup, and omit the mirrored workspace root until its location is known. (raw.githubusercontent.com)

Comment on lines +103 to +105
const tabId = selectedConflictReviewFile?.id ?? activeFile?.id ?? null
const load = tabId !== wokenTabIdRef.current ? ACTIVE_TAB_LOAD : undefined
wokenTabIdRef.current = tabId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Allow a tab to wake WSL when its panel becomes visible again.

If the panel becomes hidden and the same tab needs a read when the panel reopens, wokenTabIdRef still holds its ID. The read receives no wake option and a stopped WSL distro refuses it. Reset the ref when isVisible becomes false, so showing the tab can start its distro. (raw.githubusercontent.com)

@nwparker
nwparker merged commit 362104c into main Oct 27, 2026
48 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