diff --git a/surfsense_web/components/assistant-ui/message-timestamp.tsx b/surfsense_web/components/assistant-ui/message-timestamp.tsx new file mode 100644 index 000000000..65a1da9be --- /dev/null +++ b/surfsense_web/components/assistant-ui/message-timestamp.tsx @@ -0,0 +1,24 @@ +import { useAuiState } from "@assistant-ui/react"; +import { useAtomValue } from "jotai"; +import type { FC } from "react"; +import { showMessageTimestampsAtom } from "@/atoms/chat/show-timestamps.atom"; +import { formatMessageTimestamp } from "@/lib/format-date"; +import { cn } from "@/lib/utils"; + +/** + * Muted, always-visible timestamp under a chat message. Renders only when the + * user has opted in via {@link showMessageTimestampsAtom} and the message + * carries a ``createdAt`` (absent on optimistic pre-persist messages). + */ +export const MessageTimestamp: FC<{ className?: string }> = ({ className }) => { + const show = useAtomValue(showMessageTimestampsAtom); + const createdAt = useAuiState(({ message }) => message?.createdAt); + + if (!show || !createdAt) return null; + + return ( +