From eab29b54a0fd4d403dc7ce9ff73238564112c187 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 29 Oct 2025 12:29:38 +0800 Subject: [PATCH] fix(ai-chat): optimize result rendering in ToolInvocationComponent --- .../components/message/ToolInvocationComponent.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/ToolInvocationComponent.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/ToolInvocationComponent.tsx index cfd2311ad..40ea3bc94 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/ToolInvocationComponent.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/message/ToolInvocationComponent.tsx @@ -25,6 +25,17 @@ export const ToolInvocationComponent: React.FC = R // Generate a unique value for this accordion item const accordionValue = `tool-${"toolCallId" in part ? part.toolCallId : Math.random()}` + const result = React.useMemo(() => { + if (hasResult) { + const string = JSON.stringify(part.output, null, 2) + if (string.length > 1000) { + return `${string.slice(0, 1000)}\n...` + } else { + return string + } + } + }, [hasResult, part]) + return (
= R
Result:
) : null}