Skip to content

fix(wsl): background file reads and watches never start a stopped WSL distro (E9) - #34222

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

nwparker merged 4 commits into
mainfrom
nwparker/wsl-unc-no-boot

Conversation

@nwparker

@nwparker nwparker commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​771 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​734
Prod 33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​453 $\color{#cf222e}{\Huge{\mathbf{−}}}$​107 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​346

ELI5

On Windows, if Orca so much as looks at a file inside a stopped WSL Linux, Windows starts that Linux again. When you stopped a distro, the file explorer refreshed a quarter-second later and started it right back up. Now background file reads and file watching first ask whether the distro is running and leave it alone if it isn't. Opening the workspace, or pressing Retry, still starts it.

What Changed

Before: wsl --terminate stopped the distro. Its file-explorer watcher (a wsl.exe process) died with it, and the explorer refreshed. In the verify-15b re-run, that refresh ran realpath on the project folder 0.23 s after the terminate, and the distro booted in the same second. Because the distro looked running again, the pane-exit logic (#34095, #34200) also took the stop for a normal exit.

After: the explorer shows "WSL distro 'X' is not running. Retry, or open a terminal in it, to start it." The distro stays stopped. When the distro runs again, by any means, the explorer re-watches and refreshes on its own.

Mechanism:

  • One shared gate, src/main/wsl/wsl-unc-access-gate.ts. A background touch of a \\wsl.localhost or \\wsl$ path is allowed only when the shared running list (isWslDistroRunning) confirms the distro, using a read that started after the later of these two times:

    • 60 s ago, a lease: with no stop signal, the last confirmed read is trusted for a minute;
    • the last "may have stopped" signal for that distro. After a signal, only a read that started later counts.

    If the list can't be read, the touch is refused too.

  • Stop signals are recorded before anything re-reads:

    • the explorer watcher's wsl.exe exiting on its own, recorded before its overflow refresh is scheduled;
    • the hook relay link failing. In the 5e log the relay link died 80 ms before the readDir.
  • Running-distro cache: a caller that passes startedAfter can now be answered by the last confirmed read when that read started after startedAfter. This is the rule startedAfter already documents. Callers that don't pass it still get a fresh read.

  • Gated reads: fs:readDir, fs:stat, fs:pathExists, fs:pathsExist, fs:readFile, fs:readFileChunk and fs:listMarkdownDocuments. They refuse before the realpath, so nothing touches 9P. A refused pathExists throws instead of answering false, so restored dirty tabs are never marked as deleted.

  • Watcher:

    • A watch install on a stopped distro neither stats nor spawns. It waits (deferUntilWslDistroRunning, which now returns a cancel) and is not cached as unwatchable.
    • A watcher that dies on its own re-watches once the distro is seen running. That re-watch sends the existing resync overflow, so the explorer clears its error and refreshes.
    • Both reuse the watcher-capacity retry path, which now takes a "wait for" function.
  • User acts wake the distro: fs:readDir, fs:readFile, fs:stat and fs:readFileChunk take an optional wakeWslDistro, sent only to the local IPC, never over SSH or to a remote runtime. The flag is set by:

    • opening a workspace;
    • a user's folder expand;
    • every path a user opens (statUserOpenedPath, which covers the explorer, quick-open, links and drops);
    • the active editor tab's load, including restored tabs on relaunch;
    • the explorer and editor Retry buttons.

    A successful wake read counts as proof the distro is running and resumes waiting work, such as the re-watch. Watch overflows, stale-dir refreshes, background editor reloads, restored-tab conflict scans and watchers never set it.

  • Unverifiable is not stopped: if the running list can't be read, the gate re-reads once, skipping the failure backoff. Only one such re-read happens per failure window, so a long wsl.exe outage doesn't spawn one per read. If it still fails, the touch is refused with "WSL didn't answer whether 'X' is running", not "not running". It never touches the path.

  • Settle after a stop: right after a stop, WSL can still list the distro. After any stop signal, isWslDistroRunning waits out EXIT_SETTLE_MS (500 ms) and never counts a read that started inside that window. This covers both the watcher's own overflow refresh and the hook relay's restart check, so fix(agent-hooks): the WSL hook relay stays down while its distro is stopped (E9) #34195 can't be re-opened by a stale read another caller made.

  • Observed stops reset the lease: any confirmed read that no longer lists a distro records a stop signal for it (wsl --shutdown, idle stop).

Why

E9 says background work never boots a stopped distro. The file explorer was the booter in 5e. Gating at the main-process handlers catches every renderer caller, including the restored-tab scan and editor overflow reloads. Gating only the explorer's refresh path in the renderer would have missed those.

Other approaches I considered:

  • A fresh wsl.exe read for every touch: too costly for explorer bursts.
  • A TTL alone: a read taken just before a terminate could let the next touch boot the distro.

The stop signals close that gap, and they are what let the lease be long. A stopped distro always comes with a signal: the watcher's wsl.exe is a child that keeps the distro from idling out, so a terminate kills it. That keeps the cost to about one wsl.exe a minute per distro, shared by all callers.

Not in this PR (follow-up PR2): background git for WSL worktrees and the repo catalog. These are status polling, the 3 s git:conflictOperation poll, upstream status, branch compare, and the authorized-roots rebuild and worktrees:listDetected running git worktree list through wsl.exe.

Linked Issue

WSL re-write, gate E9. Evidence: verify-15b re-run, 5e-boottrace.txt and 5e-terminate-mainlog.txt.

Visual Proof

N/A: the only visible change is the explorer's existing error row, which now shows a "not running" message with the existing Retry button.

Testing

  • wsl-unc-access-gate.test.ts covers:
    • a stopped distro is refused with no touch;
    • a running distro is let through;
    • no probe off Windows or for non-UNC paths;
    • one read per burst, no new read for a minute without a stop signal, and a re-read after the lease;
    • a read from before a stop signal is not trusted;
    • a failed list read refuses;
    • a wake touches without asking and resumes waiting work only on success.
  • filesystem-wsl-stopped-distro-reads.test.ts: every gated handler refuses with no realpath, stat or read; pathsExist reports an error, not "absent"; a wake read skips the check.
  • Watcher: an install on a stopped distro neither stats nor spawns, isn't cached as unwatchable, and retries once the distro runs (and not when another distro does). A watcher that dies on its own reports the stop before scheduling its refresh, then re-watches.
  • Cache and gate: an anchored caller reuses a confirmed read that started after the anchor, never a failed one; the deferred-task cancel removes only its own task.
  • Relay: a relay failure records the stop signal. wsl-hook-relay-stop-settle.test.ts: WSL still lists the distro during settle, the restart check waits it out, sees the stop, and the relay stays down.
  • Unverifiable: one failed read is retried past the backoff and the read goes ahead. Repeated failures refuse with "WSL didn't answer", with no further spawn in the same window and no touch of the path.
  • Settle: a read that started inside a just-signalled stop's settle window is not trusted; the gate waits and reads again. A stop observed by another caller resets the lease.
  • User acts: the readDir, readFile, stat and readFileChunk handlers skip the check when wakeWslDistro is set. The active tab's load and its Retry pass the flag, and a plain reload doesn't. A user-opened stat, a folder expand and the explorer Retry pass it. A local file read sends it, and an SSH read doesn't.
  • Renderer:
    • opening a workspace passes wakeWslDistro, and a background refresh doesn't;
    • Retry passes it;
    • the flag reaches only the local read.
  • pnpm tc is clean apart from two errors already on main, in agent-account-restart-startup.ts and doc-preview-external-link-confirmation.test.ts.
  • oxlint and check:code-quality:changed pass; the filesystem, WSL, agent-hooks, runtime and right-sidebar suites pass (8,189 tests).
  • Not yet re-run on Windows with a real terminate. verify-15b 5e 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 with a WSL bridge project. The WSL hosts gate doesn't cover it.
    • If wsl.exe --list --running fails or hangs, the gate re-reads once. If that also fails, background reads are refused with "WSL didn't answer" until WSL recovers. User acts (open, expand, Retry, the active tab) still read.
    • Right after a stop signal, background reads of that distro wait up to 500 ms before their running check.
    • Probes added per minute of normal use: at most 1 shared wsl.exe --list --running per distro whose files are being browsed, and 0 when no WSL path is involved. Each stop signal (watcher exit, relay failure) adds 1 more read. The gate also reuses any confirmed read another caller already made, so it often adds none. Writes and saves stay ungated.
    • Residual window: if a distro stops with no Orca process inside it and no read observes the stop, for example by idling out while unwatched, a background read within 60 s of the last confirmed read could still start it. A read that observes the stop does reset the lease.
    • The AI vault resume pathExists(cwd) check is unchanged: it runs only for SSH or runtime hosts, which this gate doesn't touch, and it already keeps the session on any error.
    • A watcher that keeps dying while its distro runs is re-watched at most once per confirmed running read. Before, it was never re-watched.
  • Flag-off: not behind the WSL hosts flag. With it off, the behaviour is the same as described above.
  • Cross-platform: every check returns early off Windows and for non-UNC paths. macOS, Linux and SSH are unchanged, and wakeWslDistro is never sent to remote runtimes.
  • Wire compatibility: wakeWslDistro is a new optional field on a local IPC call. An older main process ignores it.
  • Folder workspaces: gated the same way. The gate keys on the path, not on git.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: f5fcf9c8-717b-4c5e-854b-85568131874b
Commits

Reviewing files that changed from the base of the PR and between cf3a360 and 57c522d.

Files selected for processing: 5
  • src/renderer/src/components/quick-open-file-navigation.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-click-fallback.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-escaping-file-open.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-paired-click-fallback.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-wsl-path-mapping.test.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.

Walkthrough

The changes add a WSL UNC access gate for filesystem reads and check distro state before access. Watcher installation and recovery can defer retries until a distro runs. File-explorer and editor actions pass a wake option through local reads. Tests cover the access gate, stopped-distro reads, watcher recovery, and wake-option forwarding.

Priority: Normal

Merge Risk: High · up to 57c52

Background and restored UI operations can still start stopped WSL distros, while watcher recovery and expanded reads can remain unavailable.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.23% 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: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: preventing background file reads and watches from starting stopped WSL distros.
Description check Passed The description is detailed and aligned with the template. It explains the user impact, implementation, rationale, testing, cross-platform behavior, risks, and scope. The Linked Issue section lacks a …
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 is detailed and aligned with the template. It explains the user impact, implementation, rationale, testing, cross-platform behavior, risks, and scope. The Linked Issue section lacks a concrete issue link, and the final checklist is omitted, but the description is otherwise substantially complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 30.23% 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 43 functions across 59 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.

@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: 6


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: 17b1a3a5-98d4-406a-83ca-ae5f620eda0c
Commits

Reviewing files that changed from the base of the PR and between 01db1c6 and 7a6b516.

Files selected for processing: 33
  • src/main/agent-hooks/wsl-hook-relay-recovery.test.ts
  • src/main/agent-hooks/wsl-hook-relay-state-machine.ts
  • src/main/ipc/filesystem/filesystem-chunk-read-handler.ts
  • src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts
  • src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts
  • src/main/ipc/filesystem/filesystem-read-handlers.ts
  • src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts
  • src/main/ipc/filesystem/filesystem.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-lifecycle-state.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-capacity.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-subscription.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-wsl.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-wsl.ts
  • src/main/wsl-background-distro-gate.test.ts
  • src/main/wsl-background-distro-gate.ts
  • src/main/wsl-running-distro-cache.ts
  • src/main/wsl/wsl-unc-access-gate.test.ts
  • src/main/wsl/wsl-unc-access-gate.ts
  • src/preload/api/filesystem-api.ts
  • src/preload/api/fs-bridge.ts
  • src/renderer/src/components/right-sidebar/FileExplorerFilesTreePane.errors.test.tsx
  • src/renderer/src/components/right-sidebar/FileExplorerFilesTreePane.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-directory-listing.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-directory-listing.ts
  • src/renderer/src/components/right-sidebar/file-explorer-stale-retry.test.tsx
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-load-effects.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.stale-dirs.test.tsx
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.ts
  • src/renderer/src/runtime/runtime-file-client-test-harness.ts
  • src/renderer/src/runtime/runtime-file-client.test.ts
  • src/renderer/src/runtime/runtime-file-mutation-client.ts

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

Comment on lines +105 to +107
const media = readMediaPreview(event, args, store)
if (media) {
return media

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

Guard media-preview requests when they open the file.

For a previewable file, readMediaPreview returns a reusable media URL; this guarded IPC call does not read the file. handleMediaPreviewRequest in src/main/media/media-preview-protocol.ts, Lines 75-76, later resolves and opens the file without a WSL check. If the distro stops after the URL is issued, a subsequent preview or range request can restart it. Apply the shared gate at the protocol request’s file-open path. (raw.githubusercontent.com)

Comment on lines +79 to +81
onUnexpectedStop: (stoppedRoot, distro) => {
noteWslDistroMayHaveStopped(distro)
scheduleRetry(stoppedRoot.listeners, waitForDistro(distro))

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

Supported by static analysis

Script executed:

set -eu
printf '%s\n' '--- reviewed file ---'
nl -ba src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts | sed -n '1,180p'
printf '%s\n' '--- relevant symbols ---'
rg -n -F --glob '*.ts' -e 'waitForDistro' -e 'WaitForLocalWatcherRetry' -e 'deferUntilWslDistroRunning' -e 'noteWslDistroMayHaveStopped' -e 'scheduleRetry' src/main
printf '%s\n' '--- changed file diff ---'
git diff --no-ext-diff --unified=80 07b5c083bd995457a503353cb059685622719759 7a6b5168c09ec12c094ed52f19d0de5f687bb7da -- src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts

Repository: stablyai/orca

Length of output: 21941


Script executed:

set -eu
nl -ba src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts | sed -n '1,180p'
printf '%s\n' '--- symbols ---'
rg -n -F --glob '*.ts' -e 'waitForDistro' -e 'WaitForLocalWatcherRetry' -e 'deferUntilWslDistroRunning' -e 'noteWslDistroMayHaveStopped' -e 'scheduleRetry' src/main || test "$?" -eq 1
printf '%s\n' '--- diff ---'
git diff --no-ext-diff --unified=80 07b5c083bd995457a503353cb059685622719759 7a6b5168c09ec12c094ed52f19d0de5f687bb7da -- src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts

Repository: stablyai/orca

Length of output: 21897


Script executed:

set -eu
printf '%s\n' '--- local watcher retry scheduler ---'
nl -ba src/main/ipc/filesystem/watchers/filesystem-watcher-local-capacity.ts | sed -n '1,220p'
printf '%s\n' '--- background distro gate ---'
nl -ba src/main/wsl-background-distro-gate.ts | sed -n '1,220p'
printf '%s\n' '--- UNC access gate ---'
nl -ba src/main/wsl/wsl-unc-access-gate.ts | sed -n '1,240p'
printf '%s\n' '--- callers of installLocalWatcher and retry scheduling ---'
rg -n -F --glob '*.ts' -e 'installLocalWatcher(' -e 'onWatcherChildCapacityAvailable' -e 'scheduleLocalWatcher' -e 'scheduleRetry' src/main/ipc/filesystem/watchers src/main/ipc/filesystem

Repository: stablyai/orca

Length of output: 16832


Script executed:

set -eu
printf '%s\n' '--- running distro cache ---'
nl -ba src/main/wsl-running-distro-cache.ts | sed -n '1,260p'
printf '%s\n' '--- observation producers ---'
rg -n -F --glob '*.ts' -e 'noteWslDistrosRunning(' -e 'onConfirmedRunningWslDistros(' -e 'listConfirmedRunningWslDistros(' -e 'readConfirmedRunningWslDistros(' src/main
printf '%s\n' '--- subscription call site ---'
nl -ba src/main/ipc/filesystem/watchers/filesystem-watcher-local-subscription.ts | sed -n '150,220p'

Repository: stablyai/orca

Length of output: 11522


Script executed:

set -eu
printf '%s\n' '--- confirmed-list callers ---'
nl -ba src/main/wsl/wsl-host-connector.ts | sed -n '1,150p'
nl -ba src/main/wsl/wsl-orcad-liveness-wiring.ts | sed -n '1,110p'
printf '%s\n' '--- all running-list call sites ---'
rg -n -F --glob '*.ts' -e 'listRunningWslDistrosAsync' -e 'resolveRunningWslDistros' -e 'readConfirmedRunningWslDistros' -e 'listConfirmedRunningWslDistros' src/main

Repository: stablyai/orca

Length of output: 23543


Trigger a confirmed WSL probe after an unexpected watcher stop.

waitForDistro only registers a deferred task. deferUntilWslDistroRunning runs that task only after a successful confirmed running-list observation. The unexpected-stop callback does not request one, so a running distro can leave its watcher retry pending until an unrelated component probes WSL.

Start a confirmed probe after registering the retry. Do not touch the UNC root.

Suggested fix
 import { deferUntilWslDistroRunning } from '../../../wsl-background-distro-gate'
+import { listConfirmedRunningWslDistros } from '../../../wsl-background-distro-gate'
...
               onUnexpectedStop: (stoppedRoot, distro) => {
                 noteWslDistroMayHaveStopped(distro)
                 scheduleRetry(stoppedRoot.listeners, waitForDistro(distro))
+                void listConfirmedRunningWslDistros()
               }

Comment thread src/main/wsl/wsl-unc-access-gate.ts Outdated
Comment on lines +30 to +34
const startedAfter = Math.max(
mayHaveStoppedAt.get(distroKey(distro)) ?? -Infinity,
performance.now() - WSL_UNC_RUNNING_LEASE_MS
)
return isWslDistroRunning(distro, { startedAfter })

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 · Heavy lift

Recheck running state before an unobserved stop can trigger UNC access.

If Ubuntu stops after a successful probe but before the watcher or relay reports its exit, this 60-second lease still treats Ubuntu as running. A background read can then touch its UNC path and restart the stopped distro. The same gap applies when no stop-signal source is active. The lease does not satisfy the stated no-background-wake guarantee; use a state check that can detect stops without relying on a prior exit notification. (raw.githubusercontent.com)

Comment on lines +59 to +62
const result = await access()
const parsed = process.platform === 'win32' ? parseWslUncPath(path) : null
if (parsed) {
noteWslDistrosRunning([parsed.distro])

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 · Functional Correctness · Quick win

Refresh the stopped-state cache after a successful wake.

If an earlier read confirmed that Ubuntu was stopped, the cache contains an empty list. A successful wake: true access drains deferred tasks but leaves that list unchanged. Subsequent ordinary reads reuse it for up to 60 seconds and reject the now-running distro. Invalidate or refresh the cached state on successful wake before background reads resume. (raw.githubusercontent.com)

Comment on lines +85 to +86
// Opening a workspace is a user act: it may start its stopped WSL distro.
resetAndLoad({ wakeWslDistro: true })

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 · Functional Correctness · Heavy lift

Do not wake WSL during passive file-explorer initialization.

If the Files sidebar and a WSL workspace are restored on launch, this effect runs with a null lastResetWorktreePathRef. It calls resetAndLoad({ wakeWslDistro: true }) without a new user action. The wake flag bypasses the running-state check and can start a stopped distro. Pass the flag from an explicit workspace-open action instead; keep initial and restored reads gated. (raw.githubusercontent.com)

As per coding guidelines, “All UI work — … UX behavior — must follow docs/STYLEGUIDE.md.”

Source: Coding guidelines

updateLoadingDirPaths(() => EMPTY_FILE_EXPLORER_LOADING_DIRS)
setRootError(null)
if (worktreePath) {
void loadDir(worktreePath, -1, { force: true, wakeWslDistro: options?.wakeWslDistro })

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 · Functional Correctness · Heavy lift

Wait for the root wake before loading expanded directories.

If a stopped WSL workspace has expanded directories, resetAndLoad starts the wake-enabled root read but does not wait for it. The expanded-directory effect can start background reads before that wake succeeds. Those reads can record stopped-distro errors, and the effect then skips their cached errors even after the root loads. Sequence expanded reads after the root wake, or retry those stopped-distro errors when the root succeeds. (raw.githubusercontent.com)

As per coding guidelines, “All UI work — … UX behavior — must follow docs/STYLEGUIDE.md.”

Source: Coding guidelines

… distro

Any Windows touch of a \\wsl.localhost path boots a stopped distro. After a
terminate, the dying explorer watcher's overflow refresh ran realpath on the
project root 0.23 s later and booted the distro again. Background reads, stats
and watch installs now ask a fresh running list first (shared, with a 5 s lease
and a stop signal from the watcher exit and the hook relay link) and refuse when
the distro is stopped. Opening the workspace and Retry still start it. A stopped
watch waits for the distro and resyncs the explorer when it runs again.
… stop

- Opening a workspace, expanding a folder, opening a path (explorer, quick-open,
  links), the active editor tab's load and every Retry pass wakeWslDistro on
  readDir, readFile, stat and readFileChunk. Background reloads, restored-tab
  scans and watchers stay gated.
- A failed running-list read is 'unverifiable', not 'stopped': the gate re-reads
  once past the failure backoff (once per failure window) and otherwise refuses
  with 'WSL didn't answer', never touching the path.
- After any stop signal, a running read that started within EXIT_SETTLE_MS of it
  never counts, in isWslDistroRunning itself, so neither the watcher's own
  overflow refresh nor the hook relay's restart check can read a stale listing.
- A confirmed read that sees a distro stop records a stop signal, resetting the
  60 s lease.
@nwparker
nwparker force-pushed the nwparker/wsl-unc-no-boot branch from 7a6b516 to cf3a360 Compare October 27, 2026 03:37

@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: 2


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: 1e64ba6e-4bdf-4f72-8049-6795da495422
Commits

Reviewing files that changed from the base of the PR and between 7a6b516 and cf3a360.

Files selected for processing: 37
  • src/main/agent-hooks/wsl-hook-relay-stop-settle.test.ts
  • src/main/ipc/filesystem/filesystem-chunk-read-handler.ts
  • src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts
  • src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts
  • src/main/ipc/filesystem/filesystem-read-handlers.ts
  • src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts
  • src/main/ipc/filesystem/filesystem.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts
  • src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts
  • src/main/wsl-background-distro-gate.ts
  • src/main/wsl-running-distro-cache.ts
  • src/main/wsl.ts
  • src/main/wsl/wsl-unc-access-gate.test.ts
  • src/main/wsl/wsl-unc-access-gate.ts
  • src/preload/api/filesystem-api.ts
  • src/preload/api/fs-bridge.ts
  • src/renderer/src/components/editor/EditorConflictReviewSurface.live-record.test.tsx
  • src/renderer/src/components/editor/EditorConflictReviewSurface.tsx
  • src/renderer/src/components/editor/EditorContent.tsx
  • src/renderer/src/components/editor/EditorEditFileSurface.tsx
  • src/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.overview.test.tsx
  • src/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.ts
  • src/renderer/src/components/editor/useEditorPanelContentState.test.tsx
  • src/renderer/src/components/editor/useEditorPanelContentState.ts
  • src/renderer/src/components/editor/useEditorPanelExternalContentEvents.ts
  • src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-load-effects.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerHandlers.test.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerHandlers.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.refresh-projection-churn.test.tsx
  • src/renderer/src/lib/user-opened-local-path.test.ts
  • src/renderer/src/lib/user-opened-local-path.ts
  • src/renderer/src/runtime/runtime-file-client-types.ts
  • src/renderer/src/runtime/runtime-file-client.test.ts
  • src/renderer/src/runtime/runtime-file-metadata-client.ts
  • src/renderer/src/runtime/runtime-file-range-client.ts
  • src/renderer/src/runtime/runtime-file-read-client.ts

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

Comment on lines +63 to +70
const stoppedAt = mayHaveStoppedAt.get(distroKey(distro))
const anchor =
stoppedAt === undefined
? startedAfter
: Math.max(startedAfter ?? -Infinity, stoppedAt + WSL_STOP_SETTLE_MS)
const waitMs = (anchor ?? -Infinity) - performance.now()
if (waitMs > 0) {
await new Promise((resolve) => setTimeout(resolve, waitMs))

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 · Functional Correctness · Quick win

Recheck the stop timestamp after the settle wait.

If a watcher reports a possible stop and a relay reports another stop for the same distro during this wait, anchor still uses the first timestamp. The subsequent probe can start inside the second settle window, accept WSL’s still-running result, and allow a background UNC read to wake the stopping distro. Recalculate the deadline after waking, and repeat the wait if it moved. (raw.githubusercontent.com)

Comment on lines +160 to +161
fileToLoad.relativePath,
ACTIVE_TAB_LOAD

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 · Functional Correctness · Heavy lift

Keep restored active-tab loads behind the WSL gate.

If Orca restores a selected tab on startup, this effect can load it with ACTIVE_TAB_LOAD without a new user action. The wake option makes the filesystem guard access the path before checking whether its distro is running. Startup can therefore start a stopped distro. Supply the wake option from an explicit open, selection, or Retry action; leave restoration reads gated. (raw.githubusercontent.com)

@nwparker
nwparker merged commit fe82078 into main Oct 27, 2026
48 checks passed
audichuang added a commit to audichuang/orca that referenced this pull request Oct 28, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Oct 28, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 29, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Oct 29, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Oct 30, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Oct 30, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 2, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 2, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 3, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 3, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 4, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 4, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 5, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 5, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 5, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 8, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 10, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 12, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 12, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 13, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 13, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 14, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 14, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 16, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 16, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 18, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 19, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 19, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 20, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
audichuang added a commit to audichuang/orca that referenced this pull request Nov 21, 2026
…r assertions

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Upstream stablyai#34222 passes { wakeWslDistro: true } on the active tab's load and Retry.
audichuang added a commit to audichuang/orca that referenced this pull request Nov 21, 2026
…esh wake a stopped WSL distro

Upstream stablyai#34222 rejects git:status on a stopped WSL distro unless the request carries
wakeWslDistro, which useGitStatusPolling sets on the active workspace's first status. The folder
panel's repo refresh is a parallel path: its open and manual sweeps now wake, polls and change
nudges stay gated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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