'use client'; import { useWarmup, WarmupStatus } from '@/lib/hooks/useWarmup'; import { Cpu, Check, Loader2, AlertCircle } from 'lucide-react'; import { clsx } from 'clsx'; interface WarmupIndicatorProps { className?: string; showWhenReady?: boolean; } const STATUS_CONFIG: Record = { idle: { icon: Cpu, label: 'Checking model...', color: 'text-zinc-400', bgColor: 'bg-zinc-800/50', }, checking: { icon: Loader2, label: 'Checking model...', color: 'text-blue-400', bgColor: 'bg-blue-500/10', animate: true, }, warming: { icon: Cpu, label: 'Pre-warming model...', color: 'text-amber-400', bgColor: 'bg-amber-500/10', animate: true, }, ready: { icon: Check, label: 'Model ready', color: 'text-emerald-400', bgColor: 'bg-emerald-500/10', }, error: { icon: AlertCircle, label: 'Warmup failed', color: 'text-red-400', bgColor: 'bg-red-500/10', }, }; /** * Small indicator showing the pre-warming status of the model. * Appears in the header or corner of the chat interface. */ export function WarmupIndicator({ className, showWhenReady = false }: WarmupIndicatorProps) { const { status, workers } = useWarmup(true); if (status === 'ready' && !showWhenReady) { return null; } if (status === 'idle') { return null; } const config = STATUS_CONFIG[status]; const Icon = config.icon; return (
{config.label} {workers && status === 'warming' && workers.initializing > 0 && ( ({workers.initializing} starting) )}
); } export function WarmupIndicatorCompact({ className }: { className?: string }) { const { status, message } = useWarmup(true); if (status === 'ready' || status === 'idle') { return null; } const config = STATUS_CONFIG[status]; const Icon = config.icon; return (
{/* Pulse effect for warming */} {status === 'warming' && ( )}
); }