import { memo } from "react"; interface DiffBlockProps { content: string } interface DiffLine { type: "add" | "remove" | "context" | "header"; content: string; } function parseDiff(raw: string): DiffLine[] { return raw.split("\n").map(line => { if (line.startsWith("+++") || line.startsWith("---") || line.startsWith("@@")) return { type: "header" as const, content: line }; if (line.startsWith("+")) return { type: "add" as const, content: line.slice(1) }; if (line.startsWith("-")) return { type: "remove" as const, content: line.slice(1) }; return { type: "context" as const, content: line.startsWith(" ") ? line.slice(1) : line }; }); } const DiffBlock = memo(function DiffBlock({ content }: DiffBlockProps) { const lines = parseDiff(content); const adds = lines.filter(l => l.type === "add").length; const removes = lines.filter(l => l.type === "remove").length; return (
| {prefix} | {line.content} |