SPA collections: custom playback order has no endpoint/UI; add-items picker covers 4 of 10 media kinds (blocks #91 phase b) #211

Closed
opened 2026-07-09 21:40:36 +02:00 by timothy · 2 comments
Owner

From the #203 mutation-depth sweep (2026-07-09). Manual CRUD, smart-collection CRUD (inline query preview), item listing across all kinds, and item removal are FULL. Two real gaps:

  • Custom playback order cannot be set: the SPA toggles useCustomPlaybackOrder (CollectionsScreen.tsx:705–717) but has no reorder UI, and no /api/* endpoint exists — Blazor's drag-reorder goes through the legacy [FromForm] SortController (SortController.cs:15–28, IgnoreApi=true) → UpdateCollectionCustomOrder. Enabling the toggle in the SPA is an unfulfillable no-op. Needs a new endpoint (e.g. PUT /api/collections/{id}/custom-order) + reorder UI.
  • Add-items picker covers 4 of 10 kinds: ADDABLE_TYPE_LIST (CollectionsScreen.tsx:50) allows Movie/Show/Season/Artist only; episodes, music videos, other videos, songs, images, remote streams — all addable in Blazor — can't be added from the SPA even though POST /api/collections/{id}/items already accepts them (screen self-labels "can't be added from here yet", lines 436–440).

Severity: MUST-FIX (both are capabilities lost outright on Blazor deletion). Refs: #91, #203.

From the #203 mutation-depth sweep (2026-07-09). Manual CRUD, smart-collection CRUD (inline query preview), item listing across all kinds, and item removal are FULL. Two real gaps: - **Custom playback order cannot be set**: the SPA toggles `useCustomPlaybackOrder` (`CollectionsScreen.tsx:705–717`) but has no reorder UI, and **no `/api/*` endpoint exists** — Blazor's drag-reorder goes through the legacy `[FromForm]` `SortController` (`SortController.cs:15–28`, `IgnoreApi=true`) → `UpdateCollectionCustomOrder`. Enabling the toggle in the SPA is an unfulfillable no-op. Needs a new endpoint (e.g. `PUT /api/collections/{id}/custom-order`) + reorder UI. - **Add-items picker covers 4 of 10 kinds**: `ADDABLE_TYPE_LIST` (`CollectionsScreen.tsx:50`) allows Movie/Show/Season/Artist only; episodes, music videos, other videos, songs, images, remote streams — all addable in Blazor — can't be added from the SPA even though `POST /api/collections/{id}/items` already accepts them (screen self-labels "can't be added from here yet", lines 436–440). **Severity: MUST-FIX** (both are capabilities lost outright on Blazor deletion). Refs: #91, #203.
Author
Owner

Implementation up as PR #214. Approach notes:

  • PUT /api/collections/{id}/custom-order takes { mediaItemIds: [] } with Index derived from array order (api-conventions §7); controller 404 pre-check added since the handler's existence error is a plain 422 BaseError.
  • GET /api/collections/{id}/items now orders by CustomIndex (nulls last, title tiebreak) when the flag is on — the DTO is unchanged; array order carries the order.
  • SPA reorder is an explicit mode with move up/down buttons (no drag dependency). It loads ALL pages before enabling reorder because the PUT replaces the whole order from array position — submitting a partial page would scramble unlisted items. Deliberate deviation from Blazor's movies-only drag: the API and CustomOrderCollectionEnumerator sort by CustomIndex for any kind, so any manual collection with the flag on can be reordered (decisions.md entry).
  • Add picker widened to all 10 kinds (toAddItemsRequest now maps every bucket; backend accepted them all along). "All" search fan-out stays Movie/Show/Artist; the 6 new kinds are reachable via their filter chip — mirrors Blazor's per-kind list pages without a 10-way Lucene fan-out.

Closing on merge.

Implementation up as PR #214. Approach notes: - `PUT /api/collections/{id}/custom-order` takes `{ mediaItemIds: [] }` with Index derived from array order (api-conventions §7); controller 404 pre-check added since the handler's existence error is a plain 422 BaseError. - `GET /api/collections/{id}/items` now orders by CustomIndex (nulls last, title tiebreak) when the flag is on — the DTO is unchanged; array order carries the order. - SPA reorder is an explicit mode with move up/down buttons (no drag dependency). It loads ALL pages before enabling reorder because the PUT replaces the whole order from array position — submitting a partial page would scramble unlisted items. Deliberate deviation from Blazor's movies-only drag: the API and `CustomOrderCollectionEnumerator` sort by CustomIndex for any kind, so any manual collection with the flag on can be reordered (decisions.md entry). - Add picker widened to all 10 kinds (`toAddItemsRequest` now maps every bucket; backend accepted them all along). "All" search fan-out stays Movie/Show/Artist; the 6 new kinds are reachable via their filter chip — mirrors Blazor's per-kind list pages without a 10-way Lucene fan-out. Closing on merge.
Author
Owner

Closed via PR #214 (merged to main, CI green).

What was done

  • New PUT /api/collections/{id}/custom-order ({ mediaItemIds: [] }, Index from array order per api-conventions §7; controller 404 pre-check since the handler's existence error maps 422).
  • GetCollectionItemsHandler orders by CustomIndex (nulls last, title tiebreak) when useCustomPlaybackOrder is on — array order carries the order; DTO unchanged. Handler test added (InMemoryTvContext).
  • SPA reorder mode: loads ALL pages before enabling (partial-list PUT would scramble unlisted items), move up/down + Save/Cancel; add/remove disabled during reorder. Any-kind collections, not movies-only — deliberate deviation, decisions.md entry (CustomOrderCollectionEnumerator sorts by CustomIndex regardless of kind).
  • Add-items picker widened to all 10 media kinds (ADDABLE_TYPE_LIST, MEDIA_KIND_FILTERS, toAddItemsRequest buckets); "All" fan-out stays Movie/Show/Artist (seasons exclusion per #180 kept), new kinds via their filter chip; picker note updated.

Files: CollectionController.cs, UpdateCollectionCustomOrderRequest.cs, GetCollectionItemsHandler.cs, web/src/api/collections.ts, CollectionsScreen.tsx, tests, OpenAPI artifacts.

Verified: full test suites green (see #210 comment); adversarial review confirmed no path produces a partial-list PUT and every kind maps to its correct request bucket; live E2E showed the Reorder affordance and 10-kind picker on a real instance.

Deferred: nothing from this issue's scope.

Docs updated: blazor-route-parity.md (collections cluster → PARITY-OK), decisions.md (reorder-buttons/any-kind entry).

**Closed via PR #214** (merged to main, CI green). **What was done** - New `PUT /api/collections/{id}/custom-order` (`{ mediaItemIds: [] }`, Index from array order per api-conventions §7; controller 404 pre-check since the handler's existence error maps 422). - `GetCollectionItemsHandler` orders by `CustomIndex` (nulls last, title tiebreak) when `useCustomPlaybackOrder` is on — array order carries the order; DTO unchanged. Handler test added (InMemoryTvContext). - SPA reorder mode: loads ALL pages before enabling (partial-list PUT would scramble unlisted items), move up/down + Save/Cancel; add/remove disabled during reorder. Any-kind collections, not movies-only — deliberate deviation, decisions.md entry (`CustomOrderCollectionEnumerator` sorts by CustomIndex regardless of kind). - Add-items picker widened to all 10 media kinds (`ADDABLE_TYPE_LIST`, `MEDIA_KIND_FILTERS`, `toAddItemsRequest` buckets); "All" fan-out stays Movie/Show/Artist (seasons exclusion per #180 kept), new kinds via their filter chip; picker note updated. **Files**: `CollectionController.cs`, `UpdateCollectionCustomOrderRequest.cs`, `GetCollectionItemsHandler.cs`, `web/src/api/collections.ts`, `CollectionsScreen.tsx`, tests, OpenAPI artifacts. **Verified**: full test suites green (see #210 comment); adversarial review confirmed no path produces a partial-list PUT and every kind maps to its correct request bucket; live E2E showed the Reorder affordance and 10-kind picker on a real instance. **Deferred**: nothing from this issue's scope. **Docs updated**: `blazor-route-parity.md` (collections cluster → PARITY-OK), `decisions.md` (reorder-buttons/any-kind entry).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#211