import { Sparkles } from "lucide-react"; import { Link } from "@/lib/router"; import { cn, relativeTime } from "@/lib/utils"; import { type SourceResolvedWatchdogFold, formatCleanupOutcome, formatSilenceAgeMs, shortenEvidenceId, } from "@/lib/source-resolved-watchdog-fold"; export interface SourceResolvedFoldCalloutProps { fold: SourceResolvedWatchdogFold; /** Time the run was finalized — used for the "system audit · {when}" header chip. */ finalizedAt?: string | Date | null; className?: string; } function isoOrLocaleString(value: string | null | undefined): string | null { if (!value) return null; const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleString(); } function issueLink(id: string, identifier: string | null) { return `/issues/${identifier ?? id}`; } function MetaRow({ label, children, }: { label: string; children: React.ReactNode; }) { return (
{label}
{children}
); } export function SourceResolvedFoldCallout({ fold, finalizedAt, className, }: SourceResolvedFoldCalloutProps) { const sourceLabel = fold.sourceIssueIdentifier ?? fold.sourceIssueId.slice(0, 8); const evidenceShort = shortenEvidenceId(fold.sameRunEvidenceId); const evidenceAt = isoOrLocaleString(fold.sameRunEvidenceAt); const silenceAgeLabel = formatSilenceAgeMs(fold.silenceAgeMs); const silenceStartedLabel = isoOrLocaleString(fold.silenceStartedAt); const cleanupLabel = formatCleanupOutcome(fold.cleanup.outcome); const finalizedRelative = finalizedAt ? relativeTime(finalizedAt) : null; const evaluationLabel = fold.evaluationIssueIdentifier ?? fold.evaluationIssueId?.slice(0, 8); return (
SOURCE-RESOLVED FOLD · system audit {finalizedRelative ? ( <> · {finalizedRelative} ) : null}

This run was folded as a source-resolved false positive.

*]:border-emerald-300/40 dark:[&>*]:border-emerald-500/20", )} > {sourceLabel} {fold.sourceIssueStatus} {fold.sameRunEvidenceKind} {evidenceShort} {evidenceAt ? ( at {evidenceAt} ) : null} {silenceAgeLabel ? ( {silenceAgeLabel} {silenceStartedLabel ? ( (silence started {silenceStartedLabel}) ) : null} ) : ( unknown )} {cleanupLabel} {fold.cleanup.error ? ( — {fold.cleanup.error} ) : null} {fold.evaluationIssueId ? ( {evaluationLabel} ) : null}
); } export default SourceResolvedFoldCallout;