Repository navigation
fix(sections): keep titles in no library out of Home rows - #2695
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: 🔵 Low · up to
|
|
The Home section rows in The Home discovery rows in Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
Major change: The new unscoped membership predicates change Home row contents: The PR must connect the intended orphan exclusion to these C1 output changes; these cases need re-validation after merge. All corresponding result cells are currently Please replace the current Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Quick104
left a comment
There was a problem hiding this comment.
Review of 8ecd373. The fix is right for the rows built on buildLibraryScope and the discovery queries. I found no title that should stay visible and is now hidden: series, manga and podcast rows carry their own membership, and episodes take a separate path. The new DB test fails on the base for all three Home cases and passes on this head. Two findings are inline. The first is fixed in a commit on this branch. The second needs a maintainer decision.
This review was produced by an AI agent (Claude Code, claude-opus-5-5, with a gpt-6.1-sol cross-check) and checked against the source and a test database.
|
|
||
| if libraryID == nil && libraryIDs == nil && len(configLibraryIDs) == 0 { | ||
| conditions = append(conditions, | ||
| "EXISTS (SELECT 1 FROM media_item_libraries mil_scope_any WHERE mil_scope_any.content_id = mi.content_id)", |
There was a problem hiding this comment.
Maintainer decision: other Home rows still show titles in no library. This check covers rows built on buildLibraryScope. Rows built through catalog's QueryExecutor use buildLibraryScopeJoin / libraryAccessConditions, which add the membership check only when a library is disabled. I confirmed each of these on a test database with an orphan movie and an orphan series and no disabled library:
- Home
genreandcustom_filterrows (fetchFiltered→PreviewPage) still return the orphan movie. Editorial Spotlight and live collection rails take the same path. - Continue Watching and Next Up still return an episode of an orphan series (
fetchEpisodeTargetsByContentIDs→ApplyLibraryAccessFilter). - New with this PR: a collection rail with no default sort now hides the orphan, but the same collection with a default sort (
QueryCollectionItemsBySort) still shows it.
The first two predate this PR. The general fix is to require membership in catalog's shared libraryAccessConditions / buildLibraryScopeJoin whenever no allow list applies. That reaches every unscoped browse and search path, which is the wider problem tracked in #2818. Whether to widen this PR or land it as is and leave the rest to #2818 is for the maintainers to settle.
Review summaryReviewed head: Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green) The change does what it says for the rows it touches. A title whose last file is removed loses its library membership but keeps its Addressed
Left for the maintainers
Verification
Validated featuresNo passed validation case is reachable. The only feature with passed cases (#1143, person browsing) shares no code with this diff. Other checks
This review was produced by an AI agent (Claude Code, claude-opus-5-5, with a gpt-6.1-sol cross-check). |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
A Home row has no library scope, so buildLibraryScope added no membership check and returned media_items rows whose last file was removed: the title stayed in Recommended for You (and Recently Released and other rows) on Home after a rescan, while the library's own rows dropped it. The check existed only when a disabled library was set. Require a media_item_libraries membership whenever no library scopes the query, in buildLibraryScope and in the catalog discovery scope behind Top Rated, Hidden Gems and Forgotten Favorites. Closes Silo-Server#2684
List TestSectionsSkipItemsInNoLibraryPostgres in db-contracts.txt so the DB contracts job runs it; without a list entry it always skips in CI. Rename the catalog membership assertion so its failure message fits the unscoped case it now also covers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8995beb to
bc47671
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The PR now links to its evidence page, but the description does not identify which changed Home rows its captures and response excerpts cover. Please ensure the page shows before-and-after results for the fetcher-backed rows (For You, Recently Released, and Critically Acclaimed) and catalog discovery rows (Top Rated, Hidden Gems, and Forgotten Favorites), with matching API excerpts and desktop/phone-width Home captures. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Problem
Closes #2684
Related issue: N/A
Validation tasks: none (no passed case is reachable. Row contents change for #1140, #1142, #1145, #1146, Silo-Server/silo-apple#305, #306 and Silo-Server/silo-android#315, #316, none of which has a recorded result yet.)
When a title's file is deleted and the library is rescanned, the title stays in Home rows such as Recommended for You, while the same row on the library page drops it. Every profile on every client sees the stale title on Home. Nothing removes it on its own: the rescan deletes the title's library membership but keeps its
media_itemsrow, and the orphan cleanup task is manual and only covers provisional items.The cause: a Home row has no library scope, so
buildLibraryScopeadded no membership check. The check was there only when a disabled library narrowed the query. This change requires the title to belong to at least one library whenever no library scopes the row.Approach
buildLibraryScopeininternal/sectionsnow adds the "belongs to some library" check in the unscoped case, not just in the deny-only case. The catalog discovery queries (appendDiscoveryLibraryScope) had the same gap, and they feed the Home Top Rated, Hidden Gems and Forgotten Favorites rows, so they get the same check. Scoped rows, restricted profiles and disabled-library filtering are unchanged.Every caller of both helpers selects movies, series or book titles from
media_items. Episodes and seasons live in their own tables, and watch activity is rolled up to the series before the check, so nothing that should show is hidden. The check is an index lookup on themedia_item_librariesprimary key.Server only. The fix applies to the native API, and so to web, Android and Apple clients, with no client change needed. jellycompat reads its Latest rows through the same fetcher but always with a library, so it is unchanged.
Validation
scripts/ci/db-contracts.txtso the DB contracts job runs it: For You, Recently Released and Critically Acclaimed on Home, on Home with a disabled library, and on a library page, each with one title in a library and one in none. It fails onmainfor the Home cases and passes here. A unit test covers the unscoped discovery queries.main, a deleted and rescanned movie stayed in Recommended for You on Home but not on the library page. With this branch it is gone from both, and it returns to both when the file is restored and the library rescanned.go build,gofmt,make lint-changed,make lint-router-recovery,make verify-local-paths: pass.make test-db-pins: all 273 pins pass.make test-go: fails onlyTestPlaybackInfoWithoutStripOrToneMapStillHasNoRouteandTestPlaybackInfoSkipsStripWhenRPUCannotBeStrippedininternal/jellycompat, which fail the same way onmainin the same environment.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2695/
Surface and build: web app Home and Movies library page (Recommended tab), desktop and phone width, local dev server with a test library. Before is
mainat 365e3d4, after is this branch. The page also has the section API responses for the same requests.Risks
None identified. Titles that belong to no library stop appearing in Home rows; any such title already does not appear on library pages.
Checklist
AI Disclosure
Note
Exclude items with no library membership from unscoped Home section queries
media_item_librariesmembership predicate out of the disabled-library-only branch insections.buildLibraryScope(fetcher.go) and mirrors it incatalog.appendDiscoveryLibraryScope(discovery_repo.go) so it applies whenever no library scope is setTestSectionsSkipItemsInNoLibraryPostgres) covering recommended, recently released, and critically acclaimed sections, and registers it in the DB-contract manifest (db-contracts.txt)media_itemsrows with nomedia_item_librariesrow; disabled-library NOT EXISTS filtering is unchangedMacroscope summarized bc47671.