Repository navigation
Conversation
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to A persisted terminal pane can reconnect to the same handle too quickly after an initial stream end, potentially extending the reconnect banner. The fix is localized; address it before merge if possible. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b7e56f68-0110-4afd-b9f5-3183c3a87755
📥 Commits
Reviewing files that changed from the base of the PR and between 9d305f3 and a6f3417883fa6404adf438ea4f38155ad6af08d3.
📒 Files selected for processing (10)
src/main/runtime/rpc/methods/terminal/terminal-multiplex-cleanup.tssrc/main/runtime/rpc/methods/terminal/terminal-multiplex-frame-delivery.tssrc/main/runtime/rpc/methods/terminal/terminal-multiplex-slot-frames.tssrc/main/runtime/rpc/methods/terminal/terminal-multiplex-stream-initialization.tssrc/main/runtime/rpc/methods/terminal/terminal-stream-types.tssrc/main/runtime/rpc/terminal-multiplex-source-range-output-pause.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport-pending-host-surface-attach.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stale-handle-recovery.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport-sticky-replacement-policy.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
a6f3417 to
23839f4
Compare
…arking it (stablyai#27178) A host that answered without a ready handle left the pane parked for an online/resume trigger that never fires on a healthy link, so the banner spun for the whole ~3 min deadline until Reconnect. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g it out (stablyai#27178) After an unverifiable stream end the pane waited the whole 15 s inventory window for a replacement handle even while the host kept reporting the same one ready, and a third end within 60 s parked it for the ~3 min deadline. Reuse the ready handle after a 1 s grace, and treat repeated ends as a slower reattach rather than a reason to stop retrying. Only an end within 10 s of reattach counts as a flap, and a pending send that may still prove the handle stale keeps the full wait. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd backoff (stablyai#27178) The bounded-wait fallback no longer returns an ended handle with an unanswered send, and persisted panes now wait out the flap backoff and in-flight sends before reattaching the same handle, like web-terminal panes do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
23839f4 to
beb7095
Compare
|
Rebased onto #27546 deleted the host-side source-range ledger, which is exactly what this PR's host commits patched (resyncing the ledger after output was dropped while a pane was hidden). On The client commits still apply: released hosts (1.4.224 and earlier, none of which include #27546) still end the stream this way, and other |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1f8b7648-bc05-4897-823a-2b3d5b36b2f4
📥 Commits
Reviewing files that changed from the base of the PR and between 23839f4d003b20b862bc332b06c093205482d708 and beb7095.
📒 Files selected for processing (1)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
ELI5
When you switch away from a worktree on a remote runtime and come back, its terminals sometimes show "Reconnecting to remote runtime" for seconds to minutes, even though the connection is fine. Clicking Reconnect fixes it instantly. This PR removes the three client-side things that made the terminal wait instead of just reattaching.
What Changed
Before: after a worktree switch the banner showed for 15 s, sometimes ~3 min, and then turned into "Automatic retries stopped" until you clicked Reconnect.
After: when the stream ends, the terminal reattaches in about 1–2 s, and repeated ends never park it.
The stream end itself came from the host: hiding a worktree pauses its remote panes' output, the host dropped that output without advancing its source-range ledger, and the first chunk after reveal failed the ledger's continuity check, so a healthy stream ended as
unverifiable. #27546 has since deleted the host-side ledger onmain, so hosts built frommainno longer end streams this way. Released hosts (1.4.224 and earlier) still do, and otherunverifiableends remain (a failed recovery snapshot, a failed PTY wait), so the client still has to recover quickly:remote-runtime-pty-transport.ts). After an unverifiable end, the pane waited the whole 15 s inventory window for a replacement handle, while the host kept answering that the same handle was ready. It now reuses that handle after a 1 s grace. The exception is a send that is still unanswered and could come backterminal_handle_stale; that case keeps the full wait.require-replacement, which parked the retry until the ~3 min deadline. A newreuse-after-backoffpolicy reattaches the still-ready handle with growing delays (1 s → 8 s max). Only an end within 10 s of reattach counts as a repeat. A genuinely stale handle (terminal_handle_stale) still usesrequire-replacement.online/ resume event that never fires on a healthy link.Why
mainand dropped those commits; only the client fixes remain. They are still needed because clients and hosts update independently, and released hosts keep ending streams this way.terminal.send, which could still come backterminal_handle_stale.Linked Issue
Fixes #27178
Visual Proof
Measured on macOS. The client connects to an Orca desktop host on another Mac, which reaches its terminals over SSH. Banner time comes from renderer logs:
while true; do date; sleep 2; done, 5+ switches)With a host that also had the (now dropped) host-side resync, there was no banner at all. A host built from
mainshould behave the same, since #27546 removed the check that ended the stream, but I have not re-measured that live.Opening a new remote terminal still flashes the banner for about 0.4 s. Released 1.4.224 does the same, so this PR doesn't cause it.
There is no video. The timings come from renderer logs: temporary diagnostics, not part of this PR, plus a CDP watcher that records when the banner appears and disappears. Times below are relative to the moment the client started recovering from the stream end.
Log excerpts
Before: the host keeps reporting the same handle ready, but the pane waits the whole 15 s window.
With this PR (host 1.4.224): the same handle is reused after the 1 s grace.
Testing
remote-runtime-pty-transport-sticky-replacement-policy.test.ts: covers the 1 s reuse, the growing delays for real flaps, no growth for ends long after reattach, the same backoff on persisted panes, and no fallback to a handle with an unanswered send when the bounded wait ends.remote-runtime-pty-transport-pending-host-surface-attach.test.ts: an unknown-liveness reattach retries instead of parking.remote-runtime-pty-transport-stale-handle-recovery.test.ts: repeated ends keep reattaching instead of disconnecting. This intentionally replaces the old "flaps until it disconnects" expectation.main: ranpnpm tc, the remote-runtime transport and terminal multiplex suites (57 files, 347 tests), andpnpm run check:code-quality:changed.AI Disclosure
Investigation, code, and tests were written with Claude Code (Claude Opus 5.5), and reviewed and tested by me.
Review
Agent skill upstream boundary
Notes
main.[terminal] replay guard released … (undeliverable write pipeline)errors after reattach. Both happen without this PR.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code