Repository navigation
fix(terminal): a WSL bridge pane whose distro went away keeps its tab and cold-restores - #34095
Merged
Merged
Conversation
… and cold-restores wsl --terminate (or a shutdown or crash) exits every live bridge pane with an ordinary code, so Orca closed those tabs as if the shell had exited, and the next launch opened new sessions instead of restoring the old ones. A proven exit of a WSL bridge session now checks the shared, coalesced wsl --list --running (never boots, bounded); if the distro is confirmed gone it is host loss: code -1, history left unended, tab kept, exactly as after a daemon crash. A running distro or an unanswered check leaves the exit as is, so still closes the tab. Native and SSH sessions are untouched. Co-Authored-By: Claude <[email protected]>
nwparker
marked this pull request as ready for review
October 26, 2026 21:37
Contributor
|
Warning Review limit reachedYou'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 5 minutes. View limit details
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. Comment |
… exit; close a kept tab's history Review of the WSL bridge distro-loss check: - A probe already in flight from before the exit can predate the distro's boot, so it could call a user's own quick exit host loss. Only a probe that started after the exit answers; one fresh probe is chained after an older in-flight one and shared by the whole wave. - The outer bound drops to 3 s: every bridge exit waits on it. - Closing a kept tab later hit SessionNotFound before removeSession, leaking its history; an explicit close now treats that as already stopped. Co-Authored-By: Claude <[email protected]>
…se as already gone Swallowing SessionNotFound for any id could remove the history of a session a legacy daemon (sharing the history dir) still runs. The adapter now records the sessions it turned into host loss, clears them on respawn or close, and swallows SessionNotFound on an explicit close only for those. Co-Authored-By: Claude <[email protected]>
This was referenced Oct 26, 2026
Merged
nwparker
added a commit
that referenced
this pull request
Oct 27, 2026
…on across a relaunch #34095 turns a bridge pane's exit into host loss (code -1) when its distro is gone, so the window keeps the tab and the history stays unended. But main's exit handling still retired the pane's surface from the saved workspace session, as for any provider-observed exit, so the next launch found no session id for the tab and started a fresh shell instead of cold-restoring. The adapter now labels that exit hostLost, the pty listener forwards it, and the runtime keeps the surface, as it already does for a sleep or an SSH loss. Co-Authored-By: Claude <[email protected]>
nwparker
added a commit
that referenced
this pull request
Oct 27, 2026
…on across a relaunch (#34200) #34095 turns a bridge pane's exit into host loss (code -1) when its distro is gone, so the window keeps the tab and the history stays unended. But main's exit handling still retired the pane's surface from the saved workspace session, as for any provider-observed exit, so the next launch found no session id for the tab and started a fresh shell instead of cold-restoring. The adapter now labels that exit hostLost, the pty listener forwards it, and the runtime keeps the surface, as it already does for a sleep or an SSH loss. Co-authored-by: Claude <[email protected]>
7 of 9 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
When a WSL distro was shut down or crashed (
wsl --terminate,wsl --shutdown), Orca closed every WSL terminal tab that had a shell running in it, as if you had typedexit. The next time you opened Orca those terminals were gone or started fresh, even though their history was still saved. Now Orca treats this the way it already treats its own terminal service crashing: the tabs stay, and their history comes back when you open them.What Changed
wsl.exereports that as an ordinary exit code (1), the same code a shell's ownexit 1gives. The renderer treated it as a proven process exit:-1, the same as a daemon crash), and the session's history is left unended. The renderer marks the pane as lost-contact, keeps the tab, and cold-restores it when shown.exitin a shell still closes its tab.isWslBridgeDistroLostindaemon-wsl-bridge-exit.tscalls the existingreadConfirmedRunningWslDistros.wsl --list --runningprobe. It never boots a distro.wsl.exespawn, so a terminate that exits ten panes costs one probe.startedAfter, monotonic). A probe already in flight from before the exit might predate the pane's shell booting the distro, so it would wrongly say "gone". The exit instead waits for one fresh probe chained after it, and every exit in the same wave shares that probe.wsl.exetimeout, and the check adds a 3 s outer bound. Every bridge exit, a user's ownexitincluded, waits on the check before its tab reacts. On timeout the exit goes through unchanged.SessionNotFound. For a session this adapter itself turned into host loss, an explicit close (no keep-history) now treats that as already stopped and still removes the session's history. Before, the history directory and writer leaked until the worktree was deleted. Any other id'sSessionNotFoundis rethrown as before, and no history is removed. A legacy daemon after a protocol-bump update shares the history directory and may still run that id. The host-loss mark is cleared when the session is spawned again or closed.Why
@@4a01061dexited with code 1 atwsl --terminate, and its tab was closed. On the next launch it got a new session (@@4bd82ce1), while the old checkpoint, with 1,500 lines and cwddeep, sat unused on disk.Linked Issue
Internal: WSL via orcad, verify-15a 5e.
Visual Proof
N/A. Covered by unit tests; the next verify run repeats 5e. A terminated distro's open terminal stays open and restores, instead of disappearing.
Testing
wsl --terminate, then quit and relaunch, and the open pane should cold-restore its session.daemon-pty-adapter-wsl-distro-loss.test.ts:-1and history is left unended (tab kept);exitstill closes the tab;SessionNotFoundand removes nothing;The host-loss and many-panes cases fail without the fix, and I ran them that way.
daemon-wsl-bridge-exit.test.ts:resolveRunningWslDistros;exitan exit.pnpm tc:node, the daemon adapter suites andcheck:code-quality:changedpass. CI runs full lint and tests.EDR / process cost: each WSL bridge exit wave costs one
wsl.exe --list --runningspawn, through the existing shared probe. It's coalesced across panes, never boots a distro, and runs no interpreter. If a background probe was already running, one more spawn is chained after it. This is the same command Orca already runs for WSL host liveness and background-work gating.User risk: this affects every Windows user with WSL bridge terminals. After
wsl --shutdown,wsl --terminateor a distro crash, their open WSL terminals now stay open as disconnected and restore their history when shown, instead of closing. A user's ownexitnow waits up to 3 s (usually about 100 ms) for the check before the tab closes. Each WSL bridge exit costs one sharedwsl --list --running, coalesced across panes and never booting a distro. Typingexitin a running distro closes the tab as before.AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)