import { Match, Show, Switch, createSignal, type JSX } from "solid-js"; import type { RagMessage } from "@/api/client"; import { CelebiMarkdown } from "@/components/layout/celebi-markdown"; import { IconAlert, IconCopy, IconRefresh } from "@/components/ui/icons"; import { RagCitations } from "@/components/rag/rag-citations"; import { RagThinkingLabel } from "@/components/rag/rag-thinking-label"; import { LogoMark } from "@/components/brand/logo-mark"; import { formatTime } from "@/lib/format"; import { currentLocale } from "@/api/client"; export function RagMessageRow(props: { message: RagMessage; /** Rendered under the citations of an answer (e.g. study actions). */ footer?: JSX.Element; /** * Re-asks the question this answer replies to. Passed only for the newest * answer — re-asking an older one would append it at the end of the * transcript, far from the turn the reader was looking at. */ onRetry?: () => void; labels: { thinking: string; thinking2: string; thinking3: string; copy: string; copied: string; retry: string; sources: string; source: string; subject: string; pages: string; document: string; failed: string; failedWithCode: (code: string) => string; abstained: string; abstainedReason: (reason: string) => string; }; }) { const [copied, setCopied] = createSignal(false); const assistant = () => props.message.role === "assistant"; const failure = () => props.message.error_code ? props.labels.failedWithCode(props.message.error_code) : props.labels.failed; const settled = () => props.message.status === "complete" || props.message.status === "failed"; const copyable = () => assistant() && props.message.status === "complete" && !!props.message.content; const copy = async () => { try { await navigator.clipboard.writeText(props.message.content); } catch { // No clipboard permission (or an insecure origin): nothing to confirm. return; } setCopied(true); window.setTimeout(() => setCopied(false), 1_500); }; const iconButton = "inline-flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground sm:h-7 sm:w-7 touch:h-10 touch:w-10 outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"; return ( // Vibe's turns: the question is a pill on the right; the answer runs the // reading column beside a small brand mark, with no frame, and its // actions sit on one quiet icon row under it with the time at the end.
{props.message.content}
} >

{failure()}

{props.message.content || props.labels.abstained}

{props.labels.abstainedReason(props.message.reason)}

{props.footer}
{(retry) => ( )} {props.labels.copied} {formatTime(props.message.created_at, currentLocale())}
); }