Skip to content

fix(cli): in-place mutations of off-screen entries still trigger scrollback-clearing redraws #1135

Closed

Description

@Astro-Han

Problem

Pre-existing and independent of the #1097 toggle fix (#1130): several transcript paths mutate the rendered lines of entries that have scrolled above pi-tui's live viewport. Any such change makes pi-tui's differential renderer hit its firstChanged < viewportTop path and emit ESC[2J ESC[H ESC[3J, clearing pre-Maka scrollback and resetting the scroll position.

Known mutation paths (all in packages/cli/src/pi-transcript.ts):

  • refreshRunningShellRunElapsed — the 1s ticker rewrites the running Ns segment of every running shell-run card. A background task whose card has scrolled off-screen causes a full redraw every second while the session keeps growing. This is the worst case and was reproduced against the real renderer during the fix(cli): anchor Ctrl+O/Ctrl+T expansion to the live viewport so toggles never clear scrollback #1130 review (fullRedraws 1 → 2 with ESC[3J on a single tick).
  • shell-run settle/ownership updates applied to old Bash cards (applyShellRunViewUpdateToTranscript, applyShellRunUpdateToTranscript).
  • late thinking_complete replacing a streamed thinking entry in place (setThinking).
  • tool_result folding that splices an off-screen poll card out of state.entries.
  • tool_progress / tool_output_delta appended to an expanded off-screen card.

Direction

The invariant #1130 established for the toggles should own all of these: the rendered prefix of off-screen entries must stay frozen. Later state changes should keep updating the underlying entry state but be projected as transcript-tail updates instead of in-place rewrites while the entry is off-screen. pushShellRunSettledNotice is the existing precedent for exactly this pattern (card flips off-screen, a tail notice announces it).

The render-geometry data added in #1130 (renderGeometry.entryFirstLine / viewportTop) already answers "is this entry off-screen", and the layout's shadow diff self-heals the estimate after any wipe that does slip through.

Verification

Behavioral tests through the real pi-tui renderer asserting no ESC[3J for: off-screen running-Bash ticker updates, settle updates, progress/output deltas on an expanded off-screen card, late thinking completion, and poll-card removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions