From bcb0269ef6d6e75785eab884303a4c6a78a75bb9 Mon Sep 17 00:00:00 2001 From: caoyawen Date: Fri, 30 Jan 2026 08:12:13 +0800 Subject: [PATCH] fix: support tool result image format in Control UI Add support for the backend tool result image format { type: "image", data: "base64...", mimeType: "image/png" } in the extractImages function. Previously, Control UI only recognized the Anthropic standard format with a nested source object. This fix allows browser screenshots and other tool-generated images to display correctly in the chat interface. Co-Authored-By: Claude Opus 4.5 --- ui/src/ui/chat/grouped-render.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/ui/chat/grouped-render.ts b/ui/src/ui/chat/grouped-render.ts index 4a9ccec14..a12029bb6 100644 --- a/ui/src/ui/chat/grouped-render.ts +++ b/ui/src/ui/chat/grouped-render.ts @@ -39,6 +39,14 @@ function extractImages(message: unknown): ImageBlock[] { ? data : `data:${mediaType};base64,${data}`; images.push({ url }); + } else if (typeof b.data === "string" && typeof b.mimeType === "string") { + // Handle tool result format: { type: "image", data: "base64...", mimeType: "image/png" } + const data = b.data as string; + const mimeType = b.mimeType as string; + const url = data.startsWith("data:") + ? data + : `data:${mimeType};base64,${data}`; + images.push({ url }); } else if (typeof b.url === "string") { images.push({ url: b.url }); }