authorgravatar for 97427849+flamboh@users.noreply.github.comoliver <97427849+flamboh@users.noreply.github.com> 2026-10-07 22:24:58-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-08 02:24:58-03:00
log6053a7878d24e5fd596d2b417ed94964a4b9c1c6
tree66fc73c164b11bc9e76b5a5661756f5160ea624e
parentc28cd905572e2a28934a6229d88bcf2975963032
signature Signed by PGP key B5690EEEBB952194

fix(web): PR file stats ignore the hide-whitespace toggle (#16162)


1 files changed, 21 insertions(+), 7 deletions(-)

apps/web/src/components/pullRequest/PullRequestCodeTab.tsx+21-7
......@@ -37,6 +37,7 @@ import { orderDiffFiles } from "./pullRequestFileOrder.logic";
3737import {
3838 buildFileDiffRenderKey,
3939 fnv1a32,
40 getDiffLineStat,
4041 getRenderablePatch,
4142 resolveDiffThemeName,
4243 resolveFileDiffPath,
......@@ -596,6 +597,23 @@ function PullRequestCodeTab({
596597 ),
597598 [loadedSlices],
598599 );
600 const sourceFileStats = useMemo(
601 () =>
602 new Map(
603 parsedSlices.flatMap((parsed) =>
604 parsed?.kind === "files"
605 ? parsed.files.map(
606 (file, index) =>
607 [
608 buildFileDiffRenderKey(file),
609 getDiffLineStat([parsed.sourceFiles[index] ?? file]),
610 ] as const,
611 )
612 : [],
613 ),
614 ),
615 [parsedSlices],
616 );
599617 const fileKeys = useMemo(() => items.map((item) => item.id), [items]);
600618 const collapsedFileKeys = useMemo(
601619 () => new Set(items.filter((item) => item.collapsed === true).map((item) => item.id)),
......@@ -811,12 +829,8 @@ function PullRequestCodeTab({
811829 const renderHeaderMetadata = useCallback(
812830 (item: CodeViewItem<ReviewAnnotationGroup>) => {
813831 if (item.type !== "diff") return null;
814 let additions = 0;
815 let deletions = 0;
816 for (const hunk of item.fileDiff.hunks) {
817 additions += hunk.additionLines;
818 deletions += hunk.deletionLines;
819 }
832 let { additions, deletions } =
833 sourceFileStats.get(item.id) ?? getDiffLineStat([item.fileDiff]);
820834 const path = resolveFileDiffPath(item.fileDiff);
821835 if (additions === 0 && deletions === 0) {
822836 const withheld = omittedFileStats.get(path);
......@@ -864,7 +878,7 @@ function PullRequestCodeTab({
864878 </span>
865879 );
866880 },
867 [omittedFileStats],
881 [omittedFileStats, sourceFileStats],
868882 );
869883
870884 const diffViewOptions = useMemo(