Skip to content

[codex] feat(jellycompat): use catalog search provider - #236

Merged
Quick104 merged 2 commits into
mainfrom
codex/jellycompat-search-provider
Jun 28, 2026
Merged

Quick104 merged 2 commits into
mainfrom
codex/jellycompat-search-provider

Conversation

@Quick104

@Quick104 Quick104 commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Part of #201. Follow-up to #220.

What changed

  • Wire the Jellyfin-compatible API to the shared catalog search provider service.
  • Route JellyCompat search through the configured provider: Postgres by default/fallback, Meilisearch when configured and usable.
  • Preserve Jellyfin-compatible QueryResult response shape while propagating EnableTotalRecordCount=false as SkipTotal to the search provider.
  • Keep the previous direct item repository path as a fallback for tests or deployments without an injected provider.

Why

Clients such as Infuse, VidHub, and other Jellyfin API consumers should benefit from the same search engine selection as the native Silo catalog API instead of staying on the older direct search path.

Validation

  • git diff --check
  • GOWORK=off go test ./internal/jellycompat -run 'Test(SearchItemsUsesCatalogSearchProviderWithCompatScope|SearchItemsFallsBackToItemRepoWhenProviderMissing|HandleItemsSearchPropagatesEnableTotalRecordCount)$' -count=1
  • GOWORK=off go test ./internal/catalog ./internal/api/handlers -count=1
  • Deployed to dev with make dev-deploy.
  • Verified dev search settings use catalog.search.provider = meilisearch, the active index is populated, and pending index events are 0.
  • Verified authenticated JellyCompat search smoke tests:
    • /Search/Hints?SearchTerm=Little Trouble Girls&Limit=5 returned 200 with the expected movie result.
    • /Users/{id}/Items?...IncludeItemTypes=Movie,Series&EnableTotalRecordCount=false returned 200 with results.
    • /Users/{id}/Items?...IncludeItemTypes=Movie,Series&EnableTotalRecordCount=true returned 200 with results.

Notes

  • Full GOWORK=off go test ./internal/jellycompat -count=1 still fails the existing web-component lock tests: TestBeginWebOperationRecoversDeadProcessLock and TestBeginWebOperationRejectsLiveProcessLock.
  • ./cmd/silo compile remains blocked locally when web/dist is absent, due the existing embed asset requirement.

AI-assisted implementation with manual review and live dev validation.

Summary by CodeRabbit

  • New Features
    • Search results now use catalog-aware searching when available, improving consistency across compatibility endpoints.
    • Item searches now apply include/exclude media type filters more accurately, including combined include+exclude scenarios.
  • Bug Fixes
    • Search requests now correctly honor total-count settings (when totals are disabled, responses skip total counting).
    • Compatibility searches fall back to repository-based search cleanly when catalog search isn’t available.

@coderabbitai

coderabbitai Bot commented Jun 27, 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: 7280a65d-530b-46d3-8e99-f73f104e659e

📥 Commits

Reviewing files that changed from the base of the PR and between 9472b34 and 1c06316.

📒 Files selected for processing (2)
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/handlers_items_test.go

📝 Walkthrough

Walkthrough

Updates Jellyfin compat search to use SearchItemsOptions, adds ExcludeItemTypes handling, routes compat searches through CatalogSearchProvider when available, and wires the provider through compat server setup and handler call sites.

Compat Catalog Search Integration

Layer / File(s) Summary
SearchItemsOptions contract
internal/jellycompat/content_service.go
Introduces SearchItemsOptions with SkipTotal and updates ContentService.SearchItems to accept it.
ExcludeItemTypes parsing
internal/jellycompat/query.go, internal/jellycompat/query_test.go
Adds ExcludeItemTypes parsing, effectiveItemTypes, and hasNonEmptyValues, and updates item-type filter detection.
directContentService search routing
internal/jellycompat/content_direct.go
Adds a catalog search provider field and constructor argument, and routes SearchItems through provider or repository search.
Dependency wiring
internal/jellycompat/server.go, internal/jellycompat/router.go, cmd/silo/main.go, internal/api/router.go
Adds CatalogSearchProvider to compat dependencies and wires catalog search service construction into compat and API setup.
Handler call sites
internal/jellycompat/handlers_items.go, internal/jellycompat/handlers_persons.go
Updates compat handlers to call SearchItemsOptions, adds searchItemTypesForQuery, and maps EnableTotalRecordCount to SkipTotal.
Tests and stubs
internal/jellycompat/content_direct_test.go, internal/jellycompat/handlers_items_test.go, internal/jellycompat/batch_progress_test.go
Updates stubs and adds tests for provider routing, fallback behavior, query parsing, and SkipTotal propagation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

