From 3732d65784b7c798ecb150c0fa836cb78c6db376 Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 24 Sep 2025 14:07:52 +0800 Subject: [PATCH] fix(ai-chat): enhance tool part handling in AIMessageParts component - Updated the AIMessageParts component to improve handling of tool-related message parts by modifying the condition to check for "tool-" prefix. - Introduced the ToolInvocationComponent for rendering tool-specific parts, enhancing the modularity and clarity of the message display logic. These changes aim to streamline the integration of tool functionalities within the AI chat interface, improving user experience and maintainability. Signed-off-by: Innei --- .../ai-chat/components/message/AIMessageParts.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx index 2ac82af46..4fe56559f 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/AIMessageParts.tsx @@ -22,6 +22,7 @@ import { AIDisplaySubscriptionsPart, } from "../displays" import { AIMarkdownStreamingMessage } from "./AIMarkdownMessage" +import { ToolInvocationComponent } from "./ToolInvocationComponent" const LazyAIDisplayFlowPart = React.lazy(() => import("../displays/AIDisplayFlowPart").then((mod) => ({ default: mod.AIDisplayFlowPart })), @@ -60,7 +61,7 @@ export const AIMessageParts: React.FC = React.memo( } if (part.type === "text") { parts.push(part) - } else if (part.type.startsWith("tool-display")) { + } else if (part.type.startsWith("tool-")) { parts.push(part as ToolUIPart) } else if (part.type === "reasoning" && part.text) { mergedReasoningParts.push(part as ReasoningUIPart) @@ -143,6 +144,12 @@ export const AIMessageParts: React.FC = React.memo( } default: { + if (part.type.startsWith("tool-")) { + return ( + } /> + ) + } + return null } }