feat(chat): render timestamp under assistant messages and reuse shared formatter

This commit is contained in:
CREDO23 2026-07-13 23:12:07 +02:00
parent 0093664fd1
commit 855f824097

View file

@ -35,6 +35,7 @@ import {
useAllCitationMetadata,
} from "@/components/assistant-ui/citation-metadata-context";
import { MarkdownText } from "@/components/assistant-ui/markdown-text";
import { MessageTimestamp } from "@/components/assistant-ui/message-timestamp";
import { ReasoningMessagePart } from "@/components/assistant-ui/reasoning-message-part";
import { RevertTurnButton } from "@/components/assistant-ui/revert-turn-button";
import {
@ -62,6 +63,7 @@ import { withArtifactAnchor } from "@/features/chat-artifacts";
import { useComments } from "@/hooks/use-comments";
import { useMediaQuery } from "@/hooks/use-media-query";
import { useElectronAPI } from "@/hooks/use-platform";
import { formatMessageTimestamp } from "@/lib/format-date";
import { getProviderIcon } from "@/lib/provider-icons";
import { tryGetHostname } from "@/lib/url";
import { cn } from "@/lib/utils";
@ -249,16 +251,6 @@ export const MessageError: FC = () => {
);
};
function formatMessageDate(date: Date): string {
return date.toLocaleDateString(undefined, {
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
});
}
/**
* Format provider USD cost (in micro-USD) for inline display next to a
* token count. Falls back to ``"<$0.001"`` for sub-tenth-of-a-cent
@ -367,7 +359,7 @@ const MessageInfoDropdown: FC<{ chatTurnId: string | null | undefined }> = ({ ch
>
{createdAt && (
<DropdownMenuLabel className="text-xs text-muted-foreground font-normal select-none">
{formatMessageDate(createdAt)}
{formatMessageTimestamp(createdAt)}
</DropdownMenuLabel>
)}
{hasUsage && (
@ -463,6 +455,8 @@ const AssistantMessageInner: FC = () => {
<MessageError />
</div>
<MessageTimestamp className="ml-2 mt-2" />
{isMobile && (
<div className="ml-2 mt-2">
<MobileCitationDrawer />