Skip to content

fix(access): let Settings → Libraries show a restricted profile's hidden libraries - #2058

Merged
Quick104 merged 2 commits into
mainfrom
fix/hidden-library-restore
Oct 8, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/hidden-library-restore

Conversation

@Quick104

@Quick104 Quick104 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2055
Related issue: N/A
Validation tasks: none

When an account or profile is limited to certain libraries, hiding one of those libraries in Settings → Libraries removes it from that page entirely. The page counts only what's left ("5 of 5 libraries visible"), the hidden library has no switch to turn back on, and "Show all" is disabled. To the user the library looks deleted. A user on a real server ran into this with an anime library. Profiles without a library limit are not affected.

The cause is server-side. For a library-limited scope, both viewer resolvers subtract the profile's hidden libraries (ui.disabled_library_ids) from AllowedLibraryIDs, and GET /user/libraries lists exactly that set. The settings page draws from that list.

Approach

GET /api/v2/user/libraries gets an opt-in include_hidden parameter, advertised as supports_include_hidden on its capability response. Only the web Settings → Libraries page sends it. The default v2 response, the frozen /api/v1/user/libraries, navigation, and content reads are unchanged. That matters because Apple and Android don't read ui.disabled_library_ids. For a limited profile they rely on the server leaving hidden libraries out, so changing the default would put an empty library in their navigation.

To know which libraries to add back, the viewer scope now reports them. The scope policy (scope.rego) emits hidden_library_ids: the profile's own hidden libraries that the account limit, the profile limit, and any custom override would otherwise allow. The legacy Go resolver computes the same set, and both put it on access.Scope.HiddenLibraryIDs. That field grants nothing; only the opt-in list reads it. It comes from the request's single scope evaluation, so there's no second resolve and no extra database read.

Because the web's navigation list and the settings list are now separate queries, a change to ui.disabled_library_ids (saved on this device, or announced over the realtime channel) invalidates the library lists. Otherwise the sidebar would keep the old list after unhiding.

Two alternatives a reviewer might ask about:

  • Re-resolving the scope with the preference cleared. Dropped because the second resolve's reads aren't snapshot-consistent with the first, and it changes the input custom overrides see.
  • Passing hidden libraries through as DisabledLibraryIDs for limited profiles, as unrestricted scopes already do. Not done because it would change content filtering for limited profiles and overlaps with [bug] Hiding a library hides titles that are also in a visible library #2011.

Validation

  • Reproduced on a dev sandbox built from main: with the profile limited to two libraries, hiding one removed it from /api/v2/user/libraries and from Settings → Libraries.
  • On the fixed build: the hidden library is listed with its switch off, turning it on restores it in the sidebar immediately, and a library outside the profile's limit is still not listed. The default v2 list, the v1 list, and catalog reads for the hidden library are unchanged.
  • Go tests for internal/access, internal/policy (including the vendor Rego tests and the Go/Rego parity matrix), internal/api/handlers (including the database-backed list test), internal/apiv2, internal/api, and internal/progresssync pass. New cases cover the hidden set from both resolvers, a custom override that hides a library the profile also hid, an override that restricts an unrestricted base, and the opt-in and v1 paths.
  • The regenerated OpenAPI contract, web types, and API fixtures pass verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-contract, verify-apiv2-fixtures, verify-route-inventory, and verify-migration-ledger. verify-local-paths passes.
  • Vitest for src/hooks/queries, the settings page, and the realtime provider; tsc; eslint; prettier; and the changed-lines Go lint pass.
  • The validation board couldn't be read (the token lacks read:project). Of the validation issues found by search, User management / access groups / invites — Server #1196 C1 (enforcing inherited library policy) is reachable. What a profile can browse, search, or play is unchanged, so that case is unaffected.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2055/

Surface and build: web app Settings → Libraries, desktop and phone width, dev sandbox before (main at fca2720) and after (this branch).

Risks

  • /api/v2/user/libraries gains an optional query parameter and the capability response gains a field, both additive. The v1 bridge is unchanged.
  • The scope decision gains a hidden_library_ids output. Custom scope overrides are unaffected: their output keys are read as before, and the new set can only shrink under an override's allowlist and disabled list. Scope.HiddenLibraryIDs is kept out of the access fingerprint, so socket tickets and progress snapshots hash as before.
  • Known edge: a custom override whose allowlist depends on the hidden-library preference itself (allowing a library only while the profile hides it) would let the opt-in list show that library's name and poster. Content access still follows AllowedLibraryIDs.

