import { useState } from 'react'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import Alert from '@mui/material/Alert'; import LinearProgress from '@mui/material/LinearProgress'; import CircularProgress from '@mui/material/CircularProgress'; import Table from '@mui/material/Table'; import TableBody from '@mui/material/TableBody'; import TableCell from '@mui/material/TableCell'; import TableRow from '@mui/material/TableRow'; import { Rocket, ArrowRight } from 'lucide-react'; import { getOverview, getFunnel, getAlerts, generateDataset, runPipeline, usePoll, } from '../services/labeleval'; import { useLabelEval, resolvePageId } from '../context/LabelEvalContext'; import VerificationFunnel from '../components/labeleval/VerificationFunnel'; import QueueStatus from '../components/labeleval/QueueStatus'; import { MetricCard, SectionCard, StatusChip, LoadingBox, ErrorNote, EmptyState, fmtInt, fmtPct, fmtNum, } from '../components/labeleval/shared'; export default function OverviewPage() { const { stream, navigate, setActiveDatasetId } = useLabelEval(); const overview = usePoll(getOverview, 3000); const funnel = usePoll(getFunnel, 5000); const alerts = usePoll(getAlerts, 5000); const [bootstrapping, setBootstrapping] = useState(false); const [bootError, setBootError] = useState(null); const data = overview.data; const pipeline = stream?.pipeline ?? null; const counters = data?.counters; const allZero = counters !== undefined && Object.values(counters).every((v) => v === 0); const bootstrap = async () => { setBootstrapping(true); setBootError(null); try { const ds = await generateDataset({ num_sequences: 8, frames_per_sequence: 25, seed: 42 }); setActiveDatasetId(ds.dataset_id); await runPipeline(ds.dataset_id); overview.refresh(); } catch (err) { setBootError(err instanceof Error ? err.message : String(err)); } finally { setBootstrapping(false); } }; if (overview.loading && !data) return ; return ( {overview.error && !data ? : null} {pipeline?.running ? ( } sx={{ bgcolor: '#12314a' }}> Pipeline running — stage: {pipeline.stage}. Counters update live. ) : null} {data && allZero && !pipeline?.running ? ( {bootError ? ( {bootError} ) : null} } /> ) : null} {counters ? ( ) : null} {data ? ( ) : null} {!alerts.data || alerts.data.alerts.length === 0 ? ( No active alerts — anomaly, regression and shift monitors are all quiet. Alerts will appear here as the pipeline processes data. ) : ( {alerts.data.alerts.map((a) => ( {a.message} {a.kind} · {new Date(a.created_at).toLocaleString()} ))}
)}
); }