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

This commit was merged in pull request #656.
This commit is contained in:
2026-07-26 20:10:04 +00:00
16 changed files with 1155 additions and 85 deletions
+1
View File
@@ -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.