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
fix(wsl): session history reads never boot a stopped WSL distro (E9) - #35367
Flag-off: This is not WSL-host-specific. On main it affects any Windows desktop that has WSL distros: the bridge, which is the default, and WSL hosts alike. Bridge users on main boot a terminated distro today whenever these background reads run: AI Vault history listing, session titles, native-chat transcript tails, the opt-in session-search reconcile (every 20 s) and the OpenCode WSL reader. This PR fixes it for both. User-risk: Low.
History that lives in a stopped distro drops out of a background scan until the distro runs again. In its place is a "WSL distro 'X' is not running" issue.
Opening a chat still starts the distro and shows its history. So do paging its history and resuming a session from AI Vault.
Running distros cost at most one wsl --list --running per 5 s of transcript reads, shared per process.
ELI5
After you stop a WSL distro (wsl --terminate Ubuntu), Orca's history scanner could start it again a few seconds later, just by reading old chat logs stored inside it. Orca must never start a stopped distro unless you ask (rule E9). Now the scanner checks whether the distro is running right before each read, and leaves stopped distros alone.
What Changed
Before: the session scanner, which runs in its own process, and the transcript readers got a list of WSL homes once per scan. Every file touch on \\wsl.localhost\<distro>\… started the distro if it had stopped since, and so did every wsl.exe --exec (the OpenCode SQLite reader, its setup, HOME and realpath probes). Nothing re-checked. Windows verification on main (verify-18 a) saw the distro running again 9 s after wsl --terminate, with wsl.exe spawned from the session-scanner process.
After: every new transcript touch of a WSL path asks first whether its distro is running. That covers stat, lstat, readdir, open, access and readFile, in main and in the scanner process. So do the OpenCode reader spawn, its preparation, the HOME probe and the realpath probe. A stopped or unverifiable distro is refused with a WslTranscriptFsError ("WSL distro 'X' is not running…"), which existing callers already contain per root. Reads on an already open handle and closes are unchanged, because they can't boot anything.
blockedWslDistroForPath takes an optional leaseMs. The default is unchanged.
wsl-transcript-fs-access admits before scheduling a UNC operation.
The OpenCode reader beforeSpawn and prepareOpenCodeWslReaders use the admission instead of the unsettled filterPathsToRunningWslDistrosAsync.
AI Vault and transcript-path WSL homes use a new listRunningWslHomeDirsUnlessStopped, built on the existing wslHomeUnlessStopped. The guest realpath probe is admitted first.
User-opened chats still start their distro (new native-chat/native-chat-open-wake.ts). Before the read, nativeChat:readSession (open and page) and nativeChat:subscribe (a chat pane opening) start the transcript's distro if it is stopped, as a user act. The distro comes from the transcript's \\wsl.localhost path, or else from the WSL hook relay that reported the session. The start is one runAsWslUserAct touch of the distro root. After it, the normal gated reads find the distro running. aiVault:prepareSessionResume does the same for the session file's distro.
What counts as the user act: a chat pane becoming visible, which is when it subscribes and reads. That includes a pane restored as the visible tab at launch. This matches the focused-WSL-workspace wake policy in fix(wsl): background preflight and agent detection never boot a stopped WSL distro (E9) #35411 and is intended. Panes that are not visible never subscribe, so they never start a distro.
What stays background: the watch and resolve polls after the pane opens, AI Vault scans, titles, the first-prompt preview, and the search reconcile. None of these start a stopped distro.
The scanner process hears main's stop and wake notes.noteWslDistroMayHaveStopped, noteWslDistroWoken and main's own --list --running stop detection are forwarded to the scanner child over its existing IPC channel (a new wslDistroNote parent message, session-scanner-service-wsl-notes.ts). The child applies them to its own gate, so a terminate that main saw is honoured at once, not after the 5 s lease.
Why
Gate at the shared transcript filesystem layer rather than in each scanner. Every reader (scanner, search index, titles, native-chat tails) goes through it, so none can slip past.
A short lease plus forwarded stop notes, rather than piping main's running list into the utility process. The child still probes for itself, so a lost note is covered by the 5 s lease. The notes close the window for any stop main saw.
Start the distro once at open, rather than running the whole read inside a user act. The pane's first read happens in a watch drain after the subscribe call returns, where a user-act scope would already have ended. Starting the distro up front lets that read, and only that read, go through.
Refuse rather than silently skip. Callers already contain the refusal to one root, so other agents' history still lists.
Linked Issue
Internal WSL tracker, E9; Windows verification verify-18 (a).
Visual Proof
N/A: no UI change. A stopped distro's history shows the existing per-root "unavailable" issue.
Testing
New wsl-transcript-running-admission.test.ts (mocked wsl.exe and process.platform = win32):
a background read of a stopped distro is refused and never reaches the filesystem helper;
a running distro is read;
after a wsl --terminate that nothing reported, a running read older than the 5 s lease is re-checked and the read refused;
a user act on the distro reads through.
The first and third cases fail without the fix (checked by reverting wsl-transcript-fs-access.ts).
New native-chat-wsl-open-wake.test.ts (the distro's share backed by a temp dir; any touch starts it):
nativeChat:readSession on a stopped distro starts it and returns the history;
nativeChat:subscribe starts it and paints the snapshot;
the same read with no user act is refused and touches nothing.
The first two fail with the ipc/native-chat.ts change reverted.
New session-scanner-service-wsl-notes.test.ts: main's stop and wake notes reach a live scanner child. It fails with the client change reverted.
ai-vault-resume.test.ts: a WSL resume starts the session file's distro before the resume is prepared. It fails with the wake in ipc/ai-vault-resume.ts removed.
The OpenCode reader and preparation tests now go through the admission gate. The AI Vault and native-chat path-policy tests mock the gate, because they test root selection.
The ai-vault, native-chat, ai-vault-search, wsl, claude, codex, kimi, skills and ipc/filesystem suites pass (1,301 files). The exceptions also fail on an exact main baseline: session-search-indexer "stops everything on close", and the two real @parcel/watcher tests.
Load rule: pnpm tc, typecheck:ci, oxlint, the anti-slop lint, oxfmt, check:code-quality:changed, and the ast-grep gates.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
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
Windows only. Off Windows, blockedWslDistroForPath returns null, so nothing changes. SSH transcripts take their own path. The phone is unaffected.
Re-check needed: the Windows re-run of verify-18 (a), wsl --terminate, then 60 s with no boot.
Out of scope here: main-process wsl.exe --exec callers outside session history (codex rate-limit fetcher, account helpers and others). They were not in this report; I'll audit them if wanted.
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 running-state admission for WSL transcript operations and stop-aware WSL home lookup. Native chat reads and subscriptions resolve transcript paths and can wake the associated distro. AI Vault preparation and scanner startup use transcript admission. WSL stop and wake notes are forwarded to scanner child processes and handled by the service entry point. Tests cover admission, chat wake behavior, note forwarding, and updated WSL helper usage.
Priority: Normal
Merge Risk: Moderate · up to bf944
Some chat sessions may be unavailable until their WSL distro is started manually, while background reads can still restart a stopped distro. These issues should be addressed before merging.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description follows the repository template. It has ELI5, What Changed, Why, Testing, Notes, and Checklist sections, plus a Visual Proof section marked N/A with a reason. It explains the before an…
1. Link an actual issue in the 'Linked Issue' section, replacing the 'Internal WSL tracker, E9' note and the empty 'Fixes #' line. Outside contributors need a real issue link. 2. Fill in the 'AI Disclosure' section, or state that it does no…
Docstring Coverage
Docstring coverage is 65.22% 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 "fix(wsl): session history reads never boot a stopped WSL distro (E9)" matches the main change. The changeset adds a running-state admission gate to WSL transcript filesystem access and Open…
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: Title check
Explanation
The title "fix(wsl): session history reads never boot a stopped WSL distro (E9)" matches the main change. The changeset adds a running-state admission gate to WSL transcript filesystem access and OpenCode reader probes so background reads do not start stopped distros, and it keeps user-opened chats waking their distro. The title uses a conventional commit prefix and one sentence. It does not name the mechanism, and the 'E9' tag is an internal reference, but both are minor.
Full details: Description check
Explanation
The description follows the repository template. It has ELI5, What Changed, Why, Testing, Notes, and Checklist sections, plus a Visual Proof section marked N/A with a reason. It explains the before and after behavior, the mechanism, and the alternatives considered. Gaps: the 'Linked Issue' section has no real issue link (only 'Internal WSL tracker, E9' and 'Fixes #' remains unfilled), the 'AI Disclosure' section is missing, and the 'Testing' checklist box for manual testing is unchecked while the 'Windows re-run of verify-18 (a)' is still outstanding. The 'pnpm lint, typecheck, test, build' checklist item is unchecked. The description also has a large scope (17 prod files), which conflicts with the 'PR is small and focused' box being checked.
Resolution
Link an actual issue in the 'Linked Issue' section, replacing the 'Internal WSL tracker, E9' note and the empty 'Fixes #' line. Outside contributors need a real issue link. 2. Fill in the 'AI Disclosure' section, or state that it does not apply. 3. Confirm the manual test status. The Windows re-run of verify-18 (a) is still outstanding, so either complete it or leave the manual-test box unchecked with an explanation. 4. Complete or explain the unchecked 'pnpm lint, typecheck, test, and build' item. 5. Reconsider the 'This PR is small and focused' checkbox, or split the change, since it touches 17 production files and a new mechanism.
Full details: Docstring Coverage
Explanation
Docstring coverage is 65.22% 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 23 functions across 28 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.
The reason will be displayed to describe this comment to others. Learn more.
Queued reads restart stopped distros
admitWslTranscriptPath finishes before the request joins the filesystem queue. A scan can wait behind another scan for longer than the five-second lease. If the user stops the distro during that wait, the queued request still touches its files without another running check and can start it again.
Run admission inside the scheduled callback, immediately before dispatch. Apply the same change to openAdmittedWslTranscriptFile.
The reason will be displayed to describe this comment to others. Learn more.
Cancelled reads keep waiting
The new admission wait does not observe signal. If WSL discovery stalls, cancelling a read leaves its promise waiting through discovery and its retry instead of rejecting promptly. An already-aborted request also starts admission unnecessarily.
Check cancellation before admission and race the wait against signal, as the OpenCode callers already do. Cover both reusable operations and opens.
Transcript and session-history reads touched \\wsl.localhost shares, and ran
`wsl.exe --exec` probes, for any distro the root list named. Those touches are
the OpenCode reader, its setup, HOME and realpath probes, and the session
scanner and search index. Nothing re-checked that the distro still ran. A
`wsl --terminate` mid-scan, or a list taken while the distro was still
stopping, let background work boot it again.
Every UNC transcript touch (stat, readdir, open, access, readFile) and every
scanner `--exec` now asks a settled running read first. That read is no older
than 5 s, because the scanner process hears of no stop by itself. A user act on
the distro still passes.
…n's stop notes
A user-opened chat, a history page and an AI Vault resume start the
transcript's stopped WSL distro once, as a user act, so its history
shows; watch and scan reads stay background. Main forwards WSL stop and
wake notes to the session-scanner process so a terminate main saw is
honoured there at once.
⚠️Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Match the relay row to the opened transcript.
If a local transcript and a WSL relay row share a session ID, this lookup selects the relay even when its transcript path differs. Opening the local chat then starts an unrelated stopped distro. Match providerSession.transcriptPath to the resolved path before using a relay as fallback; do not select an arbitrary row when the path is absent and multiple relays match. (raw.githubusercontent.com)
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: 6733cc2d-1afe-4e4f-b4db-8ee4cb289ea2
Commits
Reviewing files that changed from the base of the PR and between 3f56b8f and a819908.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
set -eu
nl -ba src/main/native-chat/wsl-transcript-running-admission.ts
printf'%s\n''--- filesystem gate ---'
nl -ba src/main/native-chat/wsl-transcript-fs-access.ts | sed -n '1,240p'
Repository: stablyai/orca
Length of output: 10782
Script executed:
set -eu
nl -ba src/main/wsl/wsl-unc-access-gate.ts | sed -n '1,260p'
Repository: stablyai/orca
Length of output: 5070
Replay WSL gate state when the scanner child starts.
forwardWslDistroNotesToChild drops a note when child() is null. If a stop note arrives before processFactory() returns, a child that starts and probes within the 500 ms settle interval has no stop timestamp. Its running probe can therefore admit the distro, and the transcript reader can touch the UNC path.
Retain the latest stop or wake note for each distro and apply that state before the child processes its first scan. Add a regression test where the stop note precedes child startup.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Quick win
Recheck admission when a queued filesystem task starts.
If a task waits in runWslTranscriptFsTask for more than the five-second lease, its admission can expire before the filesystem operation starts. If the distro stops during that wait, the queued operation can touch its UNC path and start it. The same gap affects openAdmittedWslTranscriptFile at Line 137. Keep the admission before submission, but repeat it inside each scheduled operation before filesystem access. The scheduler permits waits longer than the lease and does not recheck running state when it starts an operation. (raw.githubusercontent.com)
… wake
Keeps node:child_process out of the new scanner-notes module (the
process-host import check) and adds a test that fails if an AI Vault
resume stops starting the session's WSL distro.
The reason will be displayed to describe this comment to others. Learn more.
Earlier calls satisfy this test
On Windows, the earlier test already calls wakeMock('Ubuntu'). Because clearMocks is false and this mock is never cleared, toHaveBeenCalledWith('Ubuntu') can pass even if this resume never wakes the distro, or wakes it too late. That leaves the new test unable to catch those regressions on Windows.
Clear wakeMock before this test so it checks this resume's call.
Suggested change
it('starts the session file distro before preparing a WSL resume',async()=>{
it('starts the session file distro before preparing a WSL resume',async()=>{
Wake the WSL distro before runtime transcript access.
Runtime-owned reads, paging, and subscriptions call the handlers in src/main/runtime/rpc/methods/native-chat.ts without waking a stopped WSL distro. WSL admission can therefore return Transcript unavailable.
Project the path with runtime.getAgentProviderSessionRows(), wake the distro derived from that same path, and preserve the existing abort and cleanup checks.
If a stop note arrives while this probe is in flight, the probe can return a pre-stop running result. The transcript admission can then touch the UNC path and restart the distro, despite receiving the note. Recheck the stop floor after the probe and retry if it changed. (raw.githubusercontent.com)
Minor · Carry the persisted WSL distro through native-chat resume reads. · native-chat-open-wake.ts:20-31
Carry the persisted WSL distro through native-chat resume reads.
A persisted WSL session can provide a Linux guest transcript path from record.location.wslDistro. When its live WSL relay row is absent, nativeChatTranscriptDistro returns null, so the user-visible open skips the wake. Resolution then excludes the stopped distro and can return Transcript unavailable.
Carry record.location.wslDistro through the native-chat open flow. Use it for both the wake operation and transcript resolution.
The preceding WSL-path test calls the shared wakeMock('Ubuntu'), and automatic mock clearing is disabled. This test can therefore pass without a wake call from the resume under test. Clear the mock before starting the test.
Suggested fix
it('starts the session file distro before preparing a WSL resume', async () => {
+ wakeMock.mockClear()
const platform = Object.getOwnPropertyDescriptor(process, 'platform')
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: 5acd8347-1334-4de9-81bd-6c712f14a6c8
Commits
Reviewing files that changed from the base of the PR and between a819908 and bf9447f.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
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.
Flag-off: This is not WSL-host-specific. On main it affects any Windows desktop that has WSL distros: the bridge, which is the default, and WSL hosts alike. Bridge users on main boot a terminated distro today whenever these background reads run: AI Vault history listing, session titles, native-chat transcript tails, the opt-in session-search reconcile (every 20 s) and the OpenCode WSL reader. This PR fixes it for both.
User-risk: Low.
wsl --list --runningper 5 s of transcript reads, shared per process.ELI5
After you stop a WSL distro (
wsl --terminate Ubuntu), Orca's history scanner could start it again a few seconds later, just by reading old chat logs stored inside it. Orca must never start a stopped distro unless you ask (rule E9). Now the scanner checks whether the distro is running right before each read, and leaves stopped distros alone.What Changed
\\wsl.localhost\<distro>\…started the distro if it had stopped since, and so did everywsl.exe --exec(the OpenCode SQLite reader, its setup, HOME andrealpathprobes). Nothing re-checked. Windows verification on main (verify-18 a) saw the distro running again 9 s afterwsl --terminate, withwsl.exespawned from the session-scanner process.realpathprobe. A stopped or unverifiable distro is refused with aWslTranscriptFsError("WSL distro 'X' is not running…"), which existing callers already contain per root. Reads on an already open handle and closes are unchanged, because they can't boot anything.Mechanism
native-chat/wsl-transcript-running-admission.ts(admitWslTranscriptPath). It usesblockedWslDistroForPathfrom fix(wsl): background repo probes, PR refresh and worktree scans never start a stopped distro (E9) #34632/fix(wsl): never boot a terminated distro off a list taken while it was still stopping #35143, which applies the settled running read: it never trusts a list taken while the distro was still stopping. Its lease is 5 s instead of 60 s, because the scanner process hears of no stop by itself; main's stop signals (relay and watcher exits) don't reach it.blockedWslDistroForPathtakes an optionalleaseMs. The default is unchanged.wsl-transcript-fs-accessadmits before scheduling a UNC operation.beforeSpawnandprepareOpenCodeWslReadersuse the admission instead of the unsettledfilterPathsToRunningWslDistrosAsync.listRunningWslHomeDirsUnlessStopped, built on the existingwslHomeUnlessStopped. The guestrealpathprobe is admitted first.native-chat/native-chat-open-wake.ts). Before the read,nativeChat:readSession(open and page) andnativeChat:subscribe(a chat pane opening) start the transcript's distro if it is stopped, as a user act. The distro comes from the transcript's\\wsl.localhostpath, or else from the WSL hook relay that reported the session. The start is onerunAsWslUserActtouch of the distro root. After it, the normal gated reads find the distro running.aiVault:prepareSessionResumedoes the same for the session file's distro.noteWslDistroMayHaveStopped,noteWslDistroWokenand main's own--list --runningstop detection are forwarded to the scanner child over its existing IPC channel (a newwslDistroNoteparent message,session-scanner-service-wsl-notes.ts). The child applies them to its own gate, so a terminate that main saw is honoured at once, not after the 5 s lease.Why
Linked Issue
Internal WSL tracker, E9; Windows verification verify-18 (a).
Visual Proof
N/A: no UI change. A stopped distro's history shows the existing per-root "unavailable" issue.
Testing
New
wsl-transcript-running-admission.test.ts(mockedwsl.exeandprocess.platform = win32):wsl --terminatethat nothing reported, a running read older than the 5 s lease is re-checked and the read refused;The first and third cases fail without the fix (checked by reverting
wsl-transcript-fs-access.ts).New
native-chat-wsl-open-wake.test.ts(the distro's share backed by a temp dir; any touch starts it):nativeChat:readSessionon a stopped distro starts it and returns the history;nativeChat:subscribestarts it and paints the snapshot;The first two fail with the
ipc/native-chat.tschange reverted.New
session-scanner-service-wsl-notes.test.ts: main's stop and wake notes reach a live scanner child. It fails with the client change reverted.ai-vault-resume.test.ts: a WSL resume starts the session file's distro before the resume is prepared. It fails with the wake inipc/ai-vault-resume.tsremoved.The OpenCode reader and preparation tests now go through the admission gate. The AI Vault and native-chat path-policy tests mock the gate, because they test root selection.
The ai-vault, native-chat, ai-vault-search, wsl, claude, codex, kimi, skills and ipc/filesystem suites pass (1,301 files). The exceptions also fail on an exact main baseline:
session-search-indexer"stops everything on close", and the two real@parcel/watchertests.Load rule:
pnpm tc,typecheck:ci, oxlint, the anti-slop lint, oxfmt,check:code-quality:changed, and the ast-grep gates.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
blockedWslDistroForPathreturns null, so nothing changes. SSH transcripts take their own path. The phone is unaffected.wsl --terminate, then 60 s with no boot.wsl.exe --execcallers outside session history (codex rate-limit fetcher, account helpers and others). They were not in this report; I'll audit them if wanted.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)