fix: show loading placeholder when streaming but last message is user message
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ddd0006f1e
commit
eca231575d
@ -126,8 +126,6 @@ function PureMessages({
|
||||
|
||||
// 控制等待动画延迟消失(Gemini 图片模型延迟 4 秒,其他模型 6 秒)
|
||||
const [showThinkingWithDelay, setShowThinkingWithDelay] = useState(false);
|
||||
// 🆕 记录占位图开始显示的时间,用于超时保护
|
||||
const thinkingStartTimeRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const lastMessage = messages.length > 0 ? messages[messages.length - 1] : null;
|
||||
@ -202,6 +200,13 @@ function PureMessages({
|
||||
setShowThinkingWithDelay(true);
|
||||
thinkingStartTimeRef.current = Date.now();
|
||||
}
|
||||
// 🆕 如果是 streaming 状态但最后一条是用户消息(还没有 AI 回复),也显示占位图
|
||||
else if (status === "streaming" && lastMessage?.role === "user") {
|
||||
setShowThinkingWithDelay(true);
|
||||
if (!thinkingStartTimeRef.current) {
|
||||
thinkingStartTimeRef.current = Date.now();
|
||||
}
|
||||
}
|
||||
// 如果是 streaming 状态且没有内容,显示
|
||||
else if (status === "streaming" && lastMessage?.role === "assistant" && !hasContent) {
|
||||
setShowThinkingWithDelay(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user