From 096faa257aeaa64bc7d7e43477302b31c6e685aa Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 1 Feb 2026 03:09:03 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=B7=BB=E5=8A=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/chat.tsx b/components/chat.tsx index 05b56a0..d3a03b9 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -303,6 +303,9 @@ export function Chat({ } // 🆕 检测是否包含图片(生成完成) + const messageText = messageData.parts?.[0]?.text || ""; + console.log("[Chat] 📝 Message text preview:", messageText.substring(0, 100)); + const hasImage = messageData.parts?.some( (part: any) => part.type === "text" && part.text && ( part.text.includes("![thumb|") || @@ -310,6 +313,8 @@ export function Chat({ part.text.includes("![Generated Image") ) ); + console.log("[Chat] 🔍 hasImage check:", hasImage); + if (hasImage) { console.log("[Chat] 🎉 Image generated, hiding placeholder"); setIsGeneratingImageFlag(false); @@ -351,6 +356,13 @@ export function Chat({ // 🆕 生成完成,清除持久化状态 completeGeneration(); console.log("[Chat] onFinish called"); + + // 🆕 刷新页面获取最新消息,确保 data-appendMessage 添加的消息不会丢失 + // 延迟执行以确保所有状态更新完成 + setTimeout(() => { + console.log("[Chat] Refreshing to sync messages from database"); + router.refresh(); + }, 500); }, onError: (error) => { if (error instanceof ChatSDKError) {