From 1a3460ba0650171c3be5c64cad68ca1edf991602 Mon Sep 17 00:00:00 2001 From: Hiep Le <69354317+hieptl@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:22:14 +0700 Subject: [PATCH] fix(frontend): image attachments not working in v1 conversations (#11864) --- .../v1-conversation-service.types.ts | 18 +++++++++++------- frontend/src/hooks/use-send-message.ts | 10 ++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/frontend/src/api/conversation-service/v1-conversation-service.types.ts b/frontend/src/api/conversation-service/v1-conversation-service.types.ts index 789925047d..621283c274 100644 --- a/frontend/src/api/conversation-service/v1-conversation-service.types.ts +++ b/frontend/src/api/conversation-service/v1-conversation-service.types.ts @@ -3,15 +3,19 @@ import { Provider } from "#/types/settings"; import { V1SandboxStatus } from "../sandbox-service/sandbox-service.types"; // V1 API Types for requests -// Note: This represents the serialized API format, not the internal TextContent/ImageContent types -export interface V1MessageContent { - type: "text" | "image_url"; - text?: string; - image_url?: { - url: string; - }; +// These types match the SDK's TextContent and ImageContent formats +export interface V1TextContent { + type: "text"; + text: string; } +export interface V1ImageContent { + type: "image"; + image_urls: string[]; +} + +export type V1MessageContent = V1TextContent | V1ImageContent; + type V1Role = "user" | "system" | "assistant" | "tool"; export interface V1SendMessageRequest { diff --git a/frontend/src/hooks/use-send-message.ts b/frontend/src/hooks/use-send-message.ts index 1e1d627181..c6655b8230 100644 --- a/frontend/src/hooks/use-send-message.ts +++ b/frontend/src/hooks/use-send-message.ts @@ -41,13 +41,11 @@ export function useSendMessage() { }, ]; - // Add images if present + // Add images if present - using SDK's ImageContent format if (args.image_urls && args.image_urls.length > 0) { - args.image_urls.forEach((url) => { - content.push({ - type: "image_url", - image_url: { url }, - }); + content.push({ + type: "image", + image_urls: args.image_urls, }); }