Skip to content

Sort changelog entries by actual merge time (time-of-day, not just by day) - #259

Merged
crs48 merged 1 commit into
mainfrom
claude/condescending-shirley-a5e2fc
Jun 25, 2026
Merged

Sort changelog entries by actual merge time (time-of-day, not just by day)#259
crs48 merged 1 commit into
mainfrom
claude/condescending-shirley-a5e2fc

Conversation

@crs48

@crs48 crs48 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Problem

Changelog / What's New entries were sorted lexicographically by id — a YYYY-MM-DD date prefix plus an arbitrary slug:

Object.values(fragments).sort((a, b) => (a.id < b.id ? 1 : a.id > b.id ? -1 : 0))

So when several PRs merged on the same calendar day, they rendered in slug/name order, not the order they actually landed. An entry merged at 01:57 could sit below one merged at 15:33 just because of its title. The id also only carries day granularity (and used the author's local date), so a PR merged after midnight UTC could even land on the wrong day relative to its neighbours.

Fix

Sort by the PR's actual merge time, with time-of-day precision.

  • New mergedAt field on each fragment — an ISO-8601 UTC instant (e.g. 2026-06-17T16:41:38Z), exactly GitHub's merged_at.
  • site/src/data/changelog.ts now sorts newest-first by mergedAt, falling back to the id date prefix (midnight UTC) only when it's absent, with id as a stable tiebreak.
  • .github/workflows/stamp-pr-number.yml writes merged_at straight from the merge event when a PR lands (alongside the PR number + contributors it already stamps).
  • scripts/changelog/resolve-prs.mjs fills mergedAt from the GitHub API at deploy as the safety net (mirrors how pr/authors are resolved).
  • site/scripts/validate-changelog.ts enforces the ISO-8601 format so a malformed value fails the build instead of silently misordering.
  • Backfilled all 85 existing fragments with their PRs' real merge times (minimal textual append — inline tags arrays preserved, prettier clean).

Proof

Globally reverse-chronological by merge time after the change; previously-scrambled same-day clusters are now correct. Example, 2026-06-24 (11 entries):

before (by id) after (by merge time)
updated-terms… (15:33) clearer-editing… (01:57, merged last)
sync-fails-loudly… (21:43) entity-counts… (01:13)
… shuffled … … strictly descending …
clearer-editing… (01:57) buried mid-list updated-terms… (15:33, merged first)

pnpm validate:changelog passes (86 fragments); prettier clean on all touched files.

🤖 Generated with Claude Code

Entries were ordered lexicographically by `id` (a YYYY-MM-DD date prefix
plus an arbitrary slug), so multiple PRs merged on the same calendar day
rendered in name order rather than the order they actually landed.

Add a `mergedAt` ISO-8601 UTC instant (time-of-day precision) to each
fragment and sort newest-first by it, falling back to the id date prefix
only when it's absent. Merge time is written straight from the merge
event by stamp-pr-number.yml and backfilled from the GitHub API at deploy
by resolve-prs.mjs; the build validator enforces the timestamp format.
Backfilled all 85 existing fragments from their PRs' real merge times.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@crs48
crs48 temporarily deployed to pr-259 June 25, 2026 02:16 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Preview removed for PR #259.

github-actions Bot added a commit that referenced this pull request Jun 25, 2026
@crs48
crs48 merged commit cbc8a56 into main Jun 25, 2026
10 of 11 checks passed
@crs48
crs48 deleted the claude/condescending-shirley-a5e2fc branch June 25, 2026 02:22
github-actions Bot added a commit that referenced this pull request Jun 25, 2026
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