@devries-cameron20 / t3code-1 / commits / 85133dc578
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): PR diffs list a `.logic.test.ts` file beside the source it covers (#23129)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

MarcoDotIO committed Oct 31, 2026 at 22:23 UTC 85133dc57818cbd971d3adf91f83980a83e65ec6
2 files changed +35 -5
apps/web/src/components/pullRequest/pullRequestFileOrder.logic.test.ts
+20
@@ -118,4 +118,24 @@ describe("orderDiffFiles", () => {
118 "src/orphan.spec.ts",
119 ]);
120 });
121 +
122 + it("pairs a test with the source whose name carries its own dotted suffix", () => {
123 + expect(
124 + order([
125 + file("src/c.browser.test.tsx"),
126 + file("src/b.test.ts"),
127 + file("src/a.logic.test.ts"),
128 + file("src/c.tsx"),
129 + file("src/b.ts"),
130 + file("src/a.logic.ts"),
131 + ]),
132 + ).toEqual([
133 + "src/a.logic.ts",
134 + "src/b.ts",
135 + "src/c.tsx",
136 + "src/a.logic.test.ts",
137 + "src/b.test.ts",
138 + "src/c.browser.test.tsx",
139 + ]);
140 + });
141 });
apps/web/src/components/pullRequest/pullRequestFileOrder.logic.ts
+15 -5
@@ -117,8 +117,17 @@ function orderByImports(
117 return ordered;
118 }
119
120 -function testedBaseName(path: string): string {
121 - return (path.split("/").at(-1) ?? "").replace(/\.(?:test|spec)\..*$/, "").replace(/\.[^.]+$/, "");
120 +// `a.logic.test.ts` covers `a.logic.ts` while `a.browser.test.ts` covers `a.ts`, so the longest
121 +// dotted prefix that names a source file wins.
122 +function testedSourcePosition(path: string, sourcePositions: ReadonlyMap<string, number>): number {
123 + let name = (path.split("/").at(-1) ?? "").replace(/\.(?:test|spec)\..*$/, "");
124 + while (true) {
125 + const position = sourcePositions.get(name);
126 + if (position !== undefined) return position;
127 + const dot = name.lastIndexOf(".");
128 + if (dot <= 0) return Number.MAX_SAFE_INTEGER;
129 + name = name.slice(0, dot);
130 + }
131 }
132
133 export function orderDiffFiles(
@@ -159,9 +168,10 @@ export function orderDiffFiles(
168 const orderedTests = [...byPath.keys()]
169 .filter((path) => tiers.get(path) === "test")
170 .sort((left, right) => {
162 - const leftPosition = sourcePositions.get(testedBaseName(left)) ?? Number.MAX_SAFE_INTEGER;
163 - const rightPosition = sourcePositions.get(testedBaseName(right)) ?? Number.MAX_SAFE_INTEGER;
164 - return leftPosition - rightPosition || left.localeCompare(right);
171 + return (
172 + testedSourcePosition(left, sourcePositions) -
173 + testedSourcePosition(right, sourcePositions) || left.localeCompare(right)
174 + );
175 });
176
177 const orderedGenerated = [...byPath.keys()]