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

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
+23
View File
@@ -4,6 +4,15 @@ import { config } from "@config/config";
export type StreamEvent =
| { type: "token"; sessionId: string; content: string }
| { type: "done"; sessionId: string }
| {
type: "progress";
sessionId: string;
id: string;
phase: string;
status: "running" | "completed" | "error";
title: string;
detail?: string;
}
| {
type: "error";
sessionId?: string;
@@ -121,6 +130,10 @@ export const streamAgentChat = async ({
detail?: string;
tool?: string;
params?: Record<string, unknown>;
id?: string;
phase?: string;
status?: "running" | "completed" | "error";
title?: string;
};
if (event === "token") {
onEvent({
@@ -128,6 +141,16 @@ export const streamAgentChat = async ({
sessionId: parsed.session_id ?? "",
content: parsed.content ?? "",
});
} else if (event === "progress") {
onEvent({
type: "progress",
sessionId: parsed.session_id ?? "",
id: parsed.id ?? `${parsed.phase ?? "progress"}-${Date.now()}`,
phase: parsed.phase ?? "progress",
status: parsed.status ?? "running",
title: parsed.title ?? "正在处理",
detail: parsed.detail,
});
} else if (event === "done") {
onEvent({
type: "done",