Skip to content

fix(jellycompat): hide dismissed and superseded entries from Resume - #114

Merged
Quick104 merged 1 commit into
mainfrom
claude/distracted-ramanujan-790b46
Jun 9, 2026
Merged

Quick104 merged 1 commit into
mainfrom
claude/distracted-ramanujan-790b46

Conversation

@Quick104

@Quick104 Quick104 commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The jellycompat /UserItems/Resume endpoint served the raw in_progress progress list. Jellyfin clients therefore showed every half-watched episode a profile ever abandoned — many cards per series, mixed across seasons (reported with Monarch: Legacy of Monsters). The first-party Continue Watching row didn't have this problem because internal/sections already filters out entries the user dismissed and episodes superseded by a later-completed episode in the same series — but that logic was private to the sections fetcher.

Real Jellyfin self-cleans its Resume row by clearing the playback position once an item is marked played. Silo keeps those rows as in_progress and relies on query-time filtering, so the compat endpoint needs the same filters.

Approach

Extract the shared rules into internal/catalog and apply them on both surfaces:

  • internal/catalog/continue_watching_progress.go (new): ContinueWatchingProgressFilter.SupersededEpisodeProgressIDs (the superseded-episode SQL, moved verbatim from sections), CompletedProgressSnapshots/ProgressSnapshots/FilterSupersededProgress helpers, and HomeDismissalIndex with the dismissal timestamp rule. A nil pool disables the SQL check, preserving jellycompat's no-Postgres fallback mode.
  • internal/sections/fetcher.go: now delegates to the catalog filter; ~150 lines of moved logic deleted. First-party behavior is unchanged, including the gates (superseded filtering still only runs for continue-types that allow next-up).
  • internal/jellycompat: UserDataService gains FilterResumeProgress, implemented in directUserDataService (dismissal lookup failures log and degrade to showing entries, matching first-party; superseded query failures are hard errors, matching first-party). loadProgressPage runs each raw batch through it for in_progress status only — the watched-items view stays unfiltered.

Reviewer notes

  • Pagination: loop advancement/termination uses raw batch counts so filtering can't truncate scans early. The raw-offset fast path is restricted to StartIndex=0 for Resume, since filtered lists make raw store offsets diverge from the visible list; deeper pages go through the scan-from-zero branch that paginates over visible entries. Note most real requests already took that branch (EnableTotalRecordCount defaults to true).
  • The per-series collapse (one card per show) deliberately stays first-party only: real Jellyfin returns one card per partially-watched item and clients pair Resume with their own NextUp call, so collapsing would diverge from expected endpoint semantics. The stale cross-season duplicates disappear via the superseded filter alone.
  • Tests: moved helper tests now live in internal/catalog/continue_watching_progress_test.go with new coverage for the dismissal index and nil-pool path; internal/jellycompat/resume_filter_test.go pins filtering on Resume, correct totals with type filters, no filtering for the completed view, and the dismissal glue in directUserDataService.
  • No client (Android/Apple) follow-up needed: first-party API responses are unchanged; only the Jellyfin-compat surface gets cleaner.

Risks: Resume responses for profiles with many stale entries will shrink (intended). Per batch, filtering adds one dismissals lookup, one completed-progress page scan, and one episodes query — same cost profile the first-party row already pays.

AI-use disclosure: implemented with Claude Code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Enhanced Continue Watching to automatically hide dismissed items and outdated in-progress episodes when a newer episode in the same series is completed.
  • Tests

    • Added comprehensive test coverage for continue watching progress filtering behavior.

The jellycompat /UserItems/Resume endpoint served the raw in_progress
list, so Jellyfin clients showed every half-watched episode a profile
ever abandoned, including stale entries from earlier seasons of shows
the viewer had long moved past. The first-party Continue Watching row
already hid those via dismissal filtering and the superseded-episode
check, but that logic was private to internal/sections.

Extract the shared rules into internal/catalog
(ContinueWatchingProgressFilter, HomeDismissalIndex) and apply them to
the compat Resume path through a new UserDataService method,
FilterResumeProgress. The sections fetcher now delegates to the same
code, so both surfaces agree on what "still watching" means.

Resume pagination keeps advancing by raw batch counts so filtering
cannot terminate scans early, and the raw-offset fast path is limited
to StartIndex=0 for Resume because filtered lists make raw offsets
diverge from the visible list. The watched-items view ("completed"
status) stays unfiltered, and the per-series collapse deliberately
stays first-party only to preserve Jellyfin endpoint semantics.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new catalog/continue_watching_progress library centralizes superseded-episode and dismissal-based progress filtering, replacing file-local implementations in sections/fetcher. Jellycompat adopts the library via a new FilterResumeProgress interface on UserDataService, integrating resume filtering into request pagination while preserving store-level paging.

Changes

Progress Filtering Library & Jellycompat Integration

