Repository navigation
fix(studio): a sealed resize shows its rescaled crop at once, not after a reload - #9023
Conversation
jerry-heygen
left a comment
There was a problem hiding this comment.
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)
Edit accuracy: accurate 275 (base branch 273), smooth 80 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
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 (
drawOnSealedFrameinuseDomEditPositionPatchCommit.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,transformand the size properties. A resize's save also carries the rescaledclip-path, which nothing then drew.How
packages/core/src/runtime/drawnBox.ts: the draft's own style list, whicheditingDraft.tsalready used, is exported asDRAFT_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 inDRAFT_DRAWNand 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:--hf-studio-width/--hf-studio-heightand thedata-hf-studio-*original-box attributes;data-hf-studio-original-inline-translate.A rotate saves only
rotate, which the draft draws.Test plan
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 keepsinset(10px 20px 10px 20px)instead ofinset(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".cropcheck now also measures the crop shown right after the save, not only after a reload. Sealed, CLI built without the fix: both cases failcrop(8.34 px and 7.43 px off; the saved file is right). CLI built from this branch, both modes:crop0.01 px. The sealed and open saves match except fortranslate, which differs by 0.001 px because of the bench's fractional pointer input.packages/studio/src(850 files, 9639 tests) andpackages/core/src/runtime(180 files, 3919 tests) pass.tsc --noEmitfor both,oxlintand the comment ratchet are clean.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.
After
Same fixture and resize: the rescaled crop shows right after the save and stays.