fix(cli): normalise les timestamps chat secondes/ms pour l'heure des messages — #221

This commit is contained in:
2026-08-15 22:21:00 +02:00
parent d9172a11ae
commit 6a4787e814
2 changed files with 96 additions and 4 deletions

View File

@ -288,6 +288,66 @@ describe("CustomAgentChatView", () => {
}
});
it("replays scrollback with the current reception time instead of the reduce index", async () => {
const replayReceivedAtMs = new Date("2026-08-15T13:08:00.000Z").getTime();
const indexOneTime = expectedChatTime(1);
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(replayReceivedAtMs);
const agent = {
launchAgentChat: vi.fn(),
reattachAgentChat: vi.fn(async (sessionId: string) => ({
sessionId,
scrollback: [
{ kind: "userPrompt" as const, text: "Replay prompt" },
{ kind: "textDelta" as const, text: "Replay answer" },
{ kind: "final" as const, content: "Replay completed" },
],
})),
sendAgentChat: vi.fn(async () => {}),
cancelAgentChat: vi.fn(async () => {}),
closeAgentChat: vi.fn(async () => {}),
};
try {
render(
<DIProvider
gateways={{
agent,
system: { pickFile: vi.fn(async () => null) },
} as unknown as Gateways}
>
<CustomAgentChatView
projectId="project-1"
agentId="agent-1"
agentName="Worker"
profile={profile}
cwd="/repo"
nodeId="node-1"
sessionId="chat-session-1"
conversationId="conversation-1"
onSessionId={vi.fn()}
onConversationId={vi.fn()}
/>
</DIProvider>,
);
const agentBubble = (await screen.findByText("Replay answer")).closest("div");
const finalBubble = screen.getByText("Replay completed").closest("div");
expect(agentBubble).toBeTruthy();
expect(finalBubble).toBeTruthy();
expect(
within(agentBubble!).getByText(expectedChatTime(replayReceivedAtMs)),
).toBeTruthy();
expect(
within(finalBubble!).getByText(expectedChatTime(replayReceivedAtMs)),
).toBeTruthy();
expect(within(agentBubble!).queryByText(indexOneTime)).toBeNull();
expect(within(finalBubble!).queryByText(indexOneTime)).toBeNull();
} finally {
nowSpy.mockRestore();
}
});
it("resizes the composer vertically with mouse, keyboard, and double-click reset", async () => {
const rectSpy = vi
.spyOn(HTMLElement.prototype, "getBoundingClientRect")