Skip to content

SWF(bug): Sort changelog events by time - #670

Merged
beardthelion merged 1 commit into
mainfrom
bug/changelog-merged-pr-order
Dec 3, 2026
Merged

beardthelion merged 1 commit into
mainfrom
bug/changelog-merged-pr-order

Conversation

@beardthelion

@beardthelion beardthelion commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Sort commits and merged PRs newest first before applying the changelog limit. Commit timestamps stay numbers and merged PR timestamps stay strings.

Cause

api/changelog.rs put Git's Unix seconds into a JSON number and the PR merge time into an RFC 3339 string. The old comparator called as_str().unwrap_or("") on both. The commit got an empty sort key, so an older merged PR could take the only slot at limit=1.

The sort now compares Unix seconds and fractional nanoseconds without changing the response. The test checks that both events and their original timestamp types are present, then asks for just the newest event.

Before

test api::changelog::tests::changelog_limit_keeps_newer_commit_over_older_merged_pr ... FAILED

assertion `left == right` failed
  left: String("pr_merged")
 right: "commit"

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2646 filtered out; finished in 0.61s

After

test api::changelog::tests::changelog_limit_keeps_newer_commit_over_older_merged_pr ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2646 filtered out; finished in 0.63s

Node suite in cargo test --workspace:

test result: ok. 2631 passed; 0 failed; 16 ignored; 0 measured; 0 filtered out; finished in 223.09s

Try it

Set DATABASE_URL to a local PostgreSQL 16+ instance whose user can create test databases.

cargo test -p twigpine-node --lib api::changelog::tests::changelog_limit_keeps_newer_commit_over_older_merged_pr -- --exact

Not tested against a deployed node.

Summary by CodeRabbit

  • Bug Fixes
    • Changelog entries are now ordered by timestamp, so the most recent commit or merged pull request appears first. This also ensures that limiting the results returns the newest entries, even when comparing commits with merged pull requests.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changelog now sorts commit and merged-PR events by parsed timestamp keys before applying the result limit. Response timestamps and event fields remain unchanged. A test checks that the newer commit ranks first.

Changes: Changelog timestamp ordering

Layer / File(s) Summary
Timestamp ordering and coverage
crates/twigpine-node/src/api/changelog.rs
Commit events use seconds as sort keys. Merged-PR events use parsed RFC3339 timestamps, with updated_at as the fallback when merged_at is absent. Events are sorted newest first before the limit is applied. Tests check timestamps and ordering with limit=1.

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

Change: Bug fix

Suggested labels: crate:node, kind:bug

Suggested reviewers: kevincodex1

Merge Risk: Minimal · up to d6974

The changelog now orders commits and merged PRs by actual time, so a newer commit is no longer displaced by an older merged PR at small limits. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "SWF(bug): Sort changelog events by time" matches the main change. The PR sorts commit and merged-PR events newest first before applying the changelog limit, which fixes an older merged PR t…
Description check Passed The description covers the core required content. The Summary is implied by the first paragraph, and the Motivation & context has a clear cause section, but the template's 'Closes #' issue link is mis…
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 "SWF(bug): Sort changelog events by time" matches the main change. The PR sorts commit and merged-PR events newest first before applying the changelog limit, which fixes an older merged PR taking the only slot at limit=1. The title is short and specific, and it names the bug type. It does not mention the timestamp parsing detail, which is expected.

Full details: Description check

Explanation

The description covers the core required content. The Summary is implied by the first paragraph, and the Motivation & context has a clear cause section, but the template's 'Closes #' issue link is missing. The 'Kind of change' checkbox is not ticked. The 'What changed' section is missing, and the 'How a reviewer can verify' section has a test command, but the 'Before you request review' checklist and the 'Protocol & signing impact' block are not addressed. The description has a useful body with test output. Overall it is mostly complete, but several template sections are missing or unfilled.

Resolution

Consider adding: the linked issue under 'Closes #' (or N/A), a ticked 'Bug fix' in 'Kind of change', a bulleted 'What changed' list that names the crate touched (twigpine-node), and confirmation of the 'Before you request review' items (fmt and clippy results, Conventional Commit title). The protocol section can be deleted if the change does not touch the protocol.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7172b36-43a8-403d-b6df-7f9712ea85f5
Commits

Reviewing files that changed from the base of the PR and between 65d5540 and d6974fe.

Files selected for processing: 1

  • crates/twigpine-node/src/api/changelog.rs

Limit details: You’ve used the included review currently available.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟢 Thanks for the contribution. I do not see any actionable issues from my review.

Merge readiness

  • Approval gate: GitHub reports mergeStateStatus: BLOCKED while required CI is green (fmt/clippy, stable/beta tests, build). This looks like branch protection waiting on a human approval, not a PR-owned check failure.
  • Target freshness: origin/main matches the recorded merge-base (65d55405); no rebase drift on this branch.
  • PR template hygiene (non-blocking): CodeRabbit flagged missing template sections (linked issue, kind-of-change checkbox, protocol block). Optional cleanup for maintainer workflow; not a code defect in the diff.

@beardthelion
beardthelion added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 7ee22a8 Dec 3, 2026
22 checks passed
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.

2 participants