debug: 添加图片检测日志
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
22b9ad0d70
commit
096faa257a
@ -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(
|
const hasImage = messageData.parts?.some(
|
||||||
(part: any) => part.type === "text" && part.text && (
|
(part: any) => part.type === "text" && part.text && (
|
||||||
part.text.includes("![thumb|") ||
|
part.text.includes("![thumb|") ||
|
||||||
@ -310,6 +313,8 @@ export function Chat({
|
|||||||
part.text.includes("![Generated Image")
|
part.text.includes("![Generated Image")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
console.log("[Chat] 🔍 hasImage check:", hasImage);
|
||||||
|
|
||||||
if (hasImage) {
|
if (hasImage) {
|
||||||
console.log("[Chat] 🎉 Image generated, hiding placeholder");
|
console.log("[Chat] 🎉 Image generated, hiding placeholder");
|
||||||
setIsGeneratingImageFlag(false);
|
setIsGeneratingImageFlag(false);
|
||||||
@ -351,6 +356,13 @@ export function Chat({
|
|||||||
// 🆕 生成完成,清除持久化状态
|
// 🆕 生成完成,清除持久化状态
|
||||||
completeGeneration();
|
completeGeneration();
|
||||||
console.log("[Chat] onFinish called");
|
console.log("[Chat] onFinish called");
|
||||||
|
|
||||||
|
// 🆕 刷新页面获取最新消息,确保 data-appendMessage 添加的消息不会丢失
|
||||||
|
// 延迟执行以确保所有状态更新完成
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("[Chat] Refreshing to sync messages from database");
|
||||||
|
router.refresh();
|
||||||
|
}, 500);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
if (error instanceof ChatSDKError) {
|
if (error instanceof ChatSDKError) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user