mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(tui): recover from stuck paste mode
Prevent unterminated bracketed paste input from swallowing future keystrokes, and avoid rendering an empty Thinking panel before reasoning arrives.
This commit is contained in:
parent
cd7150a195
commit
afb20a1d67
4 changed files with 65 additions and 15 deletions
41
ui-tui/packages/hermes-ink/src/ink/parse-keypress.test.ts
Normal file
41
ui-tui/packages/hermes-ink/src/ink/parse-keypress.test.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { INITIAL_STATE, parseMultipleKeypresses } from './parse-keypress.js'
|
||||
import { PASTE_END, PASTE_START } from './termio/csi.js'
|
||||
|
||||
describe('parseMultipleKeypresses bracketed paste recovery', () => {
|
||||
it('emits empty bracketed pastes when the terminal sends both markers', () => {
|
||||
const [keys, state] = parseMultipleKeypresses(INITIAL_STATE, PASTE_START + PASTE_END)
|
||||
|
||||
expect(keys).toHaveLength(1)
|
||||
expect(keys[0]).toMatchObject({ isPasted: true, raw: '' })
|
||||
expect(state.mode).toBe('NORMAL')
|
||||
})
|
||||
|
||||
it('flushes unterminated paste content back to normal input mode', () => {
|
||||
const [pendingKeys, pendingState] = parseMultipleKeypresses(INITIAL_STATE, PASTE_START + 'hello')
|
||||
|
||||
expect(pendingKeys).toEqual([])
|
||||
expect(pendingState.mode).toBe('IN_PASTE')
|
||||
|
||||
const [keys, state] = parseMultipleKeypresses(pendingState, null)
|
||||
|
||||
expect(keys).toHaveLength(1)
|
||||
expect(keys[0]).toMatchObject({ isPasted: true, raw: 'hello' })
|
||||
expect(state.mode).toBe('NORMAL')
|
||||
expect(state.pasteBuffer).toBe('')
|
||||
})
|
||||
|
||||
it('resets an empty unterminated paste start instead of staying stuck', () => {
|
||||
const [pendingKeys, pendingState] = parseMultipleKeypresses(INITIAL_STATE, PASTE_START)
|
||||
|
||||
expect(pendingKeys).toEqual([])
|
||||
expect(pendingState.mode).toBe('IN_PASTE')
|
||||
|
||||
const [keys, state] = parseMultipleKeypresses(pendingState, null)
|
||||
|
||||
expect(keys).toEqual([])
|
||||
expect(state.mode).toBe('NORMAL')
|
||||
expect(state.pasteBuffer).toBe('')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue