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 <noreply@anthropic.com>
This commit is contained in:
caoyawen 2026-01-30 08:12:13 +08:00
parent 4583f88626
commit bcb0269ef6

View File

@ -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 });
}