mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-25 05:52:34 +00:00
fix(tui): inline todo in transcript, group across thinking
This commit is contained in:
parent
4943ea2a7c
commit
319c1c1691
6 changed files with 104 additions and 30 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { Msg } from '../types.js'
|
||||
|
||||
import { appendToolShelfMessage, canHoldToolShelf, isTodoDone, mergeToolShelfInto } from './liveProgress.js'
|
||||
|
||||
describe('isTodoDone', () => {
|
||||
|
|
@ -54,6 +56,52 @@ describe('appendToolShelfMessage', () => {
|
|||
expect(merged).toEqual([{ kind: 'trail', role: 'system', text: '', thinking: 'plan', tools: ['one ✓', 'two ✓'] }])
|
||||
})
|
||||
|
||||
it('merges through intervening thinking-only rows back into the nearest holder', () => {
|
||||
const prev: Msg[] = [
|
||||
{ kind: 'trail', role: 'system', text: '', thinking: 'plan', tools: ['one ✓'] },
|
||||
{ kind: 'trail', role: 'system', text: '', thinking: 'more plan' }
|
||||
]
|
||||
|
||||
const merged = appendToolShelfMessage(prev, {
|
||||
kind: 'trail',
|
||||
role: 'system',
|
||||
text: '',
|
||||
tools: ['two ✓']
|
||||
})
|
||||
|
||||
expect(merged).toHaveLength(2)
|
||||
expect(merged[0]).toEqual({
|
||||
kind: 'trail',
|
||||
role: 'system',
|
||||
text: '',
|
||||
thinking: 'plan',
|
||||
tools: ['one ✓', 'two ✓']
|
||||
})
|
||||
expect(merged[1]).toEqual({ kind: 'trail', role: 'system', text: '', thinking: 'more plan' })
|
||||
})
|
||||
|
||||
it('collapses a chronological thinking/tool/thinking/tool stream into one shelf', () => {
|
||||
const events: Msg[] = [
|
||||
{ kind: 'trail', role: 'system', text: '', thinking: 'plan' },
|
||||
{ kind: 'trail', role: 'system', text: '', tools: ['one ✓'] },
|
||||
{ kind: 'trail', role: 'system', text: '', thinking: 'more plan' },
|
||||
{ kind: 'trail', role: 'system', text: '', tools: ['two ✓'] },
|
||||
{ kind: 'trail', role: 'system', text: '', tools: ['three ✓'] }
|
||||
]
|
||||
|
||||
const reduced = events.reduce<Msg[]>((acc, msg) => appendToolShelfMessage(acc, msg), [])
|
||||
|
||||
expect(reduced).toHaveLength(2)
|
||||
expect(reduced[0]).toEqual({
|
||||
kind: 'trail',
|
||||
role: 'system',
|
||||
text: '',
|
||||
thinking: 'plan',
|
||||
tools: ['one ✓', 'two ✓', 'three ✓']
|
||||
})
|
||||
expect(reduced[1]).toEqual({ kind: 'trail', role: 'system', text: '', thinking: 'more plan' })
|
||||
})
|
||||
|
||||
it('starts a new shelf across assistant text boundaries', () => {
|
||||
const merged = appendToolShelfMessage(
|
||||
[{ kind: 'trail', role: 'system', text: '', tools: ['one ✓'] }, { role: 'assistant', text: 'done' }],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue