From d33deb7cbea17fbf5377c1e3f46f1016358fe88d Mon Sep 17 00:00:00 2001 From: laoli-no1 <6966326+laoli-no1@users.noreply.github.com> Date: Tue, 12 May 2026 16:42:01 -0700 Subject: [PATCH] fix(tui): clear scrollback buffer on startup to prevent tmux scrollback leakage When TUI exits, tmux captures some TUI output into its scrollback buffer. On restart, stale scrollback content appears at the top of screen before AlternateScreen takes over. Add ANSI escape sequences at startup: - ESC[2J clear visible screen - ESC[H cursor home - ESC[3J clear scrollback buffer --- ui-tui/src/entry.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui-tui/src/entry.tsx b/ui-tui/src/entry.tsx index 31111d54686..cfb0cd2f3f0 100644 --- a/ui-tui/src/entry.tsx +++ b/ui-tui/src/entry.tsx @@ -20,6 +20,12 @@ if (!process.stdin.isTTY) { // terminal tab can still have mouse/focus/paste modes enabled. resetTerminalModes() +// Clear visible screen + scrollback buffer. Without this, tmux may retain +// stale TUI output in its scrollback buffer from the previous session, +// which is visible when the user scrolls up or briefly before AlternateScreen +// takes over on restart. See entry.tsx → AlternateScreen flow. +process.stdout.write('\x1b[2J\x1b[H\x1b[3J') + const gw = new GatewayClient() gw.start()