v1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: routing JellyCompat search through the catalog search provider.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/jellycompat-search-provider

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

@Quick104
Quick104 marked this pull request as ready for review June 27, 2026 18:43
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jun 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/silo/main.go (1)

2188-2198: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Share the existing CatalogSearchService instead of creating a second one.

internal/api/router.go Lines 453-462 already build a CatalogSearchService and start StartCoverageRefresh. Spinning up another service here means every compat-enabled process runs two coverage-refresh loops against the same DB/settings. Please construct it once in cmd/silo and pass the shared service/provider into both the API router and JellyCompat. As per coding guidelines, cmd/silo contains the main server entrypoint, so server bootstrap and executable wiring should live there.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/silo/main.go` around lines 2188 - 2198, The compat bootstrap is creating
a second CatalogSearchService and starting another StartCoverageRefresh loop;
instead, construct the CatalogSearchService once in cmd/silo/main.go and share
that same instance/provider with both the API router and JellyCompat. Update the
wiring around catalog.NewCatalogSearchService, StartCoverageRefresh, and
compatDeps.CatalogSearchProvider so the service is created and initialized only
once in the main server entrypoint, then passed through to the router setup
rather than rebuilt inside internal/api/router.go.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/silo/main.go`:
- Around line 2188-2198: The compat bootstrap is creating a second
CatalogSearchService and starting another StartCoverageRefresh loop; instead,
construct the CatalogSearchService once in cmd/silo/main.go and share that same
instance/provider with both the API router and JellyCompat. Update the wiring
around catalog.NewCatalogSearchService, StartCoverageRefresh, and
compatDeps.CatalogSearchProvider so the service is created and initialized only
once in the main server entrypoint, then passed through to the router setup
rather than rebuilt inside internal/api/router.go.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a0bab040-5d3a-4b52-a0ae-ef62986a7dc1

📥 Commits

Reviewing files that changed from the base of the PR and between 41a1fc8 and 451c5a4120d6f0807465833b11e4ca3888a633f0.

📒 Files selected for processing (11)
  • cmd/silo/main.go
  • internal/api/router.go
  • internal/jellycompat/batch_progress_test.go
  • internal/jellycompat/content_direct.go
  • internal/jellycompat/content_direct_test.go
  • internal/jellycompat/content_service.go
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/handlers_items_test.go
  • internal/jellycompat/handlers_persons.go
  • internal/jellycompat/router.go
  • internal/jellycompat/server.go

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

✅ Created PR with unit tests: #237

@Quick104
Quick104 force-pushed the codex/jellycompat-search-provider branch from 451c5a4 to 9472b34 Compare June 27, 2026 23:40
@Quick104

Copy link
Copy Markdown
Contributor Author

Follow-up validation for Jellyfin Web search buckets:

  • Real Jellyfin for the exact Videos bucket query (ExcludeItemTypes=Movie,Episode,TvChannel plus MediaTypes=Video) returns TotalRecordCount: 0 and no items.
  • Dev now matches that exact query: TotalRecordCount: 0, no items.
  • Explicit IncludeItemTypes=Series search still reaches the provider-backed search path and returns Series results.

