import { SignificanceBadge } from '@/components/ui/badges'; import { Note } from '@/components/ui/section'; import { cn } from '@/lib/cn'; import { fmtPct } from '@/lib/format'; import type { BlockDelta, DiffPayload } from '@/lib/types'; /** Block-level diff (added / removed / modified with before → after text), significance meter and reasons. */ export function DiffViewer({ diff, significance, className }: { diff: DiffPayload; significance?: number | null; className?: string }) { const total = diff.added.length + diff.removed.length + diff.modified.length; return (
Significance
text delta {fmtPct(diff.text_delta_ratio, 1, true)} · similarity {fmtPct(diff.similarity, 1, true)} · {diff.counts.unchanged !== undefined ? `${diff.counts.unchanged} unchanged blocks` : `${total} changed blocks`}
Why it scored this way
{diff.reasons.length ? ({label} ({items.length})
{b.kind} {b.path} w {b.weight.toFixed(2)}{b.similarity !== null ? ` · sim ${b.similarity.toFixed(2)}` : ''}
{kind === 'modified' ? ( <>{b.before}
{b.after}
> ) : ({kind === 'removed' ? b.before : b.after}
)}