Skip to content

feat(frontend): tab Options page sources, opt into ES request_cache#1246

Open
KiaraGrouwstra wants to merge 1 commit intomainfrom
separate-options
Open

feat(frontend): tab Options page sources, opt into ES request_cache#1246
KiaraGrouwstra wants to merge 1 commit intomainfrom
separate-options

Conversation

@KiaraGrouwstra
Copy link
Copy Markdown
Collaborator

switch option categories from checkboxes to tabs to improve cacheability and decrease visual clutter.

image

Replaces the multi-checkbox includedOptionSources : Set String with a single activeOptionSource : OptionSource. The Options page now shows one source at a time per tab.
Each tab issues a single ES query with a fixed term: { type: <one> } filter, so the request body is byte-stable across users on identical input. With the new ?request_cache=true opt-in (added on the new Search.makeRequestTask Task-based path used by Options), repeated queries become near-free shard cache hits rather than per-user noise.

Compared to the previous "single query with terms array" shape:

  • Up to 7 distinct cache keys per popular query (one per checkbox combo) collapses to 1 per tab.
  • Per-result source badges become redundant (one tab = one docType) and are dropped.

Each tab carries a hit-count badge. The active tab's count comes from the in-flight query result; inactive tabs are populated by a size: 0 count query per tab fired alongside the main request. size: 0 is the workload ES's request_cache was designed for, so once a popular query has been seen on any source the count queries cost almost nothing. Counts render as 1234, 1.2k, or 10k+ (ES caps total.value at 10000 unless we ask otherwise, so don't pretend the larger numbers are exact). Counts clear on every fresh load so stale badges don't linger; inactive errors are swallowed silently since the badge is a hint, not a result.

The new URL shape is ?source=<id> (omitted for the default nixos tab).

Tackles #1237 (comment) concern regarding load on Elastic Search, and #1210's suggestion to return to a pre-badge uncluttered UI.

Disclaimer: I used a coding agent in the creation of this patch.

Replaces the multi-checkbox `includedOptionSources : Set String` with
a single `activeOptionSource : OptionSource`. The Options page now
shows one source at a time per tab.

Each tab issues a single ES query with a fixed `term: { type: <one> }`
filter, so the request body is byte-stable across users on identical
input. With the new `?request_cache=true` opt-in (added on the new
`Search.makeRequestTask` Task-based path used by Options), repeated
queries become near-free shard cache hits rather than per-user noise.

Compared to the previous "single query with `terms` array" shape:

- Up to 7 distinct cache keys per popular query (one per checkbox
  combo) collapses to 1 per tab.
- Per-result source badges become redundant (one tab = one docType)
  and are dropped along with their CSS.

Each tab carries a hit-count badge (GitHub style). The active count
is mirrored from `QueryResponse` into a shared `sourceCounts` dict;
inactive counts arrive via `size: 0` count queries fired alongside
the main one — the workload ES's `request_cache` was designed for, so
once a popular query has been seen on any source the count queries
cost almost nothing. Counts render as `1234`, `1.2k`, or `10k+` (ES
caps `total.value` at 10000 unless we ask otherwise, so don't pretend
the larger numbers are exact). Reading counts uniformly from one
place means badges survive a tab switch unchanged — the previous
tab's count stays visible until a fresh count for the new tab
arrives.

Stale-while-revalidating: while a fresh query is in flight,
`viewResult` renders the last successful result (kept around in
`previousResult`) overlaid with a small CSS spinner instead of
flashing the full-page loader. Tab switches and pagination keep the
result list visible and the page no longer jumps.

The new URL shape is `?source=<id>` (omitted for the default `nixos`
tab).

Assisted-by: Claude:claude-opus-4-7[1m]
@KiaraGrouwstra KiaraGrouwstra requested a review from raboof April 30, 2026 20:04
@github-actions
Copy link
Copy Markdown
Contributor

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