Skip to content

fix(wsl): runtime RPC background reads never start a stopped WSL distro (E9) - #35430

Merged
nwparker merged 2 commits into
mainfrom
nwparker/e9-rpc-twins
Oct 28, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/e9-rpc-twins

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​146 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​146
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

ELI5

A phone, the web client or the orca CLI connected to this computer keeps asking for details in the background: commit history, submodules, ignored files, conflict state, upstream status, whether linked files exist. When the repo lives in a stopped WSL distro, each of those questions started the distro again. The desktop app already stopped doing that. Now the same background questions from other clients also leave a stopped distro alone.

What Changed

Before: the desktop IPC follower handlers refuse while the distro is stopped. Their runtime RPC twins did not, so a phone left on a workspace booted the distro again right after the user terminated it.

After: seven runtime RPC reads that no user is looking at now check the existing settled running gate (assertWslUncPathRunning, through assertRuntimeReadWslDistroRunning) before running Git:

  • git.history
  • git.submoduleStatus
  • git.checkIgnored
  • git.conflictOperation
  • git.mutationInFlight
  • git.upstreamStatus
  • files.pathsExist (link checks on render and retry timers)

The gate covers both a UNC worktree and a Windows-path repo whose Git runs in WSL.

Not gated, on purpose:

  • git.status: a client viewing the workspace is a user act, and its status is that client's implicit wake. Old clients keep working unchanged.
  • diffs and compares: user-opened views
  • files.read, readPreview, readChunk, readDocPreview and readDir: explicit taps or browsing
  • files.stat: the browser download path uses it to check whether a file name is taken, and a refusal there would read as "free" and risk overwriting a file
  • writes, fetch and pull
  • SSH and remote-runtime hosts, which never involve WSL

Why

Remote wire compatibility: the refusal is the existing WslDistroStoppedError, which mapRuntimeError already turns into runtime_error with the readable message "WSL distro 'X' is not running. Retry, or open a terminal in it, to start it." Every released client already handles that, so there's no new code, opcode or parameter.

The alternative was an optional wakeWslDistro RPC param, so new clients could flag user acts and everything else could be gated. It's left as a follow-up, only if this turns out not to be enough.

Linked Issue

N/A (internal WSL E9 audit, PR 4 of the plan: item G7).

Visual Proof

N/A. A running distro behaves as before. A stopped one returns the existing error text for these follower reads instead of booting; showing that needs a Windows WSL host.

Testing

  • New runtime-wsl-background-read-gate.test.ts:

    • the seven background reads refuse before touching the distro
    • the user acts never ask the gate: git.status, git.diff, git.branchCompare, files.read, files.readPreview, files.readDir and files.stat
    • a Windows-path repo whose Git runs in WSL is gated
    • SSH hosts never ask WSL
    • the refusal maps to { code: 'runtime_error', message }
  • 8 of its 17 cases fail with the gate stubbed out: the seven refusals and the Windows-path case. The other 9 (the user-act, SSH and wire-shape checks) pass by design.

  • orca-runtime-git, orca-runtime-files-mobile-explorer-reads, and the files and git RPC method suites pass.

  • pnpm tc, pnpm run typecheck:ci, pnpm run check:code-quality:changed, the anti-slop oxlint and ast-grep pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Flag-off: these paths don't check ORCA_INTERNAL_WSL_HOSTS, so the change ships to everyone pairing a phone, web or CLI client with a desktop that has WSL repos. A running distro is unchanged, apart from at most one shared wsl --list --running per minute.

User-risk: low. On a stopped distro, a remote client's history, submodule, upstream or link-existence reads show the stopped message until the client's own status read (which wakes the distro) or a terminal starts it.

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: unaffected. Only local execution hosts are gated.
  • Mobile: these reads use the same runtime_error path as today's other read failures.
  • Mobile file reads stay ungated.

Status

Ready for review. Not merged.

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)

