import { forwardRef, useState } from 'react' import MessageBubble from './MessageBubble' const SUGGESTIONS = [ { emoji: '🌐', title: 'Latest AI news', text: 'What are the latest developments in AI this week?' }, { emoji: '💡', title: 'Explain quantum computing', text: 'Explain quantum computing in simple terms' }, { emoji: '📝', title: 'Write a cover letter', text: 'Write me a professional cover letter for a software engineer role' }, { emoji: '🐛', title: 'Debug my code', text: 'Help me debug and optimize my Python code' }, { emoji: '📊', title: 'Data analysis help', text: 'Help me analyze data and create visualizations' }, { emoji: '🎨', title: 'Creative writing', text: 'Write a short sci-fi story set in the year 2150' }, ] const EmptyState = ({ onSuggestion }) => (
What can I help with?
Ask me anything — code, research, writing, math, or just a conversation. I'm powered by the world's best AI models.
{SUGGESTIONS.map((s, i) => ( ))}
) const TypingIndicator = () => (
) const ChatArea = forwardRef(function ChatArea({ messages, loading, onSuggestion, user }, ref) { const [showFab, setShowFab] = useState(false) const handleScroll = (e) => { const { scrollTop, scrollHeight, clientHeight } = e.target if (scrollHeight - scrollTop - clientHeight > 200) { setShowFab(true) } else { setShowFab(false) } } const scrollToBottom = () => { if (ref.current) { ref.current.scrollTo({ top: ref.current.scrollHeight, behavior: 'smooth' }) } } return (
{messages.length === 0 && !loading ? ( ) : ( <> {messages.map((m, i) => ( ))} {loading && (messages.length === 0 || messages[messages.length - 1].role !== 'assistant') && } )}
) }) export default ChatArea