Skip to content

fix(web): archive previews list numbered files and folders in natural order - #43701

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-archive-viewer-natural-sort
Nov 26, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-archive-viewer-natural-sort

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

When a .zip or .tar holds numbered files or folders, the web archive preview lists them as page1.txt, page10.txt, page2.txt (and ch1, ch10, ch2) instead of page1.txt, page2.txt, page10.txt. The listing sorted names with a plain localeCompare, while the workspace file tree already lists numbered names in natural order and the Files breadcrumb menu and the mobile ZIP browser sort with a numeric collator.

Change

The archive listing now sorts with the same Intl.Collator(undefined, { numeric: true, sensitivity: "base" }) the Files breadcrumb menu (fileBreadcrumbChildren) and the diff file tree use, created on first comparison like theirs. The comparator, folders first and then names in natural order, moves to binaryPreviewProtocol.ts as compareArchiveRows, next to the other archive preview helpers and their tests. BinaryViewer.tsx calls it in place of the inline sort; the rest of that diff is the formatter re-indenting the same JSX.

Scope

Bug fix: wrong order in the web archive preview. It is a small fix of an obvious bug, so there is no issue. Mobile already sorts archives with a numeric collator (apps/mobile/src/features/files/zipTree.ts), and desktop renders this same web component.

Verification

Setup: Linux, web app in the Browser panel, light theme, 1280×800, fresh isolated dev data (T3CODE_DEV_SEED=0). A demo repository holds book.zip with page1.txt, page2.txt, page10.txt and folders ch1/, ch2/, ch10/.

Steps: Open the demo project → right panel → Files → book.zip → hide the file explorer → maximize the panel.

44a5333 4d02ebd
Folders list ch1, ch10, ch2 and files page1, page10, page2
Folders list ch1, ch10, ch2 and files page1, page10, page2
Folders list ch1, ch2, ch10 and files page1, page2, page10
Folders list ch1, ch2, ch10 and files page1, page2, page10

The new test in binaryPreview.worker.test.ts passes on 4d02ebd (3 of 3 runs) and fails when the comparator is swapped back to 44a5333's localeCompare or loses its folders-first check. vp run check:changed passes on 4d02ebd. On main 83d4509 the test fails (no comparator there), and on a local merge of 4d02ebd into 83d4509 it passes and typecheck is clean.

Not shown

  • Desktop (Electron) and macOS or Windows browsers: not run. Desktop renders the same web component.
  • A .tar archive in the app: not run. It goes through the same listing and sort as .zip.
Test output

4d02ebd with 44a5333's comparator (Number(b.directory) - Number(a.directory) || a.path.localeCompare(b.path)):

 × sorts archive folders first, then numbered names in natural order
AssertionError: expected [ 'vol1', 'vol10', 'vol2', …(3) ] to deeply equal [ 'vol1', 'vol2', 'vol10', …(3) ]
  [
    "vol1",
-   "vol2",
    "vol10",
+   "vol2",
    "page1.txt",
+   "page10.txt",
    "page2.txt",
-   "page10.txt",
  ]

4d02ebd:

 Test Files  1 passed (1)
      Tests  7 passed (7)

Generated with Claude Opus 5.5 in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The archive protocol now exports a comparator that sorts directories before files and compares paths in natural, case-insensitive order. BinaryViewer uses the comparator to sort archive entries.

Changes: Archive Row Ordering

Layer / File(s) Summary
Define and verify archive row ordering
apps/web/src/components/files/binaryPreviewProtocol.ts, apps/web/src/components/files/binaryPreview.worker.test.ts
The protocol adds a comparator that places directories before files and compares paths using numeric, case-insensitive ordering. The test checks directory priority and natural ordering of numbered names.
Use the comparator in BinaryViewer
apps/web/src/components/files/BinaryViewer.tsx
BinaryViewer uses the comparator instead of its inline sort. Row rendering and interactions remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: saphid, maria-rcks

Merge Risk: Minimal · up to 3aea4

Merge Risk: ⚪ Minimal · up to 3aea4

Archive previews now list numbered files and folders in natural order, with folders first. The change is small and presentation-only, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: archive previews now list numbered files and folders in natural order. It follows conventional commit form and matches the raw summary, the PR objectives, and the desc…
Description check Passed The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections, and each section gives specific content. The Problem section states the expected and …
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.
Full details: Title check

Explanation

The title names the main change: archive previews now list numbered files and folders in natural order. It follows conventional commit form and matches the raw summary, the PR objectives, and the description. The change is a comparator in binaryPreviewProtocol.ts used by BinaryViewer.tsx, which is consistent with the title.

Full details: Description check

Explanation

The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections, and each section gives specific content. The Problem section states the expected and actual order and names the affected components. The Change section explains the comparator and its location. The Scope section gives a reason for omitting an issue. The Verification section gives setup, steps, before and after screenshots, test output, and items not checked. It also names the model used, as the template asks. The description does not link a tracking issue, but it gives a reason, which the template allows.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bc0f04d and 4d02ebd.

Files selected for processing: 3

  • apps/web/src/components/files/BinaryViewer.tsx
  • apps/web/src/components/files/binaryPreview.worker.test.ts
  • apps/web/src/components/files/binaryPreviewProtocol.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Seeded the same nine-entry ZIP and unpacked files on fresh databases, opened a Replay thread → right panel → Files, expanded unzipped/, selected book.zip, and maximized the panel. Chromium, 1440×1000, light theme on both sides.

Before After
Before: lexicographic archive order After: natural archive order
bc0f04da94 3aea4fb003
ch1, ch10, ch2; page1.txt, page10.txt, page2.txt ch1, ch2, ch10; page1.txt, page2.txt, page10.txt

The unpacked tree uses natural order on both builds. The scenario fails on base and passes on head; scenarios:prove exited 0.

Scenario and synthetic ZIP seed · Before recording · After recording

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 26, 2026
@juliusmarminge
juliusmarminge merged commit 6249fe9 into pingdotgg:main Nov 26, 2026
57 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 26, 2026
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 26, 2026
… order (pingdotgg#43701)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 6249fe9)
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 26, 2026
… order (pingdotgg#43701)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 6249fe9)
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 26, 2026
… order (pingdotgg#43701)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 6249fe9)
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 Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants