From 16a5ed9a739ef9c1073f88f49ebd73a36bae9252 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Fri, 16 Jan 2026 23:15:53 +0800 Subject: [PATCH] fix: fix broken when SSE --- .../workspace/message-list/message-group.tsx | 23 ++++++++----------- .../message-list/present-file-list.tsx | 2 +- frontend/src/core/messages/utils.ts | 7 ++++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/workspace/message-list/message-group.tsx b/frontend/src/components/workspace/message-list/message-group.tsx index 3c849b9..8f5f926 100644 --- a/frontend/src/components/workspace/message-list/message-group.tsx +++ b/frontend/src/components/workspace/message-list/message-group.tsx @@ -222,19 +222,16 @@ function ToolCall({ ); } else if (name === "present_files") { return ( - 1 ? "s" : ""}`} - icon={FileTextIcon} - > + - {(args as { filepaths: string[] }).filepaths.map( - (filepath: string) => ( - - {filepath} - - ), - )} + {Array.isArray((args as { filepaths: string[] }).filepaths) && + (args as { filepaths: string[] }).filepaths.map( + (filepath: string) => ( + + {filepath} + + ), + )} ); @@ -344,7 +341,7 @@ function describeStep(step: CoTStep | undefined): { label = "Execute command"; icon = ; } else if (step.name === "present_files") { - label = `Present file${(step.args as { filepaths: string[] }).filepaths.length > 1 ? "s" : ""}`; + label = "Present files"; icon = ; } else { label = `Call tool "${step.name}"`; diff --git a/frontend/src/components/workspace/message-list/present-file-list.tsx b/frontend/src/components/workspace/message-list/present-file-list.tsx index 2d5f143..314c4df 100644 --- a/frontend/src/components/workspace/message-list/present-file-list.tsx +++ b/frontend/src/components/workspace/message-list/present-file-list.tsx @@ -12,7 +12,7 @@ import { getFileExtension, getFileName } from "@/core/utils/files"; export function PresentFileList({ files }: { files: string[] }) { return ( -
    +
      {files.map((file) => ( diff --git a/frontend/src/core/messages/utils.ts b/frontend/src/core/messages/utils.ts index 2d35c88..bfa8f80 100644 --- a/frontend/src/core/messages/utils.ts +++ b/frontend/src/core/messages/utils.ts @@ -159,9 +159,12 @@ export function extractPresentFilesFromMessage(message: Message) { if (message.type !== "ai" || !hasPresentFiles(message)) { return []; } - const files = []; + const files: string[] = []; for (const toolCall of message.tool_calls ?? []) { - if (toolCall.name === "present_files") { + if ( + toolCall.name === "present_files" && + Array.isArray(toolCall.args.filepaths) + ) { files.push(...(toolCall.args.filepaths as string[])); } }