Repository navigation
fix(ssh): switching back to a quiet remote terminal no longer refetches its snapshot - #29253
Conversation
…es its snapshot Co-Authored-By: Claude <noreply@anthropic.com>
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
… peers Co-Authored-By: Claude <noreply@anthropic.com>
…h-no-snapshot # Conflicts: # src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
…h-no-snapshot # Conflicts: # src/renderer/src/runtime/remote-runtime-terminal-binary-controller.ts
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:
81a14965-74d0-44e6-a483-6173e0618254
📒 Files selected for processing: 14
src/main/ipc/worktrees-canonical-ssh-listing.test.tssrc/main/worktree-lineage-host-peers.tssrc/renderer/src/components/new-workspace/ComposerParentWorktreePicker.tsxsrc/renderer/src/components/sidebar/DeleteWorktreeDialog.test.tsxsrc/renderer/src/components/sidebar/agent-send-picker-collapse.test.tsxsrc/renderer/src/components/sidebar/pinned-section-worktrees.test.tssrc/renderer/src/components/sidebar/pinned-section-worktrees.tssrc/renderer/src/components/sidebar/worktree-list/grouping/build-rows.tssrc/renderer/src/components/sidebar/worktree-list/grouping/cross-project-lineage.test.tssrc/renderer/src/components/sidebar/worktree-list/navigation/worktree-reveal-group-keys.tssrc/renderer/src/runtime/remote-runtime-terminal-binary-controller.tssrc/renderer/src/runtime/remote-runtime-terminal-multiplexer-implementation.tssrc/shared/project-section-grouping.tssrc/shared/resolved-worktree-lineage.test.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.
| return | ||
| } | ||
| if (typeof seq === 'number' && !resyncInFlight) { | ||
| stream.pausedOutputGapExpected = false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Trace the flag and recovery lifecycle. Confirm that recovery clears the flag,
# or that a notice cannot arrive while resync is in flight.
rg -n -C 5 '\bpausedOutputGapExpected\b|\bresyncInFlight\b|requestResyncSnapshot|recoverySnapshotSeq' \
src/renderer/src/runtime \
src/renderer/src/components/terminal-paneRepository: stablyai/orca
Length of output: 26662
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- binary controller ---'
nl -ba src/renderer/src/runtime/remote-runtime-terminal-binary-controller.ts | sed -n '40,145p'
printf '%s\n' '--- snapshot application ---'
nl -ba src/renderer/src/runtime/remote-runtime-terminal-binary-snapshots.ts | sed -n '120,195p'
printf '%s\n' '--- resync request lifecycle ---'
nl -ba src/renderer/src/runtime/remote-runtime-terminal-snapshot-controller.ts | sed -n '40,90p'
printf '%s\n' '--- paused-output notice producers ---'
rg -n -C 8 -F -- 'PausedOutputDropped' src/main src/shared src/renderer || test "$?" -eq 1Repository: stablyai/orca
Length of output: 41826
🏁 Script executed:
set -euo pipefail
nl -ba src/renderer/src/runtime/remote-runtime-terminal-binary-controller.ts | sed -n '45,138p'
nl -ba src/renderer/src/runtime/remote-runtime-terminal-binary-snapshots.ts | sed -n '145,170p'
rg -n -C 10 -F -- 'PausedOutputDropped' src/main src/shared src/renderer || test "$?" -eq 1Repository: stablyai/orca
Length of output: 41961
Clear pausedOutputGapExpected when recovery sets a new sequence baseline.
A supported drop notice can arrive while resync is in flight. The recovery path clears resyncInFlight but not pausedOutputGapExpected. The next sequenced frame can then skip gap detection and accept a real gap.
Suggested fix
stream.expectedSeq = typeof info?.seq === 'number' ? info.seq : undefined
+ stream.pausedOutputGapExpected = false
stream.commandProbeBaselineSeq = undefined…host (#29253) Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com>
…host (#29253) Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com>
…es it (#29342) * fix(terminal): a reveal after hidden output was dropped always restores it A restore that failed while its pane was hidden zeroed recovery and wrote its loss banner where nobody could see it, so the reveal skipped the restore and the gap stayed silent and permanent. Stay armed instead and spend one fresh snapshot on reveal. Main's drop latch now retires on the renderer's paint ack rather than on unhide, so a hidden pane that retires cannot spend the only marker on a handler that is already gone. Fixes #15504 Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> * fix(terminal): dedupe a disclosed hidden-output loss by drop episode The unhide marker carries main's emit-time output sequence, which visible output advances without any new drop, so a seq comparison re-bannered the same gap. Main now tags gate markers with a drop episode, and a drop after an unhide starts a new episode that the in-flight restore's ack cannot retire. Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> * fix(terminal): a restore ack retires only the drop episode it covered An older restore still in flight when a newer hide/drop/reveal cycle ran could ack and erase the newer episode's drop memory. The renderer now captures the latest reported episode before fetching and names it in the ack; main retires the latch only on a matching episode. Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> * test(terminal): pin hidden-restore recovery against a drop-reporting host (#29253) Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> --------- Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com>
ELI5
When you switch away from a remote (SSH) terminal, Orca asks the host to stop sending that terminal's output, which saves bandwidth. When you switched back, Orca always downloaded a fresh copy of the whole screen and its history, even if nothing had happened in that terminal. Over SSH that round trip is slow, so switching felt jittery. Now the host says whether it actually threw anything away while paused, and Orca only downloads the screen when something was really missed.
What Changed
Before (regression from #24863, shipped in 1.4.224): every switch back to a remote pane sent a snapshot request for 5000 rows (up to 2 MiB). It cost one round trip plus host serialization, even for a pane that printed nothing while hidden. Measured on orcad over SSH at 0 ms latency, an idle 20k-line pane cost 1 request and a ~35.6 KB reply (39–57 KB on the wire) per switch, plus a full clear-and-repaint. A live TUI (
top) cost 3 requests per switch: the restore, then an untagged "resync" request that cleared and repainted the whole pane 180–420 ms after the switch, then a third restore at ~700–960 ms. 1.4.223 (relay) did zero of this for an idle pane.After:
Measured per switch on the SSH repro rig. Client and orcad were both built from this branch, over Docker SSH, with a 50k-line idle pane and
top -d 0.5, 3 rounds × 4 hot switches:top, 150 msOn a real host (openclaw, ~27 ms RTT, client and orcad both built from this branch, compared with main 16eaceb):
top: 3 requests (1 untagged) → 1 tagged, 0 untagged, with no late full-screen repaint. Clear writes drop 4 → 1, snapshot bytes 32 KB → 10.7 KB, and the snapshot ends 21–61 ms after the switch.Out of scope here: a same-worktree tab switch after the pane was parked still pulls one snapshot (24–30 KB). That is the park-reveal path (#29269).
Mechanism:
PausedOutputDroppedframe (opcode 19).markHiddenOutputRestoreNeeded/ hidden-output-restore path as before, so a pane that is visible again when the frame arrives (a fast switch-back) still restores, and output that arrives during the restore still queues.Why
The host is the only side that knows whether bytes were lost, so the cheapest correct answer is for it to say so. Alternatives I considered:
armHiddenOutputRestoreForegroundDeadlinereturns early when the transport hasserializeBufferOutcome). The extra repaints came from the resync, not from that deadline.Compatibility (clients and hosts update independently):
outputPauseDropNotice: 1, but the old host ignores the unknown capability and does not echo it. The client keeps today's behaviour: restore on every reveal, with the resync on a gap.Linked: regression origin #24863 (old local prepaint path deleted in #27489).
Visual Proof
N/A. This is a network and repaint-timing change; see the measured table above.
Testing
src/renderer/src/components/terminal-pane/pty-connection-remote-pause-drop-notice.spec.ts(run viapty-connection-hidden-replay.test.ts) counts snapshot fetches per switch: 0 across three quiet switches, exactly 1 after a reported drop, and still 1 per reveal with an old host. The first two fail on main.src/renderer/src/runtime/remote-runtime-terminal-paused-output-drop.test.ts: an announced pause gap sends no resync request, a later real gap still resyncs, and an unnegotiated frame is ignored.src/main/runtime/rpc/terminal-multiplex-paused-output-drop.test.ts: the host sends the frame only when a pause really dropped output (including output still batched at pause time), once per pause, and never to a client that didn't negotiate it.pnpm tc,pnpm run check:code-quality:changed, and the main/runtime/rpc, renderer/runtime, terminal-pane and shared suites.remote-snapshot-alt-screen-host-chain.test.tsandremote-runtime-pty-latched-pane-retention.test.tstime out locally on main as well.I manually tested these changes locally (SSH repro rig with orcad over Docker SSH at 0 ms and 150 ms, including the old-host fallback)
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Cross-platform: no platform-specific code. SSH, orcad and Electron serve share this host code. Mobile is unaffected.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)