mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-16 23:01:06 +02:00
feat(chat): add MessageTimestamp component gated on the preference
This commit is contained in:
parent
f4870ad1c2
commit
00fbc24e4b
1 changed files with 24 additions and 0 deletions
24
surfsense_web/components/assistant-ui/message-timestamp.tsx
Normal file
24
surfsense_web/components/assistant-ui/message-timestamp.tsx
Normal file
|
|
@ -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 (
|
||||
<div className={cn("select-none text-[11px] text-muted-foreground", className)}>
|
||||
{formatMessageTimestamp(createdAt)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue