You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(sections): order Recently Released rows by release date - #4506
Closes#4492
Related issue: N/A
Validation tasks: none
Other clients: Apple N/A (no client change; apps render the row in the order the server sends); Android N/A (same); Roku N/A (same)
Recently Released rows on the home screen and library pages showed titles from the same year in the order Silo added them, not the order they came out. A movie from March could sit ahead of one from September, while the library's Release Date sort and the row's own See All page listed them correctly. This affects every client, since the server builds the row.
The row now sorts by release date, like the library's Release Date sort, and lists titles in exactly the order of its own See All page.
Approach
buildRecentlyReleasedQuery sorted by year DESC, created_at DESC. It now sorts by the expression the catalog's Release Date sort uses: the release date, or a series' premiere (first_air_date) when it has no release date, newest first. A movie-only row sorts by the movie release date alone, as See All does for movie sections. Titles with no date come after the dated ones. Ties, undated titles included, go by content ID, the same terms both See All paging paths use, so the row is always See All's first page. The library grid breaks same-date ties by title instead, so two titles released the same day can still swap places between the row and the library grid.
The expression now lives in one exported helper, catalog.ReleaseDateSortSQL. The row, the catalog query builder, the See All cursor and BrowseRepository all use it, so they cannot drift apart.
On 150,000 synthetic movies in one library, the new query and the old one both took about 47 ms. Neither can use an index, because the row is scoped through library membership.
Validation
go build ./..., gofmt -l, go mod tidy -diff, go vet on the changed packages: clean.
make lint-changed (golangci-lint v2.15.0, built with the repository's Go version) and make lint-router-recovery: 0 issues.
make verify-local-paths, verify-case-collisions, verify-bidi, verify-size-ratchet: pass.
make test-go: pass. Four packages (api/handlers, backup, ebookconvert, uploads) failed on the first run because the local umask made temp directories group-writable. They pass with umask 022 and do not touch this change.
New Postgres test, registered in scripts/ci/db-contracts.txt: the row's order across release dates, a series premiere, a same-date tie, undated titles whose year and content-ID order disagree, and a movie with only a premiere date in a mixed row and in a movie-only row, all added in reverse order. It fails on main. All internal/sections database contracts pass through the dbpins runner.
Local build with nine NFO movies added one scan at a time, newest release first: see Evidence.
Web checks not run: no web files changed.
Evidence
Local build, Movies library, nine NFO movies (seven from 2026 with different premiered dates, one from 2025, one 2026 title with no date), added newest release first. Output is title, release date, year.
Before (main), GET /api/v2/library/{id}/sections, Recently Released Movies row:
Golf Whistle 2026-01-20 2026
Foxtrot Heights 2026-02-11 2026
Echo Machine 2026-02-12 2026
Delta Undertone 2026-03-12 2026
India Year Only - 2026
Charlie Toys 2026-06-17 2026
Bravo Bomber 2026-09-25 2026
Alpha Verity 2026-09-30 2026
Hotel Last Year 2025-12-01 2025
After (this branch), same data. The row now matches both GET /api/v2/catalog?sort=-release_date and the row's See All page (GET /api/v2/library/{id}/sections/{section_id}/items):
Alpha Verity 2026-09-30 2026
Bravo Bomber 2026-09-25 2026
Charlie Toys 2026-06-17 2026
Delta Undertone 2026-03-12 2026
Echo Machine 2026-02-12 2026
Foxtrot Heights 2026-02-11 2026
Golf Whistle 2026-01-20 2026
Hotel Last Year 2025-12-01 2025
India Year Only - 2026
The Recently Added Movies row on the same page did not change.
Risks
A title that has a year but no release date or premiere, such as an unmatched title, now comes after every dated title. In a library with more dated titles than the row's item limit, it drops out of the row until its metadata has a date. The library's Release Date sort and See All already order it that way.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: Claude Code (via T3 Code); Codex CLI for code review
Adversarial review: Four independent reviews of the branch diff (GPT gpt-6.2-sol and gpt-6.2-astra via Codex CLI, Claude Opus 5.5 and Claude Fable 5.2) covering correctness, repository standards and the issue. All four found that the row's tie-break (created_at) differed from the See All page's (content_id). Fixed: ties now go by content ID, and the test covers a same-date tie. Three reviewers noted the release-date expression was still copied in the catalog query builder and the See All cursor. Fixed: both use the new helper. Two flagged the new test file. Fixed: the test moved into the existing recent-rows test file. One flagged fixture cleanup registered too late. Fixed. The year-only trade-off under Risks was raised and kept on purpose, because it matches the library sort. A re-review of the fix commit found nothing.
Note
Order Recently Released section rows by release date
buildRecentlyReleasedQuery in fetcher.go now orders by descending release date with NULLS LAST and ascending content ID as tie-breaker, replacing the old year/creation-time ordering. Movie-only sections order by mi.release_date.
Adds a shared ReleaseDateSortSQL helper in query_definition.go so the browse planner, section cursor resolver, and query builder all use the same release-date sort expression.
Behavioral Change: Recently Released rows now appear in release-date order; items without a release date sort last, and a movie with only a premiere date is treated as undated in movie-only sections.
The row ordered by year and then by when Silo added each title, so titles
from the same year came out in arbitrary order. It now uses the library's
Release Date sort (a series' premiere when it has no release date), with
undated titles last by year.
Recently Released rows break release-date ties by content ID, as their
See All page does, and the catalog's cursor and query builder use the
same ReleaseDateSortSQL helper. The ordering test moves into the
existing recent-rows test file and covers the tie.
No actionable comments were generated in the recent review.
Walkthrough
The catalog adds a shared release-date SQL expression for sorting. Recently Released results now sort by release date, with undated titles last and content ID as a tie-breaker. A database-backed test checks the ordering.
ReleaseDateSortSQL builds the release-date expression for a table alias. Catalog sorting paths use it for non-movie and non-episode sorting; movie-only and episode-scoped sorting remain unchanged.
Recently Released ordering internal/sections/fetcher.go, internal/sections/fetcher_recently_added_compat_test.go, scripts/ci/db-contracts.txt
Recently Released results sort by release date descending, with undated titles last and content ID ascending for ties. The database-backed test checks default and movie-only ordering, including series premiere-date fallback. The CI database contract list includes the test.
Recently Released now sorts by actual release date, matching the library's Release Date sort. No concrete merge-blocking risk remains. Undated titles may drop out of the row when dated titles fill its item limit, which is the author's stated and accepted behavior.
Security architecture risk: Minimal · up to 8ed74
The change adjusts result ordering without an observed expansion of access or authority. Existing catalog and cursor sort expressions remain equivalent, and no material security, ownership, or rollback risk was identified in the inspected changes.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(sections): order Recently Released rows by release date" matches the main change. The fetcher now orders the Recently Released row by release date instead of year and creation time, and…
Linked Issues check
Issue #4492 asks that the Recently Released row sort by actual release date, newest first, matching the Movies library Release Date descending sort, with missing dates handled and a deterministic tie-…
Out of Scope Changes check
The changes support the #4492 ordering fix. catalog.ReleaseDateSortSQL is the shared helper. It is used by the Recently Released query builder in fetcher.go, by releaseDateSortExpr in the catalog quer…
Description check
The description states the problem (Recently Released rows sort by year and creation time, not release date), the approach (a shared ReleaseDateSortSQL helper and new release-date ordering in buildRec…
Full details: Title check
Explanation
The title "fix(sections): order Recently Released rows by release date" matches the main change. The fetcher now orders the Recently Released row by release date instead of year and creation time, and the shared ReleaseDateSortSQL helper supports this. The title is specific and short, and it names the affected area.
Full details: Linked Issues check
Explanation
Issue #4492 asks that the Recently Released row sort by actual release date, newest first, matching the Movies library Release Date descending sort, with missing dates handled and a deterministic tie-breaker. At head 8ed7495, buildRecentlyReleasedQuery in internal/sections/fetcher.go orders by catalog.ReleaseDateSortSQL("mi") DESC NULLS LAST, then mi.content_id ASC. For filter_type movie, it orders by mi.release_date DESC NULLS LAST, then mi.content_id ASC. The movie-only branch matches the See All movie-only ordering that the code comment cites. The year-based ordering and created_at tie-break from the bug are removed. Undated titles sort last. Ties use content ID. The change since the previous review adds the movie-only branch and makes browse.go use the shared helper. Both keep the release-date ordering. I did not open the test file, so the test's content rests on the PR description and change summary. The code change itself establishes the required ordering.
Full details: Out of Scope Changes check
Explanation
The changes support the #4492 ordering fix. catalog.ReleaseDateSortSQL is the shared helper. It is used by the Recently Released query builder in fetcher.go, by releaseDateSortExpr in the catalog query builder, by the See All cursor, and by browse.go (premiereDateKeyExpr is now initialized from the helper, with the same COALESCE expression as before). The new mediaScopeMovie constant and movie-only branch in fetcher.go align the movie row with the movie See All ordering. The PR description does not mention this movie-only branch, so the description is incomplete on this point. The branch is still tied to the issue's release-date requirement, so it is not unrelated work. The new database test and its db-contracts.txt registration support the change. The Recently Added row and buildRecentlyAddedSingleLibraryQuery are not changed, apart from the added constant placed above buildRecentlyReleasedQuery.
Full details: Description check
Explanation
The description states the problem (Recently Released rows sort by year and creation time, not release date), the approach (a shared ReleaseDateSortSQL helper and new release-date ordering in buildRecentlyReleasedQuery), the validation steps, the test and its db-contracts registration, evidence output, and risks. It is specific and clearly related to the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 551a2a24-2fdf-4f71-a540-c6a8d5d7c7fe
Commits
Reviewing files that changed from the base of the PR and between e1e2cea and 8ed7495.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Year tie-break makes the row disagree with See All
Titles with the same release date, including missing dates, can produce different limited results than See All, which orders ties by mi.content_id. Remove the mi.year tie-break to match both See All pagination paths.
Prompt for LLM
File internal/sections/fetcher.go, line 2851:
Year tie-break makes the row disagree with See All
Titles with the same release date, including titles with no date, are ordered by year in the row but by content ID on See All, so the row can show a different set of titles at its limit. Remove the year tie-break to match both See All pagination paths.
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
Fixed in 8ed7495. Confirmed: both See All paging paths order by the release-date key and then content ID, while the row added mi.year between them, so undated titles could come out in a different order or a different set at the row limit. The row now uses exactly See All's terms. I kept See All as it is rather than adding year there, because BrowseRepository's release-date order also serves Jellyfin's premiere-date sort and the section cursor would need a third key. The DB test now has two undated titles whose year order and content-ID order disagree; it fails on e1e2cea and passes on 8ed7495.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this. Based on the reported fix, ordering the row by release date and then content ID resolves the mismatch with both See All pagination paths. The new test also covers the undated-title case that exposed it.
One follow-up: the PR description and summary still say undated titles are ordered by year. They should be updated to reflect the content-ID tie-break.
The computed release-date ordering cannot use the existing (type, year DESC) or movie release-date indexes, forcing limited movie rows to inspect and sort matching items. Add a matching expression index or use an indexed ordering strategy that preserves mixed-item semantics.
Prompt for LLM
File internal/sections/fetcher.go, lines 2851-2852:
Release-date expression prevents indexed top-N retrieval
The computed release-date ordering cannot use the existing `(type, year DESC)` or movie release-date ordering indexes, so fetching a limited movie row must inspect and sort matching library items instead of using an ordered index scan. Add a matching expression index or use an indexed ordering strategy that preserves the required mixed-item semantics.
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
Partly addressed in 8ed7495. A movie-only row (the default Recently Released Movies row) now orders by mi.release_date DESC NULLS LAST, mi.content_id ASC, which is the order of idx_media_items_movie_release_date_desc_content. Mixed-type rows still sort by the computed expression. The old year DESC, created_at DESC order was in the same position, since the row is scoped through library membership, and the author measured about 47 ms for both old and new queries on 150,000 movies. An expression index for mixed rows isn't worth adding for this fix.
The reason will be displayed to describe this comment to others. Learn more.
The movie-only optimization may change the intended ordering. The described order omits mi.year DESC, so:
Undated movies sort by content ID rather than newest year first.
Movies with the same release date but different years may also order differently from the catalog and See All pages.
If the movie-only query is as described, it should preserve the year tie-break, or the behavior change should be explicitly accepted and tested.
The benchmark supports deferring a mixed-row expression index for this fix. For the movie-only optimization, a matching index makes an ordered scan possible, but doesn’t establish that PostgreSQL will choose one with the library-membership filter; EXPLAIN (ANALYZE, BUFFERS) would verify the actual plan.
The reason will be displayed to describe this comment to others. Learn more.
The movie-only order leaves out the year on purpose. For a movie section, the See All cursor orders by mi.release_date and then content ID (resolveSectionOrderCursor), so the row has to use the same terms to be See All's first page. With mi.year between them, an undated movie could show in the row but not on See All's first page, which is the mismatch the earlier thread on this line fixed. The test covers undated titles whose year and content-ID order disagree, in both a mixed row and a movie-only row. The PR description now says undated titles and ties go by content ID.
The reason will be displayed to describe this comment to others. Learn more.
Understood. The row should use the same release-date and content-ID ordering as See All; adding year as a tie-breaker would break first-page consistency for undated movies.
The reported test covers that case for both mixed and movie-only rows. The index-performance suggestion is a separate concern and does not justify changing those ordering semantics.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
The row ordered titles with no release date by year before content ID,
while both See All paging paths go straight to content ID, so undated
titles could appear in a different order, or a different set, than on
See All. A movie-only row also fell back to a premiere date that See All
ignores for movies, so a movie with only a premiere date led the row but
sat with the undated titles on See All.
Drop the year term and sort movie-only rows by mi.release_date, so the
row is always See All's first page. BrowseRepository's release-date
ORDER BY now uses the shared ReleaseDateSortSQL helper too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
One new finding is below. The other one, the mi.year tie-break, is already raised in the Kody and CodeRabbit threads on this line, so I'll answer it there. I'm fixing both in a commit on this branch, so there's no need to change anything yourself.
The fix works: the new DB test fails on main with the add-order bug and passes on this branch. I pushed one commit (8ed7495) that makes the row match its See All page exactly. No decisions are left open.
Titles with no date were ordered differently on the row and on See All. The row sorted them by year before content ID, while both See All paging paths go straight to content ID. With undated titles in a row that isn't full, the row could list them in a different order, or a different set at the limit. The row now drops the year term. See All is unchanged, because BrowseRepository's release-date order also serves Jellyfin's premiere-date sort.
Movie-only rows used the premiere fallback that See All skips for movies. A movie with no release date but a premiere date could lead the row and sit with the undated titles on See All. Movie-only rows now order by mi.release_date, which also matches the existing movie release-date index.
BrowseRepository's release-date ORDER BY now uses the shared ReleaseDateSortSQL helper too, so no copy of the expression is left.
The DB test now covers both cases. Each new case fails on the head before the fix and passes on 8ed7495. make lint-changed reports 0 issues, and the catalog, sections, and jellycompat tests pass against a fresh test database.
Left as is
The library grid's Release Date sort breaks same-day ties by title, while the row and See All break them by content ID. Two titles released the same day can still swap places between the row and the library grid. The PR description now says so. Matching the grid would mean changing both See All paging paths, which this fix doesn't need.
The row's config parser drops ebook, manga, and video from a structured media_scope, while See All keeps them, so in a mixed library an out-of-scope title can take a row slot. This predates this PR and is being fixed in its own follow-up.
Cross-provider review: one round, Codex gpt-6.2-sol at xhigh effort, on e1e2cea. It found four issues: the two fixes above, the library-grid tie-break, and the media-scope drift.
Validated features: none affected. The Curated home sections server cases (#1140, C1–C4) cover row sets, per-profile row order, and access filtering, not the order of items inside a row, and none has a result yet.
User manual: unaffected. The manual doesn't describe how the Recently Released row is ordered.
Other clients: the server builds the row and the clients render it in order, so N/A for Apple, Android, and Roku is right. Jellyfin compatibility doesn't use this row.
Evidence: the published page still matches this head. Its fixture has one undated title and no movie with only a premiere date, so the follow-up commit doesn't change what it shows.
Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
Fit: a correctness fix in a 1.0 home-screen row, using the catalog's existing release-date order. It adds no setting and no new API surface.
Readiness: the behavior is proven by a test that fails on main, and my additions each fail before their fix. The author's live before/after capture matches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workinggoPull requests that update go codeimpact: polishAnnoyance, cosmetic, or nice-to-havepriority: P2Limited scope, workaround exists, or polishsize/M50–199 added + deleted lines (all files); change volume, not priority.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #4492
Related issue: N/A
Validation tasks: none
Other clients: Apple N/A (no client change; apps render the row in the order the server sends); Android N/A (same); Roku N/A (same)
Recently Released rows on the home screen and library pages showed titles from the same year in the order Silo added them, not the order they came out. A movie from March could sit ahead of one from September, while the library's Release Date sort and the row's own See All page listed them correctly. This affects every client, since the server builds the row.
The row now sorts by release date, like the library's Release Date sort, and lists titles in exactly the order of its own See All page.
Approach
buildRecentlyReleasedQuerysorted byyear DESC, created_at DESC. It now sorts by the expression the catalog's Release Date sort uses: the release date, or a series' premiere (first_air_date) when it has no release date, newest first. A movie-only row sorts by the movie release date alone, as See All does for movie sections. Titles with no date come after the dated ones. Ties, undated titles included, go by content ID, the same terms both See All paging paths use, so the row is always See All's first page. The library grid breaks same-date ties by title instead, so two titles released the same day can still swap places between the row and the library grid.The expression now lives in one exported helper,
catalog.ReleaseDateSortSQL. The row, the catalog query builder, the See All cursor andBrowseRepositoryall use it, so they cannot drift apart.On 150,000 synthetic movies in one library, the new query and the old one both took about 47 ms. Neither can use an index, because the row is scoped through library membership.
Validation
go build ./...,gofmt -l,go mod tidy -diff,go veton the changed packages: clean.make lint-changed(golangci-lint v2.15.0, built with the repository's Go version) andmake lint-router-recovery: 0 issues.make verify-local-paths,verify-case-collisions,verify-bidi,verify-size-ratchet: pass.make test-go: pass. Four packages (api/handlers,backup,ebookconvert,uploads) failed on the first run because the local umask made temp directories group-writable. They pass withumask 022and do not touch this change.scripts/ci/db-contracts.txt: the row's order across release dates, a series premiere, a same-date tie, undated titles whose year and content-ID order disagree, and a movie with only a premiere date in a mixed row and in a movie-only row, all added in reverse order. It fails onmain. Allinternal/sectionsdatabase contracts pass through thedbpinsrunner.Evidence
Local build, Movies library, nine NFO movies (seven from 2026 with different
premiereddates, one from 2025, one 2026 title with no date), added newest release first. Output is title, release date, year.Before (
main),GET /api/v2/library/{id}/sections, Recently Released Movies row:After (this branch), same data. The row now matches both
GET /api/v2/catalog?sort=-release_dateand the row's See All page (GET /api/v2/library/{id}/sections/{section_id}/items):The Recently Added Movies row on the same page did not change.
Risks
A title that has a year but no release date or premiere, such as an unmatched title, now comes after every dated title. In a library with more dated titles than the row's item limit, it drops out of the row until its metadata has a date. The library's Release Date sort and See All already order it that way.
Checklist
AI Disclosure
created_at) differed from the See All page's (content_id). Fixed: ties now go by content ID, and the test covers a same-date tie. Three reviewers noted the release-date expression was still copied in the catalog query builder and the See All cursor. Fixed: both use the new helper. Two flagged the new test file. Fixed: the test moved into the existing recent-rows test file. One flagged fixture cleanup registered too late. Fixed. The year-only trade-off under Risks was raised and kept on purpose, because it matches the library sort. A re-review of the fix commit found nothing.Note
Order Recently Released section rows by release date
buildRecentlyReleasedQueryin fetcher.go now orders by descending release date withNULLS LASTand ascending content ID as tie-breaker, replacing the old year/creation-time ordering. Movie-only sections order bymi.release_date.ReleaseDateSortSQLhelper in query_definition.go so the browse planner, section cursor resolver, and query builder all use the same release-date sort expression.TestRecentlyReleasedOrdersByReleaseDatein fetcher_recently_added_compat_test.go and registers it in db-contracts.txt.Macroscope summarized 8ed7495.