Repository navigation
fix(studio): an undo that lands mid-drag keeps the box under the pointer - #4853
Merged
Merged
Conversation
Contributor
Edit accuracy: 846 passing here, 843 on the base branchThe gate passes. Newly passing (3)
Quarantined, measured but not gated (2)
|
miguel-heygen
force-pushed
the
fix/studio-drag-after-undo
branch
3 times, most recently
from
October 1, 2026 15:07
c376a5a to
72eb622
Compare
3 tasks done
miguel-heygen
force-pushed
the
fix/studio-drag-after-undo
branch
from
October 1, 2026 16:48
90d53ad to
bbcd151
Compare
This was referenced Oct 1, 2026
miguel-heygen
marked this pull request as ready for review
October 1, 2026 18:07
5 tasks done
miguel-heygen
force-pushed
the
fix/studio-drag-after-undo
branch
2 times, most recently
from
October 1, 2026 18:52
07041ec to
e185c11
Compare
This was referenced Oct 1, 2026
7 tasks done
miguel-heygen
force-pushed
the
fix/studio-drag-after-undo
branch
from
October 1, 2026 19:17
e185c11 to
6d89daf
Compare
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 changes
Dragging a layer right after Cmd+Z no longer flashes it back to where the undo put it. The box stays under the pointer through the moment the undo lands, and the drop saves where you let go, on top of the undone file.
Before, if the previous edit's save was still pending when you pressed Cmd+Z, the undo only showed up once that save and the server's history step finished. If you had grabbed the layer by then, the undo copied every attribute of the restored file onto it, which wiped the translate the drag was drawing. For a frame, or for as long as the pointer stayed still, the box sat where the undo put it, the undone move's distance away from the pointer.
How
syncElementAttributes(gsapUndoRestore.ts) is how every in-place restore writes a restored element onto the live one. It now also takes the element as the file being replaced had it. When the live element carries the manual-edit gesture mark (data-hf-studio-manual-edit-gesture), the merge keeps:data-hf-studio-original-inline-translate), so the drag's next write doesn't record its own draft as the author's.Everything else restores as before, and a layer without the gesture mark is restored exactly as before.
What each gesture draws has one owner, next to the gesture mark in
manualEditsDom.ts:a move draws
translateand the offset variables;a resize draws those plus the box-size properties (
BOX_SIZE_STYLE_PROPS);a rotate draws
rotate,transform,transform-origin,displayand the rotation variable.an edit (the inline text edit) draws nothing, so under its mark only what changed since the replaced file stays.
beginStudioManualEditGesturerequires the kind, so a new caller has to say what it draws. The mark's value carries the kind.Every live copy in the restore goes through the merge:
applyUndoRestoreToPreview;showRestoreInPlace, and its put-back, which uses the restore it showed as the base;syncStaleEditMarks).This removes the jump once the undo lands. Painting the undo at once while the previous save is still pending is a separate change.
Tests
gsapUndoRestore.test.ts, "an undo that lands while the layer is being dragged". Each fails with its piece of the fix reverted:data-startgo back. It fails without the merge.Edit accuracy rows
The 6 drag, undo, drag cases (
sequndo, gsap none) from the edit accuracy bench in #4801, 3 runs each, at this PR's first head. Both builds use the same bench, 2 jobs. Each row shows the worst teleport, in px.The PR also takes 5 of the 6 cases out of the bench's
QUARANTINEDlist (ratchet.mjs), where #4801 parked them for this fix, and banks them from this branch's CI gate artifact, byte for byte. In that gate, all 5 pass with no case unstable; 3 were newly passing, and the other 2 were already banked as passing on main, because the race only failed some runs.sequndo-none-px-r0-root-z100stays quarantined, under the change that paints an undo at once (stacked on #4807). In one CI gate it passed 2 of 3 runs; the third had a press jump of 312.36 px. That matches the undo landing between the bench's read of the box and its press, which only painting the undo at once removes.Before
Main. A layer dragged, Cmd+Z right away, then pressed and held where it still shows; the move's save is slowed by 1.5 s so the undo lands while it is held. When the undo lands, the layer drops back to where the undo put it, about 100 screen px from the pointer (the ring), and stays there while the pointer holds still.
After
The same steps on this branch. The undo lands ("Undid: Move layer") and the layer stays under the pointer. The drop saves
translate: 202.139px 216.578pxon top of the undone file, as on main.