diff --git a/components/messages.tsx b/components/messages.tsx index 36b7e0007..b1c42e548 100644 --- a/components/messages.tsx +++ b/components/messages.tsx @@ -223,20 +223,30 @@ function PureMessages({ {/* 等待动画:根据模型类型显示不同的加载效果 */} {/* 🆕 支持恢复的生成状态(用户离开再返回) */} - {(showThinkingWithDelay || (pendingGeneration && status === "ready")) && ( - (() => { - // 优先使用恢复的状态,否则使用当前模型类型 - const modelType = pendingGeneration?.modelType; - const showGemini = modelType === "gemini" || (!modelType && isGeminiModel); - const showVolcano = modelType === "volcano-vision" || (!modelType && isVolcanoVisionModel); - const showVideo = modelType === "volcano-video" || modelType === "qianwen-video" || (!modelType && (isQianwenVideoModel || isVideoModel)); - - if (showVideo) return ; - if (showGemini) return ; - if (showVolcano) return ; - return ; - })() - )} + {(() => { + // 检查最后一条消息是否是用户消息(表示还在等待 AI 响应) + const lastMessage = messages.length > 0 ? messages[messages.length - 1] : null; + const isWaitingForResponse = lastMessage?.role === "user"; + + // 恢复的待处理状态:有 pendingGeneration 且最后一条是用户消息 + const hasRestoredPending = pendingGeneration && isWaitingForResponse; + + // 显示条件:正常等待动画 或 恢复的待处理状态 + const shouldShow = showThinkingWithDelay || hasRestoredPending; + + if (!shouldShow) return null; + + // 优先使用恢复的状态,否则使用当前模型类型 + const modelType = pendingGeneration?.modelType; + const showGemini = modelType === "gemini" || (!modelType && isGeminiModel); + const showVolcano = modelType === "volcano-vision" || (!modelType && isVolcanoVisionModel); + const showVideo = modelType === "volcano-video" || modelType === "qianwen-video" || (!modelType && (isQianwenVideoModel || isVideoModel)); + + if (showVideo) return ; + if (showGemini) return ; + if (showVolcano) return ; + return ; + })()}