[Bug] TUI clears the whole screen on content shrink and on height resize, causing visible flicker #1400
vinchey
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
TUI
What happened?
packages/tuiemitsESC[2J(full screen clear) on several render paths. Each one is a visible flash. Differential rendering itself is fine; the flashes all come from full-redraw branches.Counted
ESC[2Jwrites with the package's own headlessVirtualTerminalharness:ESC[2JPI_DEBUG_REDRAW=1attributes them to three branches:This is platform independent; the harness runs on headless xterm. Windows only sees the resize cases more often because ConPTY emits more resize events.
Shrink path. The comment at
tui.ts:1804-1808assumes a shrink is one-off:In practice collapsing and expanding tool output alternates, so it flashes on every toggle: 10 clears for 10 collapse cycles.
Height path. This one has already round-tripped:
0925fafe3dabcda0db16937947bSo any fix has to hold three things at once: no flash on height change, editor and footer stay visible, and Termux keyboard toggles do not replay history. The current
heightChanged && !isTermuxSession()gate is a platform branch standing in for viewport-aligned incremental repaint.Steps to reproduce
Interactively: run a task that produces long tool output, then collapse and expand it repeatedly, or drag the terminal's height.
Expected behavior
Collapsing tool output repaints the visible window in place without clearing the screen. Height changes realign the viewport without replaying the transcript.
Prime Agent version
0.7.2 (source checkout, 9f95011)
Environment
Windows 11, Windows Terminal / ConPTY; reproduced platform independently via
@xterm/headlessAdditional context
fullRender(clear, preserveViewport)already has an in-place repaint path that rewrites the visible window with per-lineESC[2Kand emits no screen clear.For the shrink branch, every retained line is byte-identical (
firstChangedis past the end of the new content), so routing it to that path lands the same output without the flash. I have that patched locally as a one-line change plus two regression tests; it takes scenario 4 from 10 clears to 0, and the other five scenarios are unchanged. The new tests fail with the change reverted.Height changes look like the same shape of problem but are riskier given the history above, and would need someone who can validate on both Termux and a desktop terminal. Width changes are listed for completeness but are a genuinely different case, since wrapping changes.
Separately,
PI_DEBUG_REDRAW=1currently crashes the TUI rather than helping diagnose this:logRedrawcallsappendFileSyncwith nomkdirSync, and hardcodes~/.prime/agentrather than followingPRIME_AGENT_CODING_AGENT_DIR.PI_TUI_DEBUG=1has the same shape of problem with a hardcoded/tmp/tui. I had to create the directory by hand before I could collect the attribution table above.All reactions