"use client"; import { useEffect, useState } from "react"; import type { ReactNode } from "react"; import { statusSummary } from "@/lib/api"; type Health = "healthy" | "degraded" | "offline" | "checking"; interface Group { key: string; label: string; value: string; health: Health; icon: ReactNode; } const ICON: Record = { api: , corpus: , vector: , embeddings: , llm: , voice: , tracing: , }; function Glyph({ name }: { name: string }) { return ( {ICON[name]} ); } const HEALTH_PILL: Record = { healthy: "pill-ok", degraded: "pill-warn", offline: "pill-bad", checking: "pill-neutral", }; const HEALTH_LABEL: Record = { healthy: "Healthy", degraded: "Degraded", offline: "Offline", checking: "Checking…", }; export function SystemStatus() { const [groups, setGroups] = useState(null); const [up, setUp] = useState(null); useEffect(() => { statusSummary() .then((s) => { setUp(true); setGroups(buildGroups(s)); }) .catch(() => { setUp(false); setGroups(buildGroups(null)); }); }, []); const live: Group[] = groups ?? checkingGroups(); return (

Live system status

Every subsystem, reported from your running stack.

{up === null ? "Connecting…" : up ? "API online" : "API offline"}
{live.map((g) => (
{HEALTH_LABEL[g.health]}

{g.label}

{g.value}

))}
); } // ---- mapping the /status payload into the seven product subsystems -------- interface StatusPayload { providers?: { subsystem: string; provider: string }[]; index?: { vectors?: number }; corpus?: { indexed?: boolean; indexed_document_count?: number; vector_count?: number }; tracing?: { provider?: string; enabled?: boolean; phoenix_endpoint?: string | null }; } function provider(p: StatusPayload, key: string): string | null { const row = (p.providers || []).find((r) => r.subsystem === key); const v = row?.provider; return v && v !== "null" ? v : null; } function buildGroups(p: StatusPayload | null): Group[] { if (!p) { return checkingGroups().map((g) => ({ ...g, health: "offline" as Health, value: "unreachable" })); } const vectors = p.index?.vectors ?? p.corpus?.vector_count ?? 0; const docs = p.corpus?.indexed_document_count ?? 0; const indexed = !!p.corpus?.indexed || vectors > 0; const llm = provider(p, "llm"); const vs = provider(p, "vector_store"); const emb = provider(p, "embeddings"); const asr = provider(p, "asr"); const tts = provider(p, "tts"); const tracingOn = !!p.tracing?.enabled; const tracingProv = p.tracing?.provider || (tracingOn ? "enabled" : "in-process"); const presence = (v: string | null): Health => (v ? "healthy" : "degraded"); return [ { key: "api", label: "API", value: "FastAPI · online", health: "healthy", icon: "api" }, { key: "corpus", label: "Corpus", value: indexed ? `${docs || "—"} document${docs === 1 ? "" : "s"} indexed` : "empty — ingest to begin", health: indexed ? "healthy" : "degraded", icon: "corpus", }, { key: "vector", label: "Vector DB", value: vs ? `${vs} · ${vectors.toLocaleString()} vectors` : `${vectors.toLocaleString()} vectors`, health: vectors > 0 ? "healthy" : "degraded", icon: "vector", }, { key: "embeddings", label: "Embeddings", value: emb || "not configured", health: presence(emb), icon: "embeddings" }, { key: "llm", label: "LLM", value: llm || "not configured", health: presence(llm), icon: "llm" }, { key: "voice", label: "ASR / TTS", value: asr || tts ? `${asr || "—"} · ${tts || "—"}` : "offline fallback", health: asr || tts ? "healthy" : "degraded", icon: "voice", }, { key: "tracing", label: "Tracing", value: tracingProv, health: tracingOn ? "healthy" : "degraded", icon: "tracing", }, ]; } function checkingGroups(): Group[] { return [ { key: "api", label: "API", icon: "api" }, { key: "corpus", label: "Corpus", icon: "corpus" }, { key: "vector", label: "Vector DB", icon: "vector" }, { key: "embeddings", label: "Embeddings", icon: "embeddings" }, { key: "llm", label: "LLM", icon: "llm" }, { key: "voice", label: "ASR / TTS", icon: "voice" }, { key: "tracing", label: "Tracing", icon: "tracing" }, ].map((g) => ({ ...g, value: "checking…", health: "checking" as Health })); }