You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(e2e): on the real WSL lane, background work never starts the stopped distro (E9 guard) - #35590
Most of today's "never start a stopped WSL distro" fixes protect ordinary users (WSL hosts flag off). Those code paths only exist on Windows. This adds a test to the Windows CI job that already has a real WSL distro:
it opens a project inside that distro, then stops the distro;
it keeps Orca busy with everyday background work for a while;
it checks nothing started the distro back up;
it opens a terminal there and checks that this does start it.
What Changed
New tests/e2e/wsl-bridge-no-background-boot.spec.ts. It runs only when ORCA_E2E_WSL_TERMINATE_DISTRO names a distro the run owns, because it terminates that distro. Otherwise it skips, so it never touches a developer's own distros.
Setup: the test creates a git repo inside the lane's Ubuntu and adds it as a project (\\wsl.localhost\Ubuntu\...) with a linked issue and PR. It opens that workspace, then switches to the local test workspace.
Watching for launches: the test records every child process the Orca main process starts. It does this by wrapping ChildProcess#spawn, which every spawn, exec and execFile call goes through; terminal processes don't, and don't need to.
The background window: the test runs wsl --terminate Ubuntu, waits until wsl --list --running no longer shows it, then for two rounds plus 15 s of real time does the following:
window focus, blur and reveal events;
switching between the local workspace and none;
eight Settings panes plus the WSL project's settings;
the Tasks page;
Codex and Claude account switches.
Assertions:
no wsl.exe launch ran anything in Ubuntu (-d Ubuntu, or --exec/-e with no distro named). Listings such as --list are allowed;
wsl --list --running, checked every second through the whole window, never showed Ubuntu. This also catches a \\wsl.localhost file touch or a Git call with a UNC working directory, which start the distro without any wsl.exe launch;
the distro is still stopped at the end.
Then the user act: the test activates the WSL workspace and opens a New Terminal, and expects Ubuntu to be running.
Lane wiring (windows-wsl-e2e.yml): a new step runs the guard 3 times with ORCA_E2E_WSL_TERMINATE_DISTRO: Ubuntu, the distro this job imports. A new participation check (verify-wsl-no-background-boot-participation.mjs) fails the job if the guard skipped instead of running.
PR routing sends changes to this spec or the participation check to the WSL lane. The lane contract test covers the new step.
Why
Each E9 fix guarded one caller. This guards the rule for the flag-off code paths: any future background caller that forgets the gate will start the distro, and the lane will fail. Watching the running list is the ground truth. Logging launches tells you which caller did it.
I used neither a PATH shim nor a wsl.exe path override. Most callers start the absolute System32 wsl.exe, so a shim ahead of it on PATH would miss them. File touches and Git need no wsl.exe at all. Only the running list sees every route.
Linked Issue
Internal E9 guard. No public issue.
Visual Proof
N/A. The change is test and CI only. The spec saves screenshots of the background window and of the terminal opened afterwards.
Testing
This PR's own "real WSL terminal" lane runs the new step. It is the only place the guard can execute, and it may show a background caller the gate still misses. Any such hit is a real E9 bug to fix, not test noise.
Locally (macOS) the spec skips as expected. The child-process recorder was verified locally with a throwaway spec: it saw the main process's gh and git spawns.
The lane contract and participation unit tests pass (22).
Load rule: pnpm tc, check:code-quality:changed, anti-slop, the ast-grep gates and the e2e typecheck ratchet pass. typecheck:e2e reports no errors under tests/.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Flag-off: this is the flag-off (bridge) path: the WSL hosts flag is unset. No product code changes.
User-risk: none (test and CI only). The lane job gets about 3 runs × ~2 min longer.
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.
Status
Ready for review. The lane result is pending.
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)
The changes add optional process spawn logging and startup handling for its environment setting. A Windows-only WSL E2E test checks whether background activity starts a terminated distro, then verifies that opening a terminal starts it. The Windows WSL workflow runs the test three times and verifies participation through its JSON report.
Priority: Normal
Merge Risk: Low · up to e2455
The Windows guard can miss a brief background restart caused by UNC filesystem access. Include target-distro UNC records in the assertion before relying on the test.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description explains the purpose, behavior, implementation, testing, CI wiring, risks, and checklist status. However, the Linked Issue section does not provide an actual issue reference, and the r…
Add the applicable issue link under Linked Issue. Add the AI Disclosure section and state the AI usage details, or state that it is not applicable if the contributor is an internal maintainer.
Docstring Coverage
Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly identifies the main change: an end-to-end guard that verifies background work does not restart a stopped WSL distro on the real WSL lane.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description explains the purpose, behavior, implementation, testing, CI wiring, risks, and checklist status. However, the Linked Issue section does not provide an actual issue reference, and the required AI Disclosure section is omitted.
Resolution
Add the applicable issue link under Linked Issue. Add the AI Disclosure section and state the AI usage details, or state that it is not applicable if the contributor is an internal maintainer.
Full details: Docstring Coverage
Explanation
Docstring coverage is 30.00% which is insufficient. 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 10 functions across 13 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.
Adds a real-WSL check that background work leaves a stopped distro stopped, while opening a terminal starts it.
Background activity leaves a stopped WSL distro off until someone opens a terminal.
E2e runs record process launches and WSL file touches with caller details.
The Windows WSL lane runs both background-boot guards three times.
Four earlier threads were manually resolved without explanatory replies. Their current code opens Settings, distinguishes listing errors, preserves the log’s parent directory, and confirms a stopped baseline before counting restarts.
The reason will be displayed to describe this comment to others. Learn more.
WSL account homes stay untested
The fresh profile has no managed accounts and defaults to the Windows host. Selecting accountId: null without a target uses that host path, and safeSyncToManagedHomes() has no accounts to visit. These switches therefore do not test the WSL home checks described here. Seed a WSL managed account before stopping the distro so the switches exercise those checks.
The reason will be displayed to describe this comment to others. Learn more.
Helper changes skip the guard
The route includes the new spec and participation checker, but omits tests/e2e/helpers/wsl-boot-diagnostics-log.ts and src/main/startup/e2e-spawn-log-env.ts. A later PR changing only either helper will skip the only lane that can run this guard, so changes that break it can go unchecked on Windows. Add both paths to the route and its contract test.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…pped distro (E9 guard)
The Windows real-WSL lane opens a project inside its own imported distro, terminates that distro,
and runs a window of background work elsewhere (focus/blur/reveal, workspace switches, a linked
issue/PR card, Settings panes, Tasks, account switches). Every child the main process starts is
logged; no wsl.exe may run anything in the distro (listings are fine), and `wsl --list --running`,
watched each second, must never show it, which also catches UNC touches. Opening a terminal in the
WSL workspace then starts it. A participation check fails the lane if the guard skipped.
…ckground window
openSettingsTarget alone only set the navigation target, so no pane mounted and none of its reads
(servers, accounts, agents, integrations, CLI status, the repo pane's orca.yaml check) ran. Open
Settings, wait for each pane's section to mount, then close it.
- process-host logs every spawn to ORCA_E2E_SPAWN_LOG when set, so the guard sees worker-thread
and inheriting-child spawns (e.g. the Codex rate-limit fetch), sync ones included.
- The spawn baseline is taken before `wsl --terminate`, and the running-list watcher starts right
after it, so work in the stopping window counts.
- A wsl.exe launch counts as starting the distro unless it names another or only lists/terminates.
- The watcher is async with a 5 s timeout and non-overlapping ticks; a failed read is retried and
fails the guard after three, never reads as "stopped". The recorder throws if it cannot hook,
and the spawn log must be non-empty. The doc names the watcher as the authoritative assertion.
…ed runs, tolerate torn lines
- The watcher forgives running reads only within 3 s of `--terminate` and before its first
not-running read, which the rounds now await; any running read after it fails the guard.
- Main drops ORCA_E2E_SPAWN_LOG outside e2e mode (no ORCA_E2E_USER_DATA_DIR) before anything
spawns, so no daemon, PTY or agent inherits it; the log holds full argv, tests only.
- readSpawnLog skips a line torn by a concurrent append.
…line for failures
The first lane run was cancelled at the 30-minute job limit while the guard step had run 25
minutes: past three 5-minute test timeouts, which only a blocked worker survives. Every wsl.exe
call (setup, terminate, cleanup) is now async with a timeout, so a hung one fails the test. The
guard logs a timestamped timeline (each running-list read, terminate, rounds) for diagnosis, and
the job limit goes to 50 minutes for the three added runs.
…terminate; 10 s grace
The lane run failed with "Ubuntu was still listed 3000 ms after --terminate" in all three runs.
The timeline showed why: focusing the WSL workspace in setup is a user act that opens a WSL
terminal, and its launch (codex trust probe, PTY, hook relay) landed about a second after the
terminate and restarted the distro. Setup now waits for that terminal's PTY and for wsl.exe
launches to go quiet for 3 s before terminating. The grace is two running-list reads (10 s).
The lane saw the distro boot about two seconds after the terminate with nothing naming the
launcher; each running-list tick now also prints the wsl.exe launches logged since the last one.
The E9 guard printed spawns at its poll time, up to a second late, and with
no caller. Each record now carries when it happened and the caller's stack,
and main's fs touches of \\wsl.localhost paths are logged too, so a boot
with no wsl.exe launch before it can still be attributed.
…mode
process-host now writes the spawn log, and captures caller stacks, only when
ORCA_E2E_USER_DATA_DIR is set as well, so a stray log variable in a CLI or
daemon environment does nothing. The main-process fs/spawn hook refuses to
install outside an e2e-mode app, and a source scan pins that no shipped code
imports or installs it.
Device runs saw a stopped distro restart with its bridge workspace focused
and nothing touched: the stop's own fallout re-ran renderer reads as user
acts. The new case keeps that workspace focused with a folder expanded in
the Explorer and Source Control shown, terminates, and idles. Shared guard
helpers move to tests/e2e/helpers/wsl-boot-guard.ts.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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: 2fd80a2a-7824-41df-9263-29317015dc67
Commits
Reviewing files that changed from the base of the PR and between 74fe074 and e24555d.
Files selected for processing: 4
src/main/index.ts
src/packages/process-host/src/spawn-observer.ts
tests/e2e/helpers/wsl-boot-diagnostics-log.ts
tests/e2e/wsl-bridge-no-background-boot.spec.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.
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 '101,150p' tests/e2e/wsl-bridge-no-background-boot.spec.ts
sed -n '60,95p' tests/e2e/helpers/wsl-boot-diagnostics-log.ts
sed -n '185,220p' tests/e2e/helpers/wsl-boot-guard.ts
set -eu
printf'%s\n''--- account-selection consumers ---'
rg -n -F --glob '*.ts' -e 'codexAccounts.select' -e 'claudeAccounts.select' -e 'select({ accountId' src tests | head -80
printf'%s\n''--- WSL home and UNC consumers ---'
rg -n -F --glob '*.ts' -e 'getWslHome' -e '\\wsl.localhost' -e '\\wsl$' src/main src/shared | head -160
printf'%s\n''--- process-host WSL scope comment ---'
sed -n '1,80p' src/packages/process-host/src/wsl-distro-allowlist.ts
printf'%s\n''--- diagnostic and assertion imports ---'
sed -n '1,45p' tests/e2e/wsl-bridge-no-background-boot.spec.ts
Repository: stablyai/orca
Length of output: 27778
Script executed:
set -eu
printf'%s\n''--- UNC access gate ---'
sed -n '1,240p' src/main/wsl/wsl-unc-access-gate.ts
printf'%s\n''--- account IPC handlers ---'
sed -n '1,100p' src/main/ipc/claude-accounts.ts
sed -n '1,100p' src/main/ipc/codex-accounts.ts
printf'%s\n''--- account selection definitions ---'
rg -n -F --glob '*.ts' -e 'selectAccount(accountId' -e 'selectAccountForTarget' -e 'getWslHome(' -e 'getWslHomeAsync(' src/main/claude-accounts src/main/codex-accounts src/main/rate-limits src/main | head -140
Repository: stablyai/orca
Length of output: 15479
Include target-distro UNC records in the assertion.
The WSL access gate documents that a UNC filesystem touch boots a stopped distro. The diagnostic wrapper records these touches as file: 'fs', but startsDistro ignores them. A short-lived boot can therefore evade both the one-second watcher and the final assertion.
Filter by the tested distro so accesses to other WSL distros remain valid diagnostics.
Suggested fix
import { buildWslExecArgs } from '../../../src/shared/wsl-login-shell-command'
+import { parseWslUncPath } from '../../../src/shared/wsl-paths'
import { readDiagnosticLog, UNC_TOUCH, type DiagnosticRecord } from './wsl-boot-diagnostics-log'
...
export function startsDistro(spawn: DiagnosticRecord, distro: string): boolean {
...
}
++export function touchesDistro(spawn: DiagnosticRecord, distro: string): boolean {+ if (spawn.file !== UNC_TOUCH) {+ return false+ }+ return parseWslUncPath(spawn.args[1] ?? '')?.distro.toLowerCase() === distro.toLowerCase()+}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Most of today's "never start a stopped WSL distro" fixes protect ordinary users (WSL hosts flag off). Those code paths only exist on Windows. This adds a test to the Windows CI job that already has a real WSL distro:
What Changed
tests/e2e/wsl-bridge-no-background-boot.spec.ts. It runs only whenORCA_E2E_WSL_TERMINATE_DISTROnames a distro the run owns, because it terminates that distro. Otherwise it skips, so it never touches a developer's own distros.Ubuntuand adds it as a project (\\wsl.localhost\Ubuntu\...) with a linked issue and PR. It opens that workspace, then switches to the local test workspace.ChildProcess#spawn, which every spawn, exec and execFile call goes through; terminal processes don't, and don't need to.wsl --terminate Ubuntu, waits untilwsl --list --runningno longer shows it, then for two rounds plus 15 s of real time does the following:wsl.exelaunch ran anything inUbuntu(-d Ubuntu, or--exec/-ewith no distro named). Listings such as--listare allowed;wsl --list --running, checked every second through the whole window, never showedUbuntu. This also catches a\\wsl.localhostfile touch or a Git call with a UNC working directory, which start the distro without anywsl.exelaunch;Ubuntuto be running.windows-wsl-e2e.yml): a new step runs the guard 3 times withORCA_E2E_WSL_TERMINATE_DISTRO: Ubuntu, the distro this job imports. A new participation check (verify-wsl-no-background-boot-participation.mjs) fails the job if the guard skipped instead of running.Why
Each E9 fix guarded one caller. This guards the rule for the flag-off code paths: any future background caller that forgets the gate will start the distro, and the lane will fail. Watching the running list is the ground truth. Logging launches tells you which caller did it.
I used neither a PATH shim nor a wsl.exe path override. Most callers start the absolute System32
wsl.exe, so a shim ahead of it on PATH would miss them. File touches and Git need nowsl.exeat all. Only the running list sees every route.Linked Issue
Internal E9 guard. No public issue.
Visual Proof
N/A. The change is test and CI only. The spec saves screenshots of the background window and of the terminal opened afterwards.
Testing
This PR's own "real WSL terminal" lane runs the new step. It is the only place the guard can execute, and it may show a background caller the gate still misses. Any such hit is a real E9 bug to fix, not test noise.
Locally (macOS) the spec skips as expected. The child-process recorder was verified locally with a throwaway spec: it saw the main process's
ghandgitspawns.The lane contract and participation unit tests pass (22).
Load rule:
pnpm tc,check:code-quality:changed, anti-slop, the ast-grep gates and the e2e typecheck ratchet pass.typecheck:e2ereports no errors undertests/.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Flag-off: this is the flag-off (bridge) path: the WSL hosts flag is unset. No product code changes.
User-risk: none (test and CI only). The lane job gets about 3 runs × ~2 min longer.
Agent skill upstream boundary
Status
Ready for review. The lane result is pending.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)