"use client" import { AlertTriangle, ShieldCheck } from "lucide-react" import { useAudienceMode } from "@/components/audience-mode-provider" import type { RowAnnotations } from "@/lib/backend-artifacts" import { cn } from "@/lib/utils" import { SignalTooltip } from "./signal-tooltip" import { formatMissingField } from "./signal-utils" import { getRelationshipShortLabel } from "./provenance-badge" /** * Compact, single-icon row signal indicator. Shows a warning icon when any * row-level concern fires (reproducibility gap, first-party-only reporting), * with a tooltip listing the specifics. Replaces the two full coloured badges * that were taking up vertical space under every model name. * * Returns null when there are no concerns, so green rows stay quiet. */ export function RowSignalsCompact({ annotations, className, showWhenClean = false, }: { annotations?: RowAnnotations | null className?: string showWhenClean?: boolean }) { const { mode } = useAudienceMode() if (!annotations) return null const reproGap = annotations.reproducibility_gap const provenance = annotations.provenance const hasReproGap = reproGap?.has_reproducibility_gap === true const firstPartyOnly = provenance?.first_party_only === true const concerns: { title: string; detail: string }[] = [] if (hasReproGap && reproGap) { const missing = reproGap.missing_fields.map(formatMissingField) concerns.push({ title: mode === "policy" ? "Setup not documented" : "Reproducibility gap", detail: mode === "policy" ? `${reproGap.populated_field_count} of ${reproGap.required_field_count} setup fields recorded. This score may be hard to re-run.` : `Missing: ${missing.join(", ") || "none listed"}. ${reproGap.populated_field_count} of ${reproGap.required_field_count} setup fields recorded.`, }) } if (firstPartyOnly) { concerns.push({ title: mode === "policy" ? "Only model developer reported" : `${getRelationshipShortLabel("first_party", mode)} only`, detail: mode === "policy" ? "Only the model developer reported this score; no independent replication is recorded." : "First-party only — no independent replication is recorded for this group.", }) } if (concerns.length === 0) { if (!showWhenClean) return null return ( ) } return ( {concerns.length === 1 ? "1 concern" : `${concerns.length} concerns`} {concerns.map((c) => ( {c.title}.{" "} {c.detail} ))} } > {concerns.length > 1 && {concerns.length}} ) }