This fixes the regression where Series were being inferred into the Videos bucket from exclude-only filters.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/jellycompat/query.go`:
- Around line 346-358: The effectiveItemTypes helper is collapsing exclude-only
requests with unknown values to nil, which later causes handlers_items.go to
treat the filter as no-match instead of keeping the default compat video scope.
Update effectiveItemTypes so that when rawIncluded is empty and rawExcluded maps
to no compat types, it still returns compatVideoTypeList; only return a reduced
or empty set when excluded values actually intersect with compat item types. Use
the existing symbols effectiveItemTypes, mapIncludeItemTypes, hasNonEmptyValues,
and compatVideoTypeList to keep the behavior consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eef19459-080d-4c58-9e7e-6d43882bc635

📥 Commits

Reviewing files that changed from the base of the PR and between 451c5a4120d6f0807465833b11e4ca3888a633f0 and 9472b34.

📒 Files selected for processing (13)
  • cmd/silo/main.go
  • internal/api/router.go
  • internal/jellycompat/batch_progress_test.go
  • internal/jellycompat/content_direct.go
  • internal/jellycompat/content_direct_test.go
  • internal/jellycompat/content_service.go
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/handlers_items_test.go
  • internal/jellycompat/handlers_persons.go
  • internal/jellycompat/query.go
  • internal/jellycompat/query_test.go
  • internal/jellycompat/router.go
  • internal/jellycompat/server.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • internal/jellycompat/router.go
  • internal/api/router.go
  • internal/jellycompat/content_service.go
  • cmd/silo/main.go
  • internal/jellycompat/server.go
  • internal/jellycompat/content_direct_test.go
  • internal/jellycompat/batch_progress_test.go
  • internal/jellycompat/handlers_persons.go
  • internal/jellycompat/handlers_items_test.go
  • internal/jellycompat/content_direct.go

Comment on lines +346 to +358
func effectiveItemTypes(rawIncluded, rawExcluded []string) []string {
included := mapIncludeItemTypes(rawIncluded)
excluded := mapIncludeItemTypes(rawExcluded)
if len(excluded) == 0 {
return included
}

base := included
if len(base) == 0 && !hasNonEmptyValues(rawIncluded) {
base = compatVideoTypeList
}
if len(base) == 0 {
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep exclude-only unknown types on the default compat scope.

When ExcludeItemTypes is present but none of its values map to compat types (for example ExcludeItemTypes=TvChannel), this helper returns nil. Line 278 in internal/jellycompat/handlers_items.go then treats hasItemTypeFilter && len(itemTypes) == 0 as no-match, so those requests now return an empty page instead of the default video scope. Only exclusions that actually remove compat types should collapse the set.

Suggested fix
 func effectiveItemTypes(rawIncluded, rawExcluded []string) []string {
 	included := mapIncludeItemTypes(rawIncluded)
 	excluded := mapIncludeItemTypes(rawExcluded)
 	if len(excluded) == 0 {
+		if len(included) == 0 && !hasNonEmptyValues(rawIncluded) && hasNonEmptyValues(rawExcluded) {
+			return compatVideoTypeList
+		}
 		return included
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func effectiveItemTypes(rawIncluded, rawExcluded []string) []string {
included := mapIncludeItemTypes(rawIncluded)
excluded := mapIncludeItemTypes(rawExcluded)
if len(excluded) == 0 {
return included
}
base := included
if len(base) == 0 && !hasNonEmptyValues(rawIncluded) {
base = compatVideoTypeList
}
if len(base) == 0 {
return nil
func effectiveItemTypes(rawIncluded, rawExcluded []string) []string {
included := mapIncludeItemTypes(rawIncluded)
excluded := mapIncludeItemTypes(rawExcluded)
if len(excluded) == 0 {
if len(included) == 0 && !hasNonEmptyValues(rawIncluded) && hasNonEmptyValues(rawExcluded) {
return compatVideoTypeList
}
return included
}
base := included
if len(base) == 0 && !hasNonEmptyValues(rawIncluded) {
base = compatVideoTypeList
}
if len(base) == 0 {
return nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/jellycompat/query.go` around lines 346 - 358, The effectiveItemTypes
helper is collapsing exclude-only requests with unknown values to nil, which
later causes handlers_items.go to treat the filter as no-match instead of
keeping the default compat video scope. Update effectiveItemTypes so that when
rawIncluded is empty and rawExcluded maps to no compat types, it still returns
compatVideoTypeList; only return a reduced or empty set when excluded values
actually intersect with compat item types. Use the existing symbols
effectiveItemTypes, mapIncludeItemTypes, hasNonEmptyValues, and
compatVideoTypeList to keep the behavior consistent.

@Quick104
Quick104 merged commit 0252d48 into main Jun 28, 2026
1 check passed
@Quick104
Quick104 deleted the codex/jellycompat-search-provider branch June 28, 2026 00:10
Quick104 added a commit to RXWatcher/silo-server that referenced this pull request Jul 10, 2026
* feat(jellycompat): use catalog search provider

* fix(jellycompat): route video search buckets to provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1.0 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant