diff --git a/apps/desktop/src/ui/Review.tsx b/apps/desktop/src/ui/Review.tsx index 9002d0048..8b193ff87 100644 --- a/apps/desktop/src/ui/Review.tsx +++ b/apps/desktop/src/ui/Review.tsx @@ -29,6 +29,7 @@ import { splitRows, } from "../state/diff"; import { loadPullDiff, prefetchPullDiff, usePullList } from "../state/pullQueries"; +import { pullDiffFiles } from "../state/pullReview"; import { draftCounts, EMPTY_DRAFT, @@ -57,10 +58,13 @@ import { DiffCount } from "./Rows"; interface ReviewFile { path: string; + /** The path before a rename. */ + oldPath?: string; status: string; added: number; removed: number; lines: PatchLine[]; + binary?: boolean; } type Source = @@ -399,17 +403,15 @@ export function Review({ threadId }: { threadId: string }) { if (answer.error) { throw new Error(`${pullErrorTitle(answer.error.code)}: ${answer.error.message}`); } - const chunks = splitUnifiedDiff(answer.diff ?? ""); - out = Object.entries(chunks).map(([path, lines]) => { - const parsed = parsePatch(lines); - return { - path, - status: "M", - added: parsed.filter((l) => l.kind === "add").length, - removed: parsed.filter((l) => l.kind === "del").length, - lines: parsed, - }; - }); + out = pullDiffFiles(answer.diff ?? "").map((f) => ({ + path: f.path, + ...(f.oldPath ? { oldPath: f.oldPath } : {}), + status: f.status, + added: f.added, + removed: f.removed, + lines: f.lines, + binary: f.binary, + })); } else { const folder = source.kind === "branch" && wt ? wt.path : cwd; const changes = await gitChanges(folder, source.kind === "branch" ? wt?.base : undefined); @@ -418,7 +420,9 @@ export function Review({ threadId }: { threadId: string }) { const chunks = splitUnifiedDiff(changes.diff); out = changes.files.map((f) => ({ path: f.path, + ...(f.oldPath ? { oldPath: f.oldPath } : {}), status: f.status, + binary: f.binary, added: f.added, removed: f.removed, lines: parsePatch(chunks[f.path] ?? []), @@ -592,7 +596,7 @@ export function Review({ threadId }: { threadId: string }) { const f = files?.find((x) => x.path === path); const n = comments.filter((c) => c.path === path).length; return ( - + - {file.path} + + {file.oldPath ? `${file.oldPath} → ${file.path}` : file.path} + @@ -670,7 +676,9 @@ export function Review({ threadId }: { threadId: string }) { onRemove={(c) => setComments((all) => all.filter((x) => x !== c))} /> ) : ( -

No text diff (a binary or very large file).

+

+ {file.binary ? "A binary file: no lines to show." : "No text diff to show."} +

)}