Repository navigation
fix(studio): a sealed press held across a frame swap starts on the frame shown - #8492
Conversation
…ame shown A press made while a sealed preview changes waits, then reads where its element is over the frame's channel. It read over the frame it was pressed on; when the change swapped frames, that frame was gone, no answer came, and the drag was dropped. It now reads over the frame shown once the change ends, asks again once if that frame changes, and starts from the box Studio drew when the frame never answers. A frame that answers the element is gone still drops the press, as a scriptable preview does.
…-reads-shown-frame
…-reads-shown-frame
Edit accuracy: accurate 271 (base branch 271), smooth 65 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
jrusso1020
left a comment
There was a problem hiding this comment.
Request changes at 0eff8059. The main fix is sound. The new no-answer fallback starts from a box that has already moved.
Need ✓ · Size ✓ · Reuse ✓ · Simpler ✓ · Structure ✗
Risk: low to medium. It only affects a sealed press held through a frame swap, but the fallback now runs where the press used to be dropped.
What works
- The start is read from
iframeRef.current ?? channelonce the swap ends (askShownFrame). TheaskedOf === framecheck discards an answer from the old frame. - A second swap asks once more. If no frame answers, the press falls back instead of throwing.
- A press released while the read is pending is replayed after the start. A press that has ended is skipped in
poll. Only animation frames are used, andendWaitingPresscancels them. - Red-first: with the two source files from main, exactly the two named tests fail.
- At head: 106/106 pass across the six test files that import these modules.
- Mutation: asking the press-time frame turns the swap test red.
Blocker: the fallback box includes the pointer's movement during the wait (previewGestureStarts.ts:357-360)
- The single-element fallback
drawn()readsopts.overlayRectRef.currentwhen the wait ends, not at the press. - While the press waits, every pointer move calls
drawPressedBoxordrawResizedBox. These callopts.setOverlayRectwith the shifted or resized box, andsetOverlayRectwritesoverlayRectRefsynchronously (useDomEditOverlayRects.ts:83-85). - So the gesture starts with
originLeft/originTopalready moved by the pointer's delta, anduseDomEditOverlayGestures.ts:235(g.originLeft + dx) adds the same delta again. - Repro: press a drag during a seek, move 30 px while waiting, and the shown frame never answers. The box starts from
left: 31instead of1and draws at about 60 px, and snapping runs against that box. A resize has the same problem with its width and height. - The "starts from the box Studio drew" test passes because its mock
setOverlayRectnever writes the ref and the pointer never moves. - Fix: capture the box once at the press, as
drawalready does, and return that fromdrawn:Then add a test that moves the pointer during the wait. The group drag'sconst pressedRect = opts.overlayRectRef.current;
drawnis already correct, because it usesitemscaptured at the press.
P2
-
The second ask has no test. Changing
asks >= 2toasks >= 1leaves all 46 tests green, because the swap test changesiframeRefbefore the first ask. A swap after the first ask is already pending would cover it. -
UNANSWEREDcovers more than a frame that never answers. It also covers:- a selection lookup that finds nothing;
- a malformed reply;
- more than
MAX_DESCRIBE_HANDLEShandles, as in a large group drag.
Those presses used to be dropped. They now start from the drawn box with no
startorsnap. That may be intended, but the body's wording doesn't cover it.
— Rames (hf-review)
jrusso1020
left a comment
There was a problem hiding this comment.
Approve at d7e74da8. The blocker from my last review is fixed.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. The change only affects which box and which frame stand-in a press that waited starts from.
- Blocker resolved:
pressedRectis now captured once, at the press. The resize/drag draw and thedrawn()fallback both read it, so a press whose frame never answers starts from the box as it was at the press. Before, it read the movedoverlayRectRef, which applied the delta twice. - Also:
askShownGestureStartsnow hands the gesture the shown frame's stand-in and handle (standInFor(iframe, onFrame)), so drafts after a frame swap go to the frame shown, not the removed one.
What I checked:
- Fails without the fix: I put
previewGestureStartRead.tsandpreviewGestureStarts.tsback to0eff8059. "reads over the frame shown once the change ends, when the change swapped frames" fails on the stand-in check, and "starts from the box as it was at the press…" fails. - At the head: 22/22 pass,
tsc --noEmitin studio is clean, andmerge-treeagainst main is clean.
— Rames (hf-review)
What
A press made while a sealed preview is changing (a reload, a seek, a save) now starts on the frame that's shown once the change ends. Before, if the change swapped frames, the drag was dropped silently.
Why
On a sealed preview, a press made during a change waits for it to end, then asks the frame over its channel where the pressed element is. It asked the frame that was shown at the press. When the change swapped in a new frame, that frame had already been removed, so:
The person's drag did nothing.
The edit-accuracy sequence
seqfastkeys-none-px-r0-root-z100shows it on every run, sealed only: drag, add a keyframe, seek, drag, seek, drag. The drag right after the seek was pressed while the seek's change was still going and was dropped. Studio-side logs on the bench showed the frame the press held as disconnected and no longer the shown one when it read. A plain preview starts the same drag on the page shown, as the code's own comment says a press during a reload should.Once that drag started, a second problem showed up. It drew through Studio's stand-in for the element, and stand-ins belong to the frame they were made for. The stand-in was the one from the frame the press began on, so every draft went to the removed frame:
The bench first read that as the element snapping back at release. A log on every draft message showed all of that drag's drafts going to an iframe no longer in the page.
Related work
Refs #7846 (Studio's preview sealed by default): its edit-accuracy gate flags this sequence.
How
previewGestureStarts.ts: once the change ends, a held press reads over the frame shown then. If the frame changes again before the answer arrives, it asks once more (at most two asks). If the frame shown gives no usable answer, the drag starts from the box Studio drew at the press, as a plain preview would. "No usable answer" covers four cases:All four used to drop the press. If the frame answers that the element is gone, the press is still dropped, as a plain preview does.
previewGestureStartRead.ts:askShownGestureStartskeeps "the frame gave no answer" apart from "the frame lacks the element".readShownGestureStarts(the nudge's read) still returns null for both.Limit: if the change swapped frames and the new frame never answers, Studio has no handle in it, so there's nothing on it to draw through. The drag moves Studio's box, and the element jumps when the save lands. With no swap, a silent frame is the frame shown, and the drag draws through the stand-in it was pressed with.
No visible change
On a sealed preview, a drag pressed during a change now moves the element instead of doing nothing. The interface itself doesn't change.
Test plan
fails without the fix:
previewOverlayRects.test.ts:"asks the frame shown again when a swap comes after its first ask" fails if only one ask is allowed.
The existing "drops the press when the page shown no longer has the element" still passes.
packages/studio/src/components/editorandpackages/studio/src/hooks(356 files, 3,990 tests) passes three runs in a row on Linux at this head.