fix: sort upload volumes numerically#13
Conversation
There was a problem hiding this comment.
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 andcompareVolumeHints()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
VOL2vsVOL10sorting 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]), |
There was a problem hiding this comment.
💡 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) || |
There was a problem hiding this comment.
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 👍 / 👎.
|
@copilot review |
Reviewed current branch state: the nested plan sorter already applies |
Motivation
VOL1/VOL10so numeric volume ordering is correct.rootHintcomparison.Description
VolumeSortKeyshape and avolumeSortKey(input: string)parser that recognizesVOLandBOXtokens with optional separators (e.g.VOL1,VOL 1,VOL_1,BOX_1) and yields{ kind, number, label }.compareVolumeHints(left, right)to tie-break groups by volume kind (VOLbeforeBOX) and numeric volume number while preserving existing display labels.orderedGroups.sortand to the nested plannerallBefore.sortahead of the existingrootHint.localeComparefallback.source-scanner.test.tsverifyingVOL2sorts beforeVOL10in both structured flat and nested (before/after) cases.Testing
pnpm --filter @magic-compare/internal-site test -- source-scannerand the test suite completed with all tests passing (package tests passed).pnpm --filter @magic-compare/internal-site lintand lint succeeded with no errors.Codex Task