import { Badge, Card, Loader, Stack, Table, Text, Title } from '@mantine/core'; import { useDataPlan, useScripts } from '../../api/hooks'; import { ErrorAlert } from '../../components/common'; /** A recipe's outputs as "name: value" pairs, not a JSON blob. */ function outputWords(o: unknown): string { if (o == null || typeof o !== 'object') return o == null ? '' : String(o); return Object.entries(o as Record).map(([k, v]) => `${k}: ${v == null ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v)}`).join(', '); } const DATA_COLOR: Record = { found: 'teal', not_found: 'red', seeded: 'dark', seed_refused: 'orange', unsupported: 'gray', skipped: 'gray' }; export function RunData({ id }: { id: string }) { const q = useDataPlan(id); if (q.isLoading) return ; if (q.error) return ; const d = q.data!; return ( Recipes ({Object.keys(d.data_refs).length}) Read-only finds via the egress gate; seeding only with SEED_ALLOWED=1 on a test pod; BIP is a stub. RecipeStrategyStatusOutputsNote {Object.values(d.data_refs).map((r) => ( {r.recipe_id}{r.strategy} {r.status.replace(/_/g, ' ')} {outputWords(r.outputs)}{r.note} ))}
Case to recipes {Object.entries(d.data_plan).map(([c, rs]) => {c}{rs.join(', ') || no recipe})}
{d.gaps.length > 0 && Gaps: {d.gaps.map((g) => `${g.case_id}/${g.recipe_id}: ${g.reason}`).join('; ')}}
); } export function RunScripts({ id }: { id: string }) { const q = useScripts(id); if (q.isLoading) return ; if (q.error) return ; const rows = Object.values(q.data ?? {}); const yn = (v: boolean | null) => (v === null ? 'Not checked' : v ? 'Passed' : 'Failed'); return ( Scripts ({rows.length}): {rows.filter((r) => r.status === 'existing').length} existing, {rows.filter((r) => r.status === 'generated').length} generated drafts CaseStatusPathLintDry-runLast outcome {rows.map((s) => ( {s.case_id}{s.status} {s.path || s.note}{yn(s.lint_ok)}{yn(s.dry_run_ok)} {s.last_outcome ? {s.last_outcome.replace(/_/g, ' ')} : Not run yet} ))}
); }