From 0ced55904485661c2809d375f824ceb317f5a4e7 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Mon, 16 Mar 2026 15:11:11 -0400 Subject: [PATCH] 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. --- packages/pi-tui/src/tui.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pi-tui/src/tui.ts b/packages/pi-tui/src/tui.ts index c3e39acc5..345308f31 100644 --- a/packages/pi-tui/src/tui.ts +++ b/packages/pi-tui/src/tui.ts @@ -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];