mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 09:17:09 +08:00
24 files, -319 LoC. Behaviour preserved, 369/369 tests green. - hermes-ink caches: shared lruEvict helper for the four parallel LRU caches (stringWidth, wrapText, sliceAnsi, lineWidth); touch-on-read stays inlined per cache; tightened output.ts skip-slice fast path. - wheelAccel: trimmed provenance header, collapsed env parsing, ternary dispatch in computeWheelStep. - perfPane: folded ensureLogDir into once-flag, spread-with-overrides for fastPath/phases instead of full rebuilds. - env: extracted truthy() (used 4×). - virtualHeights: collapsed user/diff/slash height bumps; trail+todos estimate. - useInputHandlers: scrollIdleTimer cleanup on unmount, ?? undefined shorthand. - useMainApp: dropped dead liveTailVisible IIFE and liveProgress indirection. - appLayout, markdown, messageLine, entry: vertical rhythm, dropped narration comments, inlined one-shot vars. - fix: empty catch blocks → /* best-effort */ for no-empty lint.
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { estimatedMsgHeight, messageHeightKey, wrappedLines } from '../lib/virtualHeights.js'
|
|
import type { Msg } from '../types.js'
|
|
|
|
describe('virtual height estimates', () => {
|
|
it('uses stable content keys across resumed message objects', () => {
|
|
const msg: Msg = { role: 'assistant', text: 'same text', tools: ['Search Files [long message]'] }
|
|
|
|
expect(messageHeightKey(msg)).toBe(messageHeightKey({ ...msg }))
|
|
})
|
|
|
|
it('accounts for wrapping and preserved blank-block rhythm', () => {
|
|
const msg: Msg = { role: 'assistant', text: `one\n\n${'x'.repeat(90)}` }
|
|
|
|
expect(wrappedLines(msg.text, 30)).toBe(5)
|
|
expect(estimatedMsgHeight(msg, 35, { compact: false, details: false })).toBeGreaterThan(5)
|
|
})
|
|
|
|
it('includes detail sections when visible', () => {
|
|
const msg: Msg = { role: 'assistant', text: 'ok', thinking: 'line 1\nline 2', tools: ['Tool A', 'Tool B'] }
|
|
|
|
expect(estimatedMsgHeight(msg, 80, { compact: false, details: true })).toBeGreaterThan(
|
|
estimatedMsgHeight(msg, 80, { compact: false, details: false })
|
|
)
|
|
})
|
|
})
|