From e684afa1519c1ef3956861217a0c0b42fe4c84f7 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 21 Apr 2026 19:13:15 -0500 Subject: [PATCH] fix(tui): keep review-diff tool rows terse When tool.complete already carries inline_diff, the assistant message owns the full diff block. Suppress the tool-row summary/detail in that case so the turn shows one detailed diff surface instead of a rich diff plus a duplicated tool-detail payload. --- .../createGatewayEventHandler.test.ts | 20 +++++++++++++++++++ ui-tui/src/app/createGatewayEventHandler.ts | 18 ++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts index 517b2be0c..22a6b281f 100644 --- a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts +++ b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts @@ -195,6 +195,26 @@ describe('createGatewayEventHandler', () => { expect((appended[0]?.text.match(/```diff/g) ?? []).length).toBe(1) }) + it('keeps tool trail terse when inline_diff is present', () => { + const appended: Msg[] = [] + const onEvent = createGatewayEventHandler(buildCtx(appended)) + const diff = '--- a/foo.ts\n+++ b/foo.ts\n@@\n-old\n+new' + + onEvent({ + payload: { inline_diff: diff, name: 'review_diff', summary: diff, tool_id: 'tool-1' }, + type: 'tool.complete' + } as any) + onEvent({ + payload: { text: 'done' }, + type: 'message.complete' + } as any) + + expect(appended).toHaveLength(1) + expect(appended[0]?.tools?.[0]).toContain('Review Diff') + expect(appended[0]?.tools?.[0]).not.toContain('--- a/foo.ts') + expect(appended[0]?.text).toContain('```diff') + }) + it('shows setup panel for missing provider startup error', () => { const appended: Msg[] = [] const onEvent = createGatewayEventHandler(buildCtx(appended)) diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts index 847f82b7c..35c412f6b 100644 --- a/ui-tui/src/app/createGatewayEventHandler.ts +++ b/ui-tui/src/app/createGatewayEventHandler.ts @@ -263,19 +263,27 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev: return case 'tool.complete': - turnController.recordToolComplete(ev.payload.tool_id, ev.payload.name, ev.payload.error, ev.payload.summary) + { + const inlineDiffText = + ev.payload.inline_diff && getUiState().inlineDiffs ? stripAnsi(String(ev.payload.inline_diff)).trim() : '' - if (ev.payload.inline_diff && getUiState().inlineDiffs) { - const diffText = stripAnsi(String(ev.payload.inline_diff)) + turnController.recordToolComplete( + ev.payload.tool_id, + ev.payload.name, + ev.payload.error, + inlineDiffText ? '' : ev.payload.summary + ) - if (!diffText.trim()) { + if (!inlineDiffText) { return } // Keep inline diffs attached to the assistant completion body so // they render in the same message flow, not as a standalone system // artifact that can look out-of-place around tool rows. - turnController.queueInlineDiff(diffText) + turnController.queueInlineDiff(inlineDiffText) + + return } return