Repository navigation
fix(wsl): background Git and the roots catalog never start a stopped WSL distro (E9) - #34231
Conversation
7a6b516 to
cf3a360
Compare
f247aa3 to
01a7c1a
Compare
Walkthrough
Priority: Merge Risk:
|
ce7f60f to
e1a6364
Compare
…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.
e1a6364 to
2b95128
Compare
There was a problem hiding this comment.
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
Files selected for processing: 34-
src/main/git/command-runner/wsl-command-resolution-launch-note.test.tssrc/main/git/command-runner/wsl-command-resolution.tssrc/main/ipc/filesystem/filesystem-allowed-roots.tssrc/main/ipc/filesystem/filesystem-git-status-handlers.tssrc/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.tssrc/main/ipc/filesystem/git-remote/compare-handlers.tssrc/main/ipc/filesystem/git-remote/sync-handlers.tssrc/main/ipc/git-status-upstream-ref-watch-request.test.tssrc/main/ipc/git-status-upstream-ref-watch-request.tssrc/main/ipc/pty/spawn-execute.tssrc/main/ipc/registered-worktree-root-probes.tssrc/main/ipc/registered-worktree-root-stopped-distro.test.tssrc/main/ipc/registered-worktree-roots-cache.tssrc/main/ipc/worktree-logic-wsl.test.tssrc/main/ipc/worktree-logic.tssrc/main/ipc/worktrees-authoritative-local-metadata-pruning.test.tssrc/main/ipc/worktrees-detected-scan-cache.test.tssrc/main/ipc/worktrees-wsl-runtime-routing.test.tssrc/main/ipc/worktrees/listing/detected-worktree-scan-cache.tssrc/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.tssrc/main/wsl-background-distro-gate.tssrc/main/wsl/wsl-home-unless-stopped.test.tssrc/main/wsl/wsl-home-unless-stopped.tssrc/main/wsl/wsl-unc-access-gate.test.tssrc/main/wsl/wsl-unc-access-gate.tssrc/main/wsl/wsl-user-act-scope.tssrc/preload/api/git-bridge.tssrc/preload/api/git-inspection-api.tssrc/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.overview.test.tsxsrc/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.tssrc/renderer/src/components/right-sidebar/git-status-refresh.tssrc/renderer/src/components/right-sidebar/useGitStatusPolling.test.tssrc/renderer/src/components/right-sidebar/useGitStatusPolling.tssrc/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) |
There was a problem hiding this comment.
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
| await invoke('git:status', { worktreePath: UNC_ROOT, wakeWslDistro: true }).catch( | ||
| (error: unknown) => expect(error).not.toBeInstanceOf(WslDistroStoppedError) | ||
| ) |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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)
| if (getCachedWslHome(distro) === undefined && (await blockedWslDistroForPath('', distro))) { | ||
| return null |
There was a problem hiding this comment.
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)
| const tabId = selectedConflictReviewFile?.id ?? activeFile?.id ?? null | ||
| const load = tabId !== wokenTabIdRef.current ? ACTIVE_TAB_LOAD : undefined | ||
| wokenTabIdRef.current = tabId |
There was a problem hiding this comment.
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)
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 backgroundgit:statusran throughwsl.exe(or read the UNC.git) and booted the distro (684025f run, 02:37:06.45). The 3 sgit:conflictOperationpoll,git:upstreamStatus,git:branchCompare, the upstream-ref watch, the authorized-roots rebuild that runs on any authorization miss, andworktrees:listDetectedcould 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
assertWslUncPathRunningfrom #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'swslDistro, because Git for a host path such asC:\…can still run throughwsl.exein a distro.Git handlers:
git:status,git:conflictOperation,git:upstreamStatus,git:branchCompareandgit:setStatusUpstreamRefWatchcheck 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:
listWorktreeRootsWithConcurrencydoesn'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:
git:statusafter it becomes active carrieswakeWslDistro, 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.git worktree addoutside the workspace folder) on a stopped distro after a relaunch is listed and authorized, instead of failing with access denied.wsl.exelaunch for a distro last read as stopped: Git or CLI runs such as commit, push and fetch (noted where the command resolves towsl.exe), and WSL terminal spawns. Polls right after them read again instead of refusing.getAllowedRoots, which runswsl.exewhen 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):
git.exerunning over a UNC path (not throughwsl.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.tracegit status on\\wsl.localhost\…\p10at 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:upstreamStatusandgit:branchComparerefuse 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'swslDistro.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".git:statuswithwakeWslDistroruns while the distro is stopped, and a later poll is refused.useGitStatusPollingsends the flag on the first status only.wsl.exelaunch for a distro last read as stopped makes the next check read again, a launch for a running distro costs no read, andresolveCommandnotes the distro of every WSL run.pnpm tcis clean apart from the two errors already on main. oxlint andcheck:code-quality:changedpass. The ipc, git, wsl and agent-hooks suites pass (11,092 tests).Review
Agent skill upstream boundary
Notes
\\wsl.localhostpath or a WSL project runtime. The WSL hosts gate doesn't cover it.wsl.exe --list --runningfails, 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.wsl.exe --list --runningper 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.