Follow-ups: Apple and Android ignore ui.disabled_library_ids, so a profile without a library limit still sees its hidden libraries in their navigation (an existing gap, unchanged here). Tracked in Silo-Server/silo-apple#691 and Silo-Server/silo-android#515. User manual: unaffected; it doesn't describe hiding libraries.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code; T3 Code delegated tasks (Codex)
  • Model(s): claude-opus-5-5 (investigation, implementation, tests, this description); claude-sonnet-5-5 (read-only check of the affected server's data, review finder, validation check); gpt-6.1-sol (adversarial review)
  • Involvement: Fully AI-generated. A maintainer relayed the report and chose the opt-in API design; the agent reproduced the problem on a dev sandbox, wrote the fix and tests, and verified them there.
  • Adversarial review: two rounds by gpt-6.1-sol (Codex, read-only) on earlier versions of this change, plus Claude review agents (claude-opus-5-5 and claude-sonnet-5-5) on each version. Round 1 found that always listing hidden libraries would put empty libraries in the Apple and Android navigation, and that a second, PIN-skipping scope resolve could race a policy change. Round 2 found that the second resolve's reads weren't snapshot-consistent, that clearing the preference changed the input custom overrides see, and that navigation stayed stale after unhiding. Resolved by making the listing opt-in (a maintainer decision), computing the hidden set inside the single scope evaluation, and invalidating the library lists when the setting changes. A final Claude review of this version found no defects; its two documentation fixes and a missing Rego test are applied.

🤖 Generated with Claude Code

Note

Add include_hidden to Settings → Libraries so hidden libraries can be reshown

  • Restricted scopes now carry profile-hidden libraries in a new HiddenLibraryIDs field on access.Scope, kept out of the access allowlist and the scope fingerprint. Policy rules (scope.rego) compute these IDs as the intersection of allowed and profile-disabled libraries, including under custom overrides.
  • The v2 route GET /api/v2/user/libraries accepts an include_hidden query flag, and the capabilities response advertises supports_include_hidden. The web LibrarySettings.tsx page opts in so hidden libraries appear with switches to re-show them; all other callers default to off.
  • Changes to the UI_DISABLED_LIBRARY_IDS setting (writes and realtime events) now invalidate cached library queries, handled in settingValues.ts.
  • Behavioral Change: the frozen v1 route explicitly passes includeHidden=false in libraries.go, and unrestricted scopes are unchanged. One test expectation in scope_test.rego (test_unrestricting_override_keeps_profile_hidden_libraries_it_allows) appears inconsistent with the merged_hidden rule, which returns an empty list when the merged result is unrestricted.

Macroscope summarized 9d4906f.

…den libraries

When an account or profile is limited to certain libraries, the viewer scope
subtracts the profile's hidden libraries (ui.disabled_library_ids) from the
allowed set, and GET /user/libraries listed only that set. Hiding a library
therefore removed it from Settings → Libraries with no switch left to show it
again.

The scope policy now also reports hidden_library_ids: the profile's own
hidden libraries that the account limit, profile limit, and any custom
override would otherwise allow. The legacy resolver computes the same set,
and both carry it on access.Scope.HiddenLibraryIDs, which grants nothing.
GET /api/v2/user/libraries gains an opt-in include_hidden parameter,
advertised by supports_include_hidden, that adds those libraries to a
restricted scope's list. Only the web settings page sends it; the default
response, the frozen v1 route, navigation, and content reads are unchanged,
so the Apple and Android apps, which don't read the hide setting, keep
their current behavior.

The web now refetches the library lists when ui.disabled_library_ids
changes locally or over the realtime channel, so the sidebar shows an
unhidden library right away.

Closes #2055

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aaf9b6b9-de46-4458-96a3-c213c5a39be4
📥 Commits

Reviewing files that changed from the base of the PR and between ce66084 and 9d4906f.

📒 Files selected for processing (3)
  • contracts/api/v2/openapi.json
  • internal/policy/viewer_resolver_test.go
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Restricted scopes now track profile-hidden libraries separately from allowed libraries. The v2 library-list API can optionally include them, and the web Settings → Libraries page requests them so their visibility controls remain available.

Changes

Profile-hidden library discovery

Layer / File(s) Summary
Resolve hidden library IDs
internal/access/*, internal/policy/*, contracts/api/v2/fixtures/admin_policy_vendor.json
Access and policy resolution now report hidden library IDs separately from allowed IDs. Policy override logic and resolver tests cover restricted, unrestricted, and override cases.
Expose hidden libraries in the v2 list
internal/api/handlers/*, internal/apiv2/user_libraries*, contracts/api/v2/openapi.json, docs/settings-api.md
The list service accepts an includeHidden option, and the v2 endpoint parses include_hidden and reports capability support. API tests, the OpenAPI contract, and documentation cover the option.
Request hidden libraries in settings
web/src/api/v2/schema.ts, web/src/hooks/queries/*, web/src/pages/settings/LibrarySettings*
The web query hook supports includeHidden, and Settings → Libraries requests hidden libraries. Changes to UI_DISABLED_LIBRARY_IDS invalidate library queries; tests cover request and invalidation behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant LibrarySettings
  participant useAvailableUserLibraries
  participant UserLibrariesAPI
  participant ListUserLibraries
  LibrarySettings->>useAvailableUserLibraries: request includeHidden
  useAvailableUserLibraries->>UserLibrariesAPI: GET with include_hidden=true
  UserLibrariesAPI->>ListUserLibraries: pass IncludeHidden
  ListUserLibraries->>ListUserLibraries: append hidden IDs for restricted scope
Loading

Suggested reviewers: rhainland

Merge Risk: ⚪ Minimal · up to 9d490

The change adds an opt-in include_hidden option so hidden libraries stay visible in settings. The default response is unchanged. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 18 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #2055 requires a hidden library that remains within account or profile limits to stay in Settings → Libraries and provide a switch to show it again. The PR computes HiddenLibraryIDs during sco…
Out of Scope Changes check ✅ Passed The changes stay within issue #2055 [#2055]. Policy and resolver changes identify navigation-hidden libraries that remain allowed. API and contract changes provide the settings-only opt-in. Web query …
Title check ✅ Passed The title clearly and concisely describes the main change: allowing Settings → Libraries to show hidden libraries for restricted profiles.
Description check ✅ Passed The description directly explains the problem, implementation, scope, validation, risks, and user-visible behavior covered by the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 18 files. (2 skipped: 1 unsupported, 1 too large.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@silo-kody

silo-kody Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 marked this pull request as ready for review October 7, 2026 23:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T00:04:52.914010Z 9d4906f New commits
🔒 Security Review ✅ Completed 2026-10-08T00:05:28.185059Z 9d4906f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@macroscopeapp

macroscopeapp Bot commented Oct 7, 2026

Copy link
Copy Markdown

The Evidence link identifies Settings → Libraries at desktop and phone widths, but does not identify evidence for the other visible effect: enabling a hidden library restores it in navigation immediately. Please add a short recording of that toggle-to-navigation flow covering desktop and phone widths. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce6608431c

ℹ️ 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".

Comment thread internal/apiv2/user_libraries.go Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

IncludeHidden bool `query:"include_hidden" doc:"Also list libraries the profile hid itself (ui.disabled_library_ids), for a screen that shows them again. Without an account, profile, or policy library limit they are listed either way. Navigation should omit it and filter by the setting" example:"false"`

P1 Badge File the Apple and Android follow-up work

Before landing this client-visible library API change, file or complete the corresponding Apple and Android work. The commit message says those parity issues are only drafted and not filed, so this change does not meet the repository requirement that cross-client follow-up be handled or filed.

AGENTS.md reference: AGENTS.md:L146-L152

ℹ️ 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".

@Quick104

Quick104 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

The evidence page already has a recording of the switch-to-navigation flow on desktop (walkthrough-restore.webm under "Showing it again"): turning TV Shows back on adds it to the sidebar without a reload. The phone layout reads the same library query and the same invalidation, and this PR changes no layout, so I didn't record that flow at phone width separately. The phone capture shows the settings page state.

@macroscopeapp

This comment has been minimized.

@Quick104
Quick104 merged commit a9b3422 into main Oct 8, 2026
22 checks passed
@Quick104
Quick104 deleted the fix/hidden-library-restore branch October 8, 2026 00:27
Quick104 added a commit that referenced this pull request Oct 8, 2026
Conflict resolution:

- internal/userdb: main took SQLite schema v30 for the profile PIN
  revision (#2020). The login-wide sharing migration moves to v31, so a
  store already at main's v30 still runs it.
- internal/catalog, internal/sections: main's fail-closed library scope
  (#1953, #2005, #2006) and this branch fixed the same empty-scope bug.
  The executor and section fetcher keep main's AccessFilter.LibraryScope;
  library collections keep this branch's ResolveLibraryCollectionMembership,
  which already returns nothing when the saved libraries miss the
  collection's own. main's scope test now exercises that resolver.
  narrowLibraryScope no longer needs the helper main removed.
- internal/policy: main's hidden-library output (#2058) and this branch's
  ContentAccessOnly input both declared `hidden`; the input side is
  renamed.
- Home sections (#2043): the admin per-profile card keeps main's row
  list but saves with this branch's override builder and a baseline, so
  like Settings > Home Screen it stores only what changed and untouched
  rows keep following the server. main's duplicate lib/sectionOverrides.ts
  is dropped; EditableSectionRows stays for that card and labels rows with
  rowKindLabel. Settings > Home Screen keeps this branch's page.
- apiv2: keep both sides' services and fixtures; the admin profile
  section settings fixture gains default_title.

Co-Authored-By: Claude Opus 5.5 (1M context) <[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.

[bug] Hiding a library on a library-limited profile removes it from Settings → Libraries

1 participant