fix: preserve interaction replies across chat recovery

This commit is contained in:
2026-10-29 17:53:33 +08:00
parent fbe273e90a
commit 52681a8451
38 changed files with 1623 additions and 314 deletions
+9
View File
@@ -7,6 +7,15 @@ import {
} from "../../src/routes/chatStreamRoute.js";
describe("task collaboration history", () => {
it("keeps accepted reply snapshots with both text and rich history", () => {
const reply = { type: "data-interaction_reply" as const, data: { interaction_id: "accepted-question" } };
for (const rich of [false, true]) {
const parts: UIMessage["parts"] = [{ type: "text", text: "核查范围: 北侧管网" }, reply,
...(rich ? [{ type: "data-final_answer" as const, data: { content: "核查范围: 北侧管网" } }] : [])];
const messages = [{ id: "reply", role: "user", parts: [...parts, { type: "data-progress", data: { title: "执行记录" } }] }] as unknown as UIMessage[];
expect(toCollaborationMessages(messages)).toEqual([{ id: "reply", role: "user", parts }]);
}
});
it("persists only user and assistant text instead of execution trajectory", () => {
const messages = [
{ id: "user-1", role: "user", parts: [{ type: "text", text: "为什么这样判断?" }] },