Skip to content

perf(web): speed up diff file sorting - #10423

Open
CouchRiv wants to merge 1 commit into
pingdotgg:mainfrom
CouchRiv:perf/diff-panel-natural-sort
Open

perf(web): speed up diff file sorting#10423
CouchRiv wants to merge 1 commit into
pingdotgg:mainfrom
CouchRiv:perf/diff-panel-natural-sort

Conversation

@CouchRiv

@CouchRiv CouchRiv commented Sep 6, 2026

Copy link
Copy Markdown

What Changed

DiffPanel repeats locale setup while comparing file paths in a patch. Create an Intl.Collator on the first comparison and reuse it for the rest of the sort, with the existing default locale, numeric ordering, and base sensitivity. This applies the folder-menu optimization from #10190 to the diff panel.

Why

Sorting 500 tracked repository paths in Git order took 5.48 ms before and 0.11 ms after in a warmed Node 24.14.0 benchmark on Windows (median of 25 batches). This compares the actual memo bodies using synthetic patches; it measures sorting, excluding parsing and rendering.

Verification

  • Output matched the baseline for numeric names, case/leading-zero ties, Unicode paths, and renamed/deleted files; the input array stayed unchanged.
  • diffRendering.test.ts and diffFileTree.logic.test.ts: 14 tests passed.
  • Web typecheck, targeted formatting, and git diff --check passed. Targeted lint reports only two warnings reproduced on the original file.

Checklist

  • This PR is small and focused
  • I explained what changed and why

No appearance or interaction changes.

Implemented with GPT-6 through Codex desktop.

Summary by CodeRabbit

  • Performance
    • Improved file path sorting efficiency in the diff panel while preserving the existing sort order.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 6, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This is a focused six-line optimization of existing diff-file sorting that reuses an equivalent collator configuration and does not introduce new user-facing behavior or broader system changes. Its runtime impact is limited to reducing sorting overhead in the existing DiffPanel path.

Not approved because:

  • Monthly spending limit reached (workspace setting). Approvability relies on correctness review in order to determine eligibility

No code changes detected at 3bf7b33. Prior analysis still applies.

Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more.

@CouchRiv
CouchRiv force-pushed the perf/diff-panel-natural-sort branch from 3bf7b33 to 2bd1022 Compare September 7, 2026 02:37
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: eb58552f-82f5-4e07-8a1f-3b8d9f7fa2fe

📥 Commits

Reviewing files that changed from the base of the PR and between de28fa1 and 2bd1022.

📒 Files selected for processing (1)
  • apps/web/src/components/DiffPanel.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

DiffPanel now caches an Intl.Collator for file path sorting. The collator preserves numeric and case-insensitive comparison behavior.

Changes

DiffPanel sorting

Layer / File(s) Summary
Cache the file path collator
apps/web/src/components/DiffPanel.tsx
renderableFiles uses a lazily initialized Intl.Collator with numeric: true and sensitivity: "base" for path comparisons.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 2bd10

Diff file paths are now sorted with a reused collator to improve rendering performance while retaining existing ordering behavior. The change is ready to merge with no current-head merge-blocking risk identified.

Suggested reviewers: juliusmarminge, maria-rcks, stienswout

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: improving diff file sorting performance.
Description check ✅ Passed The description includes the required What Changed and Why sections, explains the optimization, documents verification results, and addresses the absence of UI or interaction changes. The checklist ac…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice.


Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant