diff --git a/src/components/ai-edition/LeftPanel.copyMessage.test.tsx b/src/components/ai-edition/LeftPanel.copyMessage.test.tsx index 3c39fdfae..d9c3d061c 100644 --- a/src/components/ai-edition/LeftPanel.copyMessage.test.tsx +++ b/src/components/ai-edition/LeftPanel.copyMessage.test.tsx @@ -249,3 +249,15 @@ describe("ChatStripPanel Copy message (issue #738)", () => { expect(toastError).not.toHaveBeenCalled(); }); }); + +describe("ChatStripPanel message time (#1134)", () => { + it("shows a stored message's time as a clock time, never as the raw ISO string", async () => { + stubClipboard(copyToClipboard); + const view = await renderPanelWithAssistantMessage(); + + // The main process stores every message with an ISO `createdAt`. A session loaded from it, + // like the one a first message creates, used to print that string as is. + expect(view.container.textContent).not.toContain("2026-09-23T00:00:01"); + expect(view.getByText(new Date("2026-09-23T00:00:01Z").toLocaleTimeString())).toBeTruthy(); + }); +}); diff --git a/src/components/ai-edition/LeftPanel.tsx b/src/components/ai-edition/LeftPanel.tsx index 3a490a772..84c5227b7 100644 --- a/src/components/ai-edition/LeftPanel.tsx +++ b/src/components/ai-edition/LeftPanel.tsx @@ -34,6 +34,7 @@ interface ChatDisplayMessage { id?: string; role: string; content: string; + /** ISO timestamp, as the main process stores it; formatted only where it is drawn (#1134). */ time?: string; toolCalls?: AiEditionToolCallSummary[]; // ponytail: axcut parity — non-null on user messages that have a @@ -46,6 +47,12 @@ interface ChatDisplayMessage { thinking?: string; } +/** A message's clock time; a stored value that is no date is shown as stored. */ +function formatMessageTime(time: string): string { + const date = new Date(time); + return Number.isNaN(date.getTime()) ? time : date.toLocaleTimeString(); +} + // Quick-access model picker anchored to the composer's model pill — mirrors // axcut's LlmPopover in "models"/"providers" mode (a lightweight popover, not // the full AI-settings modal). "Provider settings…" in the providers screen @@ -601,7 +608,7 @@ export function ChatStripPanel() { id: optimisticUserId, role: "user", content: text, - time: new Date().toLocaleTimeString(), + time: new Date().toISOString(), checkpointId: optimisticUserId, }, ]); @@ -672,7 +679,7 @@ export function ChatStripPanel() { { role: "assistant", content: assistant.content, - time: new Date().toLocaleTimeString(), + time: new Date().toISOString(), toolCalls: assistant.toolCalls, // ponytail: snapshot the live reasoning trace onto the // finished message so it can be revisited (collapsed by @@ -1263,7 +1270,7 @@ export function ChatStripPanel() { color: "var(--muted)", }} > - {m.time} + {formatMessageTime(m.time)} ) : null}