Skip to content

fix(browse): tell an empty library apart from filters that match nothing - #626

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/empty-library-state
Oct 6, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/empty-library-state

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #582
Validation tasks: changes #337 C1; changes #338 C1

A library with no media showed "No items found / Try adjusting your filters" on iOS and "No titles match" on Apple TV, the same message as a filter that matches nothing. Users could not tell an empty library from an over-filtered one. Empty libraries now say so, and a filter that matches nothing offers Clear filters.

Approach

  • When a browse comes back empty, the app decides why. Without filters or a name prefix, an empty first page means the library is empty. With filters, it asks the catalog for one unfiltered item of the library (limit=1, skip_total) as the active profile, so only empty results pay for the extra request, and a profile whose rating limit hides every title also sees the empty-library state.
  • An empty library shows "This library is empty". Otherwise the grid shows "No items match your current filters" (tvOS: "No titles match your filters") with a Clear filters button that resets the facets and the letter rail and keeps the sort. If the check fails, the filter message stays.
  • On tvOS the empty-state area is a focus section, so Down from Sort or Filter and Left from the letter rail both reach Clear filters.

Validation

  • Unit tests for the decision (no probe without filters, filters over a library with and without visible items, failed probe, name prefix, probe parameters): pass.
  • Manual, iPhone simulator: an empty library shows "This library is empty"; a Dolby Vision filter on a library without DV shows the no-match state, and Clear filters brings the grid back.
  • Manual, Apple TV simulator: the same two states; Down from Sort reaches Clear filters, and Clear filters restores the grid.
  • scripts/ci/check-no-api-v1.sh: pass.
  • All 22 app fixes from this validation run, merged together on main (6242652): the full iOS unit suite ran 2,691 tests. The only failures are ArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResets and ImageSizeCapabilityTests.testResetClearsCapability, which fail the same way on main. tvOS build-for-testing and the macOS build succeed.
  • Local builds used Swift 6.3.3, which needs the ThumbHash type annotations from fix(build): annotate ThumbHash cosine tables so Swift 6.3.3 can type-check them #608 to compile. That change was applied locally and is not part of this PR.

Simulator screenshots (iOS 26.5, tvOS 26.5):

a9-empty-ios

a9-empty-tvos

Risks

One extra catalog request when a filtered browse comes back empty.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code, running in T3 Code
  • Tool(s): Claude Code subagents, xcodebuild, Xcode Simulator (simctl, Maestro), GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: A separate Claude Code reviewer agent (claude-opus-5-5) read this branch's diff against main at medium effort, checking behaviour, platform guards (iOS, tvOS, macOS), tests and commit hygiene. It checked that a stale probe result can't flash the wrong message and that the tvOS focus change follows docs/tvos-focus.md. No findings.

Note

Add tests distinguishing empty library from non-matching filters in browse

Adds BrowseEmptyReasonTests.swift covering empty-state classification in browse. Tests verify that only narrowing filters trigger a library probe, that probe results distinguish an empty library from filters that match nothing, and that probe failures keep the filtered-empty result. Also checks the probe requests one unfiltered item without a total count.

Macroscope summarized 30bf812.

An iOS library with no media showed "No items found / Try adjusting your filters", the same message as a filter that matches nothing, so users could not tell an empty library from an over-filtered one.

When a browse comes back empty, the app now decides why. Without active filters (or a name prefix), an empty first page already means the library is empty. With filters, it asks the catalog for one unfiltered item of the library (limit 1, skip_total) as the active profile, so only empty results pay for the extra request and a profile whose rating limits hide every title also sees the empty-library state. An empty library shows "This library is empty"; otherwise the grid shows "No items match your current filters" with a Clear filters button that resets the facets and keeps the sort. If the check fails, the filter message stays.

BrowseEmptyReasonTests covers the decision: no probe without filters, filters over a library with or without visible items, a failed probe, the name prefix, and the probe query's parameters.
The Apple TV library grid showed "No titles match / Try a different letter or filter." for every empty result, including a library with no media, so users could not tell an empty library from an over-filtered one.

