Skip to content

fix(jellycompat): serve real MediaSources on Resume/NextUp pages - #69

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-resume-mediasources
Jun 7, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-resume-mediasources

Conversation

@d3v1l1989

@d3v1l1989 d3v1l1989 commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #67

What problem does this solve

Continue Watching renders empty in Infuse and SenPlayer (details + evidence in the issue). Both clients build their rows from the listing's MediaSources; /UserItems/Resume and /Shows/NextUp serve a stub (Id:"0", all playability flags false, null collections) whenever the client requests Fields=MediaSources, so they discard the entire response. Verified by request logs: Infuse received 15 valid resume items and fetched images for 0 of them, while rendering /Items/Latest (real detail path, same fields=) normally.

Why this approach

The stub exists for a good reason — the old per-entry GetItemDetail fanout over the full in-progress list caused the 38s timeout (error-report-2026-05-08 §6). That fix is preserved: the scan loop (hydrateProgressItems, up to 200 entries per iteration for type filtering) stays strictly list-level, and the existing no-detail regression test still pins that.

What changes: the returned page (bounded by the request limit, hard cap 100) is re-mapped through the per-item detail path when the client asked for detail-level Fields — the exact pattern HandleLatest already uses for the same Fields. Clients that don't request detail fields (jellyfin-web, Streamyfin) take the unchanged zero-cost path.

The stub remains as fallback for entries past the cap or whose detail fetch fails, and is made honest: playable flags, Name/RunTimeTicks, nested stream, and Formats/RequiredHttpHeaders/MediaAttachments as empty collections instead of JSON null (real Jellyfin/Emby never serialize null arrays; strict client decoders fail the whole body on them).

How it was tested

  • go test ./internal/jellycompat/... green; new tests: TestSlicePageIDs (pins items/pageIDs slice alignment against sliceBaseItems), stub playability + non-null-collections + mutation-leak guards; the no-detail scan test's doc updated to describe the two-phase design.
  • Deployed on a production server (~182k items): Infuse and SenPlayer Continue Watching confirmed rendering by their users; 40-item Resume page with full detail fields serves in ~100–135 ms; zero 5xx.

Anything to watch out for

  • maxDetailUpgrades=100 means a client requesting limit>100 with detail fields gets stubs past 100 — documented in code, intentional.
  • NextUp uses parallel items/pageIDs slices; alignment is guaranteed by building both in the same loop with the same skip condition and is test-pinned.

Implementation was AI-assisted (Claude); I've read the full diff, and the change was verified live against real Infuse/SenPlayer clients before submitting.

Summary by CodeRabbit

Release Notes

  • Performance

    • Optimized progress and resume pagination to limit unnecessary detail upgrades, improving load times for large libraries.
    • Refined progress item processing for more efficient type filtering.
  • Bug Fixes

    • Enhanced media source fallback handling to prevent client-side deserialization issues and ensure better compatibility across different clients.

Infuse and SenPlayer build Continue Watching rows from the listing's
MediaSources and discard responses that carry only the detail-field stub,
leaving the row empty. Keep the progress scan list-level (the per-entry
GetItemDetail fanout removed in the error-report-2026-05-08 §6 fix stays
removed), but re-map the returned page — bounded by the request limit,
capped at 100 — through the detail path when the client requests
detail-level Fields, matching HandleLatest's existing pattern. The stub
remains as the fallback past the cap and is made honest: playability
flags set, collections serialized empty instead of null.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6eec6c19-c7ce-4046-bea4-39a77910e84a

📥 Commits

Reviewing files that changed from the base of the PR and between ad2183a and 95d3144.

📒 Files selected for processing (5)
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/hydrate_progress_no_detail_test.go
  • internal/jellycompat/mapping.go
  • internal/jellycompat/mapping_stub_detail_fields_test.go
  • internal/jellycompat/slice_page_ids_test.go

📝 Walkthrough

Walkthrough

