chore: fmt

This commit is contained in:
Brooklyn Nicholson 2026-04-08 22:02:38 -05:00
parent 9d8f9765c1
commit c49bbbe8c2
5 changed files with 2 additions and 25 deletions

View file

@ -3,9 +3,7 @@ import { describe, expect, it } from 'vitest'
import { FACES, HOTKEYS, INTERPOLATION_RE, PLACEHOLDERS, ROLE, TOOL_VERBS, VERBS, ZERO } from '../constants.js' import { FACES, HOTKEYS, INTERPOLATION_RE, PLACEHOLDERS, ROLE, TOOL_VERBS, VERBS, ZERO } from '../constants.js'
import { DEFAULT_THEME } from '../theme.js' import { DEFAULT_THEME } from '../theme.js'
describe('constants', () => { describe('constants', () => {
it('ZERO', () => expect(ZERO).toEqual({ calls: 0, input: 0, output: 0, total: 0 })) it('ZERO', () => expect(ZERO).toEqual({ calls: 0, input: 0, output: 0, total: 0 }))
it('string arrays are populated', () => { it('string arrays are populated', () => {

View file

@ -2,9 +2,7 @@ import { describe, expect, it } from 'vitest'
import { upsert } from '../lib/messages.js' import { upsert } from '../lib/messages.js'
describe('upsert', () => { describe('upsert', () => {
it('appends when last role differs', () => { it('appends when last role differs', () => {
expect(upsert([{ role: 'user', text: 'hi' }], 'assistant', 'hello')).toHaveLength(2) expect(upsert([{ role: 'user', text: 'hi' }], 'assistant', 'hello')).toHaveLength(2)
}) })

View file

@ -11,9 +11,7 @@ import {
userDisplay userDisplay
} from '../lib/text.js' } from '../lib/text.js'
describe('stripAnsi / hasAnsi', () => { describe('stripAnsi / hasAnsi', () => {
it('strips ANSI codes', () => { it('strips ANSI codes', () => {
expect(stripAnsi('\x1b[31mred\x1b[0m')).toBe('red') expect(stripAnsi('\x1b[31mred\x1b[0m')).toBe('red')
}) })
@ -28,9 +26,7 @@ describe('stripAnsi / hasAnsi', () => {
}) })
}) })
describe('compactPreview', () => { describe('compactPreview', () => {
it('truncates with ellipsis', () => { it('truncates with ellipsis', () => {
expect(compactPreview('a'.repeat(100), 20)).toHaveLength(20) expect(compactPreview('a'.repeat(100), 20)).toHaveLength(20)
expect(compactPreview('a'.repeat(100), 20).at(-1)).toBe('…') expect(compactPreview('a'.repeat(100), 20).at(-1)).toBe('…')
@ -49,9 +45,7 @@ describe('compactPreview', () => {
}) })
}) })
describe('estimateRows', () => { describe('estimateRows', () => {
it('single line', () => expect(estimateRows('hello', 80)).toBe(1)) it('single line', () => expect(estimateRows('hello', 80)).toBe(1))
it('wraps long lines', () => expect(estimateRows('a'.repeat(160), 80)).toBe(2)) it('wraps long lines', () => expect(estimateRows('a'.repeat(160), 80)).toBe(2))
@ -72,9 +66,7 @@ describe('estimateRows', () => {
}) })
}) })
describe('fmtK', () => { describe('fmtK', () => {
it('formats thousands', () => expect(fmtK(1500)).toBe('1.5k')) it('formats thousands', () => expect(fmtK(1500)).toBe('1.5k'))
it('keeps small numbers', () => expect(fmtK(42)).toBe('42')) it('keeps small numbers', () => expect(fmtK(42)).toBe('42'))
@ -85,25 +77,19 @@ describe('fmtK', () => {
}) })
}) })
describe('hasInterpolation', () => { describe('hasInterpolation', () => {
it('detects {!cmd}', () => expect(hasInterpolation('echo {!date}')).toBe(true)) it('detects {!cmd}', () => expect(hasInterpolation('echo {!date}')).toBe(true))
it('rejects plain text', () => expect(hasInterpolation('plain')).toBe(false)) it('rejects plain text', () => expect(hasInterpolation('plain')).toBe(false))
}) })
describe('pick', () => { describe('pick', () => {
it('returns element from array', () => { it('returns element from array', () => {
expect([1, 2, 3]).toContain(pick([1, 2, 3])) expect([1, 2, 3]).toContain(pick([1, 2, 3]))
}) })
}) })
describe('userDisplay', () => { describe('userDisplay', () => {
it('returns short messages as-is', () => expect(userDisplay('hello')).toBe('hello')) it('returns short messages as-is', () => expect(userDisplay('hello')).toBe('hello'))
it('truncates long messages', () => { it('truncates long messages', () => {

View file

@ -2,9 +2,7 @@ import { describe, expect, it } from 'vitest'
import { DEFAULT_THEME, fromSkin } from '../theme.js' import { DEFAULT_THEME, fromSkin } from '../theme.js'
describe('DEFAULT_THEME', () => { describe('DEFAULT_THEME', () => {
it('has brand defaults', () => { it('has brand defaults', () => {
expect(DEFAULT_THEME.brand.name).toBe('Hermes Agent') expect(DEFAULT_THEME.brand.name).toBe('Hermes Agent')
expect(DEFAULT_THEME.brand.prompt).toBe('') expect(DEFAULT_THEME.brand.prompt).toBe('')
@ -17,9 +15,7 @@ describe('DEFAULT_THEME', () => {
}) })
}) })
describe('fromSkin', () => { describe('fromSkin', () => {
it('overrides banner colors', () => { it('overrides banner colors', () => {
expect(fromSkin({ banner_title: '#FF0000' }, {}).color.gold).toBe('#FF0000') expect(fromSkin({ banner_title: '#FF0000' }, {}).color.gold).toBe('#FF0000')
}) })

View file

@ -213,6 +213,7 @@ export function App({ gw }: { gw: GatewayClient }) {
const { queueRef, queueEditRef, queuedDisplay, queueEditIdx, enqueue, dequeue, replaceQ, setQueueEdit, syncQueue } = const { queueRef, queueEditRef, queuedDisplay, queueEditIdx, enqueue, dequeue, replaceQ, setQueueEdit, syncQueue } =
useQueue() useQueue()
const { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory } = useInputHistory() const { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory } = useInputHistory()
const { completions, compIdx, setCompIdx, compReplace } = useCompletion(input, blocked(), gw) const { completions, compIdx, setCompIdx, compReplace } = useCompletion(input, blocked(), gw)
@ -733,6 +734,7 @@ export function App({ gw }: { gw: GatewayClient }) {
queueEditIdx === null queueEditIdx === null
? queueRef.current.length - 1 ? queueRef.current.length - 1
: (queueEditIdx - 1 + queueRef.current.length) % queueRef.current.length : (queueEditIdx - 1 + queueRef.current.length) % queueRef.current.length
setQueueEdit(idx) setQueueEdit(idx)
setHistoryIdx(null) setHistoryIdx(null)
setInput(queueRef.current[idx] ?? '') setInput(queueRef.current[idx] ?? '')
@ -1014,7 +1016,6 @@ export function App({ gw }: { gw: GatewayClient }) {
break break
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, },
[appendMessage, dequeue, newSession, pushActivity, send, sys] [appendMessage, dequeue, newSession, pushActivity, send, sys]
) )
@ -1470,7 +1471,6 @@ export function App({ gw }: { gw: GatewayClient }) {
return true return true
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, },
[catalog, compact, gw, lastUserMsg, messages, newSession, pastes, pushActivity, rpc, send, sid, statusBar, sys] [catalog, compact, gw, lastUserMsg, messages, newSession, pastes, pushActivity, rpc, send, sid, statusBar, sys]
) )
@ -1526,7 +1526,6 @@ export function App({ gw }: { gw: GatewayClient }) {
} }
dispatchSubmission([...inputBuf, value].join('\n')) dispatchSubmission([...inputBuf, value].join('\n'))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, },
[dequeue, dispatchSubmission, inputBuf, sid] [dequeue, dispatchSubmission, inputBuf, sid]
) )