import { useState } from 'react';
import { Check, Copy, RefreshCw, ThumbsDown, ThumbsUp, Paperclip, AlertTriangle } from 'lucide-react';
import type { Message } from '@/lib/types';
import { StreamingText } from './streaming-text';
import { ToolCallTimeline } from './tool-call-timeline';
import { cn } from '@/lib/cn';
import { fmtDate } from '@/lib/format';
function TutorAvatar() {
return (
);
}
export function MessageBubble({ msg, conversationId, initials, onRegenerate, onFeedback, isLast }: {
msg: Message;
conversationId: string;
initials: string;
onRegenerate?: () => void;
onFeedback?: (fb: 'up' | 'down' | null) => void;
isLast: boolean;
}) {
const [copied, setCopied] = useState(false);
const copy = async () => {
await navigator.clipboard.writeText(msg.content);
setCopied(true);
setTimeout(() => setCopied(false), 1200);
};
if (msg.role === 'user') {
return (
{msg.content}
{msg.attachments && msg.attachments.length > 0 &&
{msg.attachments.length} fichier(s)}
{fmtDate(msg.created_at)}
{initials}
);
}
const empty = !msg.content && !(msg.tool_calls && msg.tool_calls.length);
return (

Tuteur
{msg.tool_calls && msg.tool_calls.length > 0 &&
}
{empty && msg.streaming ? (
) : (
)}
{msg.error && (
)}
{!msg.streaming && (
{onFeedback && (
<>
>
)}
{isLast && onRegenerate && (
)}
{msg.model ? msg.model.split('/').pop() : ''} · {fmtDate(msg.created_at)}
)}
);
}