fix(studio): undo right after an edit undoes that edit, even before its save lands - #4807
Draft
miguel-heygen wants to merge 2 commits into
Draft
miguel-heygen wants to merge 2 commits into
miguel-heygen wants to merge 2 commits into
Conversation
Edit accuracy: 434 passing here, 434 on the base branchThe gate passes. |
This branch has not been deployed
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
Cmd+Z pressed right after an edit, before the edit's save has landed, now undoes that edit. Before, it could undo nothing or the edit before it, and the edit's save then landed after the undo and stayed. A resize or move undone that way left the element in a third state (size reverted, position not), and a nudge burst was never undone at all.
Why
Undo first waits for pending edits (
waitForPendingDomEditSaves), but it only saw saves already queued in the DOM edit save queue or registered as pending edits. A canvas or panel edit counts from the moment its commit is called, and many commits spend a while before their first write: a resize parses the element's animations before it writes, and a nudge burst does not call its commit until 400 ms after the last arrow key. An undo in that window found nothing pending, stepped the history, and the save landed afterwards.How
Measurement
Per-frame probe in the built Studio on the edit accuracy bench's gsap=none fixtures, px placement, no rotation, root, 100% zoom. Undo is pressed on the frame after release (or after the last arrow key), then the file and the screen are read 8 s later.
The screen for nudge on this base still differs after the undo: on main a nudge in a composition without GSAP writes a GSAP set and reloads the preview. That route changes in the move and nudge PR, and with it the screen comes back too.
Test plan
DomEditContext.test.tsx: an edit committed through the context actions, whose save has not written anything yet, holds undo's drain until it settles; an edit that fails does not fail the drain. The first fails without the registration, the second fails when the registration keeps the rejection.useDomEditNudge.test.tsx: undo's drain commits a burst still inside its debounce and waits for its save. Fails without the flush listener.Before
Undo pressed on the frame after a resize, with the save slowed to 1.5 s so the race is certain: the box ends in neither the original nor the resized state, and the file keeps the resize.
After
The same undo waits for the resize's save and undoes it: the box is back where it started and the file matches.