The tvOS grid now uses the same decision as iOS (BrowseEmptyReason with the one-item library probe). An empty library shows "This library is empty". When filters or the letter rail match nothing, the grid shows "No titles match your filters" with a Clear filters button that resets the facets and the letter rail and keeps the sort.

Clear filters is an ordinary native button in the grid column's focus section, so Down from Sort/Filter and Left from the letter rail reach it with no extra move handling. The reload removes the button, so pressing it hands focus to the Sort pill through the control row's existing focus request.
On the no-match grid, Down from Sort/Filter left focus on Sort: the focus engine searches below the focused pill, and the centered Clear filters button sits outside that path, so only Left from the letter rail reached it.

The empty-state area is now a full-width focus section. Down from either pill enters it and lands on its only focusable child, Clear filters. No move handling changes: the row's Down handler still only claims the grid when it has items.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a5a9133a-2889-4b9d-b779-ad681da0bccd
📥 Commits

Reviewing files that changed from the base of the PR and between 6242652 and 30bf812.

📒 Files selected for processing (7)
  • iosApp/Tests/BrowseEmptyReasonTests.swift
  • iosApp/iosApp/Screens/Browse/BrowseView.swift
  • iosApp/iosApp/Screens/Browse/BrowseViewModel.swift
  • iosApp/iosApp/Screens/Browse/Filtering/BrowseEmptyReason.swift
  • iosApp/iosApp/Screens/Browse/Filtering/CatalogQueryBuilder.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridView.swift
  • iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridViewModel.swift
  • 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 5, 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 ❌

@Rhainland Rhainland mentioned this pull request Oct 5, 2026
11 tasks
try await !SiloAPI.shared.catalogPage(probe).response.items.isEmpty
}
guard myGeneration == generation else { return }
emptyReason = reason

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Race condition in iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridViewModel.swift: the guard preceding emptyReason = reason checks only the reload generation after an asynchronous catalog probe, allowing authentication-owner or active server/profile scope changes during either request without a reload to publish an empty-state reason based on another profile's catalog visibility; the same issue occurs in iosApp/iosApp/Screens/Browse/BrowseViewModel.swift:109-109 and iosApp/iosApp/Screens/Browse/BrowseViewModel.swift:112-112. Capture the owner and active scope before the page read, then verify both alongside myGeneration after the classification await and before publishing the result.

Kody rule violation: Fence asynchronous results by scope and invalidation generation

Prompt for LLM

File iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridViewModel.swift:

Line 282:

Race condition in `iosApp/iosApp/tvOS/Screens/Libraries/TVLibraryGridViewModel.swift`: the guard preceding `emptyReason = reason` checks only the reload generation after an asynchronous catalog probe, allowing authentication-owner or active server/profile scope changes during either request without a reload to publish an empty-state reason based on another profile's catalog visibility; the same issue occurs in `iosApp/iosApp/Screens/Browse/BrowseViewModel.swift:109-109` and `iosApp/iosApp/Screens/Browse/BrowseViewModel.swift:112-112`. Capture the owner and active scope before the page read, then verify both alongside `myGeneration` after the classification await and before publishing the result.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing. The reason is fenced exactly like the page it describes: items from the same fetch is published under the same myGeneration check, which is unchanged from main. A scope change cannot reach this view model either. A server change re-keys the routed subtree (.id(authContentIdentity) in ContentView), and a profile switch, sign-out or session expiry moves authState off .authenticated, which removes MainTabView/TVMainTabView and the grid with its view model. A late probe result can only land on a discarded model, never on another profile's screen.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed—given the lifecycle you described, this suggestion does not warrant a change.

The generation guard rejects stale reload results, while subtree replacement or removal prevents results from an old server/profile scope from reaching the current screen. Even if the asynchronous task retains the old view model long enough to assign emptyReason, that assignment affects only the discarded model.

My original finding assumed the same view model could remain attached to the visible grid across a scope change without a generation increment. Your explanation addresses that assumption. The added classification await alone is not evidence of a cross-profile race, so I withdraw the recommendation for this PR.

@Quick104
Quick104 merged commit 16f1078 into Silo-Server:main Oct 6, 2026
6 checks passed
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.

Tell an empty library apart from filters that match nothing

2 participants