fix(chat): 重新生成前撤销旧消息
Build Push and Deploy / docker-image (push) Successful in 1m47s
Build Push and Deploy / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-06-08 14:38:52 +08:00
parent f7cd5ebfa7
commit 40cc355fff
5 changed files with 45 additions and 7 deletions
@@ -521,4 +521,33 @@ describe("useAgentChatSession", () => {
expect.anything(),
);
});
it("asks the backend to undo the previous user turn before regenerating", async () => {
listChatSessions.mockResolvedValue([]);
const { result } = renderHook(() =>
useAgentChatSession({
projectId: "project-1",
onToolCall: jest.fn(),
}),
);
await waitFor(() => expect(result.current.isHydrating).toBe(false));
await act(async () => {
await result.current.sendPrompt("重新分析压力异常");
});
await act(async () => {
await result.current.regenerate();
});
expect(streamAgentChat).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
message: "重新分析压力异常",
regenerateFromMessageIndex: 0,
}),
);
});
});