Skip to content

fix(jellycompat): fill large browse pages - #49

Merged
Quick104 merged 2 commits into
mainfrom
fix/uhf-jellycompat-items-ingest-main
Jun 6, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/uhf-jellycompat-items-ingest-main

Conversation

@Quick104

@Quick104 Quick104 commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes UHF-style Jellyfin compatibility /Items browse requests that ask for large pages and deep StartIndex offsets, such as Limit=1000&StartIndex=1925000&SortBy=PremiereDate.

Root Cause

The Jellyfin compatibility layer passed the client limit into catalog browse, but catalog silently capped pages at 100. That under-filled large Jellyfin pages and forced clients to do much more pagination work. The movie PremiereDate sort also used a text COALESCE(...) expression, which prevented the large-offset movie browse path from using a release-date btree index effectively.

Changes

  • Propagate EnableTotalRecordCount into the direct Jellyfin browse adapter.
  • Let Jellycompat explicitly request up to 1000 catalog rows for compatibility browse pages while preserving the default 100-row cap for native catalog callers.
  • Keep exact totals out of the sorted page query; exact counts use the separate count query path or are inferred when safe.
  • Make movie-only PremiereDate browse order by mi.release_date directly.
  • Add idx_media_items_movie_release_date_desc_content for movie release-date deep paging.
  • Add regression coverage for large compatibility pages, include_total=false, caller-specific catalog caps, and the movie-only release-date SQL shape.

Validation

  • go test ./internal/jellycompat ./internal/catalog

AI Use

Implemented with AI assistance.

Summary by CodeRabbit

Release Notes

  • Performance Improvements

    • Added response compression for API payloads
    • Optimized movie browse queries with efficient release date sorting
    • Implemented batch image resolution for faster content loading
  • API Enhancements

    • Browse pagination now supports configurable maximum page limits
    • Improved total record count reporting with optional calculation modes

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Need the big picture first? Review this PR in Change Stack to see what changed before going file by file.

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR refactors catalog browse query execution to eliminate window-count functions and use extra-row pagination. It introduces a MaxLimit field to cap caller limits, optimizes movie-only release_date queries with a database index, and updates the Jellyfin compat layer to use page-based pagination with optional totals and batch image presigning.

Changes

Browse Query and Compat Layer Refactoring

Layer / File(s) Summary
Browse filter contracts and limits
internal/catalog/browse.go
BrowseFilters gains MaxLimit field to enforce dynamic caller limits, and browseFiltersAreMovieOnly() helper detects when filters specify only movie type.
Browse query and pagination
internal/catalog/browse.go
Browse queries always execute page-only SELECTs without COUNT(*) OVER(), use extra-row fetching to detect HasMore, and simplify pagedSQL to decouple pagination from includeTotal. Total computation branches: empty offset sets to 0, no extra row implies all rows fit, otherwise runs countSQL().
Movie-only release_date ordering and index
internal/catalog/browse.go, migrations/174_movie_release_date_desc_index.*.sql
buildOrderByPlan branches on movieOnly to use indexed release_date directly for movies. New partial database index on media_items optimizes movie release_date DESC queries with btree over (release_date DESC NULLS LAST, content_id ASC) where type='movie'.
Catalog browse tests
internal/catalog/browse_orderby_test.go, internal/catalog/window_count_test.go
Tests verify browse pages omit window counts, MaxLimit clamping respects caller caps and defaults, and movie release_date queries use indexed columns without COALESCE.
Jellyfin compat pagination and presigning
internal/jellycompat/content_direct.go
browseSource interface changes from Browse() to BrowsePage(ctx, filters, includeTotal). BrowseItems now iterates page-by-page via BrowsePage, conditionally fetches totals, locally filters played items, and batch-presigns images via new presignListItems() instead of per-item calls.
Compat query params and router
internal/jellycompat/query.go, internal/jellycompat/router.go
Query builder propagates include_total parameter from request flags. Router adds Chi compression middleware (level 5) to compress JSON responses.
Jellyfin compat tests
internal/jellycompat/content_direct_test.go, internal/jellycompat/query_test.go, internal/jellycompat/router_test.go
Tests validate batch image resolution, pagination with optional totals, include_total parameter propagation, and gzip compression in responses.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A browse through pages, no windows in sight,
Extra rows peek ahead to show what's bright,
Movie dates flutter on indexed wings,
Jellyfin presigns all image things—
Compressed and swift, the catalog sings!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(jellycompat): fill large browse pages' directly addresses the main functional change: enabling the Jellyfin compatibility layer to handle large browse page requests by removing the page-size cap and optimizing queries for deep paging.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uhf-jellycompat-items-ingest-main

