export type Change = 'added' | 'removed' | 'changed'; export type FileNode = { path: string; change?: Change; add?: number; del?: number; note?: string }; const MARK: Record = { added: { sign: 'A', cls: 'flag-added' }, removed: { sign: 'D', cls: 'flag-removed' }, changed: { sign: 'M', cls: 'flag-changed' }, }; /** * Flat list of touched files with change flags and +/- line stats. Indent a * path with leading spaces or slashes; it renders monospace as-is. */ export function FileTree({ files, title = 'Files' }: { files: FileNode[]; title?: string }) { const tot = files.reduce((a, f) => ({ add: a.add + (f.add ?? 0), del: a.del + (f.del ?? 0) }), { add: 0, del: 0 }); return (
{title} +{tot.add}{' '} −{tot.del}
); }