🐛 fix(ai-chat): 修复重新生成时缺少状态过渡动画的问题

- handleRetryMessage 补齐 connecting 过渡消息(波纹动画),与 handleSend 流程一致
- 重试时同步重置工具调用计数器,防止继承旧计数导致过早熔断
This commit is contained in:
Syngnat
2026-04-02 10:56:27 +08:00
parent 9eb42565f1
commit b022cd63e5
4 changed files with 14 additions and 0 deletions

View File

@@ -674,7 +674,21 @@ export const AIChatPanel: React.FC<AIChatPanelProps> = ({
if (lastUserMsgIndex >= 0) {
const userMsg = historyLocal[lastUserMsgIndex];
truncateAIChatMessages(sid, userMsg.id);
// 重置计数器(与 handleSend 保持一致)
toolCallRoundRef.current = 0;
totalToolRoundRef.current = 0;
nudgeCountRef.current = 0;
setSending(true);
// 插入 connecting 过渡消息(波纹动画),与 handleSend 保持一致
const connectingMsg: AIChatMessage = {
id: genId(), role: 'assistant', phase: 'connecting', content: '',
timestamp: Date.now(), loading: true
};
addAIChatMessage(sid, connectingMsg);
const truncatedHistory = historyLocal.slice(0, lastUserMsgIndex + 1);
const messagesPayload = truncatedHistory.map(m => ({ role: m.role, content: m.content, images: m.images }));