The best way to control Claude Code, Codex and more from any computer or phone
fix(web): pull request diff follows the file tree, with a hide-tests filter (#26730)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 28, 2026 at 18:05 UTC
a5448f4c5030b4f70744db5ecfec4cc06828b621
8 files changed
+161
-19
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+2
-2
@@ -41,7 +41,7 @@ import {
41
pullRequestDiffInitialPosition,
42
} from "./pullRequestDiffDebug";
43
import { usePullRequestDiffHighlightFiles } from "./usePullRequestDiffHighlightFiles";
44
-import { isPullRequestTestFile } from "./pullRequestFileFilters";
44
+import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
45
import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
46
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
47
import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react";
@@ -1035,7 +1035,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1035
const jumpedUnder = useRef<boolean | null>(filter.hideTestFiles);
1036
const hasTestFiles =
1037
result.parsed.kind === "files" &&
1038
- result.parsed.files.some((file) => isPullRequestTestFile(file.path));
1038
+ result.parsed.files.some((file) => isTestChangedFile(file.path));
1039
const jumpStarted = () =>
1040
jumpedUnder.current !== null && (!hasTestFiles || jumpedUnder.current === filter.hideTestFiles);
1041
const scrollToFile = (fileId: string) => {
apps/mobile/src/features/pull-requests/pullRequestFileFilters.ts
+2
-8
@@ -1,12 +1,6 @@
1
-import { classifyChangedFile } from "@t3tools/shared/changedFileKind";
1
+import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
2
import type { ReviewParsedDiff } from "../review/reviewModel";
3
4
-/** Test support such as fixtures and snapshots is hidden along with the tests. */
5
-export function isPullRequestTestFile(path: string): boolean {
6
- const kind = classifyChangedFile(path);
7
- return kind === "tests" || kind === "mocks";
8
-}
9
-
4
export function filterPullRequestTestFiles(
5
parsed: ReviewParsedDiff,
6
hideTestFiles: boolean,
@@ -14,7 +8,7 @@ export function filterPullRequestTestFiles(
8
): ReviewParsedDiff {
9
if (!hideTestFiles || parsed.kind !== "files") return parsed;
10
const files = parsed.files.filter(
17
- (file) => file.path === includePath || !isPullRequestTestFile(file.path),
11
+ (file) => file.path === includePath || !isTestChangedFile(file.path),
12
);
13
if (files.length === parsed.files.length) return parsed;
14
return {
apps/web/src/components/DiffPanel.tsx
+43
-5
@@ -12,6 +12,7 @@ import {
12
CheckIcon,
13
ChevronDownIcon,
14
Columns2Icon,
15
+ FlaskConicalOffIcon,
16
FolderTreeIcon,
17
PilcrowIcon,
18
Rows3Icon,
@@ -37,6 +38,8 @@ import {
38
useDiffPanelStore,
39
} from "../diffPanelStore";
40
import { useLocalStorage } from "../hooks/useLocalStorage";
41
+import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
42
+import { useHideTestFiles } from "./diffs/useHideTestFiles";
43
import { useRenderedAppearance } from "../hooks/useTheme";
44
import { useStableCallback } from "../hooks/useStableCallback";
45
import {
@@ -218,6 +221,7 @@ export default function DiffPanel({
221
false,
222
Schema.Boolean,
223
);
224
+ const [hideTestFiles, setHideTestFiles] = useHideTestFiles();
225
const [baseRefQuery, setBaseRefQuery] = useState("");
226
const [codeViewRevision, setCodeViewRevision] = useState(0);
227
@@ -539,6 +543,16 @@ export default function DiffPanel({
543
const isRefreshingDiff = branchDiffPreview.isPending || areFilePatchesPending;
544
const renderableFileEntries = renderableFiles.map(getCachedFileEntry);
545
const diffFileKeys = renderableFileEntries.map((file) => file.fileKey);
546
+ const testFileCount = renderableFiles.filter((file) =>
547
+ isTestChangedFile(resolveFileDiffPath(file)),
548
+ ).length;
549
+ // Hiding is display-only: lazy loading indexes into the full list. A requested file stays visible.
550
+ const isFileShown = (file: FileDiffMetadata) => {
551
+ const path = resolveFileDiffPath(file);
552
+ return !hideTestFiles || path === selectedFilePath || !isTestChangedFile(path);
553
+ };
554
+ const shownFileEntries = renderableFileEntries.filter(({ fileDiff }) => isFileShown(fileDiff));
555
+ const shownFileKeys = shownFileEntries.map((file) => file.fileKey);
556
const defaultCollapsedDiffFileKeys = settings.diffFilesCollapsed
557
? new Set(diffFileKeys)
558
: EMPTY_COLLAPSED_DIFF_FILE_KEYS;
@@ -561,7 +575,7 @@ export default function DiffPanel({
575
count={renderableFiles.length - settledFileCount}
576
/>
577
) : null;
564
- const codeViewFiles = renderableFileEntries
578
+ const codeViewFiles = shownFileEntries
579
.filter(
580
({ fileDiff }) =>
581
!lazySource || !readyFilePaths || readyFilePaths.has(resolveFileDiffPath(fileDiff)),
@@ -574,10 +588,12 @@ export default function DiffPanel({
588
collapsed:
589
collapsedDiffFileKeys.has(fileKey) || fileDiff.cacheKey?.endsWith(":pending") === true,
590
}));
577
- const pendingFiles = renderableFiles.filter((file) => file.cacheKey?.endsWith(":pending"));
578
- const allDiffFilesCollapsed = areAllDiffFilesCollapsed(diffFileKeys, collapsedDiffFileKeys);
591
+ const pendingFiles = renderableFiles.filter(
592
+ (file) => file.cacheKey?.endsWith(":pending") && isFileShown(file),
593
+ );
594
+ const allDiffFilesCollapsed = areAllDiffFilesCollapsed(shownFileKeys, collapsedDiffFileKeys);
595
const diffLineStat = sourceLineStat ?? getDiffLineStat(renderableFiles);
580
- const fileTreeEntries = diffFileTreeEntries(renderableFiles);
596
+ const fileTreeEntries = diffFileTreeEntries(renderableFiles.filter(isFileShown));
597
const codeViewReveal = useCodeViewFileReveal();
598
const revealDiffFile = (filePath: string) => {
599
const index = renderableFileEntries.findIndex(
@@ -661,7 +677,7 @@ export default function DiffPanel({
677
678
const toggleDiffFileCollapse = () => {
679
setCodeViewRevision((current) => current + 1);
664
- updateCollapsedDiffFiles((current) => toggleAllDiffFiles(diffFileKeys, current));
680
+ updateCollapsedDiffFiles((current) => toggleAllDiffFiles(shownFileKeys, current));
681
};
682
683
const selectTurn = (runId: RunId) => {
@@ -991,6 +1007,28 @@ export default function DiffPanel({
1007
{diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
1008
</TooltipPopup>
1009
</Tooltip>
1010
+ {testFileCount > 0 && (
1011
+ <Tooltip>
1012
+ <TooltipTrigger
1013
+ render={
1014
+ <Toggle
1015
+ aria-label="Hide test files"
1016
+ variant="ghost"
1017
+ size="sm"
1018
+ pressed={hideTestFiles}
1019
+ onPressedChange={(pressed) => setHideTestFiles(Boolean(pressed))}
1020
+ />
1021
+ }
1022
+ >
1023
+ <FlaskConicalOffIcon className="size-3.5" />
1024
+ </TooltipTrigger>
1025
+ <TooltipPopup side="top">
1026
+ {hideTestFiles
1027
+ ? `Show ${testFileCount} hidden test ${testFileCount === 1 ? "file" : "files"}`
1028
+ : "Hide test files"}
1029
+ </TooltipPopup>
1030
+ </Tooltip>
1031
+ )}
1032
{diffFileKeys.length > 0 && (
1033
<Tooltip>
1034
<TooltipTrigger
apps/web/src/components/diffs/diffFileTree.logic.test.ts
+25
-1
@@ -1,7 +1,11 @@
1
import type { FileDiffMetadata } from "@pierre/diffs";
2
import { describe, expect, it } from "vite-plus/test";
3
4
-import { buildDiffFileTreeUpdates, diffFileTreeEntries } from "./diffFileTree.logic";
4
+import {
5
+ buildDiffFileTreeUpdates,
6
+ diffFileTreeEntries,
7
+ orderDiffFilesLikeTree,
8
+} from "./diffFileTree.logic";
9
10
function file(type: FileDiffMetadata["type"], name: string, prevName = name): FileDiffMetadata {
11
return { type, name, prevName } as FileDiffMetadata;
@@ -24,6 +28,26 @@ describe("diffFileTreeEntries", () => {
28
});
29
});
30
31
+describe("orderDiffFilesLikeTree", () => {
32
+ it("pulls a test listed last into its directory, keeping the first-seen order", () => {
33
+ expect(
34
+ orderDiffFilesLikeTree([
35
+ file("change", "server/device/Host.ts"),
36
+ file("change", "web/settings.ts"),
37
+ file("change", "server/ws.ts"),
38
+ file("change", "server/device/Host.test.ts"),
39
+ file("change", "web/settings.test.ts"),
40
+ ]).map((entry) => entry.name),
41
+ ).toEqual([
42
+ "server/device/Host.ts",
43
+ "server/device/Host.test.ts",
44
+ "server/ws.ts",
45
+ "web/settings.ts",
46
+ "web/settings.test.ts",
47
+ ]);
48
+ });
49
+});
50
+
51
describe("buildDiffFileTreeUpdates", () => {
52
it("adds a new file's directories before the file", () => {
53
expect(buildDiffFileTreeUpdates(["README.md"], ["README.md", "src/lib/a.ts"])).toEqual([
apps/web/src/components/diffs/diffFileTree.logic.ts
+30
@@ -98,6 +98,36 @@ export function diffFileTreePositions(paths: ReadonlyArray<string>): ReadonlyMap
98
return positions;
99
}
100
101
+// A flat list in tree order: each directory stays contiguous, siblings ranked as
102
+// compareDiffFileTreeEntries ranks them, so the list never disagrees with the tree.
103
+export function orderDiffFilesLikeTree(
104
+ files: ReadonlyArray<FileDiffMetadata>,
105
+): ReadonlyArray<FileDiffMetadata> {
106
+ const paths = files.map(resolveFileDiffPath);
107
+ const positions = diffFileTreePositions(paths);
108
+ const keys = paths.map((path) => {
109
+ const key: number[] = [];
110
+ let directory = "";
111
+ for (const segment of path.split("/").slice(0, -1)) {
112
+ directory += `${segment}/`;
113
+ key.push(positions.get(directory)!);
114
+ }
115
+ key.push(positions.get(path)!);
116
+ return key;
117
+ });
118
+ return files
119
+ .map((file, index) => ({ file, key: keys[index]! }))
120
+ .toSorted((left, right) => {
121
+ const length = Math.min(left.key.length, right.key.length);
122
+ for (let index = 0; index < length; index++) {
123
+ const difference = left.key[index]! - right.key[index]!;
124
+ if (difference !== 0) return difference;
125
+ }
126
+ return left.key.length - right.key.length;
127
+ })
128
+ .map(({ file }) => file);
129
+}
130
+
131
export function compareDiffFileTreeEntries(
132
getPositions: () => ReadonlyMap<string, number>,
133
): FileTreeSortComparator {
apps/web/src/components/diffs/useHideTestFiles.ts
new
+9
@@ -0,0 +1,9 @@
1
+import * as Schema from "effect/Schema";
2
+
3
+import { useLocalStorage } from "~/hooks/useLocalStorage";
4
+
5
+const HIDE_TEST_FILES_STORAGE_KEY = "t3code.diffHideTestFiles";
6
+
7
+export function useHideTestFiles() {
8
+ return useLocalStorage(HIDE_TEST_FILES_STORAGE_KEY, false, Schema.Boolean);
9
+}
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+45
-3
@@ -19,6 +19,7 @@ import {
19
ChevronDownIcon,
20
ChevronRightIcon,
21
Columns2Icon,
22
+ FlaskConicalOffIcon,
23
FolderTreeIcon,
24
InfoIcon,
25
MessageSquareOffIcon,
@@ -51,6 +52,7 @@ import {
52
canEditPullRequestComment,
53
canResolvePullRequestThread,
54
} from "@t3tools/client-runtime/pull-request-editing";
55
+import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
56
import { orderDiffFiles } from "./pullRequestFileOrder.logic";
57
import {
58
buildFileDiffRenderKey,
@@ -80,7 +82,8 @@ import { useDiffWorkerPool } from "../DiffWorkerPoolProvider";
82
import { DiffCommentAnnotation } from "../diffs/DiffCommentAnnotation";
83
import { DiffFileTree } from "../diffs/DiffFileTree";
84
import { useCodeViewFileReveal } from "../diffs/useCodeViewFileReveal";
83
-import { diffFileTreeEntries } from "../diffs/diffFileTree.logic";
85
+import { useHideTestFiles } from "../diffs/useHideTestFiles";
86
+import { diffFileTreeEntries, orderDiffFilesLikeTree } from "../diffs/diffFileTree.logic";
87
import { StyledDiffCodeView } from "../diffs/StyledDiffCodeView";
88
import { Button } from "../ui/button";
89
import { MorphIcon } from "~/components/MorphIcon";
@@ -307,6 +310,7 @@ function PullRequestCodeTab({
310
false,
311
Schema.Boolean,
312
);
313
+ const [hideTestFiles, setHideTestFiles] = useHideTestFiles();
314
const [selectedLines, setSelectedLines] = useState<{
315
id: string;
316
range: SelectedLineRange;
@@ -496,9 +500,22 @@ function PullRequestCodeTab({
500
ignoreWhitespace,
501
),
502
);
499
- const files = parsedSlices.flatMap((parsed) =>
500
- parsed?.kind === "files" ? orderDiffFiles(parsed.files) : [],
503
+ const loadedFiles = orderDiffFilesLikeTree(
504
+ parsedSlices.flatMap((parsed) =>
505
+ parsed?.kind === "files" ? orderDiffFiles(parsed.files) : [],
506
+ ),
507
);
508
+ const testFileCount = loadedFiles.filter((file) =>
509
+ isTestChangedFile(resolveFileDiffPath(file)),
510
+ ).length;
511
+ // A requested file stays visible so a jump to a hidden test still lands.
512
+ const files = hideTestFiles
513
+ ? loadedFiles.filter((file) => {
514
+ const path = resolveFileDiffPath(file);
515
+ return path === revealRequest?.path || !isTestChangedFile(path);
516
+ })
517
+ : loadedFiles;
518
+ const hiddenTestFileCount = loadedFiles.length - files.length;
519
const filePaths = files.map((file) => resolveFileDiffPath(file));
520
const omittedFileStats = new Map(
521
loadedSlices.flatMap((slice) =>
@@ -1071,6 +1088,11 @@ function PullRequestCodeTab({
1088
{files.length} {files.length === 1 ? "file" : "files"}
1089
{nextCursor === null ? "" : "+"}
1090
</span>
1091
+ {hiddenTestFileCount > 0 ? (
1092
+ <Button type="button" size="xs" variant="link" onClick={() => setHideTestFiles(false)}>
1093
+ {hiddenTestFileCount} test {hiddenTestFileCount === 1 ? "file" : "files"} hidden
1094
+ </Button>
1095
+ ) : null}
1096
{filesViewed.enabled && files.length > 0 ? (
1097
<span className="flex min-w-0 items-center gap-1 tabular-nums">
1098
<span className="shrink-0">
@@ -1283,6 +1305,26 @@ function PullRequestCodeTab({
1305
</TooltipPopup>
1306
</Tooltip>
1307
) : null}
1308
+ {testFileCount > 0 ? (
1309
+ <Tooltip>
1310
+ <TooltipTrigger
1311
+ render={
1312
+ <Toggle
1313
+ aria-label="Hide test files"
1314
+ variant="ghost"
1315
+ size="sm"
1316
+ pressed={hideTestFiles}
1317
+ onPressedChange={(pressed) => setHideTestFiles(Boolean(pressed))}
1318
+ />
1319
+ }
1320
+ >
1321
+ <FlaskConicalOffIcon className="size-3.5" />
1322
+ </TooltipTrigger>
1323
+ <TooltipPopup side="top">
1324
+ {hideTestFiles ? "Show test files" : "Hide test files"}
1325
+ </TooltipPopup>
1326
+ </Tooltip>
1327
+ ) : null}
1328
{fileKeys.length > 0 ? (
1329
<Tooltip>
1330
<TooltipTrigger
packages/shared/src/changedFileKind.ts
+5
@@ -67,6 +67,11 @@ const NOT_DOCS_NAME = /^(requirements.*|constraints.*|CMakeLists|robots|llms)\.t
67
* output count as generated, and test support (mocks, fixtures, snapshots) is kept apart from the
68
* tests themselves, and prose (Markdown, plain text) is its own kind, so a reviewer can see how much of a change is logic.
69
*/
70
+export function isTestChangedFile(path: string): boolean {
71
+ const kind = classifyChangedFile(path);
72
+ return kind === "tests" || kind === "mocks";
73
+}
74
+
75
export function classifyChangedFile(path: string): ChangedFileKind {
76
const segments = path.replaceAll("\\", "/").split("/");
77
const name = segments.pop() ?? "";