Repository navigation
fix(collections): report visible members in personal collection item_count - #1582
Conversation
…count Personal collections always reported item_count 0: the stored column is written only by import syncs, so adding or removing members never changed it and smart collections never had a count. Compute the count when a collection is read instead. Hand-picked and imported collections count the membership rows the acting profile can see, with the same access filter the items page uses; smart collections count the viewer's matches. This covers the collection list, detail, create and update responses, and the library Collections tab. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughPersonal collection views now report counts based on items visible to the acting profile. Manual collections use visible membership rows, and live-query collections use smart-query results. Collection ETags include the live item count. ChangesPersonal collection item counts
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Visible collection counts and count-aware ETags have no identified issue requiring a fix before merge. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Counts are intended to reflect what each profile can see, and existing access checks remain in place. The main unresolved risk is that a count can change independently of a collection edit while conditional writes are still committed against the collection’s stored revision. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 14 files. (2 skipped: 2 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d152df939f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Validation impact
Suggested
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
A personal collection's display filter (movies or series only, watched or unwatched) narrows what its catalog view shows, but item_count ignored it, so a filtered collection reported more items than opening it listed. Count a collection with a display filter, or a smart definition, with the same predicates as its catalog view. Hand-picked and imported collections without a display filter keep the grouped count, which now also leaves out manga chapters as the catalog view does. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
The original ETag finding and the follow-up count batching and disabled-library findings are addressed in 1208abdc9 and f8c5208ce. Collection detail responses and mutation guards now bind the live count into the strong ETag; storage retains its revision check for concurrent edits. The fix keeps visible counts in the catalog layer and restores the existing v2 validator contract. Dynamic counts now use bounded batches and reuse identical smart definitions within each request. Catalog queries consistently hide orphan rows for disabled-library viewers. Test cleanup failures are reported. No actionable findings remain.
Validation: the collection-count PostgreSQL tests and focused HTTP regression pass. A real HTTP/Postgres reproduction verifies catalog and watch-state changes produce new tags and reject stale writes. Existing concurrent-write/profile tests, v2 fixture/schema checks, local-path checks, and changed-package lint pass. PostgreSQL checks cover batching, independent filters/limits, freshness, invalid definitions, orphan exclusion, and nearby person/episode access paths. The 100,000-item synthetic check reduced 500 identical smart counts from 14.4 seconds to about 25 milliseconds; distinct costly predicates still require evaluation. Discovery SQL-shape assertions now follow the shared membership predicate (70cb03066); focused discovery tests pass. The full hosted CI run passes on the reviewed head. Codex and Kody completed review of the production repair without further findings; the final two-line test assertion update was reviewed locally. Kody's latest optional check failed with "Model does not support this protocol" and no code findings; its retry API was unavailable. No broad local suite, browser, or native-device verification was run for this repair.
Validated features
#193 records agent API testing on build 927 (66f6a52a), with no human acceptance yet:
| Cases | Surface | Classification | Reason |
|---|---|---|---|
| S1 | Server/API | No behavior change to the recorded access checks | Collection ownership and sharing rules remain in place. |
| S3 | Server/API | Minor change; re-check | Catalog queries now exclude orphan members for disabled-library scopes, matching direct item access. The focused regression verifies the count equals the visible page. |
| S5 | Server/API | Unaffected | Administrative mutation permissions are unchanged. |
| S6 | Server/API | Major change, explained | Personal collection groups sorted by most_items now use calculated counts. Re-validation is already called out in the PR. |
S2 remains the bug-fix target; #195 has no recorded Web passes. The shared predicate preserves library-backed fixture results for the passed person/access cases; person discovery already required positive membership. Calendar predicates, account-policy inheritance, and impersonation identity transitions are unchanged.
AI review and repair: gpt-6-astra in T3 Code using the Codex provider; GitHub CLI and Go.
Reviewed SHA: 70cb030666453e787b185379488e939c71818c61, against main at 3838c3acdd769abdffb397457902ac1725fad001.
Mergeability: 9/10 — ready. The verified defects are fixed, focused checks and full CI pass, and no actionable review threads or required approvals remain. The optional Kody service failure and lack of browser/native verification are the remaining validation limits.
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1208abdc98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ❌ |
Personal BoxSets reported no ChildCount: the adapter dropped item_count, and the stored column is written only by import syncs anyway. Count the items each collection shows the viewer with the function the native collection routes use since Silo-Server#1582, now shared from the catalog package. Play all and Shuffle (Silo-Server#1594) returned a personal collection's direct members, so series stayed folders and episode-only requests came back empty. Expand the members, in the collection's listed order, with the leaf logic library collections use. Document personal BoxSets in the Jellyfin compatibility reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Closes #1552
Related issue: #192
Validation tasks: unblocks #193 S2; changes #193 S3/S6; unblocks #195
Personal collections always report
item_count: 0, however many members they have. Web shows that 0 on the collection card in a library's Collections tab, and Android uses it as the total for a collection opened from that tab. The count is a stored column that only import syncs write, so adding or removing members never changes it and smart collections never get one. This change computes the count when a collection is read: the number of items the acting profile sees when it opens the collection.Approach
The count equals the total of the collection's catalog view (
source=user_collection), which is what web and Android open. That view shows the members the profile can see, or a smart collection's matches, narrowed by the collection's display filter (movies or series only, watched or unwatched). Hand-picked and imported collections without a display filter are counted together in one grouped query per list. Smart collections and collections with display filters use the same predicates as their catalog views. Distinct definitions are counted in statements of at most 32; identical smart definitions share a count within the request. The count is applied wherever a personal collection is returned: the v1 and v2 collection lists, v2 detail, the create and update responses, and the viewer's collections on a library's Collections tab (/library/{id}/user-collectionsand the tab's group cards). The v1 list shares the same service code, so its value is corrected too; no v1 or v2 response shape changes.Because the count follows the profile, a collection shared with a restricted profile shows that profile only the members it can open, and a watched or unwatched display filter uses that profile's watch state. Keeping the stored column current on every add and remove would still leave smart collections without a count and couldn't reflect per-profile access, so the count is computed on read. Admin library collection counts are unchanged. Catalog queries now exclude orphan rows for viewers with disabled libraries, matching direct item access and grouped membership counts.
The v2 detail ETag includes the live count as well as the collection revision and viewer scope. If catalog contents or watch state changes the displayed count, PATCH and DELETE with the earlier tag return 412 at precondition evaluation. The stored revision still protects concurrent collection edits in the write transaction.
Validation
0.item_countwith the catalog resolver's total for hand-picked and smart collections with no display filter, a movies-only filter, and a series-only filter. It fails when the display filter is ignored.GetByIDsWithAccessreturns under library allowlists, disabled libraries, advisory-age limits, and an empty library scope, and ignores missing items, manga chapters, sub-item rows, and other accounts. The smart count equals the cursor page total, including the definition's item limit.go build,gofmt,go vet,make lint-changed,make test-go,make test-db-pins, and the settings-binding, playback-fixture, route-inventory, migration-ledger, scenario-catalog, offline-route, apiv2 OpenAPI/contract/fixture, and local-path checks pass. Web checks were not run; no web files changed.go testwith a database for catalog, handlers, apiv2, userstore, and jellycompat:TestOrphanCleanupAfterPlexTableDropPostgres,TestAdminSubtitleListPageDB, andTestCatalogTransferPersistsJobsAndSignedLinkfail on fixture errors outside collections (ausers.roleinsert, a subtitle language filter, timestamp precision). Everything else passes.Evidence: https://evidence.siloserver.org/r/silo-server/issue-1552/
Risks
item_count, treat ETags as opaque values, and handle 412 without silently replaying an edit. Their collection tests were inspected; native builds and devices were not run. jellycompat exposes only admin collections and is unaffected.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix personal collection
item_countto report viewer-visible membersitem_countthroughhandlers.visiblePersonalCollectionCounts, with the stored count kept when a live count failscatalog.ItemRepository.CountVisiblePersonalCollectionMembers, which applies the same library, maturity, media-type, and item access predicates as item lookup; smart and filtered counts usecatalog.QueryExecutor.Counton the collection's display filter and smart item limitapiv2.personalCollectionEditorTagfolds the liveitem_countinto personal collection ETags, so a count change now invalidates validators and rejects staleIf-MatchPATCH/DELETE even when the stored revision is unchangedcatalog.buildLibraryScopeJoinso deny-only library access no longer admits orphan items with no library membership; such items now require a membership rowGET /api/v2/collections/{id}and personal collection edits change for existing clients whenever the liveitem_countdiffers from the stored count; checkapiv2/personal_collections_lifecycle.goand the updated fixture in index.jsonMacroscope summarized 70cb030.