@nwparker
nwparker force-pushed the nwparker/e9-rpc-twins branch from ceb2d4c to f998176 Compare October 28, 2026 22:46
@nwparker nwparker changed the title fix(wsl): runtime RPC git and file reads never start a stopped WSL distro (E9) fix(wsl): runtime RPC Git followers never start a stopped WSL distro (E9) Oct 28, 2026
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 4 minutes.

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: 3f647775-3a0b-423c-9904-8e3ca50913e4
Commits

Reviewing files that changed from the base of the PR and between f998176 and 3c9d13e.

Files selected for processing: 5
  • src/main/runtime/files/file-access.ts
  • src/main/runtime/runtime-git-status-commands.ts
  • src/main/runtime/runtime-git-sync-commands.ts
  • src/main/runtime/runtime-wsl-background-read-gate.test.ts
  • src/main/runtime/runtime-wsl-background-read-gate.ts
Walkthrough

Selected runtime Git reads now check that a local WSL distro is running before proceeding. The gate skips non-local execution hosts. Submodule status, ignored-path checks, history, conflict-operation detection, and mutation-in-flight queries use the gate. git.status still resolves its target directly. Tests cover stopped distros, SSH-host behavior, and runtime error mapping.

Priority: Normal

Merge Risk: Low · previous review f9981

The new check can block some Git reads for Windows linked worktrees while WSL is stopped, even though their Git runs on the host. It can also let a read through in the short window after a distro stops without notice. Both issues are limited in scope and recoverable, so the change is mergeable with follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Title check Passed The title clearly and concisely describes the main change: preventing runtime RPC background reads from starting a stopped WSL distro.
Description check Passed The description includes the required sections, explains the user impact and implementation, documents testing, and addresses compatibility and platform scope. The stated scope and test counts differ …
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Full details: Description check

Explanation

The description includes the required sections, explains the user impact and implementation, documents testing, and addresses compatibility and platform scope. The stated scope and test counts differ from the provided PR objectives and should be reconciled, but the description is otherwise complete.

Finishing Touches
📝 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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The change affects background reads for paired clients using WSL-backed workspaces.

Fix the early file reads and the remaining Windows-local conflict-check failure before merging.

Findings

  1. P1 Link checks still start WSL ▶
  2. P1 Local conflict checks fail ▶

Summary

Adds the existing stopped-WSL check to seven background runtime reads.

  • Background runtime reads leave stopped WSL distros alone.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Request["files.pathsExist"] --> Resolve["Resolve file target"]
  Resolve --> Folder["Folder or floating workspace"]
  Folder --> Stat["Read directory before gate"]
  Stat --> Wake["Stopped WSL distro can start"]
  Resolve --> Git["Stored Git worktree"]
  Git --> Gate["Check whether WSL is running"]
  Wake --> Gate
  Gate --> Refuse["Refuse stopped or unverifiable distro"]
  Gate --> Read["Read file paths"]
Loading

Reviews (3) · Last reviewed commit: "Merge branch 'main' into nwparker/e9-rpc..." · Reviewed by Greptile

