fix(tui): termux-gate scrollback preservation, touch-friendly defaults
Adds a Termux runtime detection helper and gates three TUI defaults on it: - Skip the startup scrollback clear on Termux so users can review/copy earlier output after reopening the app. Desktop keeps the existing \x1b[2J\x1b[H\x1b[3J slate (AlternateScreen takes over there anyway). - Default INLINE_MODE on under Termux: primary-buffer rendering makes long-thread review and copy/paste much less fragile when users background/foreground the app. Override with HERMES_TUI_INLINE=0/1. - Default mouse tracking off under Termux so touch selection isn't intercepted by terminal mouse protocols. Explicit override via HERMES_TUI_MOUSE_TRACKING=0/1; legacy HERMES_TUI_DISABLE_MOUSE still works on desktop. Detection is purely env-based (TERMUX_VERSION or PREFIX path) with an explicit opt-out HERMES_TUI_TERMUX_MODE=0 for debugging. Non-Termux platforms keep every existing default. Co-authored-by: adybag14-cyber <252811164+adybag14-cyber@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import './lib/forceTruecolor.js'
|
||||
|
||||
import type { FrameEvent } from '@hermes/ink'
|
||||
|
||||
import { TERMUX_TUI_MODE } from './config/env.js'
|
||||
import { GatewayClient } from './gatewayClient.js'
|
||||
import { setupGracefulExit } from './lib/gracefulExit.js'
|
||||
import { formatBytes, type HeapDumpResult, performHeapDump } from './lib/memory.js'
|
||||
@@ -21,11 +22,14 @@ 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')
|
||||
// Desktop terminals benefit from a clean startup slate because the TUI usually
|
||||
// runs in AlternateScreen. On Termux we keep prior output intact so users can
|
||||
// review/copy earlier assistant replies after reopening the app.
|
||||
if (TERMUX_TUI_MODE) {
|
||||
process.stdout.write('\n')
|
||||
} else {
|
||||
process.stdout.write('\x1b[2J\x1b[H\x1b[3J')
|
||||
}
|
||||
|
||||
const gw = new GatewayClient()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user