Skip to content

fix(terminal): stop old output bleeding into Claude's screen when revisiting a remote tab - #24926

Merged
Jinwoo-H merged 12 commits into
mainfrom
remote-terminal-overlay
Oct 4, 2026
Merged

Jinwoo-H merged 12 commits into
mainfrom
remote-terminal-overlay

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​805 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​797
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​151 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86

ELI5

A terminal has two "pages": the normal page (your shell history) and a separate full-screen page that apps like Claude Code switch to. When you come back to a remote terminal tab, Orca redraws it from a snapshot sent by the remote machine. That snapshot says "write the normal page, then switch to the full-screen page and draw it". One redraw path erased the screen but never switched back to the normal page first, so the old shell output (e.g. a setup script's pnpm install log) got written onto Claude's page and showed through the gaps in Claude's text.

What Changed

Before: in a remote workspace, run claude in a tab that already has output (the Setup tab is the common case), switch to another workspace for a few minutes, then come back. For about a second, sometimes longer, old setup output is mixed into Claude's screen ("1.titem11.is3fine…"). It clears up only when a later correct redraw happens to arrive.

After: coming back shows Claude's screen cleanly from the first frame.

Mechanism: a remote host's snapshot is a serialized terminal image with its normal buffer folded in: the normal screen (plus history, for requested snapshots), then ?1049h, then the full-screen frame. It only reproduces correctly when painted starting from the normal buffer. Two client paths painted it while still on the alternate screen:

  • The replay drain (replay-data-drain.ts), used for snapshots the host pushes when a hidden tab resumes. It cleared with ESC[2J ESC[3J ESC[H, which doesn't leave the alternate screen.
  • Hidden-output restore (buildMainModelSnapshotReplayWrites), used for snapshots the client requests. Its alt-screen branch entered alt first, assuming the history arrives separately; remote hosts fold it into data instead.

In both cases the image's normal screen (old setup output) was painted into Claude's screen. The image's own ?1049h did nothing because the pane was already on alt, and Claude's frame, which skips cells it believes are blank, was drawn on top.

The changes:

  • Remote snapshots (pushed, requested, and pushed snapshots replayed after a cancelled shutdown) are marked carriesNormalBuffer. This is renderer-only metadata; nothing on the wire changes.
  • Pushed snapshots over a live full-screen app (pane and image both on the alternate screen): the drain paints only the image's alternate-screen part, after clearing the alternate screen in place. The normal buffer froze on both sides when the app started, so the image's normal part adds nothing. The pane's history is left exactly as main leaves it, on any grid, even when the host hands over a capture that includes history. The image is split at its last ?1049h, the same boundary the host uses (splitAtAlternateScreenEntry, now in src/shared and shared with the daemon).
  • Any other pushed snapshot (the pane is on the normal buffer, or the host's app has exited) starts from the normal buffer via the existing buildSnapshotReplayPrologue and paints the whole image. The pane's buffer is read only after queued output has parsed, so a still-queued ?1049h can't be missed.
  • Requested snapshots (hidden-output restore) already start from the normal buffer while an app is running, because the host only reports the alternate screen once the app has exited. The flag extends that start to the remaining case: an exited app that left the terminal on the alternate screen.
  • Raw byte replays (the SSH relay's ring buffer) keep the in-place clear. They aren't images, and switching to the normal buffer under a running full-screen app would strand its bytes there.

Why

  • Fix in the client painters: they're where an image meets a live pane, and only they know which buffer the pane is on. Both now share one preamble instead of hand-written clears.
  • Rejected: an unconditional ?1049l. It isn't a no-op when already on the normal buffer: xterm still restores the saved cursor and swaps kitty keyboard flags.
  • Rejected: changing what the host sends. That would only help clients that update, and mixed client/host versions are normal. This fix is client-side, so it also covers older hosts.
  • Not in this PR: the client applies several full snapshots on every return. Worth a follow-up, but not needed for correctness.

Linked Issue

N/A (maintainer).

Visual Proof

The same moment (~0.35 s after switching back to the tab), real Claude Code 2.1.288 in a remote Setup tab after a real pnpm install:

Before After
before after

Testing

  • Real end-to-end repro: an isolated dev Orca host plus a paired dev Orca client (separate profiles and HOME), a repo whose orca.yaml setup runs pnpm install, real claude in that Setup tab, 6 minutes in a local workspace on the normal parking timers, then back. A write spy on the client's xterm recorded every write on return.

    • Before: reproduced on 3 of 3 runs; frames from ~250 ms to ~1 s after return showed setup output.
    • After, on the final design (e79b0ba): Claude running at the same and a different window size, 0 of 45 frames over ~4 s showed setup output, and history matched line for line before leaving, after returning, and after another turn. Claude exited while hidden: the pane returned on the normal page matching the host (54/54 lines). Plain shell (colors, wrapping, 237 rows of history) and less matched the host exactly. Every unique setup line appeared exactly once. The alternate-screen path was reached by forcing a stream re-subscribe on a mounted pane; a pane rebuilt after being unloaded starts on the normal page and takes the normal path, as on main.
  • Host-to-pane test in remote-snapshot-alt-screen-host-chain.test.ts: the host's own terminal emulator, ownership tracking, serializer and recovery publisher feed the real wire encoding, client parser, remote transport and pane drain, for a running app and after the app exited. Only the process check, the socket and the transport-to-pane hand-off are stubbed.

  • Tests in remote-snapshot-alt-screen-replay.test.ts paint onto a real headless xterm that sits on a dirty alternate screen above setup history, and compare whole buffers using production snapshot shapes:

    • a pushed image over a live app, on a matching grid, on a mismatched grid, and when the push also carries history: the alternate screen matches the image, and the normal buffer stays exactly what the pane had;
    • an app that started while the tab was hidden (pane on the normal buffer): the whole image paints;
    • an app that exited while the tab was hidden: the pane returns on the normal buffer showing the host's screen;
    • a requested image through the hidden-restore painter, and a raw SSH-style replay that must stay on the alternate screen.

    Each rule is pinned by a mutation: painting the whole image, never splitting, splitting on a normal-buffer pane, skipping the wait for queued output, or dropping the flag on the cancelled-shutdown replay each fails a test.

  • Registered under the existing terminal-output.scrollback-restore reliability gate, whose oracle already names this case.

  • src/renderer/src/components/terminal-pane and src/renderer/src/runtime: 6,541 tests pass. pnpm tc:web, oxlint, check:code-quality:changed, and the reliability-gate manifest check are clean.

  • Two Opus reviews. The first found the hidden-restore path, the unflagged shutdown replay, and the history question. The second found that kept history duplicates or drops lines when grids differ. All addressed here.

  • Platforms: reproduced and verified with a macOS host and client. First reported against a Windows host, but the mechanism is host-independent: the bad clears are in the renderer, and Claude Code enters the alternate screen on Windows too (confirmed on the Windows box). I didn't run the paired repro against a Windows host because its network only allowed the production Orca port.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote / mixed versions: no wire or host change. A new client fixes the bug against old hosts; an old client is unchanged.
  • SSH: relay replays keep their existing behavior (pinned by a test).
  • Local terminals: local replays never set the image flag, so they're unchanged.
  • Mobile: not affected.
  • Performance: one extra short prologue write per pushed snapshot.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Remote snapshot replay now marks images that carry normal-buffer content. Recovery snapshots no longer clear scrollback, but they still clear the screen and move the cursor home. The replay drain uses a normal-buffer preamble for matching payloads and can preserve scrollback when the pane is on the alternate screen. New tests cover pushed snapshots, requested snapshots, and raw-byte replay.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 45565

An undimensioned remote snapshot can leave incompatible terminal history visible. The narrow case is mergeable with owner awareness, though the grid check should be corrected.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 45565

The change is limited to restoring remote terminal displays, with safeguards against applying output to a replaced session. No new privileged operation was identified. A compatibility edge remains: recovery can preserve history without confirming that the snapshot and pane used matching dimensions.

Retained concerns

  • Low · reliability · inferred: Recovery treats missing or invalid snapshot dimensions as a matching grid. When replaying a normal-buffer image over an alternate-screen pane, this preserves existing history without proving that it continues the snapshot correctly. Incompatible history may therefore survive recovery instead of being contained by authoritative replacement. Current publisher contracts require dimensions, and no cross-session disclosure or privileged outcome was established.
Security review details

Security Blast Radius

  • inferred — The supported effect of remote-controlled snapshot content is terminal rendering within the selected PTY session. The inspected metadata consumers do not establish expanded tenant, credential, service, or command-execution authority. This is a bounded conclusion about the changed path, not a complete assessment of terminal escape-sequence handling.

Trust Boundaries and Controls

  • observed — The transport accepts snapshot callbacks only for the current subscription, recovery epoch, and remote terminal. Pane replay additionally checks PTY identity, stream generation, payload generation, and disposal state before continuing asynchronous writes.

Resilience and Maintainability Implications

  • observed — The binary snapshot handler retains a byte limit, rejects unsuitable recovery snapshots without advancing the authoritative sequence, and retries recovery. The shared normal-buffer preamble also aborts a truncated control string before replay sequences are emitted.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 19 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the terminal bug and the remote-tab scenario. It is somewhat long, but it accurately summarizes the main change.
Description check ✅ Passed The description covers the required explanation, user-visible change, rationale, linked-issue exception, visual proof, testing, platform considerations, and checklist. The combined lint, typecheck, te…
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 19 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Alt-screen-safe clear for pushed remote snapshots — replay-data-drain.ts:135 now grounds with the shared buildSnapshotReplayPrologue({ targetAlternateScreen: false, paneOnAlternateScreen }) when the payload is a serializedImage, instead of clearing the active buffer in place. On a live alt screen this leaves alt, clears the normal buffer + scrollback, and lets the image's own ?1049h re-enter a cleared alt.
  • serializedImage provenance flag — added to PtyReplayDataMeta (pty-transport-types.ts:68), ProcessPtyOutputOptions (pty-output-processor.ts:43), and set only on the remote-runtime onSnapshot push (remote-runtime-pty-transport.ts:2023); threaded through replayDataCallback (deferred-cold-restore-and-snapshot.ts:163). Renderer-only, no wire change.
  • Serialized-image fixtures/tests updated — four exact-match expectations now include { serializedImage: true }; the fixture callback type narrows to PtyReplayDataMeta.
  • New regression test — pty-connection-alt-screen-pushed-snapshot.test.ts; registered in the terminal-output.scrollback-restore reliability gate.

I verified the load-bearing assumptions rather than trusting the description: the host composes pushed snapshots as scrollbackAnsi + rehydrateSequences + snapshotAnsi (so they start on the normal buffer) in serializeBudgetedMobileSnapshot / serializeBudgetedRequestedSnapshot, and headless-emulator.getSnapshot + splitTerminalSnapshotAnsi confirm the normal-history/?1049h/alt-frame shape. I also confirmed ?1049h re-entry clears the alt viewport in the pinned xterm (activateAltBuffer → _alt.fillViewportRows), so no stale alt cells survive. Finally, I reverted only the drain's production change and re-ran the new test: it reproduces the reported garble (SETUP-OUTPUT-5, NoTnoticePtoday) and passes with the fix restored, so the test is genuine coverage, not theatre.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

What changed since the prior pullfrog review (97d943b): the follow-up commits generalise the fix from the pushed-snapshot drain to every path that paints a folded remote image, and hand the clear to the drain.

  • Provenance flag renamed and widened — serializedImage is now carriesNormalBuffer across PtyReplayDataMeta, ProcessPtyOutputOptions, PtyBufferSnapshot, and RemoteRuntimeSnapshotImage. It is now set on the pushed onSnapshot path, the cancelled-shutdown replay handler, and the requested-snapshot resolution (remote-runtime-terminal-binary-snapshots.ts), so remote images are recognised on every painter.
  • Shared normal-buffer preamble — new buildNormalBufferSnapshotPreamble({ paneOnAlternateScreen, keepScrollback? }) centralises ABORT + buildSnapshotReplayPrologue({ targetAlternateScreen: false }); the drain and buildMainModelSnapshotReplayWrites both use it instead of hand-written clears.
  • Drain owns the clear, drains before reading the buffer — the drain now waits for queued output to parse before deciding isPaneOnAlternateScreen(), and keeps the TUI's covered history via keepScrollback: paneOnAlternateScreen (the ESC[3J drop).
  • Hidden-restore/requested path grounded on normal — buildMainModelSnapshotReplayWrites takes the normal-buffer branch for carriesNormalBuffer images, not just !alternateScreen.
  • Recovery snapshot's baked-in clear removed — reduced to the latch release only; the drain's preamble now performs the clear and buffer/history choice.
  • Regression test expanded — remote-snapshot-alt-screen-replay.test.ts covers the pushed drain, the requested hidden-restore builder, and a raw SSH replay that must stay on alt; registered under the terminal-output.scrollback-restore gate.

I verified the delta rather than trusting the description. The pushed-image test is genuine coverage: reverting the drain's buildNormalBufferSnapshotPreamble to the old in-place clear makes it fail with the reported garble (SETUP-OUTPUT-9, Nocnotice today). I traced carriesNormalBuffer into the request path — serializeBufferOutcome returns the resolved image untouched (asserted in remote-runtime-snapshot-outcome.test.ts) and applyMainBufferSnapshot passes it straight to the builder — and confirmed desktop pushes/initial/recovery snapshots serialize at scrollbackRows: 0, which is what makes keepScrollback correct without duplicating history. Nine affected suites (119 tests) pass.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — this looks correct. One bit of stale documentation inline; a PR-description nit below.

Reviewed changes

The delta since the prior pullfrog review (6ed2396) is the recovery snapshot's own clear, split out of the earlier "drain owns the clear" change:

  • Recovery prefix restored to clear the screen — remote-runtime-terminal-binary-snapshots.ts again emits ${RELEASE_SYNCHRONIZED_OUTPUT}\x1b[2J\x1b[H${data} instead of the latch release alone. The \x1b[3J stays dropped. This matters because consumers that paint a recovery image straight into xterm without a replay drain (subscribeToRuntimeTerminalData falls back to watcher(data) when no onSnapshot option is set) have no drain prologue to clear the stale screen.
  • Recovery-prefix expectations updated — exact-match assertions in remote-runtime-terminal-frame-drop-resync.test.ts, remote-runtime-pty-snapshot-source-grid.test.ts, and runtime-terminal-stream.test.ts now pin \x1b[?2026l\x1b[2J\x1b[H.

I verified the delta rather than the description: the recovery image on the desktop path also reaches the drain's normal-buffer preamble (the onSnapshot handler sets carriesNormalBuffer: true unconditionally at remote-runtime-pty-transport.ts:2025), so the restored \x1b[2J\x1b[H is a redundant second screen clear there — harmless — while being the only clear for the drain-less consumers. All 4 affected suites (29 tests) pass on head.

ℹ️ Nitpicks

  • The PR description's "Mechanism" bullet still says the recovery snapshot's prefix is "reduced to the latch release" and "the drain now owns the clear". At head 3e088e9 the recovery prefix is ${RELEASE}\x1b[2J\x1b[H and only \x1b[3J was removed; the drain-less consumers are why. Worth a one-line update so the description matches the final code.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues from the incremental change — the grid-match fix is sound; one stale comment below.

Reviewed changes

Reviewed the single commit since the prior pullfrog review (3e088e9): keeping the TUI-covered history only when the pane and the host image share a grid.

  • Gated kept history on a grid match — replay-data-drain.ts now computes atSourceGrid from the pane's pre-resize geometry and passes keepScrollback: paneOnAlternateScreen && atSourceGrid, so a pushed screen-only image preserves the history it continues exactly, and otherwise clears it rather than reflowing into duplicated or dropped lines.
  • Hoisted sourceGrid above the clear — resolved once before clearBeforeReplay so the match decision reads the pane's pre-resize grid while the later resize still owns the repaint geometry.
  • Rebuilt the alt-screen replay test around real resize events — the drain harness records terminal.resize calls and the expected buffers render at hostRows before resizing down; a new mismatched-grid case pins exact normal-buffer equality.
  • Collapsed abortGapBeforeFirstWrite into buildNormalBufferSnapshotPreamble and inline call sites in terminal-snapshot-replay-paint.ts (behavior-preserving).
  • Widened RemoteRuntimeMultiplexedTerminal.serializeBuffer to return RemoteRuntimeSnapshotImage | null instead of an inline shape.

Verified rather than trusting the description: reverting only keepScrollback to paneOnAlternateScreen makes the mismatched-grid test fail with duplicated history (SETUP-OUTPUT-0..4), so it is genuine coverage. All 10 affected suites (93 tests) pass at head and pnpm tc:web is clean.

ℹ️ Nitpicks

  • replay-data-drain.ts:122 still says "the clear is grid-independent", but this commit makes the clear's keepScrollback depend on atSourceGrid, so the clear is now grid-dependent. Rewording to say the clear must precede the resize because it reads the pane's pre-resize grid would keep the rationale accurate.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc49963a-493a-4b1e-b9ef-d8b119228db2
📥 Commits

Reviewing files that changed from the base of the PR and between d34251a and 4556566.

📒 Files selected for processing (6)
  • config/reliability-gates.jsonc
  • src/renderer/src/components/terminal-pane/pty-connection/replay-data-drain.ts
  • src/renderer/src/components/terminal-pane/remote-snapshot-alt-screen-replay.test.ts
  • src/renderer/src/components/terminal-pane/terminal-snapshot-replay-paint.ts
  • src/renderer/src/runtime/remote-runtime-terminal-binary-snapshots.ts
  • src/renderer/src/runtime/remote-runtime-terminal-multiplexer-types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/runtime/remote-runtime-terminal-binary-snapshots.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the commit since the prior pullfrog review (4556566): keeping a live TUI's covered history only while the host is still on the alternate screen.

  • Gated kept history on the host still running on alt — replay-data-drain.ts now requires alternateScreen === true in addition to paneOnAlternateScreen && paneAtSourceGrid() before keepScrollback. Once the host's TUI exits, its shell has written past the pane's frozen history, so the image replaces it rather than leaving a gap above the host's screen.
  • Generalised the snapshot preamble helper — buildNormalBufferSnapshotPreamble became buildSnapshotReplayPreamble, taking the full buildSnapshotReplayPrologue arguments so the normal-buffer and alt-buffer painters share one entry point, and the abortGapBeforeFirstWrite wrapper was removed (behavior-preserving).
  • Added a regression test — remote-snapshot-alt-screen-replay.test.ts gains "replaces history when the host has left the alt screen", registered under the existing terminal-output.scrollback-restore gate.

I verified the delta rather than the description. The new test is genuine coverage: removing only the alternateScreen === true term makes it fail with the old history retained above the host's screen (SETUP-OUTPUT-0..4), and it passes with the gate restored. The helper rename is behavior-preserving at all call sites, and all 5 tests in the alt-screen suite pass at head with a clean tree.

Not approving because a previously flagged nit remains open inline (runtime-terminal-stream.test.ts:595, stale "clears screen and scrollback" comment), unchanged by this commit.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the commit since the prior pullfrog review (46c4558): gating kept scrollback on the host's proof that the TUI exited, rather than on the alt-screen flag.

  • Switched the kept-history gate to the shell-owner proof — replay-data-drain.ts now uses paneOnAlternateScreen && terminalOwner !== 'shell' && paneAtSourceGrid() for keepScrollback, replacing alternateScreen === true. The daemon's terminalOwner is 'shell' only once the host has proven the shell is the foreground process; while a TUI runs it is revoked, so the normal buffer is frozen and the pane's history still continues the host screen on a shared grid.
  • Fixed a gate that could not fire during a live TUI — decodeSnapshotInfo (remote-runtime-terminal-snapshot-state.ts:111) only surfaces alternateScreen when the host also reports terminalOwner === 'shell', so the previous alternateScreen === true term disabled keep-scrollback in exactly the live-TUI case it was meant to protect. The owner proof has no such coupling.
  • Renamed and re-centred the regression test — the host-left-alt test became "replaces history once the host proves the TUI exited", passing terminalOwner: 'shell', and the pushed-image/recovery metas dropped their now-unused alternateScreen: true.

I verified the delta rather than the description. The new test is genuine coverage: removing only the terminalOwner !== 'shell' term makes it fail with the old history retained above the host's screen (SETUP-OUTPUT-0..4), and it passes with the gate restored. The gate only ever drops preserved scrollback, so it cannot alter the screen outcome. All 5 tests in the alt-screen suite pass at head with a clean tree.

Not approving because a previously flagged nit remains open inline (runtime-terminal-stream.test.ts:595, stale "clears screen and scrollback" comment), unchanged by this commit.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the commit since the prior pullfrog review (c02d142): keeping a live TUI's covered history only when the host image proves it shares the pane's grid.

  • Required a proven source grid for kept history — replay-data-drain.ts changed paneAtSourceGrid() from !sourceGrid || (exact match) to sourceGrid !== null && exact match, so an image that does not report its capture grid can no longer keep the pane's history. resolvePositiveTerminalDimensions returns { cols, rows } | null, so the !== null narrowing is the correct form.
  • Added a no-grid regression test — remote-snapshot-alt-screen-replay.test.ts gains "replaces history when the host image has no grid", registered under the terminal-output.scrollback-restore gate.
  • Fixed the stale recovery-prefix comment — runtime-terminal-stream.test.ts now describes the recovery clear as screen-only, resolving the last open review thread. The assertion itself already pinned \x1b[2J\x1b[H.

I verified the delta rather than the description. The new test is genuine coverage: ablating only sourceGrid !== null makes it fail with the old history retained (SETUP-OUTPUT-0..4), and it passes with the gate restored. The 8 affected suites (99 tests) pass at head with a clean tree, and the previously open thread is now resolved. This is a deliberate tightening — an image with no grid has no proof its screen matches the pane, so replacing the history is the safe outcome, including on the shutdownReplayHandler path which threads no grid.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the commit since the prior pullfrog review (a5fa53e): a test-only addition that exercises the fix through the real host chain.

  • Added remote-snapshot-alt-screen-host-chain.test.ts — drives the real host runtime (OrcaRuntimeService), its shell-ownership proof, the ack-recovery publisher, the wire codec, the client multiplexer, and the remote transport; only the transport-to-pane onReplayData hand-off is wired by the test. It covers a live TUI keeping the covered history on a shared grid, and history being replaced once the host proves the TUI exited.
  • Registered the suite under the existing terminal-output.scrollback-restore gate — added to the gate command, testFiles, and assertionRefs in config/reliability-gates.jsonc.

I verified the new test can fail rather than trusting the description: setting keepScrollback: false in replay-data-drain.ts:146 makes the "keeps the covered history" case fail with SETUP-OUTPUT-0..4 dropped (expected [ 'SETUP-OUTPUT-5', …(5) ] to deeply equal [ 'SETUP-OUTPUT-0', …(10) ]), so it is genuine coverage, not theatre. Both new tests pass at head, pnpm tc:web and oxlint are clean on the new file, and check-reliability-gates.mjs passes (140 gates). No production code changed by this commit; the previously resolved stale-comment thread remains resolved.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…apshot

A remote terminal running a full-screen agent (Claude Code) could show old
output (e.g. a setup script's pnpm log) interleaved with the agent's screen
after switching back to the tab. The host's pushed snapshot is a serialized
image that starts on the normal buffer and enters the alternate screen
itself, but the replay drain cleared with ESC[2J without leaving alt. The
image's history painted into the agent's screen, its own ?1049h was a no-op,
and the agent's diff paints landed on top of the stale cells.

The remote-runtime transport now marks snapshots as serialized images, and
the drain grounds them with the shared snapshot prologue (switching to the
normal buffer first). Raw byte replays (SSH relay ring buffers) keep the
in-place clear.
…verywhere

Review follow-ups:
- Rename the flag to carriesNormalBuffer: what the painters rely on is that
  the image starts on the normal buffer and enters alt itself.
- Hidden-output restore had the same bug for remote requested snapshots
  (history folded into data, alternateScreen set): the painter entered alt
  first and painted the normal buffer into the TUI's screen. Requested remote
  snapshots now carry the flag and take the normal-buffer start.
- Flag pushed snapshots replayed after a cancelled shutdown too.
- Pushed snapshots carry only the screen, so over a live TUI the drain keeps
  the normal-buffer history it covers instead of wiping it.
- Read the pane's buffer after queued output parses.
- Tests compare whole buffers against a fresh terminal, use production image
  shapes, and pin the raw-replay path with the same oracle.
The recovery prefix's own \x1b[3J ran after the drain's prologue and wiped the
history the drain keeps under a live TUI. Keep only the latch release, which
still makes an empty recovery snapshot non-empty so it is applied.
Consumers that write recovery snapshots straight into xterm (no replay drain)
rely on the prefix clearing the stale screen. Restore \x1b[2J\x1b[H and drop
only \x1b[3J, which wiped history the image does not carry.
The multiplexer prepends its own screen clear; replaying that exact payload
pins that the prefix cannot wipe the history a TUI covers.
Second review follow-ups:
- A pushed image carries only the host's screen; the pane's frozen history
  continues it exactly only on the same grid. On another grid keeping it
  duplicated or dropped lines, so the image replaces it there.
- Tests replay the pane's writes and grid changes into a real terminal and
  compare whole buffers with the host, including a mismatched-grid case.
- The split branch shares the normal-buffer preamble; drop the now
  single-use abort helper.
- Type serializeBuffer as RemoteRuntimeSnapshotImage so the flag is carried
  by type, not by object pass-through.
- Register the grid and raw-replay cases in the reliability gate.
…on alt

The drain kept the pane's history whenever the pane was on the alt screen. If
the host's TUI exited while the tab was hidden, the shell wrote past that
history and the kept lines no longer continued the host's screen. Require the
host's own alternateScreen too; an absent flag proves nothing, so the image
replaces history as on main.

Also: one buildSnapshotReplayPreamble for every first replay write, the drain's
image and raw clears as separate branches (raw byte-identical to main, comment
restored), and a single paneAtSourceGrid check.
The host sends alternateScreen only with terminalOwner 'shell', i.e. once it has
proven the TUI exited, so `alternateScreen === true` never held for a live TUI
and the drain wiped the history it should keep. Replace the history only once
the host proves the TUI exited; tests now use production snapshot shapes. Move
the relay-overlap comment into the raw-replay branch it describes.
An image without its grid cannot prove the pane's history continues its screen,
so it now replaces history. Also update a stale recovery-prefix test comment.
…e and drain

Hand-written replay meta hid a gate that production never satisfies. Drive the
host's own emulator, ownership mirror, serializer and recovery publisher through
the real wire, client parser, remote transport and pane drain, for a live TUI
and after the host proves it exited.
@Jinwoo-H
Jinwoo-H force-pushed the remote-terminal-overlay branch from f2e8c06 to 0458230 Compare October 4, 2026 17:39
…story alone

Keeping the pane's history by clearing only the normal screen assumed a pushed
image carries no history, which the host does not guarantee: a 0-row push can
reuse a concurrent requested capture, and its history then landed twice in
scrollback. It also wiped history on a grid mismatch, where main kept it.

When pane and image are both on alt, the image's normal part adds nothing (the
normal buffers froze together), so paint only its alt payload after an alt-side
clear, split at the host's own boundary (splitAtAlternateScreenEntry, now shared
with the daemon). Any other image paints from the normal buffer. This drops
keepScrollback, the owner and grid gates, and the recovery-prefix change, so
history behaves exactly as on main.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the one commit since the last Pullfrog review (f2e8c06): repaint only the alternate-screen frame of a folded remote push over a live TUI, leaving history alone.

  • Split the image structurally instead of gating kept history — replay-data-drain.ts now calls buildFoldedImageReplayWrites, which splits a pushed image at its last ?1049h and, when the pane is already on alt, writes only the alt payload after an in-place alt clear. The pane's normal buffer and history are left untouched on any grid.
  • Removed the grid/owner/alt-screen gates — the image containing a fold ?1049h is itself the host's proof its TUI is still on alt (buildRehydrateSequences emits it only when modes.alternateScreen), so the prior terminalOwner/alternateScreen/paneAtSourceGrid conditions are redundant. This is what removes the mismatched-grid history duplication/drop.
  • Extracted splitAtAlternateScreenEntry into src/shared — now shared with the daemon's splitTerminalSnapshotAnsi (behavior-identical; both used lastIndexOf('\x1b[?1049h')).
  • Dropped keepScrollback from buildSnapshotReplayPrologue — no remaining callers; the clear is again purely targetAlternateScreen-driven.
  • Re-added \x1b[3J to the recovery push prefix — the drain path drops it (it is part of the discarded normalAnsi) and the non-split preamble already clears scrollback, so it only restores the clear for drain-less consumers.
  • Reworked the alt-screen tests — the mismatched-grid case now asserts the pane's normal buffer is preserved, plus a history-unduplicated case and a TUI-started-while-hidden case; the host-chain suite drops its reliance on a hand-written meta.

I verified the touched suites pass at head (34 tests across the replay, host-chain, frame-drop-resync, and runtime-terminal-stream suites) and traced the split back to the host composition (scrollbackAnsi + rehydrateSequences + snapshotAnsi, with rehydrateSequences beginning with \x1b[?1049h), so alternateAnsi is self-contained under the grounding prologue. The changed tests compare whole normal buffers and alt viewports against real headless xterm renders, so painting the whole image or never splitting fails them rather than merely shifting output.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Final-review follow-ups: a drain test where the TUI's ?1049h is still queued
when the image arrives, and a transport test replaying a push buffered during a
cancelled shutdown; each fails when its guard is removed. The requested-image
test now names the exited-TUI case it covers, requestSnapshot shares the
snapshot image type, and the clear comment no longer implies every clear drops
scrollback.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the single commit since the prior pullfrog review (e79b0ba): regression tests that pin two guarantees the fix relies on, plus a stale-comment fix and a type cleanup.

  • Pinned the post-parse buffer read — remote-snapshot-alt-screen-replay.test.ts gains an alternate-queued harness mode and a test asserting the drain reads the pane's buffer only after a queued ?1049h parses. I removed the production await waitForTerminalOutputParsed(...) and the test failed with the reported garble (SETUP-OUTPUT-5, NoTnoticePtoday), so it is genuine coverage rather than a tautology.
  • Pinned the cancelled-shutdown flag — remote-runtime-pty-transport-snapshot-replay.test.ts asserts that a push buffered during a shutdown replays through restorePtyDataHandlersAfterFailedShutdown with carriesNormalBuffer: true.
  • Renamed and re-annotated the requested-image test to describe the exited-TUI alternateScreen: true + carriesNormalBuffer case.
  • Behavior-neutral cleanup — reworded the replay-data-drain.ts clear-rationale comment and collapsed requestSnapshot's inline return type to RemoteRuntimeSnapshotImage | null.

Both touched test files pass at head (16 tests); the working tree is clean after reverting the mutation probe.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 3655bd9 into main Oct 4, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant