import { useEffect, useRef } from "react" import { cn } from "@/lib/utils" import { User, Database, Search, Brain, MessageSquare, Edit3, FileOutput, Server, AlertCircle, } from "lucide-react" import type { ActivityLogEntry } from "@/lib/api" interface ActivityLogProps { entries: ActivityLogEntry[] className?: string } const stepIcons: Record = { input: User, cache: Database, researcher: Search, analyzer: Brain, critic: MessageSquare, editor: Edit3, output: FileOutput, financials: Server, valuation: Server, volatility: Server, macro: Server, news: Server, sentiment: Server, error: AlertCircle, } const stepColors: Record = { input: 'text-blue-400', cache: 'text-yellow-400', researcher: 'text-purple-400', analyzer: 'text-cyan-400', critic: 'text-orange-400', editor: 'text-pink-400', output: 'text-emerald-400', financials: 'text-gray-400', valuation: 'text-gray-400', volatility: 'text-gray-400', macro: 'text-gray-400', news: 'text-gray-400', sentiment: 'text-gray-400', error: 'text-red-400', } function formatTimestamp(isoTimestamp: string): string { try { const date = new Date(isoTimestamp) return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true, }) } catch { return '--:--:--' } } function LogEntry({ entry }: { entry: ActivityLogEntry }) { const Icon = stepIcons[entry.step.toLowerCase()] || AlertCircle const colorClass = stepColors[entry.step.toLowerCase()] || 'text-gray-400' return (
{formatTimestamp(entry.timestamp)}
[{entry.step}] {entry.message}
) } export function ActivityLog({ entries, className }: ActivityLogProps) { const scrollRef = useRef(null) // Auto-scroll to bottom when new entries are added useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight } }, [entries]) return (

Activity Log

{entries.length === 0 ? (
No activity yet. Start an analysis to see real-time updates.
) : (
{entries.map((entry, index) => ( ))}
)}
) } export default ActivityLog