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
This commit is contained in:
laoli-no1 2026-05-12 16:42:01 -07:00 committed by Teknium
parent 2a3140a814
commit d33deb7cbe

View file

@ -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()