Auto-Tune DetailPanel SPA: wire per-source weight steppers + exclude/add-untagged to the #425 backend #440

Closed
opened 2026-07-18 04:31:22 +02:00 by timothy · 2 comments
Owner

Follow-up to #425 (backend) + #386 (DetailPanel SPA). #425 shipped the backend for per-source rotation weights + query corrections: POST /api/v1/channels/auto-tune now accepts an optional per-channel sources: [{sourceId, weight, excluded}] (see AutoTuneSourceWeightRequest; sourceId = a show/movie id from GET /api/v1/channels/auto-tune/members). #386 shipped the DetailPanel but deliberately deferred the weight steppers and correction controls to #425's slice; #425 delivered only the backend (it was scoped backend-only), so the SPA controls are still unbuilt.

Scope

  • In the Auto-Tune DetailPanel's Content-sources pane (currently read-only with a #425 hint), add a per-source weight stepper (1..1000, default 1 = fair-share) and an exclude toggle per member row.
  • Add-untagged: a way to add a source not in the axis's base set (its id becomes an added sources entry).
  • Thread the resulting sources array into the per-channel draft that AutoTuneScreen sends to POST /api/v1/channels/auto-tune.
  • Remove the read-only #425 hint once wired.

Notes

  • Backend semantics (for tooltips/UX copy): weight N = airs N× each other source; TV materializes every show individually + a live remainder; MovieGenre materializes only touched movies. See docs/decisions.md 2026-07-18 (#425).
  • All-default weights + no corrections ⇒ backend keeps the single-SmartCollection fair-share channel (no MultiCollection), so sending an all-default sources array is a harmless no-op.

Done-when

  • Weight steppers + exclude toggles + add-untagged wired into the DetailPanel draft and sent as sources
  • Vitest coverage for the stepper/exclude → request mapping
  • Live-E2E: set weights in the SPA → created channel's built playout reflects the ratio
  • Adversarial review passed
  • Docs updated (spa-conventions if a new control convention)
Follow-up to #425 (backend) + #386 (DetailPanel SPA). #425 shipped the backend for per-source rotation weights + query corrections: `POST /api/v1/channels/auto-tune` now accepts an optional per-channel `sources: [{sourceId, weight, excluded}]` (see `AutoTuneSourceWeightRequest`; `sourceId` = a show/movie id from `GET /api/v1/channels/auto-tune/members`). #386 shipped the DetailPanel but deliberately deferred the weight steppers and correction controls to #425's slice; #425 delivered only the backend (it was scoped backend-only), so the **SPA controls are still unbuilt**. ## Scope - In the Auto-Tune DetailPanel's Content-sources pane (currently read-only with a `#425` hint), add a **per-source weight stepper** (1..1000, default 1 = fair-share) and an **exclude** toggle per member row. - Add-untagged: a way to add a source not in the axis's base set (its id becomes an added `sources` entry). - Thread the resulting `sources` array into the per-channel draft that `AutoTuneScreen` sends to `POST /api/v1/channels/auto-tune`. - Remove the read-only `#425` hint once wired. ## Notes - Backend semantics (for tooltips/UX copy): weight N = airs N× *each* other source; TV materializes every show individually + a live remainder; MovieGenre materializes only touched movies. See `docs/decisions.md` 2026-07-18 (#425). - All-default weights + no corrections ⇒ backend keeps the single-SmartCollection fair-share channel (no MultiCollection), so sending an all-default `sources` array is a harmless no-op. ## Done-when - [x] Weight steppers + exclude toggles + add-untagged wired into the DetailPanel draft and sent as `sources` - [x] Vitest coverage for the stepper/exclude → request mapping - [x] Live-E2E: set weights in the SPA → created channel's built playout reflects the ratio - [x] Adversarial review passed - [x] Docs updated (spa-conventions if a new control convention)
timothy added the enhancementpriority: lowfrontend labels 2026-07-18 04:31:22 +02:00
timothy added the in-progress label 2026-07-25 10:50:54 +02:00
Author
Owner

Claiming — Claude Code session 2026-07-25. Session lead of a two-issue frontend bundle with #436 (disjoint SPA slices, parallel worktrees).

Claiming — Claude Code session 2026-07-25. Session lead of a two-issue `frontend` bundle with #436 (disjoint SPA slices, parallel worktrees).
Author
Owner

Closing record

Outcome: Shipped via PR #589 (merged, head 22e89fb9). The Auto-Tune DetailPanel's Content-sources pane is now writable: per-source weight steppers (1..1000), an include/exclude toggle per member row, an axis-aware library typeahead for add-untagged, an "N customised" tag, and the read-only #425 hint removed. The resulting sources: [{sourceId, weight, excluded}] array is threaded into the per-channel draft and sent to POST /api/v1/channels/auto-tune.

Root cause: n/a (feature). The gap existed because #386 deferred these controls to #425's slice and #425 was scoped backend-only, so neither issue owned the SPA half — worth noting as a pattern: a deferral that names a sibling issue rather than a deliverable can leave work owned by nobody.

Decisions/conventions changed: None. This is the SPA wiring of the already-recorded sched.autotune-per-source-weights; docs/spa-conventions.md §11 gained a bullet recording the per-source correction-row convention, but no new or reversed decision.

Reusable knowledge:

  1. A client-side "is this customised?" predicate must be verified against the server's own predicate, in both directions. Review checked sourcesRequest() against CreateAutoTunedChannelsHandler.cs:203 (sources.Any(s => s.Weight != 1 || s.Excluded || !baseIds.Contains(s.SourceId))). They match, and the client is a strict refinement: it clamps before testing while the server tests raw Weight before NormalizeWeight, so a typed 0/-3 can never reach the wire and needlessly flip the channel into MultiCollection shape. No unit test with a mocked server can establish this — it requires reading the handler.
  2. Omit rather than send an all-default array. Returning undefined when nothing is customised keeps an untouched channel on the single-SmartCollection fair-share path; sending an all-default array would be a harmless no-op server-side but is noise on the wire and blurs the Edited/dirty-guard signal.
  3. The Lucene escaper is now duplicated. LUCENE_WILD_SPECIAL in AutoTuneScreen.tsx is byte-identical to WILD_SPECIAL in builder/rules/compile.ts — copied because escapeWild is not exported. Two copies drift. Tracked in #590.
  4. Excluding every source silently produces an empty channel (Members empty, remainder query excludes everything). Nothing crashes and #415's health object flags it after creation, but there is no warning at the point of the mistake. Tracked in #590.

Verification: npm test 988/988 (14/14 in the screen's own suite), lint clean, npm run build ok, tsc --noEmit clean. Live-E2E passed with concrete evidence: fresh config dir, seeded 2-show library, driven headless through the real SPA — added "Show Beta" via the new typeahead, weight 3, "Edited" badge appeared, Create. Captured POST body carried sources:[{"sourceId":9,"weight":3,"excluded":false}]; server built a system-owned MultiCollection (show_title:"Show Alpha" w1, show_title:"Show Beta" w3, remainder w1); built playout of 106,576 items split 26,644 / 79,932 = exactly 3.000:1. Scope limit stated honestly: happy path only — exclusions, multiple customised sources, and out-of-range input are covered by unit tests, not live. Two independent review rounds (full adversarial pass + re-verification of the fix delta); CI green on 22e89fb9.

Deferred: #590 — export the shared Lucene escaper instead of duplicating it, warn on exclude-all, and handle >50-source axes (beyond the 50-row preview, a typeahead pick of an existing member gets a cosmetic "Added" label and one redundant server-no-op'd wire row; only the first 50 sources are editable).

Incident (unrelated to the change, same session): the E2E agent found a foreign ErsatzTV on port 8409, correctly moved to 8420, but cleaned up with a pattern-wide pkill -f "dotnet ErsatzTV.dll" that could have killed a parallel session's server. No damage — that session's harness traps its own PID and its runs had already printed explicit pass summaries. Root cause was my delegation brief (fresh config dir specified, process cleanup unspecified). Port separation is not mitigation; scope by PID. Tracked in #586.

Docs updated: docs/spa-conventions.md §11 (per-source correction-row convention). Two text defects found in review were fixed in-PR at 22e89fb9: a code comment that stated the opposite of the code, and doc wording implying a shared WEIGHT_MIN/WEIGHT_MAX module that does not exist.

## Closing record **Outcome:** Shipped via PR #589 (merged, head `22e89fb9`). The Auto-Tune DetailPanel's Content-sources pane is now writable: per-source weight steppers (1..1000), an include/exclude toggle per member row, an axis-aware library typeahead for add-untagged, an "N customised" tag, and the read-only `#425` hint removed. The resulting `sources: [{sourceId, weight, excluded}]` array is threaded into the per-channel draft and sent to `POST /api/v1/channels/auto-tune`. **Root cause:** n/a (feature). The gap existed because #386 deferred these controls to #425's slice and #425 was scoped backend-only, so neither issue owned the SPA half — worth noting as a pattern: a deferral that names a *sibling issue* rather than a *deliverable* can leave work owned by nobody. **Decisions/conventions changed:** None. This is the SPA wiring of the already-recorded `sched.autotune-per-source-weights`; `docs/spa-conventions.md` §11 gained a bullet recording the per-source correction-row convention, but no new or reversed decision. **Reusable knowledge:** 1. **A client-side "is this customised?" predicate must be verified against the server's own predicate, in both directions.** Review checked `sourcesRequest()` against `CreateAutoTunedChannelsHandler.cs:203` (`sources.Any(s => s.Weight != 1 || s.Excluded || !baseIds.Contains(s.SourceId))`). They match, and the client is a **strict refinement**: it clamps *before* testing while the server tests raw `Weight` before `NormalizeWeight`, so a typed `0`/`-3` can never reach the wire and needlessly flip the channel into MultiCollection shape. No unit test with a mocked server can establish this — it requires reading the handler. 2. **Omit rather than send an all-default array.** Returning `undefined` when nothing is customised keeps an untouched channel on the single-SmartCollection fair-share path; sending an all-default array would be a harmless no-op server-side but is noise on the wire and blurs the Edited/dirty-guard signal. 3. **The Lucene escaper is now duplicated.** `LUCENE_WILD_SPECIAL` in `AutoTuneScreen.tsx` is **byte-identical** to `WILD_SPECIAL` in `builder/rules/compile.ts` — copied because `escapeWild` is not exported. Two copies drift. Tracked in #590. 4. **Excluding every source silently produces an empty channel** (`Members` empty, remainder query excludes everything). Nothing crashes and #415's health object flags it *after* creation, but there is no warning at the point of the mistake. Tracked in #590. **Verification:** `npm test` 988/988 (14/14 in the screen's own suite), lint clean, `npm run build` ok, `tsc --noEmit` clean. **Live-E2E passed with concrete evidence**: fresh config dir, seeded 2-show library, driven headless through the real SPA — added "Show Beta" via the new typeahead, weight 3, "Edited" badge appeared, Create. Captured POST body carried `sources:[{"sourceId":9,"weight":3,"excluded":false}]`; server built a system-owned MultiCollection (`show_title:"Show Alpha"` w1, `show_title:"Show Beta"` w3, remainder w1); built playout of 106,576 items split **26,644 / 79,932 = exactly 3.000:1**. Scope limit stated honestly: happy path only — exclusions, multiple customised sources, and out-of-range input are covered by unit tests, not live. Two independent review rounds (full adversarial pass + re-verification of the fix delta); CI green on `22e89fb9`. **Deferred:** #590 — export the shared Lucene escaper instead of duplicating it, warn on exclude-all, and handle >50-source axes (beyond the 50-row preview, a typeahead pick of an existing member gets a cosmetic "Added" label and one redundant server-no-op'd wire row; only the first 50 sources are editable). **Incident (unrelated to the change, same session):** the E2E agent found a foreign ErsatzTV on port 8409, correctly moved to 8420, but cleaned up with a pattern-wide `pkill -f "dotnet ErsatzTV.dll"` that could have killed a parallel session's server. No damage — that session's harness traps its own PID and its runs had already printed explicit pass summaries. Root cause was my delegation brief (fresh config dir specified, process cleanup unspecified). Port separation is not mitigation; scope by PID. Tracked in #586. **Docs updated:** `docs/spa-conventions.md` §11 (per-source correction-row convention). Two text defects found in review were fixed in-PR at `22e89fb9`: a code comment that stated the opposite of the code, and doc wording implying a shared `WEIGHT_MIN`/`WEIGHT_MAX` module that does not exist.
timothy removed the in-progress label 2026-07-25 12:06:57 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#440