重建会话记录逻辑

This commit is contained in:
2026-06-04 15:26:23 +08:00
parent 0ecb2babf3
commit 0188240d62
9 changed files with 375 additions and 42 deletions
+33
View File
@@ -135,4 +135,37 @@ describe("SessionTranscriptStore", () => {
expect(forkRecentTurns).toHaveLength(1);
expect(forkRecentTurns[0]?.assistantMessage).toBe("第一轮回复");
});
it("does not duplicate the latest turn when the frontend state is saved again", async () => {
await store.appendTurn(
{
actorKey: "actor-3",
clientSessionId: "thread-3",
projectKey: "project-3",
sessionId: "thread-3",
},
{
assistantMessage: "已完成压力波动分析。",
toolCallCount: 1,
userMessage: "分析压力波动。",
},
);
const transcript = await store.appendTurn(
{
actorKey: "actor-3",
clientSessionId: "thread-3",
projectKey: "project-3",
sessionId: "thread-3",
},
{
assistantMessage: "已完成压力波动分析。",
toolCallCount: 2,
userMessage: "分析压力波动。",
},
);
expect(transcript.turns).toHaveLength(1);
expect(transcript.turns[0]?.toolCallCount).toBe(2);
});
});