Skip to content

feat(search): understand queries, rank results, suggest while typing and stream results - #747

Open
ncbudd wants to merge 19 commits into
snapetech-org:mainfrom
ncbudd:pr/search-rework
Open

ncbudd wants to merge 19 commits into
snapetech-org:mainfrom
ncbudd:pr/search-rework

Conversation

@ncbudd

@ncbudd ncbudd commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Builds on #745 (branch pr/lumen-phone-layout): the Lumen search page uses the phone filter hooks and the partial-failure note from that PR. The two server commits don't depend on it.

Summary

Search now reads what was typed instead of only passing it on. "nate standup" is split into a person ("nate") and an intent (stand-up); TMDB person search finds Nate Bargatze (comedians ranked up), and his stand-up specials come back as a top result. The query is always still searched as typed: the intent only adds results and ordering.

Server

  • Query understanding (searchIntent): a tested parser for formats, genres, media types, roles, seasons, years and decades, and "X by Y". Besides stand-up it handles " live", " audiobook", " season 3", "2015 horror" and "80s action movies".
  • Intent results (searchIntentResolver): for a person plus stand-up it collects comedy credits where they play themselves, TMDB keyword 9716 (stand-up comedy) and titles with their name.
    • A special needs the person's whole name in its title, or a first-billed "Self" credit. A surname alone matched a relative's special, and guest spots or specials the person only produced slipped in.
  • Ranking (searchRanking): typo- and prefix-tolerant matching ("bargatze", "nate barg", "bergatze"), one 0–100 score per result (text fit, exact title, intent fit, owned, popularity, provider order), results ordered within each media type, and dedupe across providers.
  • GET /search adds intent, topResult, correctedQuery (did-you-mean when nothing matched), matchScore per result and failedSources. Existing fields are unchanged.
  • GET /search/stream answers per provider group as NDJSON, so TMDB results arrive while slow catalogs fill in or time out on their own.
  • GET /search/suggest answers from an in-memory index within 120 ms: library titles, recent answers, trending, people, intent queries such as "Nate Bargatze stand-up specials", and spelling corrections.
    • The did-you-mean dictionary is seeded with TMDB's popular people (5 pages) and popular stand-up specials (keyword 9716, 5 pages), refreshed daily. Before, "bergatze" found nothing until someone had searched for Nate Bargatze.
    • Intent suggestions attach to the right kind of match: stand-up to a person, live albums to an artist, a season to a series.
  • Provider cache (searchProviderCache): Bookshelf and ComicVine answers are kept for 2 minutes, and identical searches in flight share one request.
  • All three endpoints are documented in seerr-api.yml, and the new API messages are registered in the catalog.

Lumen

  • Suggestions while typing: the top search box (and the phone search box) shows query suggestions, "Did you mean", recent searches, people, and titles with an In library badge.
    • Combobox semantics: arrow keys, Enter, Escape and aria-activedescendant; the boxes keep their searchbox role.
    • 120 ms debounce, and each keystroke aborts the previous request. Taps keep focus in the box until a choice is made, and rows are 44 px.
    • On phones the list stays closed on arrival until something is typed, so it never covers the results.
  • Streamed All search: All reads /search/stream for video, music, authors and magazines (books and comics keep their own endpoints).
    • Movies and series show as soon as they answer and slower groups fill in. Typing on aborts the old search, and a cut-off stream falls back to the classic /search.
  • Top result card above the sections: a person with their fitting works, or a series that opens at the asked season. What it shows isn't repeated below, and it steps aside when a sort is chosen.
  • Order and spelling: sections follow the order the query asked for (intent.sections). The partial-failure note names the sources that didn't answer (Music, Authors...) with Retry. Corrected searches show "Showing results for …", otherwise a "Did you mean" link.
  • New messages are in en, fr and ar.

