import ReactMarkdown from "react-markdown"; import { useTranslation } from "react-i18next"; import copy from "copy-to-clipboard"; import { toast } from "sonner"; import { FaCopy } from "react-icons/fa"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; type MessageBubbleProps = { role: "user" | "assistant"; content: string; }; export function MessageBubble({ role, content }: MessageBubbleProps) { const { t } = useTranslation(["views/chat", "common"]); const isUser = role === "user"; const handleCopy = () => { const text = content?.trim() || ""; if (!text) return; if (copy(text)) { toast.success(t("button.copiedToClipboard", { ns: "common" })); } }; return (
{isUser ? content : {content}}
{t("button.copy", { ns: "common" })}
); }