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

= 0.65 ? 'var(--warning)' : (significance ?? 0) >= 0.4 ? 'var(--accent)' : 'var(--ink-3)' }} />

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`}

+{diff.added.length} added −{diff.removed.length} removed ~{diff.modified.length} modified {diff.moved.length > 0 && ↕ {diff.moved.length} moved}

Why it scored this way

{diff.reasons.length ? (
    {diff.reasons.map((r) => (
  • · {r}
  • ))}
) : ( No reasons recorded for this diff. )}
{total === 0 ? ( No block-level differences above the noise floor between these versions. ) : (
{diff.added.length > 0 && } {diff.removed.length > 0 && } {diff.modified.length > 0 && }
)}
); } function Group({ label, items, kind }: { label: string; items: BlockDelta[]; kind: 'added' | 'removed' | 'modified' }) { return (

{label} ({items.length})

); }