worktreeSelector: string
): Promise<RuntimeGitTarget> {
const target = await host.resolveRuntimeGitTarget(worktreeSelector)
await assertRuntimeReadWslDistroRunning(target, localGitOptionsForTarget(target).wslDistro)

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 Local conflict checks fail

For a Windows-local linked worktree whose project has wslDistro set, this gate rejects git.conflictOperation when that distro is stopped. But detectConflictOperation only reads the local .git pointer and Windows-local metadata files in this case. It does not run Git in WSL.

Remote clients therefore lose a previously working conflict check until an unrelated distro starts. Account for the paths the operation actually touches before applying the distro override.

@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: 99e03188-8841-422f-8fca-9ce5bf95d48c
Commits

Reviewing files that changed from the base of the PR and between 3f56b8f and f998176.

Files selected for processing: 3
  • src/main/runtime/runtime-git-status-commands.ts
  • src/main/runtime/runtime-wsl-background-read-gate.test.ts
  • src/main/runtime/runtime-wsl-background-read-gate.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.

worktreeSelector: string
): Promise<RuntimeGitTarget> {
const target = await host.resolveRuntimeGitTarget(worktreeSelector)
await assertRuntimeReadWslDistroRunning(target, localGitOptionsForTarget(target).wslDistro)

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

Supported by static analysis

Script executed:

sed -n '1,120p' src/main/runtime/runtime-git-status-commands.ts
sed -n '1,140p' src/main/git/wsl-linked-worktree-git-routing.ts
rg -n 'localGitOptionsForTarget' src/main | head -20
rg -n 'assertWslUncPathRunning' src/main | head -30

Repository: stablyai/orca

Length of output: 14634


Script executed:

set -e
echo "=== runtime-wsl-background-read-gate.ts ==="
cat -n src/main/runtime/runtime-wsl-background-read-gate.ts
echo "=== runtime-git-command-target.ts (lines 1-110) ==="
sed -n '1,110p' src/main/runtime/runtime-git-command-target.ts | cat -n
echo "=== wsl-unc-access-gate.ts (lines 60-140) ==="
sed -n '60,140p' src/main/wsl/wsl-unc-access-gate.ts | cat -n
echo "=== references to wsl-linked-worktree routing in runtime/ and git/ ==="
rg -n -F -e 'isWslLinkedWorktreeGitRoutingCandidate' -e 'shouldUseWslLinkedWorktreeHostGit' -e 'wsl-linked-worktree-git-routing' -- src/main || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 12144


Script executed:

set -e
echo "=== wsl-unc-access-gate.ts (lines 1-60) ==="
sed -n '1,60p' src/main/wsl/wsl-unc-access-gate.ts | cat -n
echo "=== wsl-linked-worktree-git-routing.ts (lines 220-280) ==="
sed -n '220,280p' src/main/git/wsl-linked-worktree-git-routing.ts | cat -n

Repository: stablyai/orca

Length of output: 5295


Route Windows linked worktrees to host Git before the WSL distro gate.

resolveGatedGitTarget passes the configured wslDistro to the stopped-distro gate for every local target, without checking the Git route. For a Windows linked worktree, the cached route can send Git to the Windows host. The gate still throws WslDistroStoppedError when that distro is stopped, so the five gated reads fail even though Git does not run in WSL.

Resolve the route first and pass the distro to the gate only when Git runs in WSL. prepareWslLinkedWorktreeGitRouting fills the route cache asynchronously. If the route cannot be determined, it returns false, and the gate keeps its current WSL behavior.

🐛 Suggested fix
 import { assertRuntimeReadWslDistroRunning } from './runtime-wsl-background-read-gate'
+import { prepareWslLinkedWorktreeGitRouting } from '../git/wsl-linked-worktree-git-routing'
...
 async function resolveGatedGitTarget(
   host: RuntimeGitCommandHost,
   worktreeSelector: string
 ): Promise<RuntimeGitTarget> {
   const target = await host.resolveRuntimeGitTarget(worktreeSelector)
-  await assertRuntimeReadWslDistroRunning(target, localGitOptionsForTarget(target).wslDistro)
+  const { wslDistro } = localGitOptionsForTarget(target)
+  const usesHostGit = await prepareWslLinkedWorktreeGitRouting(target.worktree.path, wslDistro)
+  await assertRuntimeReadWslDistroRunning(target, usesHostGit ? undefined : wslDistro)
   return target
 }

if (target.executionHostId !== LOCAL_EXECUTION_HOST_ID) {
return
}
await assertWslUncPathRunning(target.worktree.path, wslDistro)

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

Supported by static analysis

Script executed:

#!/bin/bash
rg -n -C 4 'noteWslDistroMayHaveStopped\s*\(|onRunningWslDistrosStopped\s*\(' src/main

Repository: stablyai/orca

Length of output: 12365


Script executed:

set -o pipefail
printf '%s\n' '--- runtime gate ---'
nl -ba src/main/runtime/runtime-wsl-background-read-gate.ts
printf '%s\n' '--- UNC access gate symbols ---'
rg -n -F -e 'assertWslUncPathRunning' -e 'guardWslUncPathAccess' -e 'WSL_RUNNING' -e '60_000' src/main/wsl src/main | head -120
printf '%s\n' '--- UNC access gate ---'
nl -ba src/main/wsl/wsl-unc-access-gate.ts
printf '%s\n' '--- background distro gate ---'
nl -ba src/main/wsl-background-distro-gate.ts
printf '%s\n' '--- running distro cache ---'
nl -ba src/main/wsl-running-distro-cache.ts
printf '%s\n' '--- relevant diff ---'
git diff --unified=30 876193458cb9ec82d92637da4164bde96113cc3c f9981761ad76f0afe3d9fe6843652a0f71809501 -- src/main/runtime/runtime-wsl-background-read-gate.ts src/main/wsl/wsl-unc-access-gate.ts src/main/wsl-background-distro-gate.ts src/main/wsl-running-distro-cache.ts

Repository: stablyai/orca

Length of output: 37924


Script executed:

nl -ba src/main/wsl/wsl-unc-access-gate.ts
nl -ba src/main/wsl-background-distro-gate.ts
nl -ba src/main/wsl-running-distro-cache.ts
nl -ba src/main/runtime/runtime-wsl-background-read-gate.ts

Repository: stablyai/orca

Length of output: 24647


Script executed:

set -o pipefail
for f in src/main/runtime/runtime-wsl-background-read-gate.ts src/main/wsl/wsl-unc-access-gate.ts src/main/wsl-background-distro-gate.ts src/main/wsl-running-distro-cache.ts; do
  printf '%s\n' "--- $f ---"
  nl -ba "$f"
done
printf '%s\n' '--- changed-file diff ---'
git diff --unified=20 876193458cb9ec82d92637da4164bde96113cc3c f9981761ad76f0afe3d9fe6843652a0f71809501 -- src/main/runtime/runtime-wsl-background-read-gate.ts src/main/wsl/wsl-unc-access-gate.ts src/main/wsl-background-distro-gate.ts src/main/wsl-running-distro-cache.ts

Repository: stablyai/orca

Length of output: 25881


Require a fresh running-state probe after an unreported stop.

assertRuntimeReadWslDistroRunning reaches assertWslUncPathRunning, which accepts a confirmed running-list observation from the previous 60 seconds. Stop invalidation occurs only after a later probe detects that the distro is missing. If wsl --terminate occurs before a watcher, relay, or read signals the stop, the next runtime Git read can reuse the stale observation and reach an operation that can boot the stopped distro.

Require these runtime reads to perform a fresh confirmed running-state check instead of using the 60-second lease.

…ro (E9)

Paired phones, web clients and the CLI poll reads nobody is looking at:
history, submodule status, ignored paths, the conflict operation, the
in-flight mutation probe, upstream status and link-existence checks.
Their desktop IPC twins already refuse a stopped distro; these did not, so
a client left open booted the distro again after the user terminated it.
Each now asks the settled running gate first and refuses with
WslDistroStoppedError, which reaches every client version as the existing
runtime_error.

User acts stay ungated: git.status (a viewing client's implicit wake),
diffs and compares (opened views), file reads and directory listing
(taps and browsing), and stat (the download name check).
@nwparker
nwparker force-pushed the nwparker/e9-rpc-twins branch from f998176 to dfc28d9 Compare October 28, 2026 23:14
@nwparker nwparker changed the title fix(wsl): runtime RPC Git followers never start a stopped WSL distro (E9) fix(wsl): runtime RPC background reads never start a stopped WSL distro (E9) Oct 28, 2026
Comment on lines +130 to +132
// Link checks on render and retry timers: never start a stopped WSL distro (E9).
if (targets[0]) {
await assertRuntimeReadWslDistroRunning(targets[0])

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 Link checks still start WSL

files.pathsExist checks WSL too late for folder and floating workspaces. resolveFileExplorerPaths first calls resolveRuntimeFileTarget, which reads the folder or configured floating directory with stat before returning.

If that directory is a stopped distro's UNC path, the background link check starts the distro before this gate runs. Check WSL before those directory reads, and add a test using the real target resolver.

Knowledge Base Used: Stop WSL watchers from killing cold distro boots

@nwparker
nwparker merged commit 5598d2f into main Oct 28, 2026
43 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