SPA schedules editor is read-only at mutation depth — create/edit/delete + per-item editing missing (blocks #91 phase b) #207

Closed
opened 2026-07-09 21:39:55 +02:00 by timothy · 3 comments
Owner

From the #203 mutation-depth sweep (2026-07-09). The parity doc's "merged into schedules screen" claim for /schedules/{id}, /schedules/add, /schedules/{id}/items is false at mutation depth — the SPA schedules screen is a near read-only viewer:

  • Create: TopBar "Add Schedule" button has no onClick (dead button, web/src/App.tsx:903); no createSchedule in web/src/api/schedules.ts. POST /api/schedules exists unused.
  • Edit/delete schedule: Name is a disabled Input (App.tsx:2027); TreatCollectionsAsShows / ShuffleScheduleItems / RandomStartPoint / FixedStartTimeBehavior have no SPA surface; no delete UI. PUT/DELETE /api/schedules/{id} exist unused.
  • Per-item editing entirely non-functional: every inspector control in all four tabs is hard-coded disabled (App.tsx:2014–2060) — start type/time, collection type/picker, custom title, guide mode, playback order, playout mode, multiple count, all five filler slots, watermarks, subtitle mode, preferred audio/subtitle (placeholder "Deferred: no languages endpoint"). ~35 Blazor per-item fields (ScheduleItemsEditor.razor:160–748) are unchangeable even though ScheduleItemRequest + PUT /api/schedules/{id}/items accept them all.
  • Add-item is defaults-only (immediate POST, no configuration path, App.tsx:1741–1753); item-type pickers for Show/Season/Artist/Playlist/Search/Rerun/Multi/Smart absent; Marathon settings, Multiple Mode, Playout Duration, Fill-With-Group, Tail Mode, Discard-To-Fill, Graphics Elements, Preferred Audio Title have no SPA surface.
  • Copy/duplicate item: Blazor-only (ScheduleItemsEditor.razor:134,994).
  • Working today: item delete, drag-reorder (PUT-replace), schedule switcher. Consistently, LegacyUiRedirects.cs:30 deliberately redirects only the /schedules list.

Severity: MUST-FIX — deleting Blazor would leave schedule management with no working editor. Peer of #202 as a #91 phase (b) gate. Sub-need: a languages endpoint (GetAllLanguageCodes equivalent) — shared with the channel-editor picker gap.

Refs: #91, #203.

From the #203 mutation-depth sweep (2026-07-09). The parity doc's "merged into schedules screen" claim for `/schedules/{id}`, `/schedules/add`, `/schedules/{id}/items` is **false at mutation depth** — the SPA schedules screen is a near read-only viewer: - **Create**: TopBar "Add Schedule" button has no onClick (dead button, `web/src/App.tsx:903`); no `createSchedule` in `web/src/api/schedules.ts`. `POST /api/schedules` exists unused. - **Edit/delete schedule**: Name is a `disabled` Input (App.tsx:2027); TreatCollectionsAsShows / ShuffleScheduleItems / RandomStartPoint / FixedStartTimeBehavior have no SPA surface; no delete UI. `PUT`/`DELETE /api/schedules/{id}` exist unused. - **Per-item editing entirely non-functional**: every inspector control in all four tabs is hard-coded `disabled` (App.tsx:2014–2060) — start type/time, collection type/picker, custom title, guide mode, playback order, playout mode, multiple count, all five filler slots, watermarks, subtitle mode, preferred audio/subtitle (placeholder "Deferred: no languages endpoint"). ~35 Blazor per-item fields (`ScheduleItemsEditor.razor:160–748`) are unchangeable even though `ScheduleItemRequest` + `PUT /api/schedules/{id}/items` accept them all. - **Add-item is defaults-only** (immediate POST, no configuration path, App.tsx:1741–1753); item-type pickers for Show/Season/Artist/Playlist/Search/Rerun/Multi/Smart absent; Marathon settings, Multiple Mode, Playout Duration, Fill-With-Group, Tail Mode, Discard-To-Fill, Graphics Elements, Preferred Audio Title have no SPA surface. - **Copy/duplicate item**: Blazor-only (`ScheduleItemsEditor.razor:134,994`). - Working today: item delete, drag-reorder (PUT-replace), schedule switcher. Consistently, `LegacyUiRedirects.cs:30` deliberately redirects only the `/schedules` list. **Severity: MUST-FIX** — deleting Blazor would leave schedule management with no working editor. Peer of #202 as a #91 phase (b) gate. Sub-need: a languages endpoint (`GetAllLanguageCodes` equivalent) — shared with the channel-editor picker gap. Refs: #91, #203.
Author
Owner

Starting implementation (branch feat/207-212-schedules-channel-depth), incorporating the adversarial pre-review corrections from adversarial-reviewer#19 (slice 1/4). Approach:

Editor architecture (review finding 1): full draft model — every per-item edit, add, copy, remove, reorder is local; one explicit Save issues the single destructive PUT /api/schedules/{id}/items replace (matching Blazor's SaveChanges). Dirty-state guard on navigation and schedule-switch; a 422/network failure retains the draft.

Lossless round-trip (review finding 2): fixing #126 via its option 1 — the items endpoints (GET/POST/PUT) will return a new flat, non-polymorphic ScheduleItemResponseModel whose mutation fields are named 1:1 with ScheduleItemRequest (plus display names and {id,name} watermark/graphics element lists), mapped from the VM hierarchy. The OpenAPI schema becomes truthful, the hand-widened TS type in web/src/api/schedules.ts is deleted, and GET→draft→PUT is aligned by construction. A seeded mixed-schedule (One/Flood/Multiple/Duration + fixed start + marathon + playlist + rerun + fillers + overrides) no-op round-trip test asserting semantic equality across regenerated row ids is the release gate.

New finding from recon (beyond the pre-review): GetProgramScheduleItemsHandler.EnforceProperties (lines 59–87) rewrites StartType→Dynamic, Flood→One, and PlaybackOrder→None (playlist/rerun) in the GET response when the schedule has ShuffleScheduleItems — so any GET→PUT round-trip of a shuffled schedule persists the normalized values over the stored ones. Blazor has the identical behavior (same query feeds its editor), so this is parity-neutral, but it means un-shuffling a schedule cannot recover pre-shuffle Fixed/Flood settings. Will be covered by an explicit test + a decisions.md note rather than a behavior change in this PR.

New API surface: GET /api/languages (wraps GetAllLanguageCodes; both the schedule-item and channel preferred-language pickers store the same three-letter ISO 639-2 code, so one endpoint serves both — the #212 shared endpoint), fillerKind added to FillerPresetResponseModel + a ?fillerKind= filter (the five filler slots are unfilterable today), and the two channel enumeration endpoints (see #212). Shows/seasons/artists/multi/smart/rerun/playlists/watermarks/graphics pickers reuse existing endpoints — no new surface needed there.

Parity standard: the exhaustive Blazor capability matrix (6 schedule-level fields, 43 per-item controls, all visibility/reset side-effect rules from ProgramScheduleItemEditViewModel setters, filler-kind filters, action semantics) is committed as the checklist; the close comment will map every row to SPA control + request key + test. Two deliberate deviations to record in decisions.md: (a) SPA Copy will also copy MultiCollection/SmartCollection/RerunCollection references — Blazor's CopyItem omits them (ScheduleItemsEditor.razor:996–1036), which is a legacy bug, not a behavior to preserve; (b) RandomRotation playback order and Slate tail mode stay excluded from the UI, matching Blazor.

Conditional-rule engine (playback-order options per collection type, mode-gated fields, forced resets like MultiCollection→Shuffle and Playlist/Rerun→None, MarathonShuffleGroups doubling as "Shuffle Playlist Items", FillWithGroup eligibility) will live in a pure, unit-tested reducer module rather than scattered through JSX.

Starting implementation (branch `feat/207-212-schedules-channel-depth`), incorporating the adversarial pre-review corrections from adversarial-reviewer#19 (slice 1/4). Approach: **Editor architecture (review finding 1)**: full draft model — every per-item edit, add, copy, remove, reorder is local; one explicit **Save** issues the single destructive `PUT /api/schedules/{id}/items` replace (matching Blazor's SaveChanges). Dirty-state guard on navigation and schedule-switch; a 422/network failure retains the draft. **Lossless round-trip (review finding 2)**: fixing #126 via its option 1 — the items endpoints (GET/POST/PUT) will return a new flat, non-polymorphic `ScheduleItemResponseModel` whose mutation fields are named 1:1 with `ScheduleItemRequest` (plus display names and `{id,name}` watermark/graphics element lists), mapped from the VM hierarchy. The OpenAPI schema becomes truthful, the hand-widened TS type in `web/src/api/schedules.ts` is deleted, and GET→draft→PUT is aligned by construction. A seeded mixed-schedule (One/Flood/Multiple/Duration + fixed start + marathon + playlist + rerun + fillers + overrides) no-op round-trip test asserting semantic equality across regenerated row ids is the release gate. **New finding from recon (beyond the pre-review)**: `GetProgramScheduleItemsHandler.EnforceProperties` (lines 59–87) rewrites `StartType→Dynamic`, `Flood→One`, and `PlaybackOrder→None` (playlist/rerun) in the GET response **when the schedule has ShuffleScheduleItems** — so any GET→PUT round-trip of a shuffled schedule persists the normalized values over the stored ones. Blazor has the identical behavior (same query feeds its editor), so this is parity-neutral, but it means un-shuffling a schedule cannot recover pre-shuffle Fixed/Flood settings. Will be covered by an explicit test + a decisions.md note rather than a behavior change in this PR. **New API surface**: `GET /api/languages` (wraps `GetAllLanguageCodes`; both the schedule-item and channel preferred-language pickers store the same three-letter ISO 639-2 code, so one endpoint serves both — the #212 shared endpoint), `fillerKind` added to `FillerPresetResponseModel` + a `?fillerKind=` filter (the five filler slots are unfilterable today), and the two channel enumeration endpoints (see #212). Shows/seasons/artists/multi/smart/rerun/playlists/watermarks/graphics pickers reuse existing endpoints — no new surface needed there. **Parity standard**: the exhaustive Blazor capability matrix (6 schedule-level fields, 43 per-item controls, all visibility/reset side-effect rules from `ProgramScheduleItemEditViewModel` setters, filler-kind filters, action semantics) is committed as the checklist; the close comment will map every row to SPA control + request key + test. Two deliberate deviations to record in decisions.md: (a) SPA **Copy** will also copy MultiCollection/SmartCollection/RerunCollection references — Blazor's `CopyItem` omits them (ScheduleItemsEditor.razor:996–1036), which is a legacy bug, not a behavior to preserve; (b) `RandomRotation` playback order and `Slate` tail mode stay excluded from the UI, matching Blazor. Conditional-rule engine (playback-order options per collection type, mode-gated fields, forced resets like MultiCollection→Shuffle and Playlist/Rerun→None, `MarathonShuffleGroups` doubling as "Shuffle Playlist Items", FillWithGroup eligibility) will live in a pure, unit-tested reducer module rather than scattered through JSX.
timothy added this to the Blazor removal (#91 phase b) milestone 2026-07-11 01:14:48 +02:00
timothy added the in-progress label 2026-07-11 01:14:52 +02:00
Author
Owner

Protocol notice for the session working this issue (applies to #212 too): the handoff protocol changed while you were in flight (main @ dfd2134c, decisions.md 2026-07-11). Your prompt's final step — "update docs/handoffs/chicorytv-issue-queue.md, pop the done items, print the next prompt" — is replaced:

  1. Do NOT rewrite the handoff file's state/queue/prompt sections (they're gone; the file is now a static kickoff + lessons lore — you may still APPEND lesson bullets, git pull --rebase first).
  2. Instead, append ONE session comment to the pinned queue tracker #237 using the template in its body (Closed / Filed / Triage / Arc change / Recommended next).
  3. Remove the in-progress label from #207/#212 when you close them (it marks your claim under the new parallel-session protocol).
  4. No need to print a next-session prompt — the kickoff prompt is now standing, in the handoff file.
**Protocol notice for the session working this issue** (applies to #212 too): the handoff protocol changed while you were in flight (`main @ dfd2134c`, decisions.md 2026-07-11). Your prompt's final step — "update docs/handoffs/chicorytv-issue-queue.md, pop the done items, print the next prompt" — is **replaced**: 1. Do NOT rewrite the handoff file's state/queue/prompt sections (they're gone; the file is now a static kickoff + lessons lore — you may still APPEND lesson bullets, `git pull --rebase` first). 2. Instead, append ONE session comment to the pinned queue tracker **#237** using the template in its body (Closed / Filed / Triage / Arc change / Recommended next). 3. Remove the `in-progress` label from #207/#212 when you close them (it marks your claim under the new parallel-session protocol). 4. No need to print a next-session prompt — the kickoff prompt is now standing, in the handoff file.
Author
Owner

Done — closed via PR #229 (merged)

What was done: SPA schedules editor rebuilt to full Blazor mutation parity on a draft/explicit-Save architecture (adversarial-reviewer#19 slice-1 corrections implemented in full). Extracted from App.tsx into web/src/screens/SchedulesScreen.tsx + web/src/schedules/ (pure itemRules.ts rules module, inspector, pickers, ScheduleForm); schedule CRUD (create/edit/delete, unique-name 422 inline, flag gating); all ~43 per-item controls with every conditional/reset rule; source pickers for all 10 collection types; five kind-filtered filler slots; watermark/graphics multi-selects; language pickers; add/copy/remove/reorder draft-local with one destructive PUT on Save; dirty guards (schedule switch, in-app nav via web/src/navigationGuard.ts, beforeunload). Backend: flat 55-field ScheduleItemResponseModel (fixes #126), GET /api/languages, fillerKind filter on filler presets, lossless GET→PUT round-trip test as release gate.

Root cause (of the parity gap): the original screen was built against the read-only viewer standard and verified same-session without a per-capability diff vs ScheduleItemsEditor.razor (#203's finding). The rebuilt editor was driven from an exhaustive Blazor capability matrix (see approach comment above), verified by adversarial review + live E2E.

Checked capability matrix (Blazor rule → SPA control → request key → test) — abridged to rule families; every row was implemented and is pinned by the named test:

Family Rules implemented Where Pinning tests
Start startType [Dynamic,Fixed], Fixed hidden under schedule shuffle; startTime + fixedStartTimeBehavior [Inherit/Strict/Flexible] gated on Fixed, nulled on save otherwise itemRules.startTypeOptions, inspector itemRules.test.ts gates + normalizeForSave cases; screen shuffle test
Source 10 collection types; type-change nulls all refs; ≠Playlist+PlaylistItemSize→Count; Playlist/Rerun→order None; MultiCollection→Shuffle; per-type pickers (search autocompletes, playlist group→playlist w/ playlistGroupId preselect, shared rerun picker, searchTitle+searchQuery) applyCollectionTypeChange, pickers.tsx applyCollectionTypeChange suite + invariant test (F2)
Playback order option lists per type (never RandomRotation; Playlist labeled "Playlist"; disabled for Playlist/Rerun); ≠Chronological→MultiEpisodeGroupSize→Count; ≠Marathon resets marathon fields (not shuffleGroups) playbackOrderOptions, applyPlaybackOrderChange 7-case options test + 4-case reset test
Marathon / playlist shuffle groupBy [Album,Artist,Season,Show,Director], shuffleGroups/shuffleItems/batchSize visible only under Marathon; Playlist's "Shuffle Playlist Items" binds marathonShuffleGroups (dual-purpose column) inspector visibility fns screen Marathon test; shufflePlaylistItemsVisible test
Playout mode [Flood,One,Multiple,Duration], Flood hidden under shuffle; multipleMode options (Count / CollectionSize PlaylistItemSize / MultiEpisodeGroupSize-iff-Chronological); multipleCount expression Multiple+Count only; duration hrs+min clamped [1min,24h] + tailMode [None,Offline,Filler] + discardToFillAttempts Duration-only; mode-gated nulling on save playoutModeOptions, multipleModeOptions, normalizeForSave
FillWithGroup eligible iff mode∈{Multiple,Duration} ∧ order≠ShuffleInOrder ∧ type∈{Collection,Multi,Smart}; force-reset None when ineligible fillWithGroupModeEligible eligibility + force-reset tests
Always-on customTitle, guideMode, 5 filler slots via ?fillerKind=, watermark/graphics multi-selects → id arrays, audio/subtitle language selects via /api/languages, audio title, subtitleMode inspector per-kind filler fetch test; payload assertions
Actions add (Blazor defaults), copy (deep, including multi/smart/rerun — deliberate Blazor-bug fix, decisions.md), remove, move up/down (hidden under shuffle), Save (single PUT, response rebinds draft), Discard, 422 keeps draft, dirty guards screen screen suite (single-PUT, copy-refs, 422-keeps-draft, guard tests)
Schedule-level 6 fields, treatCollectionsAsShows gated on keepMultiPartEpisodesTogether, unique-name 422, switch-after-create ScheduleForm create/delete flow tests + App TopBar test

Verification: adversarial review fork (5 findings fixed in-PR with failing-first tests: cross-schedule draft clobber, stale-order/state divergence, inspector state leak, in-flight-save edit loss, create-switch guard bypass) + live E2E on a seeded scratch instance (18/20 pass; found+fixed: watermark-save 500 — write-path projection NRE, lazy Map masked it in tests; lineup order lost on reload — missing OrderBy(Index)). Final: 1035 dotnet + 579 web tests, CI green, merged.

Files changed: see PR #229 (47+ files). Deferred/follow-ups: #230 (popstate guard gap + shuffle-toggle draft normalization), #238 (inert TopBar primaryAction on non-schedules screens — pre-existing). Docs updated: api-conventions (§7 write-path-projection convention + regen artifacts), spa-conventions (§8 navigation guard), blazor-route-parity (schedules cluster → PARITY-OK w/ evidence pointer), decisions.md (draft/Save architecture, copy deviation, EnforceProperties preserved lossiness, flat DTO).

## Done — closed via PR #229 (merged) **What was done**: SPA schedules editor rebuilt to full Blazor mutation parity on a draft/explicit-Save architecture (adversarial-reviewer#19 slice-1 corrections implemented in full). Extracted from App.tsx into `web/src/screens/SchedulesScreen.tsx` + `web/src/schedules/` (pure `itemRules.ts` rules module, inspector, pickers, `ScheduleForm`); schedule CRUD (create/edit/delete, unique-name 422 inline, flag gating); all ~43 per-item controls with every conditional/reset rule; source pickers for all 10 collection types; five kind-filtered filler slots; watermark/graphics multi-selects; language pickers; add/copy/remove/reorder draft-local with one destructive PUT on Save; dirty guards (schedule switch, in-app nav via `web/src/navigationGuard.ts`, beforeunload). Backend: flat 55-field `ScheduleItemResponseModel` (fixes #126), `GET /api/languages`, `fillerKind` filter on filler presets, lossless GET→PUT round-trip test as release gate. **Root cause** (of the parity gap): the original screen was built against the read-only viewer standard and verified same-session without a per-capability diff vs `ScheduleItemsEditor.razor` (#203's finding). The rebuilt editor was driven from an exhaustive Blazor capability matrix (see approach comment above), verified by adversarial review + live E2E. **Checked capability matrix (Blazor rule → SPA control → request key → test)** — abridged to rule families; every row was implemented and is pinned by the named test: | Family | Rules implemented | Where | Pinning tests | |---|---|---|---| | Start | startType [Dynamic,Fixed], Fixed hidden under schedule shuffle; startTime + fixedStartTimeBehavior [Inherit/Strict/Flexible] gated on Fixed, nulled on save otherwise | `itemRules.startTypeOptions`, inspector | `itemRules.test.ts` gates + `normalizeForSave` cases; screen shuffle test | | Source | 10 collection types; type-change nulls all refs; ≠Playlist+PlaylistItemSize→Count; Playlist/Rerun→order None; MultiCollection→Shuffle; per-type pickers (search autocompletes, playlist group→playlist w/ `playlistGroupId` preselect, shared rerun picker, searchTitle+searchQuery) | `applyCollectionTypeChange`, `pickers.tsx` | `applyCollectionTypeChange` suite + invariant test (F2) | | Playback order | option lists per type (never RandomRotation; Playlist labeled "Playlist"; disabled for Playlist/Rerun); ≠Chronological→MultiEpisodeGroupSize→Count; ≠Marathon resets marathon fields (not shuffleGroups) | `playbackOrderOptions`, `applyPlaybackOrderChange` | 7-case options test + 4-case reset test | | Marathon / playlist shuffle | groupBy [Album,Artist,Season,Show,Director], shuffleGroups/shuffleItems/batchSize visible only under Marathon; Playlist's "Shuffle Playlist Items" binds `marathonShuffleGroups` (dual-purpose column) | inspector visibility fns | screen Marathon test; `shufflePlaylistItemsVisible` test | | Playout mode | [Flood,One,Multiple,Duration], Flood hidden under shuffle; multipleMode options (Count / CollectionSize|PlaylistItemSize / MultiEpisodeGroupSize-iff-Chronological); multipleCount expression Multiple+Count only; duration hrs+min clamped [1min,24h] + tailMode [None,Offline,Filler] + discardToFillAttempts Duration-only; mode-gated nulling on save | `playoutModeOptions`, `multipleModeOptions`, `normalizeForSave` | options + normalize + screen Duration tests | | FillWithGroup | eligible iff mode∈{Multiple,Duration} ∧ order≠ShuffleInOrder ∧ type∈{Collection,Multi,Smart}; force-reset None when ineligible | `fillWithGroupModeEligible` | eligibility + force-reset tests | | Always-on | customTitle, guideMode, 5 filler slots via `?fillerKind=`, watermark/graphics multi-selects → id arrays, audio/subtitle language selects via `/api/languages`, audio title, subtitleMode | inspector | per-kind filler fetch test; payload assertions | | Actions | add (Blazor defaults), copy (deep, **including multi/smart/rerun — deliberate Blazor-bug fix**, decisions.md), remove, move up/down (hidden under shuffle), Save (single PUT, response rebinds draft), Discard, 422 keeps draft, dirty guards | screen | screen suite (single-PUT, copy-refs, 422-keeps-draft, guard tests) | | Schedule-level | 6 fields, treatCollectionsAsShows gated on keepMultiPartEpisodesTogether, unique-name 422, switch-after-create | `ScheduleForm` | create/delete flow tests + App TopBar test | **Verification**: adversarial review fork (5 findings fixed in-PR with failing-first tests: cross-schedule draft clobber, stale-order/state divergence, inspector state leak, in-flight-save edit loss, create-switch guard bypass) + live E2E on a seeded scratch instance (18/20 pass; found+fixed: watermark-save 500 — write-path projection NRE, lazy `Map` masked it in tests; lineup order lost on reload — missing `OrderBy(Index)`). Final: 1035 dotnet + 579 web tests, CI green, merged. **Files changed**: see PR #229 (47+ files). **Deferred/follow-ups**: #230 (popstate guard gap + shuffle-toggle draft normalization), #238 (inert TopBar primaryAction on non-schedules screens — pre-existing). **Docs updated**: api-conventions (§7 write-path-projection convention + regen artifacts), spa-conventions (§8 navigation guard), blazor-route-parity (schedules cluster → PARITY-OK w/ evidence pointer), decisions.md (draft/Save architecture, copy deviation, EnforceProperties preserved lossiness, flat DTO).
timothy removed the in-progress label 2026-07-11 12:07:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#207