import { memo, useCallback, useEffect, useMemo, useState } from "react"; import { ChevronDown, ChevronUp } from "lucide-react"; import { MultiFileDiff } from "@pierre/diffs/react"; import type { ChangedFileSummaryItem } from "./types"; import { useDiffOptions, warmDiffHighlighter } from "@/features/agents/utils/diffUtils"; function stripProjectPathForDisplay(path: string, projectPath?: string): string { if (!projectPath) return path; const normalizedPath = path.replace(/\\/g, "/"); const normalizedProjectPath = projectPath.replace(/\\/g, "/").replace(/\/+$/, ""); if (!normalizedPath.startsWith(`${normalizedProjectPath}/`)) return path; return normalizedPath.slice(normalizedProjectPath.length + 1); } const ChangedFileRow = memo(function ChangedFileRow({ file, projectPath, open, diffReady, onToggle, }: { file: ChangedFileSummaryItem; projectPath?: string; open: boolean; diffReady: boolean; onToggle: (filePath: string) => void; }) { const diffOptions = useDiffOptions(); const displayPath = useMemo( () => stripProjectPathForDisplay(file.filePath, projectPath), [file.filePath, projectPath], ); const oldFile = useMemo( () => ({ name: displayPath, contents: file.originalContent }), [displayPath, file.originalContent], ); const newFile = useMemo( () => ({ name: displayPath, contents: file.modifiedContent }), [displayPath, file.modifiedContent], ); return (