mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-14 09:11:54 +00:00
* fix(tui): commit composer input bursts immediately Salvage the WSL/terminal multi-character input burst fix with focused regression coverage so delayed pseudo-paste buffers cannot reorder later edits. * fix(tui): keep newline input bursts on paste path Preserve paste handling for multi-character chunks with newlines while keeping repeated printable key bursts on the immediate composer path. * refactor(tui): share composer frame batch interval Use one frame-sized batching constant for parent updates, local renders, and input burst flushes.
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { applyPrintableInsert, shouldRouteMultiCharInputAsPaste } from '../components/textInput.js'
|
|
|
|
describe('applyPrintableInsert', () => {
|
|
it('applies non-bracketed multi-character bursts immediately', () => {
|
|
const burst = applyPrintableInsert('abc', 3, 'xxxxx')
|
|
|
|
const repeated = [...'xxxxx'].reduce(
|
|
(state, ch) => applyPrintableInsert(state.value, state.cursor, ch)!,
|
|
{ cursor: 3, value: 'abc' }
|
|
)
|
|
|
|
expect(burst).toEqual({ cursor: 8, value: 'abcxxxxx' })
|
|
expect(burst).toEqual(repeated)
|
|
})
|
|
|
|
it('replaces the selected range for burst input', () => {
|
|
expect(applyPrintableInsert('abZZef', 4, 'cd', { end: 4, start: 2 })).toEqual({
|
|
cursor: 4,
|
|
value: 'abcdef'
|
|
})
|
|
})
|
|
|
|
it('rejects control or escape-bearing input', () => {
|
|
expect(applyPrintableInsert('abc', 3, '\x1b[200~pasted')).toBeNull()
|
|
expect(applyPrintableInsert('abc', 3, '\t')).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('shouldRouteMultiCharInputAsPaste', () => {
|
|
it('keeps newline-bearing chunks on the paste path', () => {
|
|
expect(shouldRouteMultiCharInputAsPaste('hello\nworld')).toBe(true)
|
|
expect(shouldRouteMultiCharInputAsPaste('hello\r\nworld'.replace(/\r\n/g, '\n'))).toBe(true)
|
|
})
|
|
|
|
it('treats repeated printable key bursts as immediate input', () => {
|
|
expect(shouldRouteMultiCharInputAsPaste('xxxxx')).toBe(false)
|
|
})
|
|
})
|