'use client' import { useState, useEffect, useRef } from 'react' import { Copy, User } from 'lucide-react' import { Button } from '@/components/ui/button' import { motion } from 'framer-motion' import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import ReactMarkdown from 'react-markdown' // For rendering markdown content import remarkGfm from 'remark-gfm' // To support GitHub-flavored markdown (e.g., tables, strikethrough, etc.) export default function ChatArea({ messages, chatAreaRef }) { const [copiedId, setCopiedId] = useState(null) // State to track the copied message const bottomRef = useRef(null) // Ref for auto-scroll to bottom // Function to copy message content to the clipboard const handleCopy = (content, id) => { navigator.clipboard.writeText(content) setCopiedId(id) setTimeout(() => setCopiedId(null), 2000) // Reset copied state after 2 seconds } // Automatically scroll to the bottom whenever new messages arrive useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [messages]) return (
model: {message.model?.description || 'N/A'} [{new Date(message.timestamp).toLocaleString()}] - {message.seed}