Repository navigation
fix(core): a redo in a sealed preview puts Studio's edit marks back in place - #8264
Conversation
…n place instead of reloading
terencecho
left a comment
There was a problem hiding this comment.
P2 · Edge case — restoring motion can report success while the animation stays absent. The prefix accepts Studio's motion metadata as well as move, resize, and rotation markers. A sealed preview that loaded without any Studio edits has no seek reapply script. Restoring its first motion marker now returns applied: true, which suppresses the reload that would install the script. A focused DOM test with real GSAP confirmed that the frame accepts the attribute without creating a motion timeline, while reloading the saved HTML produces the expected animation. Restrict in-place restore to the geometry attributes it can apply, or retain the reload fallback for motion. Restore allowlist
The named move-redo test passes here and fails with the predicate reverted. The Comments check is red on the added comment. Full browser gestures were outside this run. Comments check
— tai (automated review)
Edit accuracy: accurate 271 (base branch 271), smooth 78 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
… instead of commenting
|
Fixed in 2e28dcc. The rule now takes Studio's edit marks except its motion marks ( |
terencecho
left a comment
There was a problem hiding this comment.
The motion setter now requests a reload, which closes the previous finding. The named regression test fails with the original fixed list, and the refusal test fails with the motion exception removed.
Both remaining findings come from accepting attribute changes when the frame’s seek behavior still reflects the old document.
- P2 · Edge case ·
packages/core/src/runtime/editing/restoreAttributes.ts:45. The first resize redo on a frame loaded without edit markers can report success while the authored timeline immediately overrides the restored width. The server installs its seek-reapply script only when the loaded HTML already has an edit marker. In a targeted jsdom probe with real GSAP, a timeline callback wrote150pxon redo and175pxon the next seek. Reloading the restored markup kept the intended240px. The animation works through a callback, so the element has no_gsapfield and the existing guard lets it through. - P2 · Edge case ·
packages/core/src/runtime/editing/restoreAttributes.ts:47. A restore that adds a geometry marker and removes the last motion marker now succeeds in place. The sealed seek handler leaves the old motion timeline registered after that removal. In Chromium, the restored translation applied, but the old animation still set opacity to0.25where a reload of the same markup gave1. Preserve the reload fallback for mixed restores that remove motion unless the old timeline is retired before reporting success.
The capture check passed. Required build, typecheck, runtime contract and Windows render checks were pending. I ran targeted probes and skipped the full edit-accuracy benchmark.
— tai (automated review)
|
Fixed in a42bdd1.
The mark list has one owner in core ( |
terencecho
left a comment
There was a problem hiding this comment.
P2 · Edge case — packages/core/src/runtime/editing/restoreAttributes.ts:54. An edit attribute in the DOM can exist without the seek-reapply script running. The preview fallback preserved a valid single-quoted rotation marker, while the server’s script detector in manualEditsRenderScript.ts:25 only matched double quotes. In Chromium the sealed frame accepted a resize from 80 px to 160 px, then the next seek put it back at 80 px. A fresh load held at 160 px. Check for script startup before accepting a restore that depends on it.
The earlier motion cases now reload without partially applying geometry. The named mutations failed as expected. Windows render was still running.
— tai (automated review)
…uoting finds its marks
|
Fixed in c11e76a, at both ends.
The flag name, the marks and the check live in one core module; a test runs the real in-frame script against each mark and fails if the script stops setting the flag. |
… reapply script started
terencecho
left a comment
There was a problem hiding this comment.
The single-quoted marker now receives the seek-reapply script from the preview route. In Chromium, the restored width held after seeking. With a parsed marker and no running script, both attribute restore and soft reload declined before changing the preview. The sealed move round trip and mixed motion fallback also passed.
Targeted core, Studio, and server tests passed. The quoting and startup-guard regression tests failed when their corresponding fixes were removed. The merge includes #8272. Required CI was still running at review time, and the full gesture benchmark was outside this targeted review.
— tai (automated review)
terencecho
left a comment
There was a problem hiding this comment.
The delta from the approved head is one shortened test comment. The Comments check passed, and the test and production code match the prior review.
— tai (automated review)
What
An undo or redo in a sealed preview (Studio cannot script the frame) is applied in place only when the result will hold, and reloads the preview otherwise. Before this PR, a redo of a move, nudge, resize or rotate was always refused in place, and some in-place restores reported success while the preview showed the wrong thing.
Why
Studio saves its own edit marks on an element it moves, sizes or rotates (
data-hf-studio-*), for exampledata-hf-studio-original-inline-translatenext to the newtranslate. An undo removes them, and the frame already accepted removing anydata-*attribute. A redo has to set them again, but the frame only set attributes from a fixed list that left them out, so every such redo fell back to a full reload.Some marks only work through the seek-reapply script the preview server adds to a page. It adds that script only when the page it serves already carries one of them, and the script does nothing on a page that has none. A mark on the page does not prove the script is running: the server's check only recognised double-quoted marks, so a page with a single-quoted mark got no script. Putting such a mark back in place is only safe once the script has actually started.
How
studioReappliedMarks.ts(new, core): the marks that script keeps applied, the motion marks, the name of the flag the script sets when it starts, and the check that finds the marks in a page's HTML, in one place.restoreAttributes.ts, the in-frame script's tests and the preview server's check for adding the script all read it.The seek-reapply script now sets that flag on the page's window when it starts keeping marks applied. The server's check now finds a mark in any quoting (double, single or none) and any letter case of the attribute name; the value must match exactly, as the script's own selector requires. The producer's render uses the same check (
htmlCompiler.ts), so a single-quoted mark now gets the script there too.restoreAttributes.ts:data-hf-studio-*), next to the unchanged fixed list. Handlers, URLs,sandboxand otherdata-*names are still refused.data-hf-studio-path-offset,-box-size,-rotation) on a page where that script has not started, because nothing would keep it applied after the next seek;data-hf-studio-motion,data-hf-studio-motion-original-*), because a motion runs through a timeline the script builds when the page loads.planRestore, the plannerrestore-attributesand fix(studio): a sealed undo or redo of a keyframe edit re-runs in place instead of reloading #8272's in-place undo re-run (soft-reloadwithrestore) share, so that re-run is refused for the same marks and the preview reloads.Tests
restoreAttributes.test.ts:data-hf-studio-original-inline-translateand atranslatestyle applies in place.data-hf-studio-box-sizereloads on a page that carries a rotation mark but whose script has not started, and applies in place once the script has started.data-hf-studio-motionreloads.onerror, a non-Studiodata-hf-handle, the near missesdata-hf-studioanddata-studio-x, and setting the motion marks.softReload.test.ts: an undo re-run that restoresdata-hf-studio-box-sizeon a page whose seek-reapply script has not started answerscannot-soft-reloadand changes nothing; once the script has started it applies.manualEditsRenderScript.test.ts:"false","truey","TRUE", a motion-original mark, a name glued to another word).fails without the fix: with the set check as on main, the in-place test fails. With the old check (a mark on the page), the box-size test fails; with the rule outside the shared planner, the soft-reload test fails; with the old double-quote-only server check, the quoting test fails; without the script setting its flag, the script test fails; with motion removal allowed, the motion test fails; renaming a mark in the core list fails the script test.
Run on Linux at this head (main merged in): core
restoreAttributes,softReload,editingAgentandeditingPort(200 tests), a Studio run filtered togsapSoftReload.sealed(5 files, 131 tests) and studio-servermanualEditsRenderScript(21) three runs in a row; core and Studiotscno errors; format clean; the code audit passes.Bench
Edit-accuracy cases with the sealed preview on, at rotation 0, two at a time on macOS; cases whose redo left the box more than 2 px off. Before: the sealed-by-default change with the sealed nudge fixes. After: the same plus this PR's first commit (edit marks settable, no page check yet).
The bench scores a redo against the screen right after the gesture, so a gesture that saved the wrong size or angle also counts as a redo miss. Traced one case at a time at this head (rotation 0, root level): of 63 resize and rotate redos off, 61 match a fresh load of the saved file, and the save itself is off by the same amount (rotate 45 of 49 saves, resize 31 of 48). Those redos show the file correctly; the sealed resize and rotate save is a separate fix. Two resize redos (idle and late fixtures) are off while their save is right; those are still open.