import { ActivityIcon, AlertCircleIcon, CheckCircle2Icon, HardDriveIcon, Loader2Icon, ServerIcon, SparklesIcon, } from "lucide-react"; import type { AppStatusResponse, HealthActionKind, HealthCheck, } from "../../status-model"; import { Badge } from "./ui/badge"; import { Button } from "./ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "./ui/card"; interface HealthCenterProps { health: AppStatusResponse["health"]; resident: AppStatusResponse["resident"]; onAction: (action: HealthActionKind) => void; busyAction?: HealthActionKind | null; } function getStatusIcon(status: HealthCheck["status"]) { switch (status) { case "ok": return ; case "warn": return ; case "error": return ; } } function getStatusLabel(status: HealthCheck["status"]): string { switch (status) { case "ok": return "Ready"; case "warn": return "Needs attention"; case "error": return "Blocked"; } } export function HealthCenter({ health, resident, onAction, busyAction, }: HealthCenterProps) { return ( Health Center {health.summary} {health.state === "healthy" ? "Ready" : health.state === "setup-required" ? "First run" : "Needs attention"} {resident.resident ? "Resident runtime" : "Standalone runtime"} {resident.mode} Uptime {resident.uptimeSeconds === null ? "standalone" : `${resident.uptimeSeconds}s`} Listener {resident.listenerPort ?? "none"} Sessions {resident.transport.activeSessions} Requests {resident.transport.activeRequests} {resident.transport.queuedRequests > 0 ? ` +${resident.transport.queuedRequests} queued` : ""} Models {resident.models.loadedModels} warm ยท{" "} {resident.models.activeLeases} leased Admission {resident.admission.state} {health.checks.map((check) => { const isBusy = busyAction === check.actionKind; return ( {getStatusIcon(check.status)} {check.title} {getStatusLabel(check.status)} {check.summary} {check.detail} {check.actionKind && check.actionLabel && ( onAction(check.actionKind!)} size="sm" variant={check.status === "ok" ? "outline" : "default"} > {isBusy ? ( ) : check.status === "ok" ? ( ) : null} {check.actionLabel} )} ); })} ); }
{health.summary}
{check.detail}