/** * CPU Monitor Component * * Displays CPU usage percentage with historical chart and event loop lag indicator. */ import { useMemo } from 'react'; import { Cpu, Activity, AlertTriangle } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { CPUDataPoint, ServerCPUMetrics } from '@automaker/types'; interface CPUMonitorProps { history: CPUDataPoint[]; current: ServerCPUMetrics | null; eventLoopLag?: number; className?: string; } /** * Simple sparkline chart for CPU data */ function CPUSparkline({ data, className }: { data: CPUDataPoint[]; className?: string }) { const pathD = useMemo(() => { if (data.length < 2) { return ''; } const w = 200; const h = 40; const padding = 2; // CPU percentage is 0-100, but we'll use 0-100 as our range const points = data.map((d, i) => { const x = (i / (data.length - 1)) * (w - padding * 2) + padding; const y = h - padding - (d.percentage / 100) * (h - padding * 2); return `${x},${y}`; }); return `M ${points.join(' L ')}`; }, [data]); if (data.length < 2) { return (