Repository navigation
fix(runtime): stop a remote-typed terminal hidden on the host from reconnecting on every send - #29252
Merged
Merged
Conversation
…ne remounts A pane hidden on the host remounts onto the same live PTY, and for a moment its graph leaf has no PTY. Main dropped the handle then and minted a new one, so the paired client's next send was refused as stale and the client remounted the pane, which made the host remount it again. Main now holds the live PTY on the leaf through that gap. Fixes #23759
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 7 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 |
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
If you typed from a paired client into a terminal that wasn't the tab showing on the host, every send flashed "Reconnecting", blanked the pane and repainted it. Typing into that terminal now just works, whether or not the host is showing it.
What Changed
Before: each send to a terminal hidden on the host was refused. The client then rebuilt the pane (reconnect banner, blank, repaint), and the host's
daemon.loglogged onesession-attachedfor that pane. Showing the pane on the host (orca terminal switch) made it stop.After: sends are accepted, and the pane stays put.
Mechanism. Terminal handles are minted per pane slot. When the host remounts a hidden pane (from cold parking or a paired client's reconnect), the pane's slot briefly reports no PTY until its transport reattaches the same session. Main read that gap as "this slot lost its PTY", dropped the handle, and minted a new one once the PTY came back. The client's open stream still carried the old handle, so its next send came back
terminal_handle_stale. The client treats that as "this pane can't take input" and rebuilds the pane. The rebuild asks the host to mount the pane again, which mints yet another handle, so the next send is refused too. A pane that is visible on the host never remounts, which is why it never did this.syncWindowGraph(src/main/runtime/session-graph/session-window-graph.ts) now keeps the slot's PTY through that gap when all three hold:Main already did this during a renderer reload. The handle stays the same and input keeps reaching the PTY in the meantime. A PTY that is gone, or that has moved to another slot, is still dropped as before.
Why
The execution host owns which PTY a handle names. A pane remounting onto the session it already had is not a new terminal, so main should not re-mint its identity. I considered two other fixes:
terminal.send, CLI handles and the session inventory would still see the handle churn, and the inventory change alone makes clients resubscribe.There is no wire change. The fix lands on the host, which is the side that has to be updated.
Linked Issue
Fixes #23759
Visual Proof
N/A. This changes how the host tracks terminal identity in main, with no UI change. The user-visible effect (no reconnect or repaint on send) needs two paired machines, so it is covered by the stream-level test below.
Testing
New
src/main/runtime/host-pane-remount-terminal-handle.test.ts:terminal.multiplex. The host pane then remounts (leaf PTY goes to null, then back), and the client sends input. The test asserts the handle is unchanged, the write reaches the PTY, and noWriteUnavailableframe is sent.main(terminal_handle_stale). All four pass with the fix.pnpm testpasses on the new test plus the related handle incarnation, cold-park remote subscriber, orphan and reattach suites.pnpm tc:nodeandpnpm tc:webpass.pnpm run check:code-quality:changedpasses.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Claude Opus 5.5; reviewed with Codex (gpt-6.1-sol, high).
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)