From 5c8f9b35f8c9cc54f3e48450297289a2ceabfe18 Mon Sep 17 00:00:00 2001 From: LHaghfoss Date: Wed, 25 Nov 2026 23:28:57 +0100 Subject: [PATCH] fix(desktop): show a pull request's added, deleted and renamed files in Review --- apps/desktop/src/ui/Review.tsx | 36 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/apps/desktop/src/ui/Review.tsx b/apps/desktop/src/ui/Review.tsx index 1d25b3596..49532355c 100644 --- a/apps/desktop/src/ui/Review.tsx +++ b/apps/desktop/src/ui/Review.tsx @@ -28,6 +28,7 @@ import { splitRows, } from "../state/diff"; import { loadPullDiff, prefetchPullDiff, usePullList } from "../state/pullQueries"; +import { pullDiffFiles } from "../state/pullReview"; import { featureMissing, refreshCheckpoints, @@ -48,10 +49,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 = @@ -377,17 +381,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); @@ -396,7 +398,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] ?? []), @@ -567,7 +571,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} + @@ -645,7 +651,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."} +

)}