添加进度面板,优化消息处理逻辑

This commit is contained in:
2026-04-29 16:55:14 +08:00
parent 30d85173ee
commit 2c1afdc97c
6 changed files with 174 additions and 3 deletions
+32 -1
View File
@@ -316,10 +316,41 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
content: "⚠️ **错误:** Agent 未返回内容,请稍后重试。",
isError: true,
}
: m
: m.id === assistantId
? {
...m,
progress: m.progress?.map((item) =>
item.status === "running"
? { ...item, status: "completed" as const }
: item,
),
}
: m
)
);
setIsStreaming(false);
} else if (event.type === "progress") {
if (!sessionId && event.sessionId) setSessionId(event.sessionId);
setMessages((prev) =>
prev.map((m) => {
if (m.id !== assistantId) return m;
const progress = [...(m.progress ?? [])];
const index = progress.findIndex((item) => item.id === event.id);
const nextProgress = {
id: event.id,
phase: event.phase,
status: event.status,
title: event.title,
detail: event.detail,
};
if (index >= 0) {
progress[index] = nextProgress;
} else {
progress.push(nextProgress);
}
return { ...m, progress };
})
);
} else if (event.type === "error") {
setMessages((prev) =>
prev.map((m) =>