mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
fix(tui): reset terminal modes on startup and exit
Reset sticky mouse/focus/paste terminal modes before the TUI starts and during graceful shutdown paths so stale tab state from prior crashes cannot poison the next session.
This commit is contained in:
parent
98a428fd61
commit
d05497f812
3 changed files with 87 additions and 2 deletions
29
ui-tui/src/__tests__/terminalModes.test.ts
Normal file
29
ui-tui/src/__tests__/terminalModes.test.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { resetTerminalModes, TERMINAL_MODE_RESET } from '../lib/terminalModes.js'
|
||||
|
||||
describe('terminal mode reset', () => {
|
||||
it('includes the sticky input modes Hermes enables', () => {
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1006l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1003l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1002l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1000l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1004l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?2004l')
|
||||
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1049l')
|
||||
})
|
||||
|
||||
it('writes reset sequence to TTY streams without fds', () => {
|
||||
const write = vi.fn()
|
||||
|
||||
expect(resetTerminalModes({ isTTY: true, write } as unknown as NodeJS.WriteStream)).toBe(true)
|
||||
expect(write).toHaveBeenCalledWith(TERMINAL_MODE_RESET)
|
||||
})
|
||||
|
||||
it('skips non-TTY streams', () => {
|
||||
const write = vi.fn()
|
||||
|
||||
expect(resetTerminalModes({ isTTY: false, write } as unknown as NodeJS.WriteStream)).toBe(false)
|
||||
expect(write).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue