'use client'; import { useState } from 'react'; import { Patch } from '@/libs/api'; const OP_SYMBOL: Record = { replace_text: '±', remove_block: '−', reorder_section: '↕', boost_keyword: '+', }; function PatchRow({ p, dim }: { p: Patch; dim?: boolean }) { return (
{OP_SYMBOL[p.operation] ?? '·'} {p.target_path} {p.operation}
{p.old_value && (
− {p.old_value}
)} {p.new_value && (
+ {p.new_value}
)}
); } export default function DiffViewer({ patches, inheritedPatches, ancestorLabel, }: { patches: Patch[]; inheritedPatches?: Patch[]; ancestorLabel?: string; }) { const [showInherited, setShowInherited] = useState(false); const hasInherited = (inheritedPatches?.length ?? 0) > 0; if (!patches.length && !hasInherited) { return (
No patches — identical to parent.
); } return (
{hasInherited && (
{ancestorLabel && ( via {ancestorLabel} )}
)} {showInherited && hasInherited && (
{inheritedPatches!.map(p => )}
)} {patches.length > 0 ? (
{patches.map(p => )}
) : (
No direct patches on this branch.
)}
); }