Skip to content

fix(studio): a sealed resize shows its rescaled crop at once, not after a reload - #9023

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/sealed-crop-on-frame
Nov 28, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/sealed-crop-on-frame

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

In a sealed preview, resizing a cropped element now shows its rescaled crop as soon as the resize is saved, as an open preview does. It used to keep showing the old crop on the resized box until the preview reloaded, so edges the crop hides stayed in view. The saved file was already right.

Why

When an edit is saved on a sealed preview, Studio also draws the saved styles and attributes on the frame's element (drawOnSealedFrame in useDomEditPositionPatchCommit.ts). While a canvas gesture's draft was still live, it drew none of them, so as not to fight the draft. The draft only owns the box: translate, rotate, transform and the size properties. A resize's save also carries the rescaled clip-path, which nothing then drew.

How

  • packages/core/src/runtime/drawnBox.ts: the draft's own style list, which editingDraft.ts already used, is exported as DRAFT_DRAWN (exported by @hyperframes/core/drawn-box). What the frame does is unchanged.
  • drawOnSealedFrame: while a draft is live, it leaves out only the styles in DRAFT_DRAWN and draws the rest.

Besides clip-path, this now also reaches the frame during a gesture. These are the same values the saved file has, which a reload already showed:

  • after a resize: --hf-studio-width / --hf-studio-height and the data-hf-studio-* original-box attributes;
  • after a move: data-hf-studio-original-inline-translate.

A rotate saves only rotate, which the draft draws.

Test plan

  • fails without the fix: packages/studio/src/hooks/geometryCommits.sealed.test.ts ("draws the rescaled crop on the frame while the resize's draft is still live"), against the frame's real editing port. On main the frame keeps inset(10px 20px 10px 20px) instead of inset(20px 40px 20px 40px). Drawing the draft's own styles too fails the existing "leaves the frame to a drag whose draft is still live".
  • Edit-accuracy bench: the cropped-resize cases' crop check now also measures the crop shown right after the save, not only after a reload. Sealed, CLI built without the fix: both cases fail crop (8.34 px and 7.43 px off; the saved file is right). CLI built from this branch, both modes: crop 0.01 px. The sealed and open saves match except for translate, which differs by 0.001 px because of the bench's fractional pointer input.
  • Wider bench slice, sealed, CLI from this branch: 92 move, resize and rotate cases, single and in sequences, root and nested. All pass every gated check; the ratchet gate against main's baseline holds, 92 passing on both. All 92 fail only the smoothness check, which is not gated: my machine misses frames that CI does not.
  • packages/studio/src (850 files, 9639 tests) and packages/core/src/runtime (180 files, 3919 tests) pass. tsc --noEmit for both, oxlint and the comment ratchet are clean.
  • Unit tests added/updated
  • Manual testing performed: the bench runs above
  • Comments follow CONTRIBUTING.md "Comments"

Before

Sealed preview, a cropped element just resized and saved, at about 0.5 s and 5.7 s after the release. The old crop still shows on the larger box.

Before: sealed keeps the old crop after a resize

After

Same fixture and resize: the rescaled crop shows right after the save and stays.

After: sealed shows the rescaled crop after a resize

@miguel-heygen miguel-heygen added the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026

@jerry-heygen jerry-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved at 5717a1b3. The sealed frame now applies the committed crop and metadata while leaving the draft’s box and transform styles alone. Studio and the frame use the same list of draft-owned styles. The new port test checks the crop with the draft still active, and the accuracy benchmark measures it both after save and after reload.

Hosted preview regression passed; the main Studio and edit-accuracy jobs were still running when checked. I did not independently rerun the browser benchmark.

— Jerrai (pr-review)

@jerry-heygen jerry-heygen removed the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 275 (base branch 273), smooth 80 of those

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

Newly passing (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Quarantined, measured but not gated (0)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 28, 2026
@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit a833286 Nov 28, 2026
104 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-crop-on-frame branch November 28, 2026 09:42
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