Skip to content

fix(core): an undo of a colour grade applies in place in a sealed preview - #8457

Merged
miguel-heygen merged 11 commits into
feat/player-sealed-by-defaultfrom
fix/core-sealed-grade-undo
Nov 22, 2026
Merged

miguel-heygen merged 11 commits into
feat/player-sealed-by-defaultfrom
fix/core-sealed-grade-undo

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

In a sealed preview, undoing or redoing a colour grade on a video clip now puts the grade back on screen in place. Before, the frame refused the change and the preview had to reload, and the panel and picture lagged behind the file.

This PR makes two changes to what an undo may change in a sealed frame:

  1. It adds data-color-grading to the restore allowlist.
  2. It stops counting crossorigin and preload as attributes the undo would drop when the runtime itself added them to that element, as recorded by the runtime. The same attributes written in the film's own file are still dropped (and refused) as before.

Builds on #8142 (its sealed CORS writer is where crossorigin is recorded), so it merges after it.

Why

An undo in a sealed preview sends each changed element's restored attributes into the frame (restore-attributes). The frame sets only attributes on its allowlist (#8057), so a saved file can't get handler or URL attributes set in the frame. data-color-grading wasn't on it, so every grade undo was refused (applied: false) and the parent fell back to a full reload. Unsealed, the same undo syncs the attribute onto the live element, and the runtime's grading observer redraws in place.

With the grade allowed, a video clip's undo was still refused: the planner compares the element's attributes with the file's, and every video in a sealed frame carries a crossorigin (added by the sealed CORS writer) and a preload (set by the media scheduler) that the file doesn't have. Both looked like attributes the undo would have to drop, and dropping is only allowed for a short safe list.

How

  • restore-attributes accepts data-color-grading, and only through core's own grade parser. The value is parsed by normalizeHfColorGrading and rebuilt with serializeHfColorGrading; the raw string is never copied through. A value the parser rejects is refused.
  • A rebuilt grade that names a LUT file the element doesn't already use is refused (applied: false, so the preview reloads as today). The LUT is the only part of a grade that makes the runtime load anything: lut.src is resolved against the page and fetched.
  • Every field the attribute accepts (normalizeHfColorGrading):
Field Accepts Loads or runs anything?
enabled boolean; false means no grade no
preset trimmed string, used only as a key into the built-in preset table no
intensity number, clamped 0 to 1 no
adjust, details, effects numbers per known key, each clamped to its limits no
wheels, curves, hueCurves numeric points and offsets no
secondaries up to the max count; numeric qualifier and correction ranges no
palette 2 to 6 strings matching the colour pattern no
lut { src, intensity }; src is a path yes: src is fetched, so a new src is refused
colorSpace trimmed string; the runtime never reads it no

Unknown keys are dropped by the rebuild.

  • runtime/runtimeAttributes.ts keeps, per element, the attribute names the runtime added. The sealed CORS writer (write()) records crossorigin when it sets it and forgets it when it removes it, or when the film itself changes it. Every runtime write of preload goes through setRuntimePreload, which records preload only if the element had none. The planner leaves recorded attributes alone and treats everything else as before. There is no list of names: a crossorigin or preload the file wrote is not recorded and still counts as dropped.

Before

Sealed undo before: frame white, Exposure +1.50

After

Sealed undo after: frame grey, Exposure +0.10

Test plan

fails without the fix: "is put back in place, rebuilt from the grade's own fields rather than copied" in packages/core/src/runtime/editing/restoreAttributes.test.ts

  • restoreAttributes.test.ts, three new rows: the grade is applied as its rebuilt form, never the raw string (with an unknown onload key that doesn't survive); a grade naming a LUT the clip doesn't use is refused and the DOM is untouched; a grade keeping the clip's own LUT applies. On main the first and third fail. Each guard is shown to bite: copying the raw value fails the rebuild row, and skipping the LUT check fails the refusal row.
  • The named test passed 3 runs in a row, plus the files that import the changed module, the Fallow audit and pre-push.
  • Three more rows in the same file: a video whose crossorigin came through the sealed CORS writer and whose preload came from the runtime keeps both and the undo applies; the same attributes written in the file are still dropped (refused, DOM untouched); once the film changes the runtime's crossorigin itself, it is no longer kept. Each fails with its piece removed: fix(player): a sealed player plays media from hosts without CORS and names a missing runtime #8142's writer without the record fails the first, and dropping the forget fails the third. 14 of 14, 3 runs in a row; sealedMediaCors, preloadMedia and media tests green (293); core tsc clean.
  • Manual: Studio on the grade-save branch with this branch merged, a grey video clip, a sealed preview. Drag Exposure from +0.10 to +1.50, then undo. Before: the frame refuses, reloads, and stays at the dragged grade (pixel 255, panel +1.50). After: the undo applies in place with no reload; the pixel goes back to 137 and the panel to +0.10. The unsealed preview behaves the same on both.
  • Comments follow CONTRIBUTING.md "Comments".

@mintlify

mintlify Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
hyperframes 🟢 Ready View Preview Nov 22, 2026, 6:29 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@miguel-heygen
miguel-heygen changed the base branch from main to feat/player-sealed-by-default November 22, 2026 06:28
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 74 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Record the duration probe’s preload write. packages/core/src/runtime/init.ts:2780 now sets el.preload = "metadata" directly in armLength. On a future video whose duration is still unknown and whose markup omits preload, that creates an attribute the restore planner treats as authored. A grade undo then returns refused and falls back to reloading the preview.

I reproduced this with the runtime seek fixture and a future clip without data-duration or preload. The probe passes when armLength calls setRuntimePreload(el, "metadata"). Please use that helper and add the future-clip case to the regression coverage. The other 302 focused tests passed.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Fixed at eb5b3776. Thanks, you were right.

  • armLength in init.ts (the far clip's length probe that came in with fix(player): a sealed player plays media from hosts without CORS and names a missing runtime #8142) set el.preload = "metadata" directly, so the runtime never recorded that it had added preload. It now goes through setRuntimePreload(el, "metadata") like every other runtime preload write.
  • New row in entry.test.ts: "a grade undo on a far clip whose length is still loading applies in place". It boots the runtime with a clip at 6 s that has no data-duration and no authored preload, then undoes a grade on it. The undo must apply. At 0c0c52f4 it fails (preload not recorded); with the fix it passes, 3 runs in a row.
  • entry, restoreAttributes, sealedMediaCors and preloadMedia: 164 of 164. Core tsc is clean. The push gate's covering tests (core, player, studio, engine, cli) are green.
  • My earlier search for raw preload writes after the merge used \s in a git grep -E pattern, which git's grep doesn't support, so it missed this line. Rerun with a pattern it does support, the runtime has no other raw write. What's left is the player's parent-page copies (parent-media.ts, video-source.ts), which sit outside the frame an undo restores into, plus a demo fixture's own script.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duration probe now marks the preload it adds, so grade undo on the far clip applies in place. All 78 focused runtime entry and restore tests passed. The new regression fails with the previous preload write. GitHub checks passed.

— tai (automated review)

@miguel-heygen
miguel-heygen merged commit 488ce05 into feat/player-sealed-by-default Nov 22, 2026
34 checks passed
@miguel-heygen
miguel-heygen deleted the fix/core-sealed-grade-undo branch November 22, 2026 19:32
@miguel-heygen
miguel-heygen restored the fix/core-sealed-grade-undo branch November 22, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants