oficina / slides Public

Clone
git clone https://amadan.net/oficina/slides

Plain git — no account needed to clone.

Download

Download this file

Scenes and clips Implementation Plan

> For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: A deck can hold scenes (sealed code drawing named states, carried across slides press by press, with a still per state) and clips (short muted videos played on a press, looped or once).

Architecture: Scenes are a deck-level map in the document; slides show them through a scene block whose states count as presses. The code runs in a sandboxed frame served by Slides under a sealed CSP, driven by postMessage; a frame layer outside the slide DOM lets a scene carry on between slides. Wherever code doesn't run, the state's still (uploaded by the scene's author) or a drawn placeholder shows.

Tech Stack: Go, Rust/wasm core, Yjs fixtures, esbuild bundles, chromedp browser tests.

Spec: docs/superpowers/specs/2026-11-23-scenes-and-clips-design.md (draft 2, approved 2026-11-24).

Start: the execution branch feat/scenes starts from origin/main after custom fonts has merged.

Global Constraints

  • Limits: scene bundle ≤ 2 MiB (one HTML document); data ≤ 960 KiB of canonical JSON, and a batch with a scene op must also encode to one live update (≤ 1 MiB; number-heavy data encodes larger than its JSON, so the core and the editor measure the update — corrected after the final review); a still ≤ 4 MiB (PNG or WebP); a clip ≤ 50 MiB (MP4 or WebM).
  • The sealed response header, exactly: Content-Security-Policy: sandbox allow-scripts; default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:; frame-ancestors 'self'.
  • A scene that hasn't answered ready within 3 seconds shows its still.
  • Clips play muted in this slice.
  • Thumbnails and the PDF show a scene block at its to state; the PDF stays one page a slide.
  • Existing decks render byte for byte as today.
  • Every UI string is a catalog key approved by Paul in copy review before it is written. A scene's own words are deck content.
  • No flash; scripts-off works (stills); 320px reflow; WCAG 2.2 AA; fixtures/*.mjs under 300 lines; shared machine rules; commit format as before.

Review Focus

  1. A scene that hangs, throws or never says ready. Its still shows after 3 s, presses still answer, nothing else on the page waits. Task 4, TestASilentSceneShowsItsStill.
  2. A scene that tries to escape (fetch, XMLHttpRequest, document.cookie, localStorage, top.location, window.open, a form post, parent.document). Each fails and the page is unchanged. Task 3, TestASceneCannotReachAnything.
  3. A scene removed while slides still show it, or a state removed that a block names. The block draws the placeholder panel; presses clamp; nothing breaks. Task 2 vectors, Task 4 TestARemovedSceneLeavesAPlaceholder.
  4. Oversize or malformed input (bundle that isn't HTML, data over 2 MiB, still that isn't an image). Refused with a message; nothing stored. Task 2, Task 3, Task 5.
  5. A clip that won't play (codec the browser lacks, failed load). The poster stays, its press still counts, the talk moves on. Task 7, TestAClipThatWontPlayKeepsItsPoster.

Calls this plan makes

| # | Call | Why | |---|---|---| | R1 | A scene's version is not stored: it is computed the same way in Rust, JS and Go (SHA-256 of the code ref, canonical JSON of data, and sorted words), with shared vectors. | The spec says the server computes it; computing it everywhere keeps it honest and needs no write. | | R2 | Scene states as presses reuse the each machinery: deck.Presses treats a scene block like a list whose items are the states after from up to to. | One press rule for everything. | | R3 | Clip play: press is one press, like an each item; back pauses and rewinds. | Spec §2. | | R4 | The placeholder panel for a missing still is drawn by the renderer (SVG and HTML) from the scene's name and the state's description, in the theme's colours. | Spec §8.3. | | R5 | The presenter's Next preview always uses stills; the Now panel runs the scene live. | Cheap and never late. |

---

Task 1: The copy gate

  • [ ] Draft and run the copy review for every new UI string: the scene block's card (scene name label, From, To, the words list heading, the out-of-date note and its "ask an agent" action), the data panel (table and JSON views, add/remove row), the code panel (save, preview, author line), the missing-stills check, the clip block's card (Play: on a press / loop / once) and upload refusals for bundles, stills and clips. Save approved words to the plan workspace's approved-strings.json.

---

Task 2: The document

Files: core/src/schema.rs, ops.rs, view.rs, core/tests/ops.rs, fixtures/ops-*.mjs, view.mjs, new fixtures/scenes.mjs, fixtures/data/*.json, vectors, internal/slides/deck/deck.go, new internal/slides/deck/scenes.go, deck/presses.go, fixtures/presses.mjs, docs/api.md; rebuild the wasm.

Interfaces (produced):

  • View scenes: map id → {name, author, code, states:[{id, name, description}], words:{key: text}, data: <json>, stills:{stateId: {ref, made}}}; omitted when empty.
  • Ops: add_scene{id?, name, code, states, words?, data?}, set_scene{id, name?, code?, states?, words?: {key: text|null}, data?, stills?: {stateId: {ref, made}|null}} (patches; words per key; data replaced whole), remove_scene{id}. author is set by the server from the acting principal on any op that changes code; a client-supplied author is ignored.
  • Block types scene (props: {scene, from, to}) and clip (props: {asset, play}), added to the block vocabulary.
  • deck.SceneVersion(s Scene) string and JS sceneVersion(scene) (R1), with vectors.
  • deck.Presses: scene blocks per R2; clip blocks with play: "press" per R3.
  • [ ] Step 1: Failing tests: round trips and refusals (limits, unknown state ids in a block, duplicate state ids, from after to), vectors for SceneVersion and for presses with scene and clip blocks beside other steps, a removed scene/state leaving the block valid (Review Focus 3).
  • [ ] Step 2: Implement in Rust, JS and Go; regenerate vectors; rebuild the wasm.
  • [ ] Step 3: Run cargo, node and Go tests; commit; gate.

---

Task 3: Bundles, the sealed frame and the contract

Files: internal/slides/assets.go (new kind scene: sniffed as one HTML document, ≤ 2 MiB), new internal/slides/scenes.go (routes), internal/slides/serving.go and serving_test.go (the sealed policy as a third allowed policy), docs/scenes.md, docs/scenes/example.html.

Interfaces (produced):

  • GET /d/{sqid}/scenes/{id}/{ref}, /s/{token}/scenes/{id}/{ref}, /p/{session}/scenes/{id}/{ref}: the bundle with the sealed header, only when the deck lists that scene with that code ref and the surface's picture access check passes.
  • POST /d/{sqid}/scenes/preview (signed-in editors of the deck; body ≤ 2 MiB): answers the posted HTML under the sealed header (for the code panel).
  • The message contract in docs/scenes.md: parent → scene {type:"init", state, size:{w,h}, words, data, reducedMotion, fonts} then {type:"state", state, animate}; scene → parent {type:"ready"}. Fonts are passed as data URLs of the deck's faces the scene names.
  • [ ] Step 1: Failing tests: TestTheSceneRouteSealsItsDocument (header exact), TestASceneIsServedOnlyThroughItsDeck, TestTheBundleMustBeHTML, browser TestASceneCannotReachAnything (Review Focus 2) and TestTheExampleSceneAnswersReady.
  • [ ] Step 2: Implement; write docs/scenes.md with the 40-line example.
  • [ ] Step 3: Run; commit; gate.

---

Task 4: Running scenes everywhere, and carrying on

Files: new fixtures/scene-frame.mjs (one sealed frame per scene in a layer outside the slide DOM; init, state, ready, 3 s fallback), fixtures/scene-layer.mjs (placing frames over scene blocks, carrying on), wiring into the editor stage, viewer-nav.mjs, present.js (follow; small duplicate allowed), slide-window.mjs, presenter-window.mjs; render/render.go (a scene block renders its still <img> or the placeholder panel R4, with the state's description as its text alternative); layout/svg (stills and placeholder in pictures, to state); export.

Interfaces: mountSceneLayer({root, deck, base, reducedMotion}) -> {show(slideId, positions), destroy()}; carrying on when the next slide's scene block has the same scene and the same box (canvas) or region (flow).

  • [ ] Step 1: Failing tests: TestASceneCarriesOnBetweenSlides (one frame survives the slide change and receives animate:true), TestAJumpLandsOnTheState (animate:false), TestADifferentBoxStartsFresh, TestASilentSceneShowsItsStill, TestARemovedSceneLeavesAPlaceholder, TestStillsWhereCodeDoesntRun (thumbnail, PDF at to, phone view, presenter Next, scripts off), TestReducedMotionGetsTheStill, TestExistingDecksRenderUnchanged.
  • [ ] Step 2: Implement; rebuild bundles and credits.
  • [ ] Step 3: Run Go, node and browser tests; commit; gate.

---

Task 5: Stills from agents, and out-of-date marking

Files: internal/slides/api.go (route), new internal/slides/scenestills.go, docs/api.md, the editor card's note (Task 6 draws it; this task supplies stillsCurrent(scene)).

Interfaces: PUT /api/v1/decks/{sqid}/scenes/{id}/stills/{state}?made=<version> (PNG or WebP ≤ 4 MiB, through the picture checks; refused with 409 when made isn't the current SceneVersion); writes the still asset and a set_scene{stills} op as the agent. JS stillsCurrent(scene) -> {current: bool, missing: [stateId]}.

  • [ ] Step 1: Failing tests: upload and use; stale made refused; another deck's scene refused; a hand edit of words makes stillsCurrent false.
  • [ ] Step 2: Implement; Step 3: run, commit, gate.

---

Task 6: Editing by hand

Files: new fixtures/scene-card.mjs, scene-data.mjs, scene-code.mjs; templates/editor.html; editor.css (named values only); quieter_inventory_test.go.

  • Card: scene name, From/To menus, words as text fields (one set_scene{words} per field commit), the out-of-date note with "ask an agent" (opens a prefilled note to the deck's agents; no new mechanism), and a check listing scenes missing stills.
  • Data: a table when data (or a top-level array in it) is a list of objects with scalar fields; otherwise a JSON text view with validation; edits redraw the selected block live; set_scene{data} on commit.
  • Code: a text panel with a live preview through POST /d/{sqid}/scenes/preview; Save registers a new bundle and commits set_scene{code}.
  • [ ] Step 1: Failing browser tests: TestTheSceneCardEditsWordsAndStates, TestTheDataTableRedrawsTheScene, TestTheCodePanelPreviewsAndSaves, TestAHandEditMarksStillsOutOfDate, TestQuieter* unchanged.
  • [ ] Step 2: Implement; rebuild; Step 3: run, commit, gate.

---

Task 7: Clips

Files: assets.go (kind video: MP4/WebM sniffed, ≤ 50 MiB, poster required), fixtures/uploads.mjs (capture the first frame to a canvas and upload it as the poster), new fixtures/clip.mjs, render, layout/svg (poster), presenting surfaces.

  • [ ] Step 1: Failing tests: TestAClipPlaysOnItsPress (back pauses and rewinds), TestALoopingClipStartsWithTheSlide, TestClipsAreMuted, TestAClipsPosterInPicturesAndPDF, TestAClipThatWontPlayKeepsItsPoster, upload refusals.
  • [ ] Step 2: Implement; Step 3: run, commit, gate.

---

Task 8: The HalfStack world as a scene, docs, and the whole check

Files: in the HalfStack repo (~/github.com/carlosframework/halfstack-vienna-build, branch build-deck): hack/world_export.py writing the world's model and per-state table as JSON (routes precomputed) and scenes/world.html porting acts/worldsvg.py + paintWorld() to the scene contract. In Slides: AGENTS.md, docs/api.md, docs/scenes.md (link to the worked example).

  • [ ] Step 1: Export and port; check the scene alone against the contract (TestTheExampleSceneAnswersReady style, run on world.html).
  • [ ] Step 2: Through the API on a local Slides, build a five-slide deck that shows the world from three states, carried across two slides, with stills uploaded by the script.
  • [ ] Step 3: make ci, the gate, node --test, the full browser suite once (only the known baseline failures), and walk the five-slide deck in the presenter window. Commit both repos.