diff --git a/apps/web/components/task/chat/messages/message-actions.test.tsx b/apps/web/components/task/chat/messages/message-actions.test.tsx index e96867583f..377252c3b1 100644 --- a/apps/web/components/task/chat/messages/message-actions.test.tsx +++ b/apps/web/components/task/chat/messages/message-actions.test.tsx @@ -98,6 +98,21 @@ describe("MessageActions timestamp tooltip", () => { expect(timeEl?.getAttribute("title")).toBe(new Date(MESSAGE_TIMESTAMP).toLocaleString()); }); + it.each(["", "not-a-date", "0", "2026-02-30T10:00:00Z"])( + "omits the timestamp affordance for invalid created_at value %j", + (createdAt) => { + const { container } = render( + + + , + ); + + expect(container.querySelector("time")).toBeNull(); + expect(container.textContent).not.toContain("Invalid Date"); + expect(screen.getByRole("button", { name: /copy message to clipboard/i })).toBeTruthy(); + }, + ); + it("omits the timestamp element entirely when showTimestamp is false", () => { const { container } = render( diff --git a/apps/web/components/task/chat/messages/message-actions.tsx b/apps/web/components/task/chat/messages/message-actions.tsx index b240bba6bc..8700cdfbcc 100644 --- a/apps/web/components/task/chat/messages/message-actions.tsx +++ b/apps/web/components/task/chat/messages/message-actions.tsx @@ -15,6 +15,7 @@ import { } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; import { formatRelativeTime } from "@/lib/utils"; +import { parseStrictRfc3339Timestamp } from "@/lib/utils/strict-timestamp"; import { formatPromptDuration, messageTurnDurationSeconds } from "@/lib/prompt-history"; import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"; import { useAppStore } from "@/components/state-provider"; @@ -247,7 +248,9 @@ function MessageTimestamp({ createdAt }: { createdAt: string }) { const { t } = useTranslation(); const usesTouchDrawer = useTouchDrawer(); const [open, setOpen] = useState(false); - const absoluteTime = new Date(createdAt).toLocaleString(); + if (parseStrictRfc3339Timestamp(createdAt) === null) return null; + const date = new Date(createdAt); + const absoluteTime = date.toLocaleString(); const timeEl = (