Skip to content

fix(terminal): a seen distro stop drops its cached boot id, and the relaunch test waits on the reap - #35133

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-bridge-boot-id-followup
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-bridge-boot-id-followup

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​43
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22

ELI5

This is a small follow-up to #35050, which keeps a WSL terminal's session when its distro is shut down and started again. It closes one more narrow race, and makes one test wait on a real event instead of assuming timing.

What Changed

  • (b) A seen stop drops the cached boot id.
    • The race: fix(terminal): a WSL bridge pane keeps its session when its distro is booted again before the check #35050 drops a distro's cached boot id when a bridge pane's exit reaches the adapter. A new pane opened after Orca's running-distro poll saw the distro stop, but before any exit arrived, could still take the old boot's id. Its later exit would then read as "rebooted", and its tab wouldn't close.
    • The fix: WslBridgeBootIdentity now also listens to onRunningWslDistrosStopped, the shared running-list cache's stop notice. It drops a stopped distro's cached id, so the next spawn reads it fresh.
    • Listener lifetime: the listener is only held while at least one bridge pane lives. It subscribes on the first spawn and unsubscribes when the last pane is forgotten, so idle adapters hold nothing.
  • (a) Test wait. The relaunch suite's "terminate while Orca is quit, daemon kept running" case now waits for the daemon to report the session reaped (the onPtySessionExit server hook, newly passable through the test harness). Before, it assumed reaping is synchronous.

Why

  • The poll's stop notice is the earliest signal Orca has that a distro went away. Using it costs nothing extra: no new spawn, and the existing coalesced poll.
  • The remaining gap is a spawn in the moment between the distro dying and the next poll or exit. There, the pane still falls back to today's behaviour, and the exit-time check still runs.
  • The test change removes a timing assumption reviewers flagged as a flake risk.

Flag-off: not behind the WSL hosts gate. This is WSL bridge-pane behaviour, the same with the gate on or off. Native, SSH and hosted-WSL panes are unaffected.

User risk: very low. It only drops a cache on a confirmed stop observation, which at worst causes one extra boot-id read.

Linked Issue

Follow-up to #35050 (reviewer notes a and b).

Visual Proof

N/A.

Testing

  • daemon-wsl-bridge-boot-identity.test.ts:
    • A seen stop drops the cache, so a pane spawned after it takes the new boot and its own exit is an exit. An older pane still reads "rebooted".
    • The stop listener is held only while panes live.
  • daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts waits on the reap.
  • pnpm tc:node, oxlint, pnpm run check:code-quality:changed and the ast-grep gate pass. src/main/daemon and src/main/wsl: 3,874 passed.

AI Disclosure

Written with Claude Code.

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.

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)

…elaunch test waits on the reap

Follow-up to #35050 review: a pane spawned after a running list saw its distro stop, but before
any bridge exit reached the adapter, could take the old boot's id. The identity now drops the
distro's cache on a stop observation, listening only while bridge panes live. The relaunch
suite waits on the daemon reaping the session rather than assuming it is synchronous.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

WslBridgeBootIdentity now tracks stopped-distro notifications and unsubscribes when no sessions remain. Tests cover boot identity changes, reboot detection, listener cleanup, and PTY session reaping during relaunch.

Priority: Normal

Merge Risk: Low · up to 9f7d1

Repeated adapter disconnects can retain WSL tracking state until Orca exits. Cleanup is advisable as a follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the primary change: a seen distro stop drops the cached boot ID. It also names the relaunch test change to wait on the reap. The changeset matches both parts. The title is long (99 cha…
Description check Passed The description fills every template section with specific content: ELI5, What Changed, Why, Linked Issue (follow-up to #35050), Visual Proof (N/A with reason), Testing, AI Disclosure, the upstream bo…
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.
Full details: Title check

Explanation

The title names the primary change: a seen distro stop drops the cached boot ID. It also names the relaunch test change to wait on the reap. The changeset matches both parts. The title is long (99 characters) and joins two changes with a comma, which makes it harder to scan, but it is specific and on-topic.

Full details: Description check

Explanation

The description fills every template section with specific content: ELI5, What Changed, Why, Linked Issue (follow-up to #35050), Visual Proof (N/A with reason), Testing, AI Disclosure, the upstream boundary checkbox, and the checklist. The Linked Issue section does not contain an issue link. It says 'Follow-up to #35050' and the template requires 'Fixes #' with an actual issue for outside contributors. The Testing section also leaves the full 'pnpm lint', 'pnpm typecheck', 'pnpm test', and 'pnpm build' checklist item unchecked. Neither gap makes the description largely incomplete.

Resolution

Optional: link a concrete issue in the Linked Issue section (the template asks for 'Fixes #<issue>' and says outside contributors must link an actual issue), and confirm or check off the full lint, typecheck, test, and build checklist item.

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

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.

@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: b1b3300c-6830-417c-b3ee-e88fad9d309d
Commits

Reviewing files that changed from the base of the PR and between 7f543df and 9f7d102.

Files selected for processing: 4
  • src/main/daemon/daemon-pty-adapter-test-harness.ts
  • src/main/daemon/daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts
  • src/main/daemon/daemon-wsl-bridge-boot-identity.test.ts
  • src/main/daemon/daemon-wsl-bridge-boot-identity.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment on lines +55 to +56
this.unsubscribeStops ??=
this.deps.onDistrosStopped?.((stopped) => stopped.forEach((name) => this.noteExit(name))) ??

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 · Stability & Availability · Quick win

Release the listener when the adapter closes.

dispose() and finishDisconnectOnly() in daemon-pty-event-subscriptions.ts disconnect the adapter without forgetting its tracked sessions. The global listener then retains this tracker indefinitely, even after those sessions exit. Repeated adapter lifecycles accumulate listeners and session state. Release the tracker’s subscription during both teardown paths. (raw.githubusercontent.com)

@nwparker
nwparker merged commit 5e1c26c into main Oct 28, 2026
45 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