From ed4c2fe8cd9ad0a85dcde7cddfbe77189c9f78b2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Feb 2026 02:40:45 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=BF=BD=E8=B8=AA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- components/chat.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/chat.tsx b/components/chat.tsx index b1474a8..429c2a4 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -294,7 +294,13 @@ export function Chat({ completeGeneration(); setMessages((prevMessages) => { + console.log("[Chat] 📋 setMessages 调用前:", prevMessages.map(m => ({ + id: m.id?.substring(0, 8), + role: m.role + }))); + if (prevMessages.some(m => m.id === messageData.id)) { + console.log("[Chat] ⚠️ 消息已存在,跳过"); return prevMessages; } @@ -309,7 +315,12 @@ export function Chat({ attachments: [], }; - return [...prevMessages, newMessage]; + const newMessages = [...prevMessages, newMessage]; + console.log("[Chat] 📋 setMessages 调用后:", newMessages.map(m => ({ + id: m.id?.substring(0, 8), + role: m.role + }))); + return newMessages; }); } catch (e) { console.error("[Chat] Failed to parse data-appendMessage:", e);