Testing

  • New tests:
    • server: searchIntent.test.ts (parser), searchRanking.test.ts (matching and scoring), searchSmart.test.ts (intent, top result, stand-up specials filtering, corrections, stream and suggest routes, dictionary seeding);
    • searchTiming.bench.ts measures classic, streamed and suggest timings with mocked providers (run on demand: node server/test/index.mts server/routes/searchTiming.bench.ts);
    • Lumen: searchStream.test.mjs (NDJSON line splitting, stream paths, a cut-off stream is rejected); search-suggestions.spec.ts (suggests while typing, keyboard moves and picks, a click opens a person, Escape closes, spelling correction); search-stream.spec.ts ("nate standup" top result, one quiet note with Retry for a source that doesn't answer, the Search page box suggests while typing).
  • Local checks on main as of today (00b4b12d1), with feat(lumen): compact phone filters, calmer detail pages and fewer folded boxes #745 below it:
    • server tsc -p server/tsconfig.json, ESLint on the changed files, pnpm i18n:check: pass;
    • server vitest (search tests, 4 files): 74 passed;
    • node test runner: 5,684 passed. The 1 failure also fails on untouched main: the scoped TV allowlist test in src/hooks/detailDisclosureMediaServer.test.mjs (same as in perf: keep the server responsive on SQLite, and music fallbacks for a busy Aurral #740 and fix(lumen): tidy Manage sheets, Issues filters, admin columns; faster All search #741);
    • Lumen tsc, build and unit tests (93), ESLint on the changed Lumen files: pass;
    • Lumen browser specs for search, navigation and the shell (search-suggestions, search-stream, search-localization, people-search, mobile-navigation, swipe-navigation, review-core, indexer-search; desktop, iPhone, Android, tablet): 158 passed, 16 failed. The failures are the 4 review-core tests on every size, which fail the same way on untouched main.
  • Live: running on the production install since 2026-11-28.

AI assistance

AI tools helped write parts of the code and tests. I reviewed the changes, ran the tests listed above, and checked it on a live install.

…chips

On phones, Movies and Series show only the availability switch and a
Filters button with a count. Sort, genres, network, status and More
Filters open in a bottom sheet, with Clear and Done at its foot. Each
filter in use shows as a removable chip on one scrolling line. Desktop
and tablet layouts are unchanged.
…ns the menu

The chip row under the Discover search now links only to the media pages
this server has. Coming Soon and Share & Identify were already in the
sidebar and phone More menu; Provider Discovery is added there.
A shared PhoneFilterBar keeps the control people switch most on the
page, puts the rest in a bottom sheet and shows removable chips for
filters that narrow the list. Comics keeps the type switch, Books the
library switch, Music the release types and Requests the status chips.
Podcast categories and other long chip lists scroll on one line. Stacked
sheets keep the page inert until the last one closes, and Escape closes
the top one.
…arth play links

Music sections sat 60px apart because the tab panel's display:contents
wrapper picked up the section margin rule on top of the page grid gap;
it now uses the grid gap alone. Play opens in moves from the Music page
to When you press Play on the You page, and Lumen settings gains Music
apps: which of Aurral, Plex and Hearth people may pick, plus the
default. Shelf is now Hearth, with Android intent links to Hearth's play
routes and the saved value kept as shelf. Music Discover gets release
type, sort, genre, dates and in-library filters that open the catalogue
list; Podcasts gets a Following filter on the chart.
… long text

TV, movie, book, artist and comics detail pages keep their main and
everyday actions on phones and put indexer search, blocklist, issue
reports, associations, management and similar actions in one More sheet.
Status pills share one scrolling line, long descriptions show four lines
with Show more, and disclosures no longer stack an extra 28px margin on
the grid gap. Account settings get jump links to the list imports,
linked from You. Moving the detail actions into their own containers
also stops duplicate React keys from leaving stale Watchlist buttons on
movie pages.
…ion chips

The section margin rule also skipped .dcols columns, which stacked 28px
on their 22px grid gap between Starring, Crew and Subject Tags. Wider
screens keep the detail actions visible but in their own group, set
apart from the ratings, with ratings and actions at one 36px height.
…arch

- More never holds a single item: one action shows in place
- Account and Lumen settings fold their sections on phones; jump links
  and #section addresses open the section they point to
- Search: empty Book Series hidden, partial service failures become one
  quiet note with Retry, sort is a chip on phones, no gap above results
- Phone toolbars let long button labels wrap (French metadata page)
- Member pass spec (request + auto-approve only) on every size
…ions

- User Settings on phones: the toolbar links and the jump chips become one
  sideways-scrolling row, Import lists first, nothing listed twice
- A run of collapsed sections or closed panels sits 10px apart in a page
  or detail body instead of the container's full gap
- Gap test covers Account and Lumen settings
…tings

Detail pages (movie, series, album and the rest that share the top):
- the description sits right under the title, two lines with Show more,
  instead of lower down or in a folded Overview box
- the dot line never starts or ends a wrapped line with a dot, and empty
  items (no genres) leave no stray dot
- Discover's previous/next are a labelled pair at the top corner of the
  art instead of loose arrows under the genres
- status, ratings and the small actions flow as one wrapping group: no
  chip cut off at a scroller's edge, and a lone More sits beside them;
  phones show the top two ratings and +N for the rest
- scrolled down, the back button joins a solid bar with the title so it
  never covers the content
- the sticky bar keeps every button on one line; the title gives way, and
  Manage keeps only its icon when three buttons share a phone bar
- Series Collections shows only when the series is in one, with the same
  chevron as the other boxes; the Episode Queue chip is short
Album pages: ratings are a chip row by the status and sources without a
rating are left out; song rows use a small get button; long albums show
ten songs, then All N songs.
Requests: a row's buttons run under the whole row instead of down the
narrow text column.
Discover: no Title View chip on the shelves (it stays under You >
Appearance; touch screens always show titles).
… on phones

- movie: one availability chip when HD and 4K are both on the server
  ("On Plex · HD + 4K"); phones show the best-known rating (IMDb) and +N;
  Playback Options moves into More, and More is a small icon chip
- Show more under a short description is a small text link
- album: View Artists and Subject Tags come after the songs
- phones: a shorter strip of art above the poster
- You and Administration: each settings group folds behind its title on
  phones (still a heading); folded groups sit close together
- person: each filmography group shows 12 titles, then Show all (N)
- person: the credits list is kept while it refreshes, so a bulk request's
  result stays on screen instead of vanishing with a remount
Specs open folded groups (tests/browser/phoneSections.ts) or expand first
and keep their checks.

Also: Discover's previous/next shows only the arrow that leads
somewhere. Specs open the folded You and Administration groups (also
after tab taps) and accept the combined HD + 4K chip.
…repeated Requests sentence

- folded boxes on a detail page stack 8-10px apart as one list
- phones: with two or more buttons the sticky bar drops the squeezed title;
  the main button keeps its full label
- phones: the Requests sentence that repeats the list's order is hidden
Detail pages:
- Movie and TV: Starring and Crew are one Cast & Crew box. Movie/Series Details,
  Subject Tags and (TV) Media Server are one Details box. Collection stays.
- Album: one Credits & Details box (album facts, artists, subject tags) right
  under the songs, 10px from the last song on phones.
- Book: Subjects moves into the Details box.
- Parts of a combined box keep a small heading (bare mode of VideoDisclosure,
  CreditsDisclosure and SubjectTagsDisclosure).

Saved "Keep open" choices carry over: Cast & Crew uses the cast key and also
opens for a saved crew choice; Details uses the details key and also opens for
saved subject tag, media server (TV) and artist (album) choices. Closing a box
for good clears the merged keys too. #crew and #mediaServer links open the
combined box at that part.

You and Administration on phones:
- You folds the nine admin groups into one "All Settings and Tools" box and
  Discover, Library, Acquisition and Support into "Library & Tools"
  (17 folds -> 6).
- Administration folds TV, books, music and software services into one
  "Media Services" box (9 folds -> 6).
- Wider screens keep every group as its own section, as before.

Specs open the combined Cast & Crew, Details and Credits & Details boxes
and match the You Library heading exactly next to Library & Tools.
- Book, ebook, audiobook, manga and comic descriptions show three lines with
  Show more (the shared ClampText).
- Edition and narration pickers show the first four rows, then
  "All N editions" / "All N narrations"; the selected row always stays in view.
- The stack of per-narrator Follow buttons is one Follow button under the list,
  for the selected narrator (else the owned one, else the first solo narrator).
- The ebook page shows its edition as one card, like a single-edition manga.
- Switching format on a book opened without a lookup title no longer blanks the
  page for a fresh SeerrNG lookup: the saved answer shows while the titled one
  loads, and pointing at or touching the format link asks for it ahead.
…ions

Book, ebook and audiobook pages now read like the manga page: overview right
under the format cards and action row, then the edition or narrator list, then
Collection and Advanced Request Options, then Details. Advanced Request Options
gets the same chevron as the other folded boxes.
The comic catalogue locale spec and the original language and origin
country specs check filters that phones keep in the Filters sheet. They
now open the sheet first, and again after a reload closes it; wider
screens are unchanged (the helpers do nothing there).
Search now reads what was typed. "nate standup" is split into a person
("nate") and an intent (stand-up), finds Nate Bargatze through TMDB
person search (comedians ranked up), and returns his specials (comedy
credits where he plays himself, TMDB keyword 9716, titles with his name)
as a top result. The same parser handles "<artist> live", "<author>
audiobook", "<show> season 3", "2015 horror" and "80s action movies".
The query is always still searched as typed; the intent only adds.

- searchIntent: tested parser for formats, genres, media types, roles,
  seasons, years and decades, "X by Y"
- searchRanking: typo and prefix tolerant matching ("bargatze",
  "nate barg", "bergatze"), one 0-100 score per result (text fit, exact
  title, intent fit, owned, popularity, provider order), results ordered
  within each media type, cross-provider dedupe
- GET /search adds intent, topResult, correctedQuery (did-you-mean when
  nothing matched), matchScore and failedSources
- GET /search/stream answers per provider group as NDJSON, so TMDB
  results arrive while slow catalogs fill in or time out on their own
- GET /search/suggest answers from an in-memory index (library, recent
  answers, trending) within 120 ms: titles, people, intent queries such
  as "Nate Bargatze stand-up specials" and spelling corrections
- 2-minute cache with in-flight sharing for Bookshelf and ComicVine
- searchTiming.bench.ts measures classic, streamed and suggest timings
- a person's stand-up top result lists only their own specials: the
  whole name in the title, or a first-billed "Self" credit (a surname
  alone matched a relative's special, and guest spots or produced
  specials slipped in)
…d specials

Corrections only knew words from the library and earlier answers, so
"bergatze" found nothing until someone had searched for Nate Bargatze.
The suggestion index now also holds TMDB's popular people (5 pages) and
popular stand-up specials (keyword 9716, 5 pages; their titles carry the
comedians' names), refreshed daily and triggered by suggest and stream.
Library people were already indexed through the library entries' words.

Intent query suggestions now attach to the right kind of match: stand-up
to a person, live albums to an artist, a season to a series.
- the top search box suggests while typing from GET /search/suggest:
  query suggestions ("Nate Bargatze stand-up specials", "Did you mean"),
  recent searches, people and titles with an In library badge
- combobox semantics: arrow keys, Enter, Escape, aria-activedescendant;
  taps and clicks keep focus until a choice is made, 44 px rows
- 120 ms debounce; each new keystroke aborts the previous request
- searchStream reads GET /search/stream line by line (groups arrive as
  they answer) and rejects cut-off streams so callers can fall back;
  runStreamedSearch merges each group into page snapshots, keeps the
  first top result steady and collects the sources that did not answer
- All reads GET /search/stream (video, music, authors, magazines; books
  and comics keep their own endpoints): movies and series show as soon
  as they answer, slower groups fill in, typing on aborts the old search,
  and the classic /search is the fallback
- Top result card above the sections ("nate standup": Nate Bargatze and
  his stand-up specials, or a series that opens at the asked season);
  what it shows is not repeated below, and it steps aside when a sort is
  chosen
- sections follow the order the query asked for (intent.sections)
- the quiet partial-failure note names the sources that did not answer
  (Music, Authors...) with Retry; "Showing results for" a correction and
  a "Did you mean" link
- the phone search box gets the suggestions dropdown; it stays closed on
  arrival until something is typed, so it never covers the results
- messages registered in en, fr and ar
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.

1 participant