From fcba8b86d5e42a3959c216f64575830431e53e54 Mon Sep 17 00:00:00 2001 From: Felix <24791380+vcfgv@users.noreply.github.com> Date: Wed, 11 Feb 2026 17:10:53 +0800 Subject: [PATCH] fix(chat): improve message handling, fix type errors and migrate changes to enhance branch (#50) --- src/pages/Chat/ChatMessage.tsx | 90 ++++++++-- src/pages/Chat/ChatToolbar.tsx | 4 +- src/pages/Chat/index.tsx | 49 ++++-- src/pages/Chat/message-utils.ts | 27 +-- src/stores/chat.ts | 291 +++++++++++++++++++++++++++++--- 5 files changed, 395 insertions(+), 66 deletions(-) diff --git a/src/pages/Chat/ChatMessage.tsx b/src/pages/Chat/ChatMessage.tsx index d84c09cf4..2fb2b43d9 100644 --- a/src/pages/Chat/ChatMessage.tsx +++ b/src/pages/Chat/ChatMessage.tsx @@ -16,25 +16,38 @@ interface ChatMessageProps { message: RawMessage; showThinking: boolean; isStreaming?: boolean; + streamingTools?: Array<{ + id?: string; + toolCallId?: string; + name: string; + status: 'running' | 'completed' | 'error'; + durationMs?: number; + summary?: string; + }>; } export const ChatMessage = memo(function ChatMessage({ message, showThinking, isStreaming = false, + streamingTools = [], }: ChatMessageProps) { const isUser = message.role === 'user'; - const isToolResult = message.role === 'toolresult'; + const role = typeof message.role === 'string' ? message.role.toLowerCase() : ''; + const isToolResult = role === 'toolresult' || role === 'tool_result'; const text = extractText(message); + const hasText = text.trim().length > 0; const thinking = extractThinking(message); const images = extractImages(message); const tools = extractToolUse(message); + const visibleThinking = showThinking ? thinking : null; + const visibleTools = showThinking ? tools : []; - // Don't render empty tool results when thinking is hidden - if (isToolResult && !showThinking) return null; + // Never render tool result messages in chat UI + if (isToolResult) return null; // Don't render empty messages - if (!text && !thinking && images.length === 0 && tools.length === 0) return null; + if (!hasText && !visibleThinking && images.length === 0 && visibleTools.length === 0) return null; return (