Skip to content

fix(wsl): never boot a terminated distro off a list taken while it was still stopping - #35143

Merged
nwparker merged 4 commits into
mainfrom
nwparker/wsl-bridge-exit-no-boot
Oct 28, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/wsl-bridge-exit-no-boot

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​253 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​241
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148 $\color{#cf222e}{\Huge{\mathbf{−}}}$​53 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​95

ELI5

When you stop a WSL distro (wsl --terminate) while Orca has terminals open in it, Orca could start the distro again a few seconds later on its own. Orca must never boot a distro in the background (rule E9). The cause is that WSL keeps listing a distro as "running" for a moment while it shuts down, and Orca trusted those mid-shutdown lists. Now it doesn't.

What Changed

  1. A bridge pane's exit marks its distro as possibly stopped. WslBridgeBootIdentity.noteExit, which runs synchronously on every bridge exit, now calls noteWslDistroMayHaveStopped. Every background "is it running?" check for that distro (boot id, UNC, file watcher, guest pane processes) then needs a list started after the stop has settled (WSL_STOP_SETTLE_MS). Its own stop-observation listener now only drops the cached boot id, as before.

  2. The host-loss verdict reads a settled list. checkWslBridgeDistro anchors its reads at settledWslRunningReadAnchor(distro, exitAt), newly exported from the gate (it is the gate's existing settle logic). A distro that is still stopping now reads as lost, not running.

  3. The boot-id reread is settled. rebootedSinceSpawn keeps using isWslDistroRunningForBackgroundWork. Because of (1), that check now needs a list started after the exit settled, so wsl.exe -d <distro> --exec cat …/boot_id can't run off a mid-stop list.

  4. Deferred work drains only on settled lists. onConfirmedRunningWslDistros now also passes the probe's start time. The gate drains deferred work (deferUntilWslDistroRunning: file-watcher retries, hook-relay restarts, history-tombstone cleanup, CLI registration repair) only for distros whose stop had settled before that probe started.

  5. The hook-relay restart re-reads a settled list. When deferred work drains WslRelayRecovery's restart, it now reads a settled running list (isDistroRunning(distro, now)) right before spawning the relay through wsl.exe. If the distro has stopped, it waits again.

  6. Setup-script import inspection is gated. It runs in the background (sidebar prompt card, runtime RPC repo.setupScriptImports). Both hooks:inspectSetupScriptImports and inspectRepoSetupScriptImports now return [] without opening anything when blockedWslDistroForPath(repo.path) reports the distro stopped or unverifiable.

  7. A clean exit closes at once. A bridge pane's code-0 exit is the user's own; awin shows a terminate exits -1. It now finishes immediately, with no settle wait or running-list read. It still marks the distro as possibly stopped. The user doesn't see that mark, and it covers an in-guest poweroff or wsl --shutdown that exits 0. Non-zero exits keep the full E9 handling. This combines with perf(terminal): a clean WSL bridge exit skips the boot-id read #35138's code-0 skip of the boot-id read.

  8. The guest-process fast path is settled. readWslGuestPaneProcesses({ running: true }), used by Sleep and the quit read, used to trust the cached running list whenever it was taken. It now trusts it only if that list was probed after any stop of the distro settled (wasWslDistroLastSeenRunningSettled, built on peekConfirmedRunningWslDistrosObservation).

  9. No stall after a skipped drain. When a mid-stop list skips a distro with deferred work, the gate schedules one unref'd wsl --list --running just past the settle, so the work doesn't wait for an unrelated probe.

Why

On the awin verify (build f59bd43), wsl --terminate <distro> with two bridge panes open was followed about 3.7 s later by two Orca-spawned wsl.exe processes and a boot of the distro. The hook relay's node then came up; orcad stayed down. Two holes allow this, plus two ungated background paths seen in the awin logs:

  • On build f59bd43 (the boot seen on awin): any successful running list drained every task deferred for the listed distros. A list probed mid-stop, for example by a bridge exit's own verdict check, still named the stopping distro and released deferred restarts. Some of these spawn wsl.exe straight away: the hook-relay restart launches the relay (the node that came up), and CLI repair runs the installer after an unsettled list. The new test reproduces this on f59bd43 itself.
  • awin logs (f59bd43): the bridge-exit verdicts were lost, so that path didn't fire on that build. About 2 s after each terminate, 29 ungated \\wsl.localhost\<distro>\…\{package.json, conductor.json, …} opens came from setup-script import inspection. A UNC open boots a stopped distro, so these are gated now (item 6). The hook relay's link died about 1.9 s after the terminate and scheduled a restart. A drained deferral used to restart it without checking again (item 5).
  • On main since fix(terminal): a WSL bridge pane keeps its session when its distro is booted again before the check #35050 (a newer regression): the bridge-exit verdict read the list without a settle, got running mid-stop, and then the boot-id check ran wsl.exe --exec cat boot_id, which boots the distro once it has stopped.

I chose to fix the shared gate rather than each caller, because every background caller already goes through isWslDistroRunningForBackgroundWork and the deferred-work drain. Settling once there covers the file watcher, the relay, cleanup and CLI repair together.

Flag-off: this changes behavior with ORCA_INTERNAL_WSL_HOSTS unset too. WSL bridge panes, the file watcher, the hook relay and the deferred-work gate all exist without the WSL host flag.
User-risk: low. A pane's own clean exit (code 0) still closes instantly. A non-zero bridge exit now takes about 0.5 s longer to resolve, because its verdict waits for the existing 500 ms settle before reading the list. Background work for that distro waits the same 500 ms and needs a fresh list. Deferred restarts that a mid-stop list used to release now wait for a settled list showing the distro running. The user's own acts are unchanged: opening a terminal still marks the distro woken and drains deferred work immediately. SSH and remote wire are unaffected; this is local WSL code only.

Linked Issue

Internal WSL-via-orcad tracker, E9 (never boot a stopped distro from a background path), from the awin verify on f59bd43.

Visual Proof

N/A: no UI.

Testing

src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts. It uses the real gate and running-list cache and the production boot-identity dependencies; only ../wsl and the boot-id exec are faked. Fake timers. WSL keeps listing the distro for 300 ms after the terminate.

  • Two panes exit together: both verdicts are lost, and the boot id is read only once, at spawn. Fails on main (two reads, verdicts running).
  • A list probed mid-stop drains no deferred work. Fails on main and on f59bd43; I ran the case against an f59bd43 checkout.
  • A settled list showing the distro running still drains deferred work. Liveness check.
  • wsl-hook-relay-recovery.test.ts: a drained restart whose settled re-read says stopped doesn't restart; it waits, then restarts once a later settled read says running. Fails on main, which restarts immediately.
  • Distro-loss suite: a code-0 exit closes with no running-list read, even when the list never answers, and still marks a possible stop. A non-zero exit marks it too.
  • daemon-wsl-bridge-exit.test.ts (9/9): the coalesced-probe case now waits for its probe, which starts after the settle anchor.
  • Guest-process fast path: the Sleep/quit fast path skips probing only on a settled list. In the no-boot suite, a list from before the stop, or one probed mid-stop, can't vouch for a live pane.
  • Settle probe: a skipped drain runs once the settle probe lists the distro.
  • worktree-hook-inspection-unc-drive.test.ts: a stopped distro gets [] with no readFile or stat call.

The existing bridge-exit, boot-identity, distro-loss and relaunch suites and the gate suite pass. Across src/main/daemon, src/main/wsl, src/main/agent-hooks, src/main/ipc/filesystem and src/main/cli, 6152 tests pass. Six fail locally, and they fail the same way without this change: real watcher, packaged CLI assets, quick-open and history-manager timing on macOS. pnpm tc, typecheck:ci, code-quality, anti-slop and ast-grep pass.

  • Automated tests added/updated

Status

Ready for two reviewers. Not gated here: hooks:check and hooks:readIssueCommand also read orca.yaml / .orca/issue-command over UNC. They feed launch preflight, where returning error for a stopped distro would skip setup or issue commands on a user launch, so they need a separate decision. On awin, the main log for a terminate should now read [pty] WSL bridge exit: lost, and no wsl.exe should be spawned until the user acts.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visuals with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered (Windows/WSL-only code paths; SSH unaffected)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (CI runs the rest)

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: ready for two reviewers. Head 846c5aa.

The regression test fails on main (the boot-id path and the drain path) and on f59bd43 (the drain path), and passes with this fix.

Checks run: pnpm tc, typecheck:ci, code-quality:changed, anti-slop, oxlint, ast-grep, plus the daemon, wsl, agent-hooks, ipc/filesystem and cli suites (6152 passed). Six tests fail, and the same ones fail without this change (macOS environment and timing).

Open question: none, but the awin main log line for the terminate would confirm which path booted the distro.

@nwparker
nwparker force-pushed the nwparker/wsl-bridge-exit-no-boot branch from 846c5aa to d15574f Compare October 28, 2026 14:12
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The WSL background gate now filters running-distro observations using each probe’s start time and a settled-running floor. Bridge boot-identity handling marks distros that may have stopped, and bridge exit checks use settled read anchors for their initial probe and retry. Deferred recovery rechecks distro liveness before restarting. Guest pane checks use settled observations, and hook-import inspection returns no candidates for blocked WSL paths.

Priority: Normal

Merge Risk: Moderate · up to 19096

This change makes WSL background checks wait for a settled running-distro list before booting or releasing work. Two concerns remain. An earlier exit check could still act on a list taken mid-shutdown if a later exit moves the settle floor. A bridge exit with code 0 now closes the pane and clears its history without host-loss classification, which would matter only if a distro stop can report code 0. Resolve or explicitly accept both before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description thoroughly explains the user impact, implementation, rationale, testing, scope, and known limitations. However, the required Linked Issue section contains no actual issue link or issue… Add the actual issue reference or link under Linked Issue, such as Fixes #1234 or the applicable internal tracker identifier. Complete any remaining required checklist items or explain why they do not apply.
Docstring Coverage Warning Docstring coverage is 75.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 Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and specifically summarizes the primary WSL shutdown regression fix.
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 thoroughly explains the user impact, implementation, rationale, testing, scope, and known limitations. However, the required Linked Issue section contains no actual issue link or issue reference.

Resolution

Add the actual issue reference or link under Linked Issue, such as Fixes #1234 or the applicable internal tracker identifier. Complete any remaining required checklist items or explain why they do not apply.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.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 12 functions across 15 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: 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: 6e0ee0c2-f40e-47e5-947a-267ed2cbba06
Commits

Reviewing files that changed from the base of the PR and between a6fdeda and 846c5aa.

Files selected for processing: 5
  • src/main/daemon/daemon-wsl-bridge-boot-identity.ts
  • src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts
  • src/main/daemon/daemon-wsl-bridge-exit.ts
  • src/main/wsl-background-distro-gate.ts
  • src/main/wsl-running-distro-cache.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.

stoppedAt === undefined ? -Infinity : stoppedAt + WSL_STOP_SETTLE_MS,
woken ?? -Infinity
)
const floor = settledRunningFloor(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

Recheck the stop floor after waiting.

If another pane exits while settledWslRunningReadAnchor waits, noteWslDistroMayHaveStopped advances the floor. This function still returns the earlier anchor. The first exit check can then probe during the second stop window, receive a list that still names the distro, and return 'running' for a stopping distro. Recalculate the floor after the wait, and continue waiting if it advanced. As per coding guidelines, “Never collapse ‘can't tell’ into ‘dead.’” The same stop-settle boundary must not treat a premature running list as a settled verdict.

Source: Coding guidelines

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: added the two gates from the awin evidence. Head d15574f, rebased on main.

  1. The hook-relay restart re-reads a settled running list before it spawns the relay. If the distro has stopped, it defers again.
  2. Setup-script import-candidate inspection, both the IPC handler and the runtime RPC, returns [] without any UNC open while the distro is stopped or unverifiable.

Each has a test. Both new tests fail on main.

Checks run: pnpm tc, typecheck:ci, code-quality:changed, anti-slop, oxlint, ast-grep, plus the hooks, agent-hooks, repo RPC and no-boot suites (1623 passed).

Open question: hooks:check and hooks:readIssueCommand still read over UNC. They feed launch preflight, so they're left for a separate decision.

@nwparker
nwparker force-pushed the nwparker/wsl-bridge-exit-no-boot branch from d15574f to 5dea14e Compare October 28, 2026 14:17
@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: reviewer follow-ups pushed. Head 5dea14e, rebased on main, which now includes #35138.

Changes:

  1. A code-0 bridge exit closes at once, with no stop mark, settle wait or classification.
  2. The setup-script UNC gate (unchanged since d15574f).
  3. Reviewer A's bypass: the readWslGuestPaneProcesses running:true fast path now needs a settled list.
  4. Optional: one unref'd settle probe when a mid-stop list skips deferred work.

Items 1, 3 and 4 have new tests; the setup-script gate's test came in d15574f.

Checks run: pnpm tc, typecheck:ci, code-quality:changed, anti-slop, oxlint, ast-grep, plus the daemon, wsl, gate, agent-hooks and hooks suites (5341 passed).

Open question: none. I'll handle gating the background callers of hooks:check / readIssueCommand separately, as agreed.

…s still stopping

WSL keeps listing a distro for a moment while it stops. A bridge pane's exit now marks its distro
as possibly stopped, its host-loss verdict and boot-id reread only count a running list started
after that settles, and deferred background work (file watcher and hook relay restarts, history
cleanup, CLI repair) is drained only by a settled list. Before, a bridge exit's own list could
read 'running' mid-stop and lead to a boot-id exec, and any confirmed list probed mid-stop
drained deferred restarts that spawn wsl.exe, booting the distro the user had just terminated.
…a settled running read

- A deferred hook-relay restart re-reads a settled running list right before spawning the relay
  (wsl.exe), and waits again if the distro stopped; a drained deferral is only a hint.
- Setup-script import-candidate inspection (sidebar prompt, runtime RPC) opens nothing under
  \\\\wsl.localhost while the distro is stopped or unverifiable: those UNC opens booted it about 2 s
  after each terminate on the awin verify.
…cess fast path

- A bridge pane's code-0 exit is the user's own (a terminate gives -1): it now closes at once,
  with no stop mark, settle wait or running-list read. Non-zero exits keep the E9 discipline.
- readWslGuestPaneProcesses' fast path for a live pane (Sleep, quit) trusts the cached running
  list only when it was probed after any stop of the distro settled.
- When a mid-stop list skipped deferred work, one unref'd probe just past the settle drains it,
  instead of waiting on an unrelated probe.
…it check test's probe timing

A code-0 bridge exit still closes at once, but now also marks its distro as possibly stopped, so
an in-guest poweroff or wsl --shutdown that exits 0 cannot leave background reads trusting an old
running list. The coalesced-probe test waits for the probe, which now starts after the settle
anchor, before answering it.
@nwparker
nwparker force-pushed the nwparker/wsl-bridge-exit-no-boot branch from 5dea14e to 19096e5 Compare October 28, 2026 14:33
@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: reviewer A's changes are pushed. Head 19096e5, rebased on main.

  1. The daemon-wsl-bridge-exit test now waits for its probe before answering it. 9 of 9 pass, with no hang and no EISDIR.
  2. A code-0 exit still closes instantly, and it now also calls noteWslDistroMayHaveStopped.

Every touched file was run on its own and its pass count equals its total. The daemon, wsl, agent-hooks and hooks suites pass in full (516 files, 5353 tests).

Checks run: pnpm tc, typecheck:ci, code-quality:changed, anti-slop, oxlint, ast-grep.

@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: 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: 01b83ad9-b1c9-49d6-ad4c-3339471e3685
Commits

Reviewing files that changed from the base of the PR and between 5dea14e and 19096e5.

Files selected for processing: 3
  • src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/daemon-wsl-bridge-exit.test.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.

if (wslDistro && isProvenProcessExit(event.payload.code)) {
// A terminate never exits 0 (awin: -1 per bridge pane; `exit`/`exit 0` gave 0): a clean exit is
// the user's own, so it closes at once, without the settle wait or classification.
if (wslDistro && event.payload.code !== 0 && isProvenProcessExit(event.payload.code)) {

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 · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

set -u
printf '%s\n' '--- changed hunk and nearby helpers ---'
nl -ba src/main/daemon/daemon-pty-adapter.ts | sed -n '180,285p'
printf '%s\n' '--- exit cause contract ---'
nl -ba src/shared/terminal-exit-cause.ts | sed -n '1,240p'
printf '%s\n' '--- bridge-exit references and tests ---'
rg -n -F --glob '*.{ts,tsx}' -e 'noteWslDistroMayHaveStopped' -e 'daemon-pty-adapter' -e 'bridge-exit' -e 'wsl --shutdown' -e '--terminate' src tests || test "$?" -eq 1
printf '%s\n' '--- WSL bridge event producers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'event.payload.code' -e 'payload: { code' -e 'cause:' src/main src/shared || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 42104


Script executed:

set -u
printf '%s\n' '--- adapter ---'
nl -ba src/main/daemon/daemon-pty-adapter.ts | sed -n '180,285p'
printf '%s\n' '--- exit contract ---'
nl -ba src/shared/terminal-exit-cause.ts | sed -n '1,240p'
printf '%s\n' '--- relevant references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'noteWslDistroMayHaveStopped' -e 'daemon-pty-adapter' -e 'bridge-exit' -e 'wsl --shutdown' -e '--terminate' src tests || test "$?" -eq 1
printf '%s\n' '--- bridge event producers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'event.payload.code' -e 'payload: { code' -e 'cause:' src/main src/shared || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 42016


Script executed:

nl -ba src/main/daemon/daemon-pty-adapter.ts | sed -n '210,255p'
rg -n -F -- 'noteWslDistroMayHaveStopped' src/main/daemon src/main

Repository: stablyai/orca

Length of output: 6134


Script executed:

set -u
printf '%s\n' '--- boot identity and gate ---'
nl -ba src/main/daemon/daemon-wsl-bridge-boot-identity.ts
nl -ba src/main/wsl-background-distro-gate.ts | sed -n '1,125p'
printf '%s\n' '--- focused bridge-exit tests ---'
nl -ba src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts | sed -n '1,180p'
printf '%s\n' '--- adapter WSL loss tests ---'
nl -ba src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts | sed -n '1,220p'
printf '%s\n' '--- shutdown/code-0 references with assertions ---'
rg -n -C 5 -F --glob '*.{ts,tsx}' -e 'code 0 from `wsl --shutdown`' -e 'wsl --shutdown' -e 'payload.code: 0' -e 'code: 0' src/main/daemon src/main/wsl src/packages/process-host

Repository: stablyai/orca

Length of output: 41946


Script executed:

nl -ba src/main/daemon/daemon-wsl-bridge-boot-identity.ts | sed -n '1,180p'
printf '%s\n' '--- bridge test event inputs and assertions ---'
rg -n -C 8 -F --glob 'src/main/daemon/*test.ts' -e 'code: 0' -e 'code: -1' -e 'wsl --shutdown' -e 'poweroff' -e 'hostLost' -e 'closeHistory' src/main/daemon
printf '%s\n' '--- exit event type and bridge producers ---'
rg -n -C 5 -F --glob '*.ts' -e 'DaemonPtyRouterExitEvent' -e 'DaemonPtyRouterEvent' -e 'exit: {' src/main src/shared | head -240

Repository: stablyai/orca

Length of output: 41890


Script executed:

set -u
nl -ba src/main/daemon/daemon-wsl-bridge-boot-identity.ts | sed -n '1,180p'
printf '%s\n' '--- exact daemon bridge tests ---'
rg -n -C 12 -F --glob 'src/main/daemon/*test.ts' -e 'code: 0' -e 'wsl --shutdown' -e 'poweroff' -e 'cause:' -e 'hostLost' src/main/daemon
printf '%s\n' '--- event declarations and adapter callers ---'
rg -n -C 8 -F --glob '*.ts' -e 'DaemonPtyRouterExitEvent' -e 'DaemonPtyRouterEvent' -e 'event: "exit"' src/main src/shared

Repository: stablyai/orca

Length of output: 42224


Do not treat every WSL bridge code 0 as a clean exit.

noteExit only delays later background reads. Code 0 still bypasses finishWslBridgeExit and calls finishExit, which clears the pane history. The bridge tests identify poweroff and wsl --shutdown as possible distro stops, and this branch does not inspect the optional cause. Route code 0 through settled classification.

Suggested fix
--- "a/src/main/daemon/daemon-pty-adapter.ts"
+++ "b/src/main/daemon/daemon-pty-adapter.ts"
@@ -229,7 +229,7 @@
         }
         // A terminate never exits 0 (awin: -1 per bridge pane; `exit`/`exit 0` gave 0): a clean exit is
         // the user's own, so it closes at once, without the settle wait or classification.
-        if (wslDistro && event.payload.code !== 0 && isProvenProcessExit(event.payload.code)) {
+        if (wslDistro && isProvenProcessExit(event.payload.code)) {
           const exitAt = performance.now()
           void this.finishWslBridgeExit(event.sessionId, event.payload, wslDistro, exitAt)
           return
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (wslDistro && event.payload.code !== 0 && isProvenProcessExit(event.payload.code)) {
if (wslDistro && isProvenProcessExit(event.payload.code)) {

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