Prefactor: Source Media becomes a discriminated union (source-media issue 01) - #11
Conversation
…ssue 01) The store's ephemeral media record is now a SourceMedia union on `kind` (image | video) per ADR-0026 — the video variant carries the intrinsic duration and decodability verdict the video tickets need, though nothing constructs it yet. Import paths, the texture hook, aspect math, and object-URL revocation all flow through the union; zero behavior change. Includes the ADR-0026 vocabulary docs the union is named after.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7bee833. Configure here.
|
|
||
| useEffect(() => { | ||
| if (!media) { | ||
| if (media?.kind !== 'image') { |
There was a problem hiding this comment.
Video aspect uses placeholder
Medium Severity
When bound SourceMedia is kind: 'video', useSourceImageTexture falls back to the placeholder aspect for buildSceneSpec, while useArtboardAspect in Viewport still derives aspect from media.naturalWidth / naturalHeight. Once video is bound, "auto" frame sizing and artboard letterboxing can disagree.
Reviewed by Cursor Bugbot for commit 7bee833. Configure here.
The two crop round-trip tests reference `image.crop`, which lands with issue 02's Scene Document v5 — committing them here without the schema half broke typecheck in CI. They return with the crop schema change.


Summary
SourceMediadiscriminated union onkind(image|video) per ADR-0026; the video variant carries the intrinsicdurationand thecanDecodedecodability verdict later video tickets consume, though nothing constructs it yet.kind: 'image', the texture hook accepts the union (resolving only the image kind), aspect math and object-URL revocation are kind-agnostic. Store actions renamed tosetSourceMedia/clearSourceMedia.src/state/source-media.test.ts, red→green).Test plan
source-media.test.tscovers binding each kind and URL revocation on replace / clear / start-overNote
Low Risk
Mostly types, renames, and docs; image upload and rendering behavior unchanged, with new store tests covering URL lifecycle for both kinds.
Overview
Introduces Source Media as the umbrella for ephemeral screen input (still Source Image or future Source Video), documented in ADR-0026 (superseding ADR-0014) and CONTEXT.md / architecture invariants. The render contract is phrased as
f(SceneDocument, SourceMedia); pixels stay out of the document while mapping (Fit, crop) remains document.The editor store’s
mediafield becomes akind-discriminated union: images addkind: 'image'; the video variant addsdurationandcanDecodefor later tickets (no user-facing video import yet). Actions are renamed tosetSourceMedia/clearSourceMedia; object-URL revocation on replace, clear, and Start over is kind-agnostic. Image loaders, dropzone, demo boot, anduseSourceImageTextureaccept the union but still resolve onlykind === 'image'(video shows the placeholder until preview lands).Adds
src/state/source-media.test.tsfor binding and lifecycle; serialization test smuggled payload now includeskind: 'image'.Reviewed by Cursor Bugbot for commit d65081d. Bugbot is set up for automated code reviews on this repo. Configure here.