优化历史会话排序逻辑,按首条消息时间排序
Build Push and Deploy / docker-image (push) Failing after 41s
Build Push and Deploy / deploy-fallback-log (push) Successful in 0s

This commit is contained in:
2026-05-19 16:48:56 +08:00
parent 9106b8d4a9
commit 2fbfba118f
3 changed files with 79 additions and 18 deletions
+30 -1
View File
@@ -33,8 +33,37 @@ describe("AgentHistoryPanel", () => {
fireEvent.change(screen.getByPlaceholderText("请输入会话标题"), {
target: { value: "新的会话标题" },
});
fireEvent.click(screen.getByLabelText("确认修改历史会话标题"));
fireEvent.click(screen.getByLabelText("确认"));
expect(onRenameSession).toHaveBeenCalledWith("session-1", "新的会话标题");
});
it("orders history by the first message time instead of the latest update time", () => {
renderWithTheme(
<AgentHistoryPanel
sessions={[
{
id: "session-newer-update",
title: "较新的更新",
createdAt: new Date("2026-05-18T09:00:00+08:00").getTime(),
updatedAt: new Date("2026-05-19T12:00:00+08:00").getTime(),
},
{
id: "session-newer-first-message",
title: "较新的首条消息",
createdAt: new Date("2026-05-19T08:00:00+08:00").getTime(),
updatedAt: new Date("2026-05-19T08:30:00+08:00").getTime(),
},
]}
onNewSession={jest.fn()}
onRenameSession={jest.fn()}
onSelectSession={jest.fn()}
onDeleteSession={jest.fn()}
/>,
);
const sessionTitles = screen.getAllByText(/较新的/).map((element) => element.textContent);
expect(sessionTitles).toEqual(["较新的首条消息", "较新的更新"]);
});
});