Merge pull request 'fix(644): stop seven SPA list loads truncating silently — one shared pager, bounded media pickers' (#656) from fix/644-spa-paging into main
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (push) Has been cancelled
Build ErsatzTV Image / Build & push image (amd64) (push) Has been cancelled
Build ErsatzTV Image / Build & test (.NET) (push) Has been cancelled
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Has been cancelled
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (push) Has been cancelled
Build ErsatzTV Image / Build & push image (amd64) (push) Has been cancelled
Build ErsatzTV Image / Build & test (.NET) (push) Has been cancelled
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Has been cancelled
This commit was merged in pull request #656.
This commit is contained in:
@@ -161,6 +161,7 @@ the link for rationale. Superseded/retired history lives in `archive/`. Regenera
|
||||
| `spa.deco-templates-table` | The deco-templates editor also renders its day/deco assignment as a table, extending (not replacing) the templates-editor-table convention. | 2026-07-09 | [link](records/spa/deco-templates-table.md) |
|
||||
| `spa.download-sample-gate` | The SPA disables both Download Media Sample and Download Results while a troubleshooting session is starting/running (Blazor only gated Download Results). | 2026-07-09 | [link](records/spa/download-sample-gate.md) |
|
||||
| `spa.legacy-redirect-matcher` | `LegacyUiRedirects.TryGetRedirect` is a two-tier matcher — an exact `OrdinalIgnoreCase` `Map` (Tier 1) then an ordered segment-template pattern list (Tier 2, first-match-wins) — collision-free by construction, with a guard invariant that no rule may prefix-match `/api`, `/artwork`, `/docs`, `/openapi`, `/iptv`, `/app`, or `/media/sources`. | 2026-07-11 | [link](records/spa/legacy-redirect-matcher.md) |
|
||||
| `spa.list-completeness-vs-bounded-pickers` | The shared `loadAllPages` helper (`web/src/api/paging.ts`) pages a `/api/v1` list to completeness against `totalCount` and is used ONLY for lists that are bounded by construction (rerun collections, multi-collections, playlists — admin-created, hundreds of rows at most). A `getLibraryBrowseItems` picker over a media-library table (Episode/Song/Image/Movie/MusicVideo, tens of thousands of rows possible) must NOT page to completeness — it fetches ONE bounded page (the server cap) and surfaces the truncation (a `ctv-field-help` hint wired to the real `totalCount`) instead of silently dropping the rest. | 2026-07-26 | [link](records/spa/list-completeness-vs-bounded-pickers.md) |
|
||||
| `spa.logs-page-size-local` | The Logs page rows-per-page preference is stored in `window.localStorage` (`ctv-logs-page-size`), not a server `ConfigElement`. | 2026-07-11 | [link](records/spa/logs-page-size-local.md) |
|
||||
| `spa.playback-troubleshoot-poll` | The playback-troubleshooting screen reports FFmpeg completion by polling `GET /api/troubleshoot/playback/status` (~2s) rather than a server push channel. | 2026-07-09 | [link](records/spa/playback-troubleshoot-poll.md) |
|
||||
| `spa.playout-reset-button` | The SPA keeps a single Reset action (server picks the default build mode) and drops Blazor's separate "Schedule reset" button since its capability already exists via the playout's Edit-details flow. | 2026-07-09 | [link](records/spa/playout-reset-button.md) |
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
key: spa.list-completeness-vs-bounded-pickers
|
||||
title: '2026-07-26 — `loadAllPages` is for bounded-by-construction lists only; media-library pickers stay bounded and show truncation (#644 follow-up)'
|
||||
status: active
|
||||
since: '2026-07-26'
|
||||
supersedes: none
|
||||
superseded-by: none
|
||||
rule: 'The shared `loadAllPages` helper (`web/src/api/paging.ts`) pages a `/api/v1` list to completeness against `totalCount` and is used ONLY for lists that are bounded by construction (rerun collections, multi-collections, playlists — admin-created, hundreds of rows at most). A `getLibraryBrowseItems` picker over a media-library table (Episode/Song/Image/Movie/MusicVideo, tens of thousands of rows possible) must NOT page to completeness — it fetches ONE bounded page (the server cap) and surfaces the truncation (a `ctv-field-help` hint wired to the real `totalCount`) instead of silently dropping the rest.'
|
||||
signals: '`loadAllPages`, Class A vs Class B picker, LuceneSearchIndex.Search hitsLimit, picker truncation hint, ctv-field-help, PagedResult, `complete` flag · paths: `web/src/api/paging.ts`, `web/src/screens/RerunCollectionsScreen.tsx`, `web/src/screens/PlaylistsScreen.tsx`, `web/src/screens/FillerPresetsScreen.tsx`, `web/src/screens/MultiCollectionsScreen.tsx`, `docs/spa-conventions.md` §3b · issues: #644'
|
||||
mechanics: '`docs/spa-conventions.md` §3b'
|
||||
---
|
||||
|
||||
`fe342a6a` (#644) extracted the `loadAllPages` client-side paging helper and applied it at every
|
||||
call site that had been requesting an over-cap `pageSize` to "get everything in one call" — a
|
||||
pattern that silently truncated to the server's `MaxPageSize` (100) with no error and no
|
||||
truncation indicator. A cold adversarial review of that fix found it was correct for the
|
||||
admin-created lists (rerun collections, multi-collections, playlists — bounded by construction,
|
||||
hundreds of rows at most) but dangerous for three call sites: the `getLibraryBrowseItems` pickers
|
||||
in `RerunCollectionsScreen`, `PlaylistsScreen`, and `FillerPresetsScreen`, which populate a native
|
||||
`<select>` whose `mediaType` can be `Episode`, `Song`, `Image`, `Movie`, or `MusicVideo` — the
|
||||
largest tables in an install. Paging one of those to completeness means on the order of 200 serial
|
||||
requests against a 20,000-row library, each **more** expensive than the last (`LuceneSearchIndex
|
||||
.Search` computes `hitsLimit = skip + limit`, so later pages re-scan a growing prefix), ending in a
|
||||
`<select>` with 20,000 `<option>` nodes rendered into the DOM. That is worse than the defect #644
|
||||
set out to fix.
|
||||
|
||||
The fix keeps `loadAllPages` unchanged in behavior for the bounded lists (it now also reports a
|
||||
`complete: boolean` flag and accepts an `AbortSignal`, per the same follow-up review's F4/F2
|
||||
findings) and removes it entirely from the three media-library picker call sites. Those instead
|
||||
call `getLibraryBrowseItems` directly for a single page at the server cap (`pageSize: 100`) and
|
||||
read the response's `totalCount` to detect truncation. The defect named in #644's title is
|
||||
"*silently* truncate" — the silence is the bug, not the bound. So a truncated picker load renders a
|
||||
`ctv-field-help` hint next to the `<select>` (`Showing the first 100 of 5000 — use search to
|
||||
narrow.`) instead of either paging forever or truncating without saying so. A full
|
||||
typeahead/search-driven picker over the media library is a materially larger feature (a `query`
|
||||
param already exists on `getLibraryBrowseItems` for it) and is deliberately out of scope here — a
|
||||
follow-up issue, not this fix.
|
||||
|
||||
**2026-07-26 addendum (round-3 review F1):** `loadPickerOptions`'s `multi` branch (a Class A
|
||||
source — `MultiCollection`) reused the same `truncated: boolean` field as the Class B media-library
|
||||
pickers, but the two conditions are not the same thing: Class B's `truncated` means "there are more
|
||||
rows than fit in one page — narrow via search," while a Class A picker's flag meant "the
|
||||
`loadAllPages` loop didn't converge" (`complete: false`) — a defensive/incomplete load, not a cap.
|
||||
Rendering both through the shared "Showing the first N of M — use search to narrow" copy produced a
|
||||
self-contradictory "Showing the first 47 of 47" on an incomplete Class A load, pointing at a search
|
||||
box that picker doesn't have. `RerunCollectionsScreen.tsx`/`PlaylistsScreen.tsx` now return a
|
||||
`hint: 'incomplete' | 'none' | 'truncated'` discriminator instead of a boolean, and render distinct
|
||||
copy per value — `'truncated'` keeps the existing search-narrowing text, `'incomplete'` renders
|
||||
"List may be incomplete — retry to reload" (matching the wording already used for the Class A
|
||||
list-load warn `Badge`). A picker's `console.warn` on an incomplete load — and the analogous one in
|
||||
`SchedulesScreen.loadAllRerunCollections` — is also gated on `!signal?.aborted`, so a superseded or
|
||||
user-aborted load (Retry, or a type switch mid-load) no longer logs a false "did not complete"
|
||||
warning.
|
||||
@@ -121,6 +121,70 @@ Convention — when a screen keeps stale results visible during a refetch:
|
||||
current (compare against a ref that always holds the committed value — `SearchScreen` reuses
|
||||
`lastQueryRef`) and **discard** otherwise. Checking only `activeRef` (mounted) is insufficient.
|
||||
|
||||
## 3b. Paged list endpoints clamp server-side — page to completeness ONLY for bounded lists, never a media-library picker
|
||||
|
||||
Every paged `/api/v1` list endpoint (rerun-collections, multi-collections, library/browse, search,
|
||||
trakt-lists, …) clamps `pageSize` to its own controller's `MaxPageSize` (100, as of #644) regardless
|
||||
of what the client requests. A screen that asks for `pageSize: 1000` to "get everything in one call"
|
||||
gets only the first `MaxPageSize` rows back, silently — no error, no truncation indicator, no paging
|
||||
UI to notice the gap. This was issue #644 (following on from #634, which fixed the first instance —
|
||||
`SchedulesScreen`'s rerun-collections picker load).
|
||||
|
||||
**Two classes of call site, treated differently** (decision record:
|
||||
`docs/decisions/records/spa/list-completeness-vs-bounded-pickers.md`, `spa.list-completeness-vs-bounded-pickers`
|
||||
— a #644 follow-up review found the original blanket "use `loadAllPages` for any picker" guidance
|
||||
below was itself the defect for one class of caller):
|
||||
|
||||
- **Bounded-by-construction lists** (rerun collections, multi-collections, playlists — admin-created,
|
||||
hundreds of rows at most): genuinely need the complete list, and completeness is cheap. Use the
|
||||
shared `loadAllPages` helper (`web/src/api/paging.ts`, re-exported via `web/src/api/index.ts`)
|
||||
instead of an inflated `pageSize`:
|
||||
|
||||
```ts
|
||||
const { items, complete } = await loadAllPages(getMultiCollections); // pages against totalCount, cap defaults to 100
|
||||
```
|
||||
|
||||
It pages `pageNum` from 0 (per §"paging-zero-based" in `api-conventions.md`) against the response's
|
||||
`totalCount`, stopping — and reporting `complete: false` — on an empty page (defensive guard
|
||||
against a `totalCount` that never converges) or on an aborted `signal`. **Always check `complete`**:
|
||||
a caller that needs the full list must not treat a resolved promise as proof the list is whole (a
|
||||
partial result is otherwise silently indistinguishable from a complete one — the same defect class
|
||||
as #644 itself, since `GetLibraryBrowseItemsHandler.HydrateMediaItems` can legitimately drop stale
|
||||
Lucene hits and produce a short/empty page in normal operation). Pass an `AbortSignal` (4th arg)
|
||||
from the caller's effect cleanup so a superseded load stops issuing further page requests instead
|
||||
of hammering the server for a result nobody will see. **Do not raise the server-side cap to work
|
||||
around this** — the `api.search-allitems-paging` precedent is that the client pages and the server
|
||||
stays bounded; that's a backend decision, out of scope for a screen fix.
|
||||
|
||||
- **Media-library pickers** (`getLibraryBrowseItems` backing a `<select>` for Episode / Song / Image /
|
||||
Movie / MusicVideo / etc. — the largest tables in an install, tens of thousands of rows possible):
|
||||
must **NOT** use `loadAllPages`. Paging to completeness here means on the order of 200 serial
|
||||
requests for a 20k-row library — each more expensive than the last, since
|
||||
`LuceneSearchIndex.Search` computes `hitsLimit = skip + limit` — to populate a native `<select>`
|
||||
with thousands of `<option>` nodes. That is worse than the truncation bug it would "fix". Instead,
|
||||
fetch **one bounded page** directly (`pageSize` at the cap) and make the truncation **visible**
|
||||
rather than silent — e.g. a `ctv-field-help` hint next to the picker: `Showing the first 100 of
|
||||
5000 — use search to narrow.` (wire the response's real `totalCount`). See
|
||||
`RerunCollectionsScreen.tsx`/`PlaylistsScreen.tsx`/`FillerPresetsScreen.tsx`'s `loadPickerOptions`
|
||||
for the pattern. A full typeahead/search-driven picker is a separate, larger feature — out of scope
|
||||
for this fix.
|
||||
|
||||
**A Class B truncation and a Class A `complete: false` are different conditions — don't collapse
|
||||
them into one boolean** (#644 follow-up round-3 review F1): a `loadPickerOptions` result that can
|
||||
come from either a Class A (`loadAllPages`) or Class B (single bounded page) source should carry a
|
||||
`hint: 'incomplete' | 'none' | 'truncated'` discriminator, not a `truncated: boolean` reused for
|
||||
both. `'truncated'` (Class B, an expected cap) keeps the "Showing the first N of M — use search to
|
||||
narrow" copy; `'incomplete'` (Class A, `loadAllPages`'s `complete: false`) renders different copy
|
||||
("List may be incomplete — retry to reload") — rendering both through the search-narrowing text
|
||||
produces a self-contradictory "Showing the first 47 of 47" when a Class A load doesn't converge.
|
||||
Also gate any `console.warn` on a Class A `complete: false` with `!signal?.aborted` — a superseded
|
||||
or user-aborted load returns `complete: false` too, and that's expected, not a defect.
|
||||
|
||||
**If a screen shows a bounded preview or has real paging UI** (a "load more" button, a page-size
|
||||
selector, a fixed-size typeahead result list), a `pageSize` at or below the cap is correct as-is —
|
||||
`loadAllPages` is only for "I need literally everything, and the list is small by construction"
|
||||
call sites.
|
||||
|
||||
## 4. API client modules
|
||||
|
||||
One file per domain in `web/src/api/`, e.g. `logs.ts`, `blocks.ts`, `playouts.ts`. Pattern (see
|
||||
|
||||
Reference in New Issue
Block a user