From 85d5703a3b1b47243213a39059a6e3076c92733a Mon Sep 17 00:00:00 2001 From: nachobh Date: Fri, 4 Sep 2026 19:53:16 +0200 Subject: [PATCH] ui : fix MCP image attachments not displayed in tool block (#25789) (#28089) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ui : fix MCP image attachments not displayed in tool block (#25789) Fixes regression from #25450 where ChatMessageAgenticContent passed message.extra instead of section.toolResultExtras to tool blocks, leaving tool images invisible. Also fixes TOOL_RESULT_JSON_OPEN_REGEX which misclassified "[Attachment saved: ...]" as JSON. Fixes #25789 Assisted-by: Muse Spark * Addressed PR comments: 1.- Removed ·?? mesage?extra· as it has no case left to cover 2.- Added ·[\· to cover the case of ·[[1, 2], [3, 4]]· case suggested in the PR comment 3.- Added unit test for covering up this regex case * ui : fix MCP image attachments not displayed in tool block (ggml-org#25789) - Addressed lint error on regex (redundant \) --- .../app/chat/ChatMessages/ChatMessageAgenticContent.svelte | 2 +- tools/ui/src/lib/constants/agentic.constants.ts | 7 +++++-- tools/ui/tests/unit/classify-tool-result.test.ts | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte b/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte index 011d1fbeb..5137e261f 100644 --- a/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte @@ -194,7 +194,7 @@ /> {:else if section.type === AgenticSectionType.TOOL_CALL || section.type === AgenticSectionType.TOOL_CALL_PENDING || section.type === AgenticSectionType.TOOL_CALL_STREAMING} diff --git a/tools/ui/tests/unit/classify-tool-result.test.ts b/tools/ui/tests/unit/classify-tool-result.test.ts index 6147dee67..23e9baaf3 100644 --- a/tools/ui/tests/unit/classify-tool-result.test.ts +++ b/tools/ui/tests/unit/classify-tool-result.test.ts @@ -37,6 +37,10 @@ describe('classifyToolResult', () => { expect(classifyToolResult('["a", "b", "c"]')).toBe('json'); }); + it('classifies a nested JSON array', () => { + expect(classifyToolResult('[[1, 2], [3, 4]]')).toBe('json'); + }); + it('classifies a pretty-printed JSON object', () => { expect(classifyToolResult('{\n "key": "value"\n}')).toBe('json'); });