fix(video): client tolerates a stale server (old /api/alteration shape + payload)

The operator's video wouldn't turn on: their stale uvicorn (old Python) requires a
7-way 'content' and 422s the {visual,audio} payload, and returns {content:{video}}
not {render:{video:{shown}}}. So the alteration POST failed and video never updated
(audio works because it's client-driven). Fix: controls() also sends a back-compat
'content' field (current server ignores it; old one ignores visual/audio), and
update() reads video-shown from either response shape. Verified end-to-end against a
simulated fully-stale server: video shows + audio plays, zero errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BenStullsBets
2026-06-26 13:46:49 -07:00
parent 97d2ddd573
commit 56d08d5c60
+9 -1
View File
@@ -506,6 +506,10 @@ function controls() {
return {
visual: $("visual").checked ? "on" : "off",
audio: $("audio").checked ? "soundtrack" : "off",
// Back-compat: a server process predating the visual/audio split still requires
// a 7-way `content` and would 422 the new payload. Send both — the current
// server ignores `content`, an old one ignores visual/audio.
content: $("visual").checked ? "video" : "off",
left: +$("left").value, right: +$("right").value,
dark: mood < 0 ? -mood : 0, light: mood > 0 ? mood : 0,
volume: 2, brightness: 2,
@@ -522,7 +526,11 @@ async function update() {
if (!resp.ok) { readout.textContent = "invalid: " + resp.status; return; }
const data = await resp.json();
readout.textContent = JSON.stringify(data, null, 2);
if (!data.render.video.shown) {
// Tolerate a stale server that still returns {content:{video}} instead of the
// {render:{video:{shown}}} (visual/audio-split) shape, so video works either way.
const videoShown = data.render ? !!(data.render.video && data.render.video.shown)
: !!(data.content && data.content.video);
if (!videoShown) {
// Blank the screen. Cover with #black AND hide the video layers themselves —
// the <video>/<canvas> are GPU-composited and can otherwise show through the
// overlay on a real GPU (Safari/Chrome).