Comment @coderabbitai help to get the list of available commands and usage tips.

@Quick104
Quick104 force-pushed the fix/uhf-jellycompat-items-ingest-main branch from 890e867 to 91cb9e1 Compare June 5, 2026 20:33
@Quick104
Quick104 marked this pull request as ready for review June 6, 2026 01:23
@Quick104

Quick104 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

@CodeRabbit

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@Quick104 It looks like your message may have been cut off! How can I help you with this PR? Feel free to ask me to review the changes, answer questions, explain any part of the code, or assist with something else. 🐇

@Quick104
Quick104 merged commit 8c88932 into main Jun 6, 2026
1 check was pending
@Quick104
Quick104 deleted the fix/uhf-jellycompat-items-ingest-main branch June 6, 2026 01:28
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
…t-items-ingest-main

fix(jellycompat): fill large browse pages
Quick104 added a commit that referenced this pull request Jun 11, 2026
…est-main

fix(jellycompat): fill large browse pages
Quick104 added a commit that referenced this pull request Jun 17, 2026
…est-main

fix(jellycompat): fill large browse pages
Quick104 added a commit that referenced this pull request Jun 17, 2026
…est-main

fix(jellycompat): fill large browse pages
Quick104 added a commit that referenced this pull request Jun 26, 2026
Resolves 8 open Dependabot alerts in web/pnpm-lock.yaml (all dev-only
transitive dependencies) by pinning patched versions through the existing
pnpm.overrides mechanism:

- undici  7.24.7 -> 7.28.0  (via jsdom; alerts #43-#49, incl. 2 high:
  TLS cert validation bypass & cross-origin routing via SOCKS5 ProxyAgent)
- js-yaml 4.1.1  -> 4.2.0   (via @eslint/eslintrc; alert #39, quadratic DoS)
- @babel/core 7.29.0 -> 7.29.6 (via @vitejs/plugin-react; alert #38,
  arbitrary file read via sourceMappingURL)

No vulnerable versions remain in the lockfile. Web build and lint pass;
the only failing tests (ServerStorageStep ResizeObserver) are pre-existing
on main and unrelated to these bumps.

Co-authored-by: Claude Opus 4.8 <[email protected]>
Quick104 added a commit to RXWatcher/silo-server that referenced this pull request Jul 10, 2026
…lo-Server#225)

Resolves 8 open Dependabot alerts in web/pnpm-lock.yaml (all dev-only
transitive dependencies) by pinning patched versions through the existing
pnpm.overrides mechanism:

- undici  7.24.7 -> 7.28.0  (via jsdom; alerts Silo-Server#43-Silo-Server#49, incl. 2 high:
  TLS cert validation bypass & cross-origin routing via SOCKS5 ProxyAgent)
- js-yaml 4.1.1  -> 4.2.0   (via @eslint/eslintrc; alert Silo-Server#39, quadratic DoS)
- @babel/core 7.29.0 -> 7.29.6 (via @vitejs/plugin-react; alert Silo-Server#38,
  arbitrary file read via sourceMappingURL)

No vulnerable versions remain in the lockfile. Web build and lint pass;
the only failing tests (ServerStorageStep ResizeObserver) are pre-existing
on main and unrelated to these bumps.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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