Skip to content

fix(studio): a drag pressed right after a reload moves the element on screen - #8836

Open
miguel-heygen wants to merge 3 commits into
mainfrom
fix/press-during-reload-waits
Open

miguel-heygen wants to merge 3 commits into
mainfrom
fix/press-during-reload-waits

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A drag pressed on the canvas right after a reload swapped the preview page now moves the element on screen and saves the move. Before, the press could start on the element of the page the reload had replaced: nothing on screen moved, and the release saved nothing.

Why

The edit accuracy case seqfastkeys-none-px-r0-root-z100 failed tracking (194 px) on unsealed previews now and then, and bounced PRs from the merge queue. Its step 5 drags right after Add keyframe, whose save reloads the preview. When the press landed just after that reload finished, nothing in the step-5 drag moved:

  • Studio's isPreviewChanging() was already false, so the press took the start-at-once path.
  • That path hands startGesture Studio's held selection (selectionRef), which still named the replaced page's element. The drag measured that element as "Element has no measurable box", every move drew onto it, and the release committed nothing (no write at pointerup; every passing run writes there).
  • A press that lands during the reload waits, and on its start finds its targets again on the shown page (shownOnPage), so it never had this problem.

Related work

Refs #7846 (its edit accuracy gate reported the same case).

How

  • previewGestureStarts.ts: the start-at-once path now passes findAgain (renamed from waited) when any pressed target's element is not in the shown document (namesReplacedPage). The start then finds the targets on the shown page, the same way a waited press does. A selection already on the shown page starts as before.
  • Every press start goes through this one place: startGesture and startGroupDrag in domEditOverlayStartGesture.ts are imported only by previewGestureStarts.ts, and the canvas calls them only through it (DomEditSelectionChrome.tsx: the group drag at :120, rotate :198, drag :232, resize :276).

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

fails without the fix: packages/studio/src/components/editor/previewOverlayRects.test.ts "on a scriptable frame starts on the shown page's element when the selection still names the replaced page's" fails on main (expected undefined to be <div id="turned">), and again with namesReplacedPage forced to false.

previewOverlayRects.test.ts and gestureHoldsPreviewReload.test.tsx: 68 of 68, three runs in a row. src/components/editor/: 2207 passed, 1 failed, "words selected in a unsealed text edit show the toolbar, and Bold saves one span" (5.3 s), which fails the same way on main. tsc --noEmit in packages/studio clean.

The bench on the devbox (built CLI, --filter '^seqfastkeys-none-px-r0-root-z100$', --jobs 1), each run's preview frame self.origin logged (null sealed):

Code Preview Runs Tracking (gated checks)
main 4864ade unsealed 15 10 pass, 5 fail (runs 3, 4, 7, 13, 15)
this branch unsealed 15 15 pass
this branch sealed 3 2 pass; run 3 failed with "element has no rendered box", the edit bench's own read of the waiting box, fixed in #8807 and not in this branch's base

"pass" means every gated check passed. Smoothness, which the gate reports but does not gate, is below its mark in every run of every row.

Not run: the full grid.

Before and After captures follow in a comment.

… screen

A press on a settled, scriptable preview started straight from Studio's held
selection. Just after a reload swapped the page, that selection could still name
the replaced page's element: the drag moved an element nobody sees and the
release saved nothing. Such a press now finds its targets again on the shown
page, as a press that waited for the reload already does.
@miguel-heygen

miguel-heygen commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

The step-5 drag of seqfastkeys-none-px-r0-root-z100 (unsealed), pressed just after the Add keyframe reload, 40 samples in, with the pointer at the same place in both shots.

Before

On main 4864ade2: Studio's outline follows the pointer, the element stays where the drag started, and the release saves nothing.

before: the outline moved, the element did not

After

On f56d774c: the element moves with the outline.

after: the element moves with the outline

Runs on 4231a4df (this branch with main, which now has #8807)

Same case, devbox, --jobs 1, each run's preview frame self.origin logged:

Preview Runs Gated checks
sealed (origin null) 3 3 pass
unsealed 5 5 pass

Smoothness, not gated, is below its mark in all eight, as on main.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 50 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-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

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

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

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review at 4231a4df: request changes. The fix is still right, but this merge head fails a test that main just brought in. The two changes collide.

  • Test (studio 2/3): domEditOverlayStartGesture.test.ts › "a corner resize on a frame Studio scripts" › "pins its centre by the grow the sealed frame would report, so both modes save the same offset" fails with TypeError: Cannot read properties of undefined (reading 'current') at previewGestureStarts.ts:296 (shownSelection). The stack runs startGesture (373) → startOnShownPreview (175) → the start callback (381) → shownOnPage (305) → shownSelection (296).
  • Why: that test arrived with #8824 on main. Its selection's element is not in the iframe's contentDocument, so this PR's namesReplacedPage returns true and the start takes the findAgain path. That path reads an opts ref that the test's options object does not provide. Main alone passes it (main CI at 22f268e2 is green), and so does 4267801f alone. Only the combination fails.
  • Fix, either way: give that test's opts the ref shownSelection reads, with its element in the frame's document if it means "a selection on the shown page". Or, if that test's selection really can live in another document, decide whether namesReplacedPage should apply there.

I'll approve the next head once required CI is green.

Need · Size · Reuse · Simpler · Structure: unchanged.
Risk: low. The only blocker is the collision with #8824's test.

— Rames

This branch has not been deployed

No deployments
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