Layer / File(s) Summary
Progress filtering types and core entry points
internal/catalog/continue_watching_progress.go
ProgressLister interface enables paginated progress lookup; ProgressSnapshot pairs content IDs with timestamps; ContinueWatchingProgressFilter queries superseded episodes via Postgres unnest-based SQL; HomeDismissalIndex maps dismissals for timestamp-aware filtering.
Catalog progress filtering tests
internal/catalog/continue_watching_progress_test.go
Unit tests verify superseded filtering, dismissal matching, pagination deduplication, snapshot building, and SQL query structure; test doubles capture store calls and return deterministic paged results.
FilterResumeProgress interface and mocks
internal/jellycompat/content_service.go, internal/jellycompat/batch_progress_test.go
New FilterResumeProgress method added to UserDataService interface; mockUserDataService stub returns unfiltered entries to satisfy interface contract.
Router dependency wiring
internal/jellycompat/router.go
withDefaults extracts *pgxpool.Pool from BrowseRepo and constructs catalog.NewContinueWatchingProgressFilter for injection into directUserDataService.
Direct user-data service filtering
internal/jellycompat/userdata_direct.go
directUserDataService accepts resumeFilter dependency; FilterResumeProgress applies dismissal and superseded-episode filtering via catalog library, with error logging and graceful degradation on dismissal lookup failure.
Handler pagination with resume filtering
internal/jellycompat/handlers_items.go
loadProgressPage fast-path and scan-from-zero branches apply FilterResumeProgress for in_progress status; pre-filter row count (rawCount) governs pagination to keep boundaries aligned with underlying store paging while filtering operates on results.
Resume filtering integration tests
internal/jellycompat/resume_filter_test.go
Tests verify resume filtering in loadProgressPage, correct dismissal-record application, type-filter interaction, and filtering bypass for non-resume statuses; minimal dismissal store fakes support end-to-end flow.
Sections fetcher migration to catalog library
internal/sections/fetcher.go
Fetcher gains progressFilter dependency initialized via catalog.NewContinueWatchingProgressFilter; dismissal and superseded-episode filtering switched to catalog methods; file-local helper functions removed.
Sections test cleanup
internal/sections/fetcher_continue_watching_test.go
Obsolete pagination and query-validation tests removed; unused imports cleaned; remaining helper functions retained.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Silo-Server/silo-server#69: Both PRs modify ItemsHandler.loadProgressPage for progress pagination—this PR integrates resume-view filtering via FilterResumeProgress while the related PR refactors pagination for Resume/NextUp surfaces, potentially requiring sequencing or conflict resolution.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.31% 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): hide dismissed and superseded entries from Resume' directly and specifically describes the main change: filtering dismissed and superseded entries from the Resume view in jellycompat. It is clear, concise, and accurately summarizes the primary objective of the changeset.
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 claude/distracted-ramanujan-790b46

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

@Quick104
Quick104 merged commit 7040fa4 into main Jun 9, 2026
1 check was pending
@Quick104
Quick104 deleted the claude/distracted-ramanujan-790b46 branch June 9, 2026 22:01
Quick104 added a commit that referenced this pull request Jun 11, 2026
…114)

The jellycompat /UserItems/Resume endpoint served the raw in_progress
list, so Jellyfin clients showed every half-watched episode a profile
ever abandoned, including stale entries from earlier seasons of shows
the viewer had long moved past. The first-party Continue Watching row
already hid those via dismissal filtering and the superseded-episode
check, but that logic was private to internal/sections.

Extract the shared rules into internal/catalog
(ContinueWatchingProgressFilter, HomeDismissalIndex) and apply them to
the compat Resume path through a new UserDataService method,
FilterResumeProgress. The sections fetcher now delegates to the same
code, so both surfaces agree on what "still watching" means.

Resume pagination keeps advancing by raw batch counts so filtering
cannot terminate scans early, and the raw-offset fast path is limited
to StartIndex=0 for Resume because filtered lists make raw offsets
diverge from the visible list. The watched-items view ("completed"
status) stays unfiltered, and the per-series collapse deliberately
stays first-party only to preserve Jellyfin endpoint semantics.

Co-authored-by: Claude Fable 5 <[email protected]>
Quick104 added a commit that referenced this pull request Jun 17, 2026
…114)

The jellycompat /UserItems/Resume endpoint served the raw in_progress
list, so Jellyfin clients showed every half-watched episode a profile
ever abandoned, including stale entries from earlier seasons of shows
the viewer had long moved past. The first-party Continue Watching row
already hid those via dismissal filtering and the superseded-episode
check, but that logic was private to internal/sections.

Extract the shared rules into internal/catalog
(ContinueWatchingProgressFilter, HomeDismissalIndex) and apply them to
the compat Resume path through a new UserDataService method,
FilterResumeProgress. The sections fetcher now delegates to the same
code, so both surfaces agree on what "still watching" means.

Resume pagination keeps advancing by raw batch counts so filtering
cannot terminate scans early, and the raw-offset fast path is limited
to StartIndex=0 for Resume because filtered lists make raw offsets
diverge from the visible list. The watched-items view ("completed"
status) stays unfiltered, and the per-series collapse deliberately
stays first-party only to preserve Jellyfin endpoint semantics.

Co-authored-by: Claude Fable 5 <[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