You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(audiobooks): make Audiobookshelf library filters, sort, and search return the right books - #4208
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.
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.
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.
Risk: the MediaStore interface changes (ListAudiobooks signature, new search methods) require all implementations to be updated; series filtering no longer collapses results by series.
…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]>
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).
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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
The reason will be displayed to describe this comment to others. Learn more.
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.
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)
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.
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.
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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.
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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.
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
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.
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 settingsReview 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
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
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.
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workinggoPull requests that update go codeimpact: compatBreaks a supported client or server pathpriority: P2Limited scope, workaround exists, or polishsize/XXL1000–2999 added + deleted lines (all files); change volume, not priority.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
in-progressandfinishedmatched nothing. The official app also base64-encodes progress values andno-series, which the parser passed through undecoded. All filters now run in SQL; progress reads only the requesting profile's rows.sortanddescwere echoed back but not applied. The handler now honors the keys real Audiobookshelf accepts where Silo has the data: title, added date (also used forbirthtimeMsandmtimeMs, 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, andprogress.finishedAthave no data in Silo and fall back to title order. List items also carriedaddedAt: 0; they now report when the book joined the library.ILIKEqueries on thepeople.nametrigram index and a new trigram index onaudiobook_series.series_name, scoped to the library and the viewer's access.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.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
ListAudiobookstakes anItemsQuery(filter, sort, viewer) and renders it as SQL predicates and anORDER BYwith 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=1still folds series in Go over the filtered set; making that andlimit=0cheaper is a separate pull request stacked on this one.Validation
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.scripts/ci/db-contracts.txtand 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./api/v2code.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.
filter=genres.<Fantasy>filter=progress.<in-progress>filter=progress.<finished>filter=progress.<not-started>sort=addedAt&desc=1addedAt0addedAtsearch?q=shadow?include=filterdata/authorsitems?limit=50&page=0The 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
/authorsand 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
audiobook_serieswithCREATE INDEX CONCURRENTLY.Checklist
AI Disclosure
code-reviewskill, medium). Confirmed and fixed: base64-encoded progress andno-seriesfilters, 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
ListAudiobooksnow takes anItemsQueryand 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.ParseFilterdecodes base64-encoded filter values while preserving plain progress values and the no-series sentinel;ListContinueListeningnow requires exact user ID and profile ID matches, including an empty profile ID.SearchLibraryAuthorsandSearchLibrarySeriesstore queries, scoped to visible books, with prefix matches ordered first.AudiobookSeriesMembershipgains aKeyfield for that identity. A trigram GIN index is added onaudiobook_series.series_name.MediaStoreinterface changes (ListAudiobookssignature, new search methods) require all implementations to be updated; series filtering no longer collapses results by series.Macroscope summarized 5f8908c.