Repository navigation
fix(studio): a sealed crop lands where it was dragged - #8279
Merged
Merged
Conversation
… an unsealed one saves
… crop stays where it was let go
…so it shows the undone edit
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 79 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Nov 20, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 240da76b.
Verified
gesture-startnow reportsplanar, the a-d ofreadElementTransformSnapshot. That is the same composed transform (the element's own and its ancestors') that Studio'sreadPlanarTransformreads for a live element. So a stand-in's crop frame gets the turn, scale and layout size the unsealed path already uses, and the edit scale is still applied on top.- The press/reply handling:
waitingis set before the firstawait. Moves before the reply keep only the latest pointer, and a release before the reply commits once it arrives. A reply that lands after a cancelled press or a newer press is ignored (settleMeasuredPress), and anullreply cancels the press back to its start insets. A live element resolvesundefinedand runs exactly as before. commitDomStyles: the capture/revert now runs on the stand-in for a sealed edit, so a failed save puts its previous inline values back. The copied properties are reset to the frame's own inline value on every selection re-read, so they never outlive a later frame change.- The undo announce fires only on an applied
restore-attributesreply or a soft re-run that did not returncannot-soft-reload. Fallbacks still go throughreloadPreview. - Tests at this head, after building parsers/lint/core/studio-server: core
editingGestureStart.test.ts14/14. Studio crop handles, crop overlay, sealed commits, preview sync, undo restore, soft reload and preview elements: 210/210, twice. - Mutation checks:
- With
readElementCropFrameignoring the measured start, both new sealed crop tests fail. - With the
showSavedStylesOnStandIncall removed from the commit, "shows a sealed style commit on the selection at once" and "shows the undone crop on the selection after a sealed undo restores it in place" fail.
- With
Non-blocking
- The measured
startstays in the handles' state after the press until the selection changes. Scrubbing to a frame where a GSAP layer has a different turn therefore draws the idle crop at the press-time angle. Before this change it was drawn at 0°, so this is no worse, and it sits next to the follow-up you already list. isPlanarOrNullbounds the matrix entries withMAX_DRAFT_PX. These are unitless, so a tighter bound would fit better, but it only drops a bad field.
Need to fix: none. Approving once CI is green.
This was referenced Nov 20, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In a sealed preview (Studio cannot script the frame), a crop now lands where it was dragged:
The second change applies to every sealed style edit, not only crop: an opacity or color edit also shows on the selection at once.
The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.
Why
A gesture on a sealed preview edits Studio's stand-in for the element: an element with no layout, no styles of its own, and none of GSAP's transform. Each problem came from reading the stand-in where the frame's own element was needed.
DomEditCropHandlesmaps the drag throughreadElementCropFrame(selection.element). On a stand-in it found no transform and no size, so it fell back to the box's screen bounds: angle 0 and the zoom as the only scale. The drag was never turned into the layer's frame and was divided by the zoom alone, so the error grew with the layer's turn or scale at the playhead.clip-path, else the clip the frame reported when the layer was selected. The style commit wrote a live element's style at once, but in a sealed preview it only sent the edit to the frame, so the stand-in kept the old crop until the save's resync.How
gesture-startalso reportsplanar, the turn and scale the element paints under (its own transform with its ancestors'), next to the offset size it already sends.readElementCropFrametakes the frame's turn, scale and size from that read for a stand-in.commitDomStylesalso writes a sealed edit's styles on the stand-in and records which. A failed save puts the stand-in's previous inline styles back exactly. Every re-read of the selection (the one place frame values come back fresh) resets those recorded properties to the frame's current inline value, so a copy never outlives a later change in the frame.restore-attributes, or the script re-run) announces it on the iframe.useDomEditPreviewSync, which already re-reads the selection when a preview loads, re-reads it then too. Only the selection reacts.Readers of a stand-in's inline style, checked before writing to it:
domEditOverlayCrop.tsreadElementClipPath), the reader this is for;gestureUndoRevert.ts), which draws a translate relative to the stand-in's own start:commitDomStylesrefuses left, top, width and height, and a copied translate equals what the frame holds, so the draft stays right;gestureUndoRevert.tsreadElementLook), which is restored on the stand-in only;previewSelection.ts);domStyleCommit.ts).No frame request is built from a stand-in's inline style.
Test plan
editingGestureStart.test.ts:gesture-startreports the transform an element paints under, its own composed with its parent's.DomEditCropHandles.sealed.test.ts: a crop on a sealed card GSAP draws at twice its size, and on one turned a quarter, saves the crop an unsealed crop saves. Both drag and let go before the frame answers.domEditCommits.sealed.test.ts:useDomEditPreviewSync.test.ts: the selection is re-read when a sealed preview restores an undo in place, as when it loads a new page.fails without the fix:
gesture-startnot reporting the transform, the gesture-start test and both crop tests fail; with the crop frame ignoring the read, or a stand-in's press never asking for it, both crop tests fail;Run on Linux at this head: core
editingGestureStart,editingGeometry,editingAgent,editingPort(192 tests) and Studio's touched crop, style commit, preview sync, sealed undo and soft-reload tests (161) pass three runs in a row; core and Studiotscno errors; format clean; the code audit passes.Bench
Edit-accuracy bench, every crop case at r0 (60), on the sealed-by-default change at 9028129, before and after this change:
The unsealed failing cases, and most sealed ones after, fail only
smooth, which the gate reports and does not count.Known and next: the six crop cases on a layer GSAP spins still fail
teleportandtrackingafter the release. Their crop is off by 21, 42 and 82 px (growing with the turn) 15 to 25 frames after the pointer comes up, not at it. The saved crop is right (drop 0). The likely cause is the crop drawn while no gesture holds the frame's turn: a stand-in's crop is drawn from its unturned box outside a press. It is the next change.Sealed undo or redo misses: 4 before, 5 after (one undo). They are 40 px misses on root cases at 50% zoom. In two earlier re-runs of three of these cases without this change, the same 40 px miss moved between cases and between undo and redo, so they read as timing, not this change. This run's five have not been re-run one at a time.
Before
Sealed preview, a layer GSAP spins (40 degrees at the playhead), its right crop edge dragged in. Just after the release the drawn crop is straight and 31 px from where it was let go; the saved crop is 99 px off.
After
The same crop: drawn on the turned box and 0 px off just after the release, and saved where it was let go.