Skip to content

fix(studio): a press just after a sealed preview reloads drags the selection - #9126

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/sealed-box-through-reload
Nov 30, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/sealed-box-through-reload

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A press on the selected element right after a sealed preview reloads now drags it, as it does unsealed. After a reload the new page's frame does not know the selection's handle from the page before. So Studio dropped the selection box until it had found the selection again on the new page, which takes a round trip to the frame. A press in that time landed on the empty canvas and started nothing: no drag, no save. The box now stays where it was shown until the selection is found again. A press on it waits and starts on the new page, as a press during the reload itself already did.

  • Gate: unchanged at 40 behaviours, all with a test. This is the cause of the sealed-only "save never landed" error I reproduced on a replay of the merge queue's shard 3 (seqplainkeys-none-px-r30-nested-z100, 4 times in 28 replays). seqplainkeys-none-px-r0-root-z100 and seqplainkeys-none-pct-r0-root-z100 failed in the merge queue with the same error, dropping pull requests that changed sealed preview paths.

Why

The sealed preview may only become the default once it behaves as the unsealed one does. Unsealed, the overlay finds the selected element in the live page every frame, so there is no such gap.

Related work

Follow-up to #9068 and #9089 (the sealed edit accuracy run and its gate). #9107 and #9121 fix the other two sealed-only failures in the same run.

How

  • useDomEditOverlayRects.ts: when the frame measures no box for the selection, or for a member of a group selection, and that selection's handle is from the page before the current one (currentLoadHandle no longer names it), the box keeps the place it was last shown. A selection the current page does not show, or one whose element is gone, still loses its box as before.
  • Why there: this is where the sealed overlay decides what box to draw from the frame's answer. The press path already waits on a reload and finds a pressed selection again on the new page (previewGestureStarts.ts); it only needed a box to press.

Test plan

  • fails without the fix: "keeps the box while a reloaded page's selection is found again, and a press on it starts on the new page" (packages/studio/src/components/editor/gestureStartReadAhead.sealed.test.ts) swaps in a new page whose frame answers the old handle with nothing. Without the fix the box is dropped on that answer. The press on the kept box starts a drag once the selection is found on the new page.

  • Not tested: the group selection path. It uses the same check, and only the type check runs over it.

  • The 21 Studio test files that use the overlay rects, the overlay's frame reads, currentLoadHandle, DomEditOverlay or the read made before a press: 288 of 288, 3 runs in a row. tsc --noEmit in packages/studio: exit 0.

  • Edit accuracy bench, sealed build, the 25 cases of the merge queue's shard 3 with a log of each press. Before: "save never landed" in 4 of 28 replays, In the 21 of those replays that logged each press, 4 presses landed while the selection was being found again: 3 hit a box still drawn and saved, and the one that met no box was a failure. After: 0 of 12 replays, and the one press made during a re-find hit the kept box and saved. One replay after the fix lost a crop on release (crop-keys-px-r0-root-z50-after). The merge queue's runs show the same 40 px crop loss on two other sealed crop cases without this change, so that is a separate failure.

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

No visible change

The sealed preview is not on by default. In a sealed preview, the selection box no longer disappears for a moment after an edit reloads the preview.

…lection

After a reload, a sealed frame no longer knows the selection's handle from
the page before, so the box was dropped until Studio found the selection
again on the new page. A press in that time landed on nothing and started no
drag. The box now stays where it was shown until then, and a press on it
waits and starts on the new page, as a press during the reload does.

@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.

Reviewed at dace79b. No blocker.

Read: useDomEditOverlayRects.ts whole at head; the test file as its hunk; currentLoadHandle in previewSelection.ts and the selection refresh in useDomSelection.ts (lines 365 to 425) to see when a kept box goes away.

Checked

  • fails without the fix: line is present and names the new test. By reading: on main the channel answer elements: [null] goes straight to setOverlayRect(null), so shownLeft() cannot stay 230 there.
  • The box is kept only when the frame measured none AND the selection's handle is not one the current page knows. A selection the current page knows and does not show still gets null, so hidden elements lose the box as before. The scriptable-frame path (update) is untouched.
  • A kept box does not outlive a removed element: the refresh clears the selection when the element is not found on the new page, and with no selection the channel path clears every box.
  • Group members use the same rule keyed by the member's cache key; the body says this path has no test.

Note, not blocking

  • If the refresh gets no answer from the frame (findSelectionElement returns undefined), the selection keeps its old handle and the box now stays at its last place until the next refresh or reload. Before, it vanished. A press there still waits and looks the selection up again, so I read this as acceptable; say if you want a bound on it.

Not run: the test file and type check (no installed packages on this machine). No check was red when I posted; several were still pending.

Need: yes · Size: small · Reuse: uses the existing page-handle lookup · Simpler: no · Structure: fine
Risk: low to medium; sealed preview only, which is not the default.

— Rames

@github-actions

Copy link
Copy Markdown
Contributor

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

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

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

Quarantined, measured but not gated (0)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 782252a Nov 30, 2026
84 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-box-through-reload branch November 30, 2026 06:15
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