The best way to control Claude Code, Codex and more from any computer or phone
perf(web): reuse the collator when sorting diff files (#18420)
Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: GPT-6.1 Sol <noreply@openai.com>
Alex Southwell committed
Oct 12, 2026 at 11:37 UTC
7ab28a3b2e8837bb919c9b83b4b463b6ebf85c4a
1 file changed
+7
-8
apps/web/src/components/diffs/useReviewFilePatches.ts
+7
-8
@@ -15,6 +15,11 @@ import {
15
import { getRenderablePatch, resolveFileDiffPath, type RenderablePatch } from "~/lib/diffRendering";
16
import { reviewEnvironment } from "~/state/review";
17
18
+const filePathCollator = new Intl.Collator(undefined, {
19
+ numeric: true,
20
+ sensitivity: "base",
21
+});
22
+
23
export function useReviewFilePatches({
24
environmentId,
25
cwd,
@@ -49,10 +54,7 @@ export function useReviewFilePatches({
54
[requested, scope],
55
);
56
const files = useMemo(
52
- () =>
53
- source?.files?.toSorted((a, b) =>
54
- a.path.localeCompare(b.path, undefined, { numeric: true, sensitivity: "base" }),
55
- ) ?? [],
57
+ () => source?.files?.toSorted((a, b) => filePathCollator.compare(a.path, b.path)) ?? [],
58
[source?.files],
59
);
60
const queries = useMemo(
@@ -191,10 +193,7 @@ export function useReviewFilePatches({
193
};
194
})
195
: (preview?.kind === "files" ? preview.files : []).toSorted((a, b) =>
194
- resolveFileDiffPath(a).localeCompare(resolveFileDiffPath(b), undefined, {
195
- numeric: true,
196
- sensitivity: "base",
197
- }),
196
+ filePathCollator.compare(resolveFileDiffPath(a), resolveFileDiffPath(b)),
197
),
198
[source, files, patches, scope, preview],
199
);