'use client'; import React, { useCallback } from 'react'; import { cn } from '@/lib/utils'; import { useChatContext } from './ChatProvider'; import { MessageList } from './MessageList'; import { ChatComposer } from './ChatComposer'; import { Sparkles, AlertCircle, X } from 'lucide-react'; // ============================================================================= // Types // ============================================================================= interface ChatInterfaceProps { className?: string; } // ============================================================================= // Status Indicator Component // ============================================================================= interface StatusIndicatorProps { status: 'idle' | 'loading' | 'streaming' | 'error'; } function StatusIndicator({ status }: StatusIndicatorProps) { const statusConfig = { idle: { color: 'bg-emerald-400', pulse: false, label: 'Ready', }, loading: { color: 'bg-amber-400', pulse: true, label: 'Loading', }, streaming: { color: 'bg-indigo-400', pulse: true, label: 'Responding', }, error: { color: 'bg-red-400', pulse: false, label: 'Error', }, }; const config = statusConfig[status]; return (
{config.label}
); } // ============================================================================= // Error Banner Component // ============================================================================= interface ErrorBannerProps { message: string; onDismiss: () => void; } function ErrorBanner({ message, onDismiss }: ErrorBannerProps) { return (

{message}

); } // ============================================================================= // Header Component // ============================================================================= interface HeaderProps { status: 'idle' | 'loading' | 'streaming' | 'error'; } function Header({ status }: HeaderProps) { return (

Control Center

AI-powered assistant

); } // ============================================================================= // Main Component // ============================================================================= export function ChatInterface({ className }: ChatInterfaceProps) { const { isLoading, isStreaming, error, clearError, sendMessage, } = useChatContext(); // Determine current status const getStatus = (): 'idle' | 'loading' | 'streaming' | 'error' => { if (error) return 'error'; if (isStreaming) return 'streaming'; if (isLoading) return 'loading'; return 'idle'; }; // Handle message sending from ChatComposer const handleSend = useCallback((message: string, provider?: string) => { sendMessage(message, provider); }, [sendMessage]); return (
{/* Header */}
{/* Error Banner */} {error && ( )} {/* Message List */}
{/* Chat Composer */}
); } export default ChatInterface;