fix: remove CSI 3J scrollback clear from TUI full redraws (#455)

During full redraws, the TUI emitted \x1b[3J (clear scrollback) before
\x1b[2J\x1b[H (clear screen + home). In terminals like Ubuntu Terminal
that honor CSI 3J, this destroyed the scrollback buffer and caused the
scrollbar/view position to jump to the top during phase transitions.

Replace with just \x1b[2J\x1b[H which clears the visible screen and
homes the cursor without touching scrollback history. This preserves
view continuity while still performing a clean redraw.
This commit is contained in:
Tom Boucher 2026-03-16 15:11:11 -04:00
parent a90aa0c8d6
commit 0ced559044

View file

@ -909,7 +909,7 @@ export class TUI extends Container {
const fullRender = (clear: boolean): void => {
this.fullRedrawCount += 1;
let buffer = "\x1b[?2026h"; // Begin synchronized output
if (clear) buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
if (clear) buffer += "\x1b[2J\x1b[H"; // Clear screen and home (no scrollback clear — preserves view position)
for (let i = 0; i < newLines.length; i++) {
if (i > 0) buffer += "\r\n";
let line = newLines[i];