Skip to content

fix(terminal): preserve escape tails during quiet snapshot handoff - #33677

Merged
nwparker merged 2 commits into
mainfrom
nwparker/terminal-replay-escape-tail
Oct 26, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/terminal-replay-escape-tail

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

A slow terminal restore could turn a split color sequence into visible text such as 214mWorking, or erase the color of ordinary output. Preserve the terminal's parser and styling when the snapshot and queued output form an intact stream.

What Changed

Reuse the deadline's existing gap/repaint decision to preserve replay state only when a snapshot answered and the queued bytes can drain without a known gap. Other abandonment paths keep their existing parser, styling, and Kitty resets. No acknowledgement, protocol, timer, or retry-budget changes.

Extend the existing fit-deadline test and reliability gate with split-escape, styled-output, and genuine-gap controls. The tests compare full terminal buffers and actual cell color attributes before any later repaint.

Why

The quiet handoff still wrote CAN plus a rendition reset between the snapshot's ESC[38;5; tail and the live 214mWorking continuation. Those bytes cancel a valid sequence. An intact handoff needs no gap reset; genuine byte loss still does.

Linked Issue

Follow-up to merged #33474, addressing the escape-sequence finding from its adversarial review.

This does not claim to resolve #33608: that report measures kernel PTY icanon echo and failed input. This change concerns output replay/parser state and does not alter kernel TTY flags.

Visual Proof

Same real PTY fixture and main-owned snapshot, with pane fitting held unavailable for 1.8 seconds during reveal. The snapshot was verified to contain the incomplete escape tail. Screenshots are from a hidden macOS Electron renderer.

Before After
Before: escape continuation renders literally After: Working renders in the intended orange

Testing

  • Reproduced both failures on current main before the production change: literal 214mWorking and lost foreground color. The genuine-gap control passed before and after.
  • Nine focused cases pass; 215 tests across six replay suites pass, including remote snapshot recovery, overflow, unmappable chunks, and uncovered markers.
  • Same rendered fixture changes from literal text/default color to Working in palette color 214. Real shell input/output still works after recovery.
  • Passed ORCA_BACKGROUND_LAUNCH=1 pnpm tc:web, changed-code quality checks, reliability-gate validation, and git diff --check.

Review

Independent adversarial Claude CLI review found no must-fix defects and recommends merging. It checked parser/write ordering, gap classification, Kitty and synchronized-output state, timer/generation/PTY guards, other abandonment callers, remote compatibility, and test branch coverage. It confirmed that an intact deadline drain now matches normal successful replay, which also writes no additional gap reset. The review was read-only; test and rendered evidence above were run separately.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer content is copied or translated.

Notes

  • Invariant/gate: terminal-output.scrollback-restore; intact snapshot/live bytes preserve escape parsing and rendition through a fit deadline, while genuine gaps still ground state.
  • Performance/diagnostics: skips an unnecessary reset write; adds no polling, timers, scans, or IPC. Exact buffers, cell attributes, request counts, and before/after screenshots are the oracle.
  • Coverage: rendered local/daemon PTY on macOS and deterministic remote recovery suites. No filesystem, workspace-path, platform API, or wire-format changes; native Linux/Windows/WSL, mobile, and a live remote host were not exercised.
  • Residual: painted-snapshot acknowledgement behavior remains a separate follow-up. The original customer's exact trigger and actual Pi session remain unverified.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ab7d3c7-b674-43e7-9832-d05bacb14a35
Commits

Reviewing files that changed from the base of the PR and between f81c533 and 494530b.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ede67442-25d3-487e-a748-958566399abb
Commits

Reviewing files that changed from the base of the PR and between 3aec926 and f81c533.

Files selected for processing: 4
  • config/reliability-gates.jsonc
  • src/renderer/src/components/terminal-pane/pty-connection-hidden-restore-fit-overflow.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/hidden-output-restore-abandon.ts
  • src/renderer/src/components/terminal-pane/pty-connection/hidden-output-restore-drain.ts

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

Walkthrough

The deadline path now preserves replay state when a replayed snapshot does not require repaint. When repaint is required, it records flood backpressure and does not preserve replay state. The tests and reliability assertions add coverage for split-escape, styled-output, and styled-gap recovery.

Priority: Normal

Merge Risk: Minimal · up to f81c5

No actionable issue is established for this change; it is mergeable after normal checks.

Pre-merge checks: Passed 2 · Failed 3

Failed Failed checks: 3 warnings

Check name Status Explanation Resolution
Linked Issues check Warning [#33608] requires interactive TUI panes to retain PTY raw mode (-icanon -echo) and accept Enter. The reviewed changes only alter hidden output snapshot replay and ANSI/parser-state handling in `hidd… Implement and test the PTY input-mode behavior required by [#33608], including raw-mode retention and Enter handling, or remove [#33608] as a direct link if this PR does not intend to address that issue.
Out of Scope Changes check Warning The production changes address output replay state, escape-sequence continuity, and repaint-gap handling. These changes do not address [#33608]'s input-side failure in which the PTY returns to canonic… Remove [#33608] from the direct issue links or add implementation that addresses its raw-mode and Enter requirements. Keep the current output-replay changes linked only to the issue that defines that scope.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 2 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving escape tails during terminal snapshot handoff.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, linked issue context, visual proof, testing, scope, and residual risks. It omits the template's final Checklist secti…
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, linked issue context, visual proof, testing, scope, and residual risks. It omits the template's final Checklist section and does not use the exact Fixes # format, but the required information is otherwise substantially present.

Full details: Linked Issues check

Explanation

[#33608] requires interactive TUI panes to retain PTY raw mode (-icanon -echo) and accept Enter. The reviewed changes only alter hidden output snapshot replay and ANSI/parser-state handling in hidden-output-restore-drain.ts and hidden-output-restore-abandon.ts. The supplied PR evidence states that kernel TTY flags are unchanged. No implementation or test establishes compliance with the issue requirements.

Resolution

Implement and test the PTY input-mode behavior required by [#33608], including raw-mode retention and Enter handling, or remove [#33608] as a direct link if this PR does not intend to address that issue.

Full details: Out of Scope Changes check

Explanation

The production changes address output replay state, escape-sequence continuity, and repaint-gap handling. These changes do not address [#33608]'s input-side failure in which the PTY returns to canonical mode and echoes input. The PR description also explicitly states that it does not resolve [#33608]. Therefore the reviewed implementation is outside the scope of the directly linked issue.

Resolution

Remove [#33608] from the direct issue links or add implementation that addresses its raw-mode and Enter requirements. Keep the current output-replay changes linked only to the issue that defines that scope.

Full details: Docstring Coverage

Explanation

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

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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.

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.

[Bug]: Claude Code / Antigravity TUI panes end up in canonical mode (icanon echo): ^[[ garbage in input, Enter does nothing (1.4.240)

1 participant