/** * SetupTab/RagHealthCard.tsx — mini RAG health summary for the Overview tab * (H3.2). Shows pass rate, avg lift, and an on/off indicator dot, fetched * inline from /api/rag-metrics. * * PREVENT-PI-004: relative-path fetch to the same-origin dashboard server. */ import type React from "react"; import { useMemo } from "react"; import { useApi } from "../../hooks/useApi"; import { fetchRagMetrics } from "../../api/client"; import type { RagMetricsResponse } from "@contracts"; import { Card, CardHeader, CardTitle, CardContent } from "../../components/ui/card"; export const RagHealthCard: React.FC = () => { const { data: m } = useApi( useMemo(() => () => fetchRagMetrics(), []), { pollInterval: 30_000 }, ); if (!m) { return ( Loading RAG health… ); } const { totals, flags } = m; const active = flags.hydeEnabled || flags.recallMetricsEnabled; return ( {!active ? (
All RAG recall feature flags are off.
) : (
Pass rate
{Math.round(totals.recentPassRate * 100)}%
Avg lift
{totals.avgLift.toFixed(2)}×
Telemetry turns
{totals.telemetryTurns}
HyDE ran
{totals.hydeRanTurns}
)}
); }; export default RagHealthCard;