The PR implements page-bounded detail upgrading for resume/next-up progress lists while fixing the MediaSources stub to remain playable. Progress hydration now carries detail-upgrade inputs, pagination logic refactors to extract finishProgressPage/upgradeProgressPageToDetail for conditional per-item remapping, NextUp applies the pattern to its returned page with proper ID tracking, and the stub is enhanced with playable flags and non-null collections.

Changes

Resume/NextUp detail upgrade and playable MediaSources stub

Layer / File(s) Summary
Progress item hydration expansion
internal/jellycompat/handlers_items.go, internal/jellycompat/hydrate_progress_no_detail_test.go
progressHydratedItem struct is expanded to hold content ID, favorite state, item type, upstream entry, optional episode target, and list-level DTO needed for later detail remapping. hydrateProgressItems populates expanded fields for both episode and non-episode paths. Test documentation clarifies hydration as detail-free SCAN, with detail-serving deferred to upgradeProgressPageToDetail.
Progress page loading and detail-upgrade extraction
internal/jellycompat/handlers_items.go
loadProgressPage refactored to accumulate progressHydratedItem entries during type filtering and pagination, then pass through finishProgressPage to conditionally upgrade to detail DTOs. New upgradeProgressPageToDetail remaps bounded page prefix using GetItemDetail, preserving episode targets and favorite state during field substitution.
NextUp response with page-bounded detail upgrade
internal/jellycompat/handlers_items.go, internal/jellycompat/slice_page_ids_test.go
writeNextUpResponse tracks page content IDs alongside items using new slicePageIDs helper and conditionally performs per-item detail upgrades only for the visible page when detail Fields are requested, capped by maxDetailUpgrades. Test validates slicePageIDs bounds clamping and positional alignment across multiple paging scenarios.
Stub MediaSources as playable fallback
internal/jellycompat/mapping.go, internal/jellycompat/mapping_stub_detail_fields_test.go
stubDetailListFields enhanced to construct playable MediaSources stub with direct-play/stream/transcoding flags, non-null collections (Formats, RequiredHTTPHeaders, MediaAttachments), and metadata mirroring (ID, name, runtime). Documentation clarifies stub as honest fallback preventing client null-deserialization errors. Tests validate stub playability flags, metadata mirroring, and per-call isolation.

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing MediaSources delivery on Resume/NextUp pages.
Linked Issues check ✅ Passed The PR comprehensively addresses #67 objectives: real MediaSources served on detail-field requests, scan loop kept list-level, page remapping via detail path, stub made playable-honest, and maxDetailUpgrades=100 cap implemented.
Out of Scope Changes check ✅ Passed All changes are scoped to Resume/NextUp MediaSources fix: handler refactoring, progress hydration, detail-field stubbing, and corresponding tests with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Quick104
Quick104 merged commit e9cf274 into Silo-Server:main Jun 7, 2026
1 check passed
Quick104 pushed a commit that referenced this pull request Jun 7, 2026
Infuse and SenPlayer build Continue Watching rows from the listing's
MediaSources and discard responses that carry only the detail-field stub,
leaving the row empty. Keep the progress scan list-level (the per-entry
GetItemDetail fanout removed in the error-report-2026-05-08 §6 fix stays
removed), but re-map the returned page — bounded by the request limit,
capped at 100 — through the detail path when the client requests
detail-level Fields, matching HandleLatest's existing pattern. The stub
remains as the fallback past the cap and is made honest: playability
flags set, collections serialized empty instead of null.
Quick104 pushed a commit that referenced this pull request Jun 17, 2026
Infuse and SenPlayer build Continue Watching rows from the listing's
MediaSources and discard responses that carry only the detail-field stub,
leaving the row empty. Keep the progress scan list-level (the per-entry
GetItemDetail fanout removed in the error-report-2026-05-08 §6 fix stays
removed), but re-map the returned page — bounded by the request limit,
capped at 100 — through the detail path when the client requests
detail-level Fields, matching HandleLatest's existing pattern. The stub
remains as the fallback past the cap and is made honest: playability
flags set, collections serialized empty instead of null.
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.

jellycompat: Continue Watching empty in Infuse and SenPlayer (Resume/NextUp serve stub MediaSources)

2 participants