Skip to content

fix(studio): a sealed resize, move or turn typed or made by the agent shows in the preview - #8283

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/sealed-geometry-commits
Nov 20, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/sealed-geometry-commits

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What

In a sealed preview (Studio cannot script the frame), a resize, move or turn that is not a drag now shows in the preview when it is made:

  • a size, position or angle typed in the inspector's Layout group;
  • a resize, move or turn made by the agent tools.

Before, each was saved but the preview kept the old geometry until something later reloaded it, so the inspector and the canvas disagreed. Drags were already right: they draw on the frame as they go.

The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.

Why

These edits write the new size, translate or rotate on the selection's element and save with no reload, trusting that element to be what the preview shows. In a sealed preview that element is Studio's stand-in, so the frame never got the edit. A drag draws the same values on the frame through its own draft, which is why drags looked right.

How

commitPositionPatchToHtml, which every geometry save goes through, draws the patch's own inline styles and attributes on the frame's element when the preview is sealed. It uses the same steps as a sealed style save (#8279):

  • the frame draw (editSealedSelection), waited for briefly before saving, with a reload if the frame never answers;
  • the stand-in's copy registered so the next re-read of the selection takes the frame's values;
  • on a failed save, the frame's element put back exactly. The stand-in is already put back by each caller.

A save made at the end of a drag skips this: the drag's live draft already shows it.

A sealed move typed in the inspector takes the plain translate route, which reads the stand-in's own translate marks, so its input is right. The left/top route, which measures the element's computed position, is only reached by a GSAP-owned element, and a stand-in never reads as GSAP-owned.

Test plan

geometryCommits.sealed.test.ts, on a sealed frame served by the real runtime agent:

  • a resize from the agent, a size typed in the inspector, an offset typed in the inspector and a turn from the agent each draw on the frame's element;
  • a failed save puts the frame's element and the selection back exactly;
  • while a drag's draft is live, the save leaves the frame to the drag.

fails without the fix:

  • with the commit not drawing on a sealed frame, the four draw tests fail;
  • with a failed save not restoring the frame, "puts the frame's element and the selection back exactly" fails;
  • with the save drawing over a live drag draft, "leaves the frame to a drag whose draft is still live" fails.

Run on Linux: the new tests (6) and the position-commit tests pass three runs in a row; Studio's hooks, components/editor and webmcp tests (4038) pass; Studio tsc no errors; format clean; the code audit passes.

Bench

Edit-accuracy bench, nudge cases at r0 (60) and resize cases at r0, root, 100% zoom (18), at main and at this head:

preview cases drop / reload / undo / redo / teleport misses failing cases
unsealed, main 78 0 / 0 / 0 / 0 / 0 13 (smooth only)
unsealed, this head 78 0 / 0 / 0 / 0 / 0 8 (smooth only)
sealed, main 78 9 / 9 / 3 / 3 / 9 69
sealed, this head 78 9 / 9 / 3 / 3 / 9 69

Unsealed: no change (smooth is reported, not gated). Sealed: no change either way. These cases are drags and arrow-key nudges, not the typed or agent edits this fixes. Their sealed misses (nudge tracking and undo, resize-drag drop and teleport) are as on main and are tracked separately.

Before

Sealed preview at main, inline-text-caret fixture: Title selected, X typed as 300 in the Layout group. The inspector says 300px; the preview's Title has not moved.

before: X reads 300px but the Title has not moved in the preview

After

The same at this head: the Title moves 300px and the selection follows it.

after: the Title moved 300px and the selection follows it

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 75 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

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

Approving at 8ec24eba. I found no blocker.

  • Unsealed path unchanged. selection.handle is unset, so editSealedSelection returns null and afterSealedDraw(null, …) saves synchronously with drawn=true. That gives the same skipRefresh and .catch as before.
  • Sealed draw. The wait is bounded at 300 ms. If the frame is silent or the draw isn't applied, drawn=false, so the frame reloads. Nothing hangs or gets stuck.
  • Failed save. restore() runs before the rethrow. The before snapshot records an absent attribute as null, so restore removes it again. Names that a later edit owns are left alone.
  • Drag-end skip. Each draft end (endManualOffsetDragMembers, endResizeWithoutMember, endRotationGestureIfCurrent) runs in .finally after the commit, so the draft is still live at the drag-end save. A cancelled drag's leftover draft is cleared by restoreStudioPathOffset and restoreStudioBoxSize.
  • Stand-in copies. They are kept per frame and per handle, and consumed on the next re-read, so nothing leaks across selections.
  • Fails-without claims. All three hold: the draw tests assert on the frame's card.style, the restore test compares cssText, and the live-draft test would see 200px instead of 150px.

Non-blocking:

  • The restore test covers styles only. Absent-attribute restore is tested only in core's editElement tests.
  • A keyboard-nudge draft that is still live while someone types in the inspector skips the typed draw, so the frame can show the nudge value until the next reload. It's a rare race.
  • If one sealed draw times out during fast typed commits, the 300 ms wait could let a later save land first.

CI: every check finished and passed or was skipped, except "Studio and player captures" (run 44713055184). That job was cancelled 8 s into setup, at 8ec24eba. It needs a re-run if it's required for merge.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 89edb0a Nov 20, 2026
123 of 124 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-geometry-commits branch November 20, 2026 10:16
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