diff --git a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts index 517b2be0c2..22a6b281f9 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 847f82b7c6..35c412f6bb 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