mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
fix(tui): keep inline diffs below tool rows and strip ANSI
Follow-up on #13729 from blitz screenshot feedback.\n\n- When tool.complete carried inline_diff but no buffered assistant text existed, pending tool rows were still in streamPendingTools, so diff rendered above the tool row section. appendSegmentMessage now emits pending tool rows as a trail segment before appending the diff artifact.\n- Strip ANSI color escapes from inline_diff payloads so we don't render loud red/green terminal palettes in the transcript.
This commit is contained in:
parent
dff1c8fcf1
commit
bddf0cd61e
3 changed files with 28 additions and 7 deletions
|
|
@ -146,7 +146,8 @@ describe('createGatewayEventHandler', () => {
|
|||
it('routes inline_diff into the active segment stream, not historyItems', () => {
|
||||
const appended: Msg[] = []
|
||||
const onEvent = createGatewayEventHandler(buildCtx(appended))
|
||||
const diff = '--- a/foo.ts\n+++ b/foo.ts\n@@\n-old\n+new'
|
||||
const diff = '\u001b[31m--- a/foo.ts\u001b[0m\n\u001b[32m+++ b/foo.ts\u001b[0m\n@@\n-old\n+new'
|
||||
const cleaned = '--- a/foo.ts\n+++ b/foo.ts\n@@\n-old\n+new'
|
||||
|
||||
onEvent({
|
||||
payload: { context: 'foo.ts', name: 'patch', tool_id: 'tool-1' },
|
||||
|
|
@ -161,7 +162,10 @@ describe('createGatewayEventHandler', () => {
|
|||
// held in segmentMessages so the transcript renders it inline with the
|
||||
// current turn rather than above it.
|
||||
expect(appended).toHaveLength(0)
|
||||
expect(turnController.segmentMessages).toContainEqual({ role: 'system', text: diff })
|
||||
expect(turnController.segmentMessages).toContainEqual(
|
||||
expect.objectContaining({ kind: 'trail', role: 'system', text: '' })
|
||||
)
|
||||
expect(turnController.segmentMessages).toContainEqual({ role: 'system', text: cleaned })
|
||||
|
||||
onEvent({
|
||||
payload: { text: 'patch applied' },
|
||||
|
|
@ -170,9 +174,10 @@ describe('createGatewayEventHandler', () => {
|
|||
|
||||
// After the turn closes, the diff lands in history in the order the
|
||||
// gateway emitted it — before the assistant's final text, not above it.
|
||||
expect(appended).toHaveLength(2)
|
||||
expect(appended[0]).toMatchObject({ role: 'system', text: diff })
|
||||
expect(appended[1]).toMatchObject({ role: 'assistant', text: 'patch applied' })
|
||||
expect(appended).toHaveLength(3)
|
||||
expect(appended[0]).toMatchObject({ kind: 'trail', role: 'system', text: '' })
|
||||
expect(appended[1]).toMatchObject({ role: 'system', text: cleaned })
|
||||
expect(appended[2]).toMatchObject({ role: 'assistant', text: 'patch applied' })
|
||||
})
|
||||
|
||||
it('shows setup panel for missing provider startup error', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue