Repository navigation
Restore hidden remote terminal TUIs without typing regressions - #4759
Conversation
There was a problem hiding this comment.
Reviewed changes — threads snapshot source and sequence metadata through the PTY data pipeline and adds on-demand snapshot requests so hidden remote terminal TUIs restore correctly without typing regressions.
- Add
SnapshotRequestterminal stream opcode — enables renderer-to-runtime snapshot requests for remote terminals, with server-side handlersendRequestedSnapshotin the RPC methods. - Thread
source,seq, andrawLengthmetadata fromOrcaRuntimeServicethroughsubscribeToTerminalData,TerminalOutputBatcher,appendPendingMultiplexOutput, and into transport callbacks — enables sequence-aware replay that prevents live output from being lost or rendered out of order during hidden restore. - Add
serializeBuffertoPtyTransportandcanUseHiddenOutputSnapshot/serializeHiddenOutputSnapshotinpty-connection.ts— unifies local main buffer and remote transport snapshot paths under a single check function. - Implement snapshot request lifecycle in
remote-runtime-terminal-multiplexer.ts— 10s timeout withtimer.unref(), pending-request deduplication, proper cleanup on stream close/error/end, and routing between initial-subscribe and on-demand snapshot responses viasnapshotTarget. - Add E2E visual restore tests — covers hidden full-screen TUI restore and the snapshot/live-output race condition using deterministic
__terminalHiddenSnapshotOverrideinjection.
✅ No new issues found.
The snapshot request protocol is cleanly layered — SnapshotRequest opcode flows renderer → runtime, response frames flow back through the existing SnapshotStart/Chunk/End pipeline, with snapshotTarget routing to the correct consumer. Threading seq metadata through the output path is backward-compatible (optional meta param on all callbacks) and enables the sequence-aware replay that prevents live TUI output from being lost during a delayed snapshot. The timer.unref() on snapshot request timeouts avoids keeping the process alive during teardown, and the E2E override seam (__terminalHiddenSnapshotOverride) enables deterministic testing of the snapshot/live-output race.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
32833d1 to
4d34d02
Compare
There was a problem hiding this comment.
Reviewed changes — incremental diff since prior pullfrog review at c7e4228. This force-push threads a source field through all snapshot return types, refactors pendingOutput from string[] to TerminalOutputChunk to carry sequence metadata through the buffering layer, adds the server-side SnapshotRequest handler (sendRequestedSnapshot), and adds client-side snapshot request infrastructure in RemoteRuntimeTerminalMultiplexer.
- Thread
source('headless'/'renderer') through snapshot return types — added fromOrcaRuntimeService.serializeHeadlessTerminalBufferup through the preload API, IPC handler, and into the terminal multiplex RPC.renderer-sourced snapshots are tagged inserializeTerminalBufferFromAvailableState. - Refactor
pendingOutputtoTerminalOutputChunk[]— each chunk carries{ data, meta }with optionalseq/rawLength, enabling sequence-aware replay.trimPendingOutputToBudgetnow returns{ chars, overflowed }for accurate overflow tracking during snapshot requests. - Add
sendRequestedSnapshotserver-side handler — reacts toSnapshotRequestopcode frames, flushes the output batcher, serializes the terminal buffer, sends a truncated empty snapshot on pending output overflow, and replays buffered output through the output batcher after snapshot delivery. - Add
requestSnapshot/serializeBufferon the remote transport —RemoteRuntimeTerminalMultiplexerdispatchesSnapshotRequestframes with 10s timeout (timer.unref()), pending-request dedup,snapshotTargetrouting between initial-subscribe and on-demand snapshots, and cleanup on close/error/end. - Add
decodeSnapshotInfo— extracts cols, rows, seq, source, requestId, truncated from SnapshotStart payload with explicit type guards;sourcevalidates against known literals and defaults toundefinedfor anything else. - Add E2E hidden snapshot override seam —
__terminalHiddenSnapshotOverride(setPending/resolve/clear) enables deterministic testing of the snapshot/live-output race. - Add tests — 2 visual E2E tests (basic hidden TUI restore + snapshot/live-output race), server-side snapshot request unit test with overflow scenario, client-side
serializeBufferrequest/response unit test, background drain backpressure test.
✅ No new issues found.
The source threading is backward-compatible (optional field at every layer). The sendFrame optional seq parameter correctly preserves the runtime output sequence on Output frames while letting the internal cursor handle frame-level ordering for control frames. The sendRequestedSnapshot overflow guard (resetting pendingOutputOverflowed before serialization, checking after) correctly captures mid-flight output. decodeSnapshotInfo's literal guard on source and the SnapshotEnd routing (checking requestId match before falling back to initialSnapshotReceived) are clean.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Reviewed changes — incremental diff since 32833d1. The server-side sendRequestedSnapshot now retries serialization once when live output overflows during the first attempt, rather than immediately returning a truncated empty snapshot.
- Retry on overflow in
sendRequestedSnapshot— whenpendingOutputOverflowedis true after the firstserializeTerminalBuffer, the pending output buffer is cleared and a second serialization attempt is made. If the retry succeeds, the full snapshot is delivered to the client. If the retry also overflows, a truncated empty snapshot is sent as before.
✅ No new issues found.
The retry is bounded (one attempt), correctly clears the overflowed state before retrying, and re-checks both stream validity and overflow after the second serialization. The test was updated to verify the retry path — the mock supplies a { data: 'retry snapshot', cols: 120, rows: 40 } on the third serializeTerminalBuffer call and the test asserts the snapshot is untruncated with the retry data.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
4d34d02 to
15fb7c7
Compare
15fb7c7 to
c425701
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — force-push consolidation of the hidden remote terminal snapshot restore pipeline. All substantive features from prior reviews are present (snapshot request protocol, source/seq threading, overflow retry, E2E tests) with one notable behavioral change: a null-snapshot response now triggers an automatic retry instead of writing the unavailable-warning escape sequence.
- Replaced hidden-output-restore-unavailable warning with automatic retry — when
serializeHiddenOutputSnapshotreturns null,hiddenOutputRestoreRetryDeferredis set and the restore loop retries on the next foreground output event, rather than writing the[Orca skipped hidden terminal output...]warning banner. - Bumped
MIN_COMPATIBLE_RUNTIME_SERVER_VERSIONto 3 — the newSnapshotRequestopcode requires server support; old servers are rejected upfront.
ℹ️ Protocol version bump rollout sequencing
The MIN_COMPATIBLE_RUNTIME_SERVER_VERSION bump from 2 to 3 means new clients will reject runtime servers running protocol version 2. The SnapshotRequest opcode (11) justifies the bump, but servers must be deployed before or alongside clients to avoid a window where new clients reject still-running v2 servers.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Summary
This PR keeps hidden terminal output off the interactive renderer path while making the restore path robust for remote/runtime terminals.
The previous merged perf work made local hidden panes cheap by skipping renderer writes while the pane is hidden and restoring from the main terminal buffer when the pane becomes visible again. This follow-up closes the corresponding remote/runtime gap: hidden remote terminal streams now request a headless/runtime snapshot and then replay only live output that is newer than that snapshot. That avoids stale hidden output corrupting a full-screen TUI when a workspace is foregrounded again.
It also keeps the foreground scheduler on the proven low-latency path. A broader experiment that added per-write xterm parse callback backpressure measured worse for same-workspace pane storms, so this PR does not include that behavior. Background drains continue to be chunked by the shared scheduler without waiting on parse callbacks.
What Changed
Benchmarks
Command:
Results from this PR branch:
Comparison against earlier measured points:
Takeaway: this preserves the low median typing latency from the merged perf work, improves the cross-workspace worst case in the measured run, and avoids carrying the experimental scheduler backpressure path that made same-workspace storms noisier.
Verification
Passed: 5 files, 195 tests.
Passed.
SKIP_BUILD=1 npx playwright test tests/e2e/terminal-hidden-tui-visual-restore.spec.ts \ --config tests/playwright.config.ts \ --project electron-headless \ --reporter=list \ --output=/tmp/orca-pr-hidden-visual-outputPassed: 2 visual restore tests.
Passed with the benchmark numbers above.