Skip to content

fix: sort upload volumes numerically#13

Merged
CircleCrop merged 2 commits into
mainfrom
codex/-volumelabel
Jul 13, 2026
Merged

fix: sort upload volumes numerically#13
CircleCrop merged 2 commits into
mainfrom
codex/-volumelabel

Conversation

@CircleCrop

Copy link
Copy Markdown
Member

Motivation

  • Make ordering deterministic and human-friendly when multiple files share the same episode/frame but differ by volume markers like VOL1/VOL10 so numeric volume ordering is correct.
  • Ensure both flat and nested upload plans prefer volume-aware ordering before falling back to lexical rootHint comparison.

Description

  • Added a small VolumeSortKey shape and a volumeSortKey(input: string) parser that recognizes VOL and BOX tokens with optional separators (e.g. VOL1, VOL 1, VOL_1, BOX_1) and yields { kind, number, label }.
  • Added compareVolumeHints(left, right) to tie-break groups by volume kind (VOL before BOX) and numeric volume number while preserving existing display labels.
  • Applied volume-aware tie-breaking to the flat planner orderedGroups.sort and to the nested planner allBefore.sort ahead of the existing rootHint.localeCompare fallback.
  • Added regression tests to source-scanner.test.ts verifying VOL2 sorts before VOL10 in both structured flat and nested (before/after) cases.

Testing

  • Ran pnpm --filter @magic-compare/internal-site test -- source-scanner and the test suite completed with all tests passing (package tests passed).
  • Ran pnpm --filter @magic-compare/internal-site lint and lint succeeded with no errors.

Codex Task

Copilot AI review requested due to automatic review settings July 11, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves deterministic, human-friendly ordering in the internal-site web uploader’s source scanner by ensuring VOL/BOX markers are parsed and sorted numerically (e.g., VOL2 before VOL10) when episode and frame number are identical.

Changes:

  • Added volumeSortKey() parsing and compareVolumeHints() tie-breaking (VOL before BOX, then numeric volume).
  • Applied volume-aware ordering to both flat and nested upload planners ahead of existing lexical tie-breakers.
  • Added regression tests covering VOL2 vs VOL10 sorting in both flat and nested planning.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/internal-site/components/web-uploader/source-scanner.ts Adds volume parsing + comparator and applies it to flat/nested planner sort order.
apps/internal-site/components/web-uploader/source-scanner.test.ts Adds regression tests ensuring numeric volume ordering for structured filenames.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Number(left[1].episode) - Number(right[1].episode) ||
left[1].frameNumber - right[1].frameNumber ||
compareVolumeHints(left[1].rootHint, right[1].rootHint) ||
left[0].localeCompare(right[0]),

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdec96ffe0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return (
Number(leftCandidate.episode) - Number(rightCandidate.episode) ||
leftCandidate.frameNumber - rightCandidate.frameNumber ||
compareVolumeHints(leftCandidate.rootHint, rightCandidate.rootHint) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve title grouping before comparing volume numbers

When a flat upload contains distinct prefixes that share the same episode/frame, this tie-breaker makes the volume number outrank the root title, so entries like BBB_VOL2_00000.m2ts-1-src.png sort before AAA_VOL10_00000.m2ts-1-src.png. The scanner already keeps same-number prefixes as separate frames, so volume-aware sorting should only apply after comparing the non-volume root/title; otherwise unrelated titles can be interleaved just because both contain VOL markers.

Useful? React with 👍 / 👎.

@CircleCrop

Copy link
Copy Markdown
Member Author

@copilot review

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Reviewed current branch state: the nested plan sorter already applies compareRootHints(...) before the final matchKey tie-break (left[0].localeCompare(...)), so the previously raised ordering concern is already addressed in the latest commits. Re-ran pnpm --filter @magic-compare/internal-site lint and pnpm --filter @magic-compare/internal-site test -- source-scanner; both passed, so no additional code changes were needed.

@CircleCrop
CircleCrop merged commit 48a6007 into main Jul 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants