Skip to content

fix: sort milestones ascending by ID in browser UI#644

Open
raincrossgazette wants to merge 1 commit into
MrLesk:mainfrom
raincrossgazette:fix/milestone-sort-ascending
Open

fix: sort milestones ascending by ID in browser UI#644
raincrossgazette wants to merge 1 commit into
MrLesk:mainfrom
raincrossgazette:fix/milestone-sort-ascending

Conversation

@raincrossgazette
Copy link
Copy Markdown

Problem

The milestones page in the browser UI sorts milestone cards by ID descending (newest first). This means a project with milestones created in phase order ends up displaying them in reverse — e.g. Phase 9 (m-6) appears at the top, then Phase 7 (m-4), then Phase 8 (m-5).

The comment in the code itself acknowledges the intent: "IDs are sequential m-0, m-1, etc." — but descending order defeats the natural sequence users build when creating milestones in phase/sprint order.

Root cause

In src/web/components/MilestonesPage.tsx, the sortByIdDesc comparator returns bNum - aNum, sorting largest ID first:

// Sort milestones by ID descending (newest first - IDs are sequential m-0, m-1, etc.)
const sortByIdDesc = (a: MilestoneBucket, b: MilestoneBucket) => {
  ...
  return bNum - aNum;  // ← descending
};

Fix

Flip the comparator to ascending (aNum - bNum) so milestones display in creation order (m-1 → m-2 → m-3 …). Also renamed the function to sortByIdAsc and updated comments for clarity.

The fallback value for non-m-N milestones was also changed from -1 to Number.MAX_SAFE_INTEGER so that milestones without a numeric ID sort to the end rather than colliding at the front.

Behavior change

Before After
m-6 (Phase 9) first m-3 (Phase 6) first
m-5 (Phase 8) second m-4 (Phase 7) second
m-4 (Phase 7) third m-5 (Phase 8) third
m-3 (Phase 6) last m-6 (Phase 9) last

This matches what users expect when they name milestones in phase/sprint sequence.

Testing

The change is a single-line logic inversion in the comparator function. No new test assertions exist for this display order in the existing test suite (web-milestones-page-search.test.tsx, web-milestones-page-unassigned-filter.test.tsx).

Previously the milestones page sorted milestone cards by ID descending
(newest first), so a project with phases m-3 through m-6 would display
Phase 9 (m-6) at the top, followed by Phase 7 (m-4) and Phase 8 (m-5).

This reverses the sort to ascending so milestones appear in their natural
creation order (m-1 → m-2 → m-3 … ), matching the sequence users intend
when they create milestones in phase/sprint order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant