oficina / slides Public

Design draft: scenes and clips

Approach A as Paul chose: a sealed frame on the same site, stills made by
whoever writes the scene, scenes carried across slides.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e888eb81722c85fb72af333b2573d323191466ad parent 3395115
1 file changed, +197 −0
  • docs/superpowers/specs/2026-11-23-scenes-and-clips-design.md +197 −0
diff --git a/docs/superpowers/specs/2026-11-23-scenes-and-clips-design.md b/docs/superpowers/specs/2026-11-23-scenes-and-clips-design.md
new file mode 100644
index 0000000..0616cee
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-23-scenes-and-clips-design.md
@@ -0,0 +1,197 @@
+# Scenes and clips — design
+
+Design, 2026-11-23, by Claude Opus 5.5 from conversation with Paul the
+same day. Not yet approved. Builds on the editor-tidy design §9 (the
+order of slices) and the steps slice (presses, the presenter window).
+
+## 0. Intent
+
+The HalfStack Vienna talk explained itself with moving pictures: one
+small world (the corporate district, Paul's garden, the buildings he
+owns) shown from slide to slide, changing a little with each press, and
+short screen recordings of apps in use. Slides could not do either, so
+the talk ran on a custom deck. This slice lets a deck carry both.
+
+**Success** is that the HalfStack world can be a scene in a Slides deck:
+written by an agent, its words and pieces adjustable by Paul in the
+editor, carried from slide to slide as he presses, and shown as a still
+picture wherever code can't run.
+
+### 0.1 Goals
+
+1. A **scene** is code (HTML, CSS, JavaScript, WebGL) that belongs to a
+ deck and draws named **states**.
+2. Any slide can show a scene and walk it through a range of its states,
+ one per press.
+3. When the next slide shows the same scene in the same place, the scene
+ **carries on**: it stays on screen and moves to the new state.
+4. A scene runs **sealed**: no network, no cookies, no way into Slides or
+ the person's account.
+5. Every state has a **still picture**, used wherever the scene doesn't
+ run, and a text **description** for assistive technology.
+6. Paul can change a scene by asking an agent, or by hand in the editor:
+ its words, its data, which states a slide shows, and its code.
+7. A **clip** is a short video uploaded to a deck, played on a press,
+ looped or played once.
+
+### 0.2 Non-goals
+
+- Dragging a scene's pieces on the slide (the data table covers it).
+- Scenes that talk to the network, play sound, or read the camera.
+- Server-side rendering of stills (no headless browser on our side).
+- A separate origin for scenes (approach B, possible later).
+- Editing or trimming video; streaming; captions files (later).
+
+### 0.3 Anti-goals
+
+- **A scene that can reach anything.** A scene that reads a cookie, calls
+ the network or touches the page around it is a failure even if it
+ draws beautifully.
+- **A blank where a scene should be.** The PDF, a thumbnail, the phone,
+ the presenter's Next preview, reduced motion and scripts-off all show
+ the state's still.
+- **A press with no visible answer**, as in the steps slice.
+- **A cut between slides that share a scene.** Carrying on is the point.
+
+## 1. Decisions
+
+| # | Decision | Whose |
+|---|---|---|
+| C1 | A scene is code an agent writes, run sealed, told only its state, size, words, data and whether to reduce motion. Slides keeps the presses. | Paul (editor-tidy §9) |
+| C2 | Stored as a fixed bundle with a named author. | Paul (§9) |
+| C3 | A still picture per state, used by the PDF, thumbnails, phone view and checks. | Paul (§9) |
+| C4 | A scene can appear on several slides and carries on between them. | Paul, 23 Nov |
+| C5 | Changed by asking an agent, and by hand in the editor. | Paul, 23 Nov |
+| C6 | Approach A: a sealed frame on the same site; stills made by whoever writes the scene. | Paul, 23 Nov |
+| C7 | Editing by hand has three layers: words and states in the slide's card, data as a table, code in a panel with a live preview. | Paul ("Seems good") |
+| C8 | States are named and absolute, like positions. | This design |
+| C9 | A scene's words and data live in the deck, not in its code. | This design |
+| C10 | Clips are stored like pictures; their still is their first frame, captured in the uploader's browser. | This design |
+
+## 2. The document
+
+**Scenes** are a deck-level map, `scenes`, keyed by scene id:
+
+- `name`: shown in the editor.
+- `author`: the agent or person who wrote the current code.
+- `code`: the ref of a stored bundle, one HTML document (≤ 2 MiB) holding
+ all its script and style inline.
+- `states`: an ordered list of `{id, name, description}`. `id` is stable;
+ `name` shows in the editor; `description` is the text assistive
+ technology reads for that state.
+- `words`: a map of key → text, the scene's labels.
+- `data`: one JSON value (≤ 256 KiB), the scene's model (for the world:
+ its pieces with kind, position and label key).
+- `stills`: a map of state id → `{ref, made}`, where `made` is the
+ version of code + data + words the still was drawn from.
+
+**A scene block** on a slide: `type: "scene"`, `props: {scene, from,
+to}` where `from` and `to` are state ids. The block arrives with the
+slide at `from`; each press then moves one state towards `to`. It takes
+part in presses exactly as an `each` list does: its own `step` says
+which press starts it (absent means right after arrival), and
+`deck.Presses` gives it one press per state after `from`.
+
+**Clips**: a picture-like asset of kind video (MP4 or WebM, ≤ 50 MiB)
+with a poster still; a `clip` block, `props: {asset, play: "press" |
+"loop" | "once", muted}`. `play: press` makes the clip start on the
+block's press.
+
+All of it travels on existing ops plus `add_scene`, `set_scene`,
+`remove_scene`, in Rust, JS and Go with vectors, as the fixtures rule
+requires.
+
+## 3. Running a scene
+
+- **The frame.** A scene runs in an `<iframe>` whose document comes from
+ `/{surface}/scenes/{id}/{code}` with the response header
+ `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:`. The sandbox without
+ `allow-same-origin` gives it an opaque origin: no cookies, no storage,
+ nothing of the page around it, no network, no forms, no popups, no
+ navigation of the top window.
+- **The conversation.** Slides sends `{type: "init", state, size, words,
+ data, reducedMotion, fonts}` and then `{type: "state", state, animate}`;
+ the scene answers `{type: "ready"}` once and nothing else matters.
+ Messages are checked by source window. A scene that doesn't answer
+ within 3 seconds is shown as its still.
+- **A small contract**, `docs/scenes.md`, with a 40-line example, is all
+ an agent needs to write one.
+- **Carrying on.** When the next slide in the talk has a scene block for
+ the same scene with the same box, the presenting windows keep the
+ frame and send the new state with `animate: true`. Otherwise the new
+ slide's frame starts at its `from` state. Going back moves it back.
+ Jumps send the target state with `animate: false`.
+- **Where it runs live:** the editor stage (while the block is selected
+ or the play-through runs), the slide and presenter windows' Now panel,
+ the viewer and share link, the follow link. **Where the still shows:**
+ thumbnails, the PDF, the phone view, the presenter's Next preview,
+ scripts off, reduced motion (the scene still runs, told to reduce
+ motion, but readers who asked for less motion get the still until a
+ state settles), and any frame that isn't ready.
+
+## 4. Stills
+
+- The agent that writes or changes a scene renders each state in its own
+ browser and uploads the stills through the API
+ (`PUT /api/v1/decks/{sqid}/scenes/{id}/stills/{state}`, PNG or WebP,
+ ≤ 4 MiB), recording the version they came from.
+- When code, data or words change, the editor marks the scene's stills as
+ out of date (a small note on the block's card) and offers to ask the
+ deck's agent to redo them. Out-of-date stills are still used rather
+ than nothing.
+- A clip's still is its first frame, drawn by the uploader's browser onto
+ a canvas and uploaded with it.
+
+## 5. Editing by hand
+
+- **The slide's card** for a scene block: the scene's name, *From* and
+ *To* state menus, its words as text fields, and the out-of-date note.
+- **Data**: a table for a list of objects (rows and columns from the
+ data), with a raw JSON view for anything else; changes redraw the
+ selected block live.
+- **Code**: a panel with the bundle's text and a live preview in the same
+ sealed frame. Saving makes a new bundle and marks the stills out of
+ date. Paul is the named author of a hand edit.
+- Agents use the API ops and the stills route; they see scenes in the
+ deck's JSON like everything else.
+
+## 6. Constraints and testing
+
+From AGENTS.md: no flash, scripts-off works, 320px reflow, WCAG 2.2 AA,
+every UI string a catalog key through Paul's copy review first. A
+scene's own words are deck content, edited by the deck's people, not UI
+copy.
+
+Tests, each written first:
+- The sandbox: a scene that tries `fetch`, `document.cookie`,
+ `localStorage`, `top.location` and a form post gets nothing and
+ changes nothing.
+- Presses: a scene block's states as presses beside other steps, with
+ the same vectors in Go and JS.
+- Carrying on: two slides sharing a scene keep one frame and animate; a
+ jump lands on the right state; a different box starts fresh.
+- Stills everywhere a scene can't run, and out-of-date marking.
+- Clips: play on a press, loop, once; the poster in pictures and PDF.
+- Existing decks render byte for byte.
+- The HalfStack world as the worked example: a scene built from
+ `acts/world.py`'s model and drawn with its CSS 3D kit, walked through
+ a short deck.
+
+## 7. Order of building
+
+1. The document: scenes, scene and clip blocks, ops, presses, vectors.
+2. Serving and the sealed frame, the contract and the example.
+3. Running scenes on every surface, carrying on, stills in pictures and
+ PDF.
+4. The stills API and out-of-date marking.
+5. The editor: the card, the data table, the code panel.
+6. Clips.
+7. The HalfStack world as a scene, in a deck.
+
+## 8. Left to the builder
+
+Table and column layouts; the message field names beyond those above;
+how the data table infers columns; exact size limits if a real scene
+needs more.