mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-21 10:22:18 +00:00
Merge pull request #48982 from NousResearch/salvage/48965-tmux-fast-echo
fix(tui): disable fast-echo bypass inside tmux (incl. SSH-from-tmux)
This commit is contained in:
commit
5e93075fd5
2 changed files with 53 additions and 0 deletions
|
|
@ -178,6 +178,43 @@ describe('supportsFastEchoTerminal', () => {
|
|||
expect(supportsFastEchoTerminal({ TERM_PROGRAM: 'Apple_Terminal' } as NodeJS.ProcessEnv)).toBe(false)
|
||||
})
|
||||
|
||||
it('disables fast-echo inside tmux', () => {
|
||||
expect(supportsFastEchoTerminal({ TMUX: '/tmp/tmux-1000/default,1234,0' } as NodeJS.ProcessEnv)).toBe(false)
|
||||
expect(supportsFastEchoTerminal({ TMUX: '/private/tmp/tmux-501/default' } as NodeJS.ProcessEnv)).toBe(false)
|
||||
})
|
||||
|
||||
it('tmux wins over Termux fast-echo opt-in', () => {
|
||||
expect(
|
||||
supportsFastEchoTerminal({
|
||||
TMUX: '/tmp/tmux-1000/default,1234,0',
|
||||
HERMES_TUI_TERMUX_FAST_ECHO: '1',
|
||||
TERMUX_VERSION: '0.118.0'
|
||||
} as NodeJS.ProcessEnv)
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps fast-echo enabled when TMUX is empty or unset', () => {
|
||||
expect(supportsFastEchoTerminal({ TMUX: '' } as NodeJS.ProcessEnv)).toBe(true)
|
||||
expect(supportsFastEchoTerminal({ TERM_PROGRAM: 'vscode' } as NodeJS.ProcessEnv)).toBe(true)
|
||||
})
|
||||
|
||||
it('disables fast-echo when only a tmux-flavored TERM is present (SSH from tmux, no TMUX forwarded)', () => {
|
||||
// OpenSSH forwards TERM but not TMUX, so a TUI on a remote host launched
|
||||
// from inside local tmux sees TERM=tmux-256color with no TMUX var. The
|
||||
// cursor-drift bug still applies, so fast-echo must stay off.
|
||||
expect(supportsFastEchoTerminal({ TERM: 'tmux' } as NodeJS.ProcessEnv)).toBe(false)
|
||||
expect(supportsFastEchoTerminal({ TERM: 'tmux-256color' } as NodeJS.ProcessEnv)).toBe(false)
|
||||
})
|
||||
|
||||
it('does NOT disable fast-echo for screen-flavored TERM (GNU screen out of scope, no reported drift)', () => {
|
||||
// GNU screen sets TERM=screen/screen-256color and has no reported drift.
|
||||
// We must not widen the tmux guard to screen* and regress its perf.
|
||||
expect(supportsFastEchoTerminal({ TERM: 'screen' } as NodeJS.ProcessEnv)).toBe(true)
|
||||
expect(supportsFastEchoTerminal({ TERM: 'screen-256color' } as NodeJS.ProcessEnv)).toBe(true)
|
||||
// And an unrelated 256color TERM must stay enabled.
|
||||
expect(supportsFastEchoTerminal({ TERM: 'xterm-256color' } as NodeJS.ProcessEnv)).toBe(true)
|
||||
})
|
||||
|
||||
it('disables fast-echo by default in Termux mode', () => {
|
||||
expect(
|
||||
supportsFastEchoTerminal({ TERMUX_VERSION: '0.118.0', PREFIX: '/data/data/com.termux/files/usr' } as NodeJS.ProcessEnv)
|
||||
|
|
|
|||
|
|
@ -359,6 +359,22 @@ export function supportsFastEchoTerminal(env: NodeJS.ProcessEnv = process.env):
|
|||
return false
|
||||
}
|
||||
|
||||
// tmux adds a PTY multiplexing layer that desyncs stdout.write() cursor
|
||||
// advances from its internal cursor model, causing cursor drift and ghost
|
||||
// whitespace under the fast-echo bypass path.
|
||||
//
|
||||
// `TMUX` catches the local case. It is NOT forwarded over SSH, so when the
|
||||
// TUI runs on a remote host launched from inside local tmux we only see a
|
||||
// tmux-flavored `TERM` (tmux sets `tmux`/`tmux-256color`); match that too so
|
||||
// remote-over-tmux sessions still fall back to the safe render path. We
|
||||
// deliberately do NOT match `screen*`: GNU screen sets the same TERM and has
|
||||
// no reported drift, so widening to screen would disable the optimization for
|
||||
// those users with no evidence of a bug.
|
||||
const term = (env.TERM ?? '').trim().toLowerCase()
|
||||
if ((env.TMUX ?? '').trim().length > 0 || term === 'tmux' || term.startsWith('tmux-')) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Termux terminals are especially sensitive to bypass-path cursor drift and
|
||||
// stale paints at soft-wrap boundaries on tall/narrow viewports. Keep this
|
||||
// off by default in Termux mode; allow explicit opt-in for local debugging.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue