Skip to content

fix(audiobooks): make Audiobookshelf library filters, sort, and search return the right books - #4208

Merged
Quick104 merged 3 commits into
mainfrom
fix/abs-library-items-filters-and-sort
Nov 15, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/abs-library-items-filters-and-sort

Conversation

@Quick104

@Quick104 Quick104 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none passed; reaches #1247 C1 and C2 and #1254 C3 and C4, all not run yet

Other clients: N/A (the change is on the Audiobookshelf-compatible API used by third-party Audiobookshelf apps; Silo's Apple, Android, Roku, and web clients use /api/v2)

Audiobookshelf apps connected to Silo got wrong results from the library browse filters and sort. Filtering by genre or by listening progress returned no books at all, sort and direction were ignored, author and series search could not find names past the first 5,000 alphabetically, and Continue Listening for a token without a profile showed every household profile's books. This change applies every filter and sort in SQL, fixes the progress filters, makes search an indexed query, gives a series one identity across list, detail, and filter, and limits Continue Listening to the viewer's profile.

  • Filters. The genre, tag, language, and progress filters ran in Go after loading the whole library, and never received the viewer's progress. Genres, tags, and languages always failed to match; in-progress and finished matched nothing. The official app also base64-encodes progress values and no-series, which the parser passed through undecoded. All filters now run in SQL; progress reads only the requesting profile's rows.
  • Sort. sort and desc were echoed back but not applied. The handler now honors the keys real Audiobookshelf accepts where Silo has the data: title, added date (also used for birthtimeMs and mtimeMs, which Silo reports as the added date), duration, published year, author name (first-last and last-first), series sequence inside a series filter, the viewer's last progress update, and random. size, progress.createdAt, and progress.finishedAt have no data in Silo and fall back to title order. List items also carried addedAt: 0; they now report when the book joined the library.
  • Search. Author and series results were filtered in Go from the first 5,000 names. They now come from ILIKE queries on the people.name trigram index and a new trigram index on audiobook_series.series_name, scoped to the library and the viewer's access.
  • Series identity. The list grouped by exact name, detail matched case-insensitively and answered with a lowercased ID, and the filter compared exact names, so a series spelled two ways showed as two and its list ID did not filter. A series is now every book whose name matches case-insensitively, with the database's LOWER(series_name) as its ID in list, detail, filter, search, and item metadata. Detail now counts only books the viewer may see and returns 404 when there are none, instead of answering with the series name.
  • Continue Listening. The shelf matched user_id::text, which skipped the progress indexes, and treated an empty profile ID as "any profile". It now matches the user ID as an integer and the profile ID exactly.

Approach

ListAudiobooks takes an ItemsQuery (filter, sort, viewer) and renders it as SQL predicates and an ORDER BY with the title key and content ID as tiebreakers, so pages never skip or repeat. A filter kind Silo has no data for matches nothing, as before. Every predicate sits beside the existing library and access conditions (library restrictions, rating ceiling, unrated policy, disabled libraries), and the new search queries use the same conditions.

collapseseries=1 still folds series in Go over the filtered set; making that and limit=0 cheaper is a separate pull request stacked on this one.

Validation

  • Go: go build ./..., gofmt, go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery: pass. make test-go: pass except two real-FFmpeg tests (internal/mediasample, internal/playback) that fail the same way on main with this host's FFmpeg.
  • make verify-migrations, verify-local-paths, verify-bidi, verify-size-ratchet, verify-case-collisions: pass.
  • Database contracts: the new tests in scripts/ci/db-contracts.txt and the existing audiobooks DB tests pass against a freshly migrated database. They cover each filter kind, each implemented sort, profile-scoped progress and Continue Listening (the empty-profile case fails on main), series identity across spellings, detail outside the viewer's libraries, and search scoping.
  • Web, generated contracts, and API v2 checks: not run; this change touches no web, settings, playback fixture, route, or /api/v2 code.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-4208/

Steps: an isolated sandbox built from main and then from this branch, a 30,000-book synthetic audiobook library (tones only, no metadata provider), 10 books in progress and 5 finished for the admin profile, then the same Audiobookshelf requests on each build. Times are warm, three runs each.

Request Main This branch
filter=genres.<Fantasy> 0 items, 910–1080 ms 1,373 items, 14–18 ms
filter=progress.<in-progress> 0 items, 870–1030 ms 10 items, 11–19 ms
filter=progress.<finished> 0 items, 965–1190 ms 5 items, 9–12 ms
filter=progress.<not-started> 0 items 29,985 items
sort=addedAt&desc=1 title order, addedAt 0 newest first, real addedAt
search?q=shadow 430–460 ms 36–51 ms
?include=filterdata 250–310 ms 150–165 ms
/authors 200–260 ms 26–34 ms
items?limit=50&page=0 14–15 ms 14–23 ms

The test library has 2,946 authors and 2,424 series, under the old 5,000-name cutoff, so it cannot show search missing a late name; that case comes from reading the code. The /authors and filterdata times drop because the main run read the authors view before its first refresh and took the live fallback; this branch does not change that path. The build host was under heavy load from other work, so differences of a few tens of milliseconds are noise.

Risks

  • One migration builds a trigram index on audiobook_series with CREATE INDEX CONCURRENTLY.
  • Sorting by author name or duration sorts the whole filtered library per page (about 90 ms and 150–180 ms at 30,000 books); title and added-date sorts use indexes.
  • Series IDs are now lowercased names everywhere. Clients that cached an exact-case ID from the old list still match, since lookups are case-insensitive.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; not yet verified by a person
  • Adversarial review: one independent review of the diff (repository code-review skill, medium). Confirmed and fixed: base64-encoded progress and no-series filters, series IDs computed in Go instead of SQL, single-book series in search, inconsistent added-date sort without a library, silent hydration failures, slow author-name sort. Kept as documented: the duration sort reads the per-folder file total, which differs from the shown duration only for a book with two versions in one folder.

🤖 Generated with Claude Code

Note

Move Audiobookshelf library filters, sort, and search into SQL

  • ListAudiobooks now takes an ItemsQuery and builds SQL filter predicates (author, narrator, series, genre, language, progress) plus SQL ordering for the ABS sort keys, instead of the handler filtering results after fetch. Unsupported filter kinds and unrecognized progress values return no matches.
  • ParseFilter decodes base64-encoded filter values while preserving plain progress values and the no-series sentinel; ListContinueListening now requires exact user ID and profile ID matches, including an empty profile ID.
  • Library search replaces loading up to 5000 authors/series with new SearchLibraryAuthors and SearchLibrarySeries store queries, scoped to visible books, with prefix matches ordered first.
  • Series names differing only by case are grouped into one series with a lowercased ID; AudiobookSeriesMembership gains a Key field for that identity. A trigram GIN index is added on audiobook_series.series_name.
  • Adds database-backed tests in media_store_items_db_test.go covering filters, sort, pagination, profile-scoped continue listening, and search; registered in db-contracts.txt.
  • Risk: the MediaStore interface changes (ListAudiobooks signature, new search methods) require all implementations to be updated; series filtering no longer collapses results by series.

Macroscope summarized 5f8908c.

…h return the right books

Audiobookshelf apps got no books for genre, tag, language, and progress
filters, had sort and desc ignored, could not search authors or series
past the first 5,000 names, and saw every household profile's books in
Continue Listening for a token without a profile.

Every library items filter and sort now runs in SQL beside the access
conditions. Progress filters and Continue Listening read only the
viewer's profile, and base64-encoded progress and no-series values are
decoded as real ABS does. Author and series search use trigram indexes.
A series is every book whose name matches case-insensitively, keyed by
LOWER(series_name) in list, detail, filter, and search, and detail only
counts books the viewer may see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Nov 14, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T23:42:09.788468Z 5f8908c New commits
🔒 Security Review ✅ Completed 2026-11-14T23:45:11.546452Z 5f8908c 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.

@silo-kody

silo-kody Bot commented Nov 14, 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 ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: compat Breaks a supported client or server path priority: P2 Limited scope, workaround exists, or polish labels Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8c69b37-c52a-4bac-8891-bde00d83aaf9
Commits

Reviewing files that changed from the base of the PR and between 2c9e594 and 5f8908c.

Files selected for processing: 2

  • internal/audiobooks/media_store.go
  • internal/audiobooks/media_store_items_db_test.go
Walkthrough

Audiobook listing now supports SQL-backed filtering and sorting with viewer context. Author and series searches use scoped queries. Series identity is case-insensitive across membership, listing, and lookup. Database tests cover listing, search, series identity, and profile-specific Continue Listening.

Changes: Audiobook listing and search

Layer / File(s) Summary
Query contract and handler wiring
internal/audiobooks/abs/filter.go, internal/audiobooks/abs/filter_test.go, internal/audiobooks/abs/handler.go, internal/audiobooks/abs/libraries_handler.go, internal/audiobooks/abs/login_refresh_test.go, internal/audiobooks/abs/smart_collections_handler.go, internal/audiobooks/abs/smart_collections_handler_test.go
ItemsQuery carries filter, sort, direction, user, and profile data. The library handler passes the query to the store and uses dedicated author and series search methods. Parsing recognizes plain progress and no-series values as well as encoded values.
SQL listing, filtering, and sorting
internal/audiobooks/media_store.go, internal/audiobooks/media_store_items_db_test.go, scripts/ci/db-contracts.txt
The store applies listing filters and ordering in SQL, hydrates results, and matches Continue Listening to the exact profile ID. Database tests cover filters, sorting, pagination, and progress behavior.
Series identity and scoped search
internal/models/media.go, internal/audiobooks/abs/handler.go, internal/audiobooks/abs/libraries_handler.go, internal/audiobooks/media_store.go, internal/audiobooks/media_store_items_db_test.go, migrations/sql/20261114223220_add_audiobook_series_name_trgm_index.sql
Series memberships and results use lowercase keys. Series lookup and author and series searches apply library and access scope. The migration adds a concurrent trigram index on series names.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant handleLibraryItems
  participant MediaStore
  participant PostgreSQL
  participant ListingHydration
  handleLibraryItems->>MediaStore: ListAudiobooks with ItemsQuery
  MediaStore->>PostgreSQL: Query filtered, sorted, and paginated items
  PostgreSQL-->>MediaStore: Return item IDs and total
  MediaStore->>ListingHydration: Hydrate ordered listing results
  ListingHydration-->>handleLibraryItems: Return hydrated audiobook items
Loading

Suggested reviewers: pukabyte

Merge Risk: Low · previous review 2c9e5

Library browsing, filtering, sorting and search now run in SQL and are scoped to the requesting profile, which fixes the reported empty filters and cross-profile Continue Listening. Two small edge-case inconsistencies remain: sorting by date added across all libraries can disagree with the displayed date when a book was added earlier to a library the viewer cannot see, and a series literally named "No-Series" cannot be filtered correctly. Neither blocks the main workflows, so the risk is low.

Security architecture risk: Minimal · up to 2c9e5

The inspected changes preserve library-access restrictions and bind listening-state reads to the signed-in profile. The database change adds a removable search index with retry cleanup. No introduced or worsened risk materially affecting security, ownership, or recovery was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed read paths expose audiobook metadata and listening-state-derived results through existing bearer-protected ABS library endpoints. Library resolution validates the requested library against the viewer's accessible library list before invoking the store.

Trust Boundaries and Controls

  • observed — The handler takes viewer identity from the authenticated request context, not filter or sort parameters. Authentication checks token validity and revocation before creating that context; access-resolution errors return a refusal rather than continuing with an unrestricted filter.
  • observed — Series detail now derives its display name and key only from accessible books and returns not-found when none match. The base version resolved the series name before applying book-access predicates.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Audiobookshelf library filters, sort, and search are fixed so they return the right books. The changeset moves filters and sorting into SQL, adds indexed author and se…
Description check Passed The description is detailed and clearly relates to the changeset. It covers the problem (broken genre and progress filters, ignored sort, capped search, Continue Listening leaking profiles), the appro…
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.
Full details: Title check

Explanation

The title names the main change: Audiobookshelf library filters, sort, and search are fixed so they return the right books. The changeset moves filters and sorting into SQL, adds indexed author and series search, and fixes progress filters. The title is specific and matches the primary intent. It is a single sentence of 93 characters with a conventional fix(audiobooks) prefix.

Full details: Description check

Explanation

The description is detailed and clearly relates to the changeset. It covers the problem (broken genre and progress filters, ignored sort, capped search, Continue Listening leaking profiles), the approach (ItemsQuery rendered as SQL predicates and ORDER BY, trigram index, lowercase series keys, exact user/profile matching), validation steps, and risks such as the CONCURRENTLY trigram index migration. It matches the file-level summaries.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

WHERE content_id = ANY($1)
AND ($2::int[] IS NULL OR media_folder_id = ANY($2))
AND (COALESCE(cardinality($3::int[]), 0) = 0 OR NOT (media_folder_id = ANY($3)))
GROUP BY content_id`, ids, allowed, access.DisabledLibraryIDs)

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

Added-date hydration sends an unbounded ID batch to PostgreSQL

ListAudiobooks permits unlimited results, so the added-date lookup can send an arbitrarily large ids array to PostgreSQL. Split ids into bounded batches and merge the results before updating the items.

Kody rule violation: Batch scoped Go lookups and bound dependency fan-out

Prompt for LLM
File internal/audiobooks/media_store.go, line 396:

Added-date hydration sends an unbounded ID batch to PostgreSQL

Split `ids` into bounded batches and execute the added-date lookup once per batch, merging the results before updating the items. `ListAudiobooks` permits an unlimited result set, so this query can otherwise receive an arbitrarily large ID array in a single database operation.

Kody rule violation: [Batch scoped Go lookups and bound dependency fan\-out](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/d2a64d9a-568c-46c2-9fa4-ad93c54ef90e?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

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.

Only limit=0 reaches this unbounded, and the people, series, and runtime hydrations take the same ID list today. #4211, stacked on this pull request, streams limit=0 in batches of 1,000 books, which bounds every hydration query, so I am leaving this one as is here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That makes sense. If #4211 bounds all hydration queries by streaming unlimited results in batches of 1,000, batching only the added-date lookup here would address just one of several similar queries.

The unbounded-query risk remains in #4208 until #4211 is merged, so it’s worth keeping that dependency visible. I haven’t independently verified #4211.

Comment on lines +348 to +349
case "random":
return "", "random()"

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 Bug high

Random sort reshuffles the library on every page

Clients paging through a library can receive duplicate books and miss others because random() generates a new order for each page. Use a seed shared across pages, or avoid random ordering with offset pagination.

Prompt for LLM
File internal/audiobooks/media_store.go, lines 348-349:

Random sort reshuffles the library on every page

Every page generates a new random order, so clients paging through a library receive duplicates and miss books. Use a stable seed shared across pages, or avoid exposing random ordering through offset pagination.

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.

This matches real Audiobookshelf, whose random sort also orders each request independently (Database.sequelize.random() in getOrder); clients use it for a shuffled shelf, not for paging a full library. Keeping it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. Keeping random() is reasonable for Audiobookshelf compatibility and shuffled-shelf use. The pagination caveat remains: separate requests can return duplicates or omit items, so the comment claiming that every order prevents skipped or repeated rows should exclude random sort.

Comment on lines +302 to +306
authorNames := func(expr string) string {
return ` LEFT JOIN (SELECT ip_sort.content_id, string_agg(` + expr + `, ', ' ORDER BY ip_sort.sort_order, p_sort.name) AS names
FROM item_people ip_sort JOIN people p_sort ON p_sort.id = ip_sort.person_id
WHERE ip_sort.kind = ` + strconv.Itoa(int(models.PersonKindAuthor)) + `
GROUP BY ip_sort.content_id) an_sort ON an_sort.content_id = mi.content_id`

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 Performance medium

Author sorting reaggregates the entire catalog for every page

Each author-sorted page repeats the aggregation of author memberships across the entire catalog. Restrict an_sort to matching library items or maintain an indexed per-item author sort key.

Prompt for LLM
File internal/audiobooks/media_store.go, lines 302-306:

Author sorting reaggregates the entire catalog for every page

Each author-sorted page aggregates every author membership in the catalog before joining to the requested library and filter, repeating that work for every page. Restrict the aggregation to matching library items or maintain an indexed per-item author sort key.

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.

The aggregation reads only author rows (kind = 7), which belong to books. On the 30,000-book test library it ran in 89 ms against 253 ms for the per-book subquery it replaced. A stored per-item author sort key would need its own migration and upkeep, which this pull request leaves out.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That benchmark supports using the aggregate-and-join approach over a per-book subquery, and I agree that a stored sort key would be a separate change.

The remaining concern is narrower: kind = 7 limits the aggregation to authors, but it does not limit it to the requested library or filtered books. The 89 ms result therefore doesn’t establish how this performs with multiple libraries or a highly selective filter.

I’d treat this as a documented performance tradeoff, not a blocker for this PR. If author sorting becomes a bottleneck, a follow-up could compare the current plan with aggregation restricted to matching items using EXPLAIN ANALYZE on a representative multi-library dataset.

-- CONCURRENTLY keeps audiobook_series writable during the build; it cannot run
-- inside a transaction, hence the NO TRANSACTION annotation above.
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_audiobook_series_name_trgm

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

A failed index build can leave the search index invalid

Drop the existing index concurrently before recreating it.

Kody rule violation: Make denormalization migrations resumable with bounded lock and retry costs

Prompt for LLM
File migrations/sql/20261114223220_add_audiobook_series_name_trgm_index.sql, line 12:

A failed index build can leave the search index invalid

A failed concurrent index build can leave an invalid index with this name. On retry, `IF NOT EXISTS` skips that index instead of rebuilding it, so the migration can succeed without providing the intended search index. Drop any existing index concurrently before recreating it.

Kody rule violation: [Make denormalization migrations resumable with bounded lock and retry costs](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/9729677f-bea5-4d32-90cd-9da32c7a9a60?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Suggested code:

DROP INDEX CONCURRENTLY IF EXISTS public.idx_audiobook_series_name_trgm;
CREATE INDEX CONCURRENTLY idx_audiobook_series_name_trgm

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.

Fixed in 2c9e594: the migration drops any index left by a failed build before creating it, so a retry builds a valid one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the update. Dropping the leftover index before recreating it addresses the retry concern. I haven’t independently verified commit 2c9e594353.

@silo-kody

silo-kody Bot commented Nov 14, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@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: 2

Nitpick comments: 1

internal/audiobooks/media_store_items_db_test.go: 1

161-161: Trivial · Maintainability & Code Quality · Quick win

Exercise filtering and sorting with a nonzero page offset.

The table requests every matching book. This bounded request selects the same first book as the default title order. These assertions do not detect filtering or sorting after pagination.

Extend this test with limit=1 and offset=1. For example, Fantasy books sorted by title descending must return only alpha, with total 2. An added-date ascending page at offset 1 must return charlie, with total 4.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c33e629e-cde0-45b7-b4ef-04bf577ff5e5
Commits

Reviewing files that changed from the base of the PR and between feae205 and 2c9e594.

Files selected for processing: 12

  • internal/audiobooks/abs/filter.go
  • internal/audiobooks/abs/filter_test.go
  • internal/audiobooks/abs/handler.go
  • internal/audiobooks/abs/libraries_handler.go
  • internal/audiobooks/abs/login_refresh_test.go
  • internal/audiobooks/abs/smart_collections_handler.go
  • internal/audiobooks/abs/smart_collections_handler_test.go
  • internal/audiobooks/media_store.go
  • internal/audiobooks/media_store_items_db_test.go
  • internal/models/media.go
  • migrations/sql/20261114223220_add_audiobook_series_name_trgm_index.sql
  • scripts/ci/db-contracts.txt

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

Comment thread internal/audiobooks/media_store.go Resolved
}
rows, err := s.Pool.Query(ctx, `
SELECT content_id, series_name, COALESCE(series_index::text, '')
SELECT content_id, series_name, LOWER(series_name), COALESCE(series_index::text, '')

@coderabbitai coderabbitai Bot Nov 14, 2026 •

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.

Minor · Functional Correctness · Heavy lift

Keep real series IDs distinct from the no-series sentinel.

For a real series named No-Series, this expression produces the ID no-series. Lists and item metadata expose that ID. When a client sends its encoded series filter, ParseFilter returns SentinelNoSeries, and the store selects books without a series instead.

Give real series an unambiguous identity when the lowercase name equals the sentinel. Preserve that distinction through list, metadata, and filter handling.

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.

Confirmed, and leaving it. A series is keyed by its lowercased name, so only a series literally named "no-series" in some casing collides, and the Audiobookshelf app sends the same encoded value for its own "No series" entry, so the request alone cannot tell them apart. Separating them would mean changing every series ID (for example a prefix or a hash), which changes IDs clients have already stored. The sentinel wins, which matches what the app's "No series" entry means.

…braries only

Without a route library, the added-date and duration orders read every
library a book is in, while the dates shown came only from libraries
the viewer may see, so a hidden copy could decide where a book sorted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 14, 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 merged commit 436f0fb into main Nov 15, 2026
21 checks passed
@Quick104
Quick104 deleted the fix/abs-library-items-filters-and-sort branch November 15, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: compat Breaks a supported client or server path priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant