Repository navigation
fix(runtime): re-attach every terminal a daemon reconnect detached - #38704
Merged
Merged
Conversation
…ote views and input When the host's main process loses and re-makes its daemon connection, the daemon drops main's attachments and the adapter refuses input to every session until it is attached again. Only a pane mounted in the host's own window re-attaches by itself; a session with no pane there stays silent and refuses every keystroke from a paired desktop, a phone or `orca terminal send`, while `terminal list` still calls it connected and writable. A client remount or restart did not help: its new subscription never re-attached the session. Main now notes each session the provider's endpoint loss names, re-attaches it once a remote view shows it (at the loss or when a view subscribes later), and holds input for it until that attach lands instead of refusing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 56 seconds. 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. |
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
Sometimes Orca's main process loses its link to the terminal host and then reconnects. Terminals open in the host's own window recovered by themselves. Terminals you used only from a phone, another paired desktop or
orca terminal sendstayed cut off: no output, and every keystroke was refused. Orca now takes back every terminal the lost link dropped.What Changed
terminal liststill reported it as connected and writable.notePtyEndpointLoss). Main re-attaches each of them, four at a time like startup adoption, whether or not a view shows it. Background agents' records stay fresh too, not only the panes someone is watching.request_aborted).Why
On a Windows host, main remade its daemon connection twice in one evening while the daemon kept running. A paired desktop's panes for terminals not open in the host window then went silent and refused input.
Re-attaching only the sessions some view or input needs would leave background agents' sessions detached and their records stale. So main now takes back every session the loss names, at a bounded concurrency.
Because main re-attaches every lost session itself, a write never has to work out why it was refused, and no refusal classification is needed. Either the re-attach is in flight and input waits for it, or it has finished. A refusal after that is a real one, such as an exited session, and is reported as before.
Linked Issue
Fixes #38433
Supersedes #38457
Thanks to @registered2nd for reporting this, for finding that
MainDaemonAttachmentskept ids after the endpoint loss, and for the first version of this fix. Their commit is kept with their authorship.Visual Proof
N/A: this changes how main tracks daemon attachments. Nothing in the UI changes.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
terminal-subscriber-driven-daemon-attach.test.tscovers the following after an endpoint loss, against a model daemon that refuses writes to detached sessions:Each fails without its fix.
pty-write-ipc-validation.test.tschecks that the provider's loss reaches the runtime.pnpm tcpasses.Every test file that imports a changed module passes: 4 files, 63 tests.
Codex review is clean. An independent Opus review found no P0 or P1 issues.
Risk
Level: Medium
This touches the input path every remote view and
terminal senduse. The riskiest part is input to a session whose re-attach hangs: it now waits up to 10 s, where it used to be refused at once. Sends with no pending re-attach cost one extra map lookup.SSH sessions and sessions with a
connectionIdare excluded, and there is no protocol change, so mixed versions are unaffected. A plain revert backs this out.Follow-up, not in this PR: output printed between the loss and the re-attach does not reach main's copy of the screen (main already holds the screen, so the daemon snapshot is skipped). Remote reads can show a slightly stale screen until the next output.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Only main's local provider changes; SSH-relayed sessions are untouched. It applies on all platforms and on headless
orca servehosts.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)