Repository navigation
feat(core): sealed previews can run Delete and arrow nudges in-frame once Studio arms them - #8946
Conversation
…once Studio arms them
Edit accuracy: accurate 273 (base branch 271), smooth 57 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) Unstable (1)
|
…s first draw Studio's first nudge on a cold read now uses this start, so a GSAP clip is not moved twice.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at fe32890. Approving: no blocker.
Read whole: runtime/editing/canvasKeys.ts and canvasKeys.test.ts. Read as hunks: editingPort.ts, editingAgent.ts (plus its key-watch section whole), removeElements.ts, textEdit.ts, domRealm.ts, editingGestureStart.ts and the two test list updates. The regenerated generated/position-edits-render-inline.ts was not read. Nothing was run.
This is a feature, so the "fails without the fix:" rule does not strictly apply; the line is there anyway and names a real test.
What I checked:
- Inert claim: nothing calls
installPreviewKeyShieldat load, and the only other caller isarmCanvasKeys, reachable only through the new port request. With no Studio sending it, no listener is added. - Both new requests parse at the port boundary with exact key sets, handle and combo caps and bounded steps; the event back to Studio is validated the same way.
- Only trusted events act; a dispatched Delete does nothing. An active text edit is left alone.
- Delete keeps what it removed until Studio answers, and rollback puts each node back at its old place (test 3 pins order).
- The agent's dispose clears armed state, pending deletes and the listeners.
Notes for the Studio half, none blocking here:
armCanvasKeysinstalls the shield withallowSameOrigin = true, and tests 2 to 4 rely on that. So "same-origin previews are never shielded" holds for the load-time path only (the last test covers just that path). If Studio ever arms a same-origin preview, typing into the film's own editable elements stops. Either Studio must never arm there, or the arm path should keep the origin check.- When the shield is added at arm time, the agent's existing key watch may already be listening on
windowin capture and runs first. A watched combo is then forwarded by the watch and handled again by the shield (a second forward, or a local Delete on top of the forwarded one). The load-time install avoids it, but after a dispose and re-arm the order can flip. - Arming with nothing to do clears
armedbut leaves the shield on: trusted keys are then stopped for the film and forwarded to nobody until the next arm. - In-frame Delete uses
isRemovableNode, which is looser than the port path'sremovableClip(no clip selector check). Studio's commit or rollback is the backstop. - A Delete whose armed handles are all stale is swallowed with no event, so Studio does not hear about that key press.
armCanvasKeysanswersarmed: trueeven when the shield declined to install.
Need: yes, removes a round trip per key · Size: +1063/-11, 590 in one new file · Reuse: remove, GSAP position and text-edit checks are shared, not copied · Simpler: no · Structure: fine
Risk: low while unarmed; notes 1 and 2 decide how it behaves once armed.
— Rames
Keeps both the canvas-key and stage-act request kinds and push listeners. The editing port's push handling becomes a table so both fit under the complexity gate.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at e83c3e0. Approving: no blocker. This is a re-review after the merge of main; my earlier approval was at fe32890.
What changed since fe32890
- The PR's own diff against main is the same as before except in
editingPort.ts. I compared the two diffs line by line. - The merge keeps both sets of request kinds, param parsers, handlers and listeners (the canvas-key ones from this branch, the stage-act ones from main). The agent's dispose runs both resets.
onPushbecame a table of routes. It tries the same parsers in the same order and stops at the first match, so each push still reaches one listener set. The canvas-key route sits before the two stage routes, and their event shapes do not overlap.- The two kind-list tests carry both new sets in the same order as
EDITING_REQUEST_KINDS.
My earlier non-blocking notes still stand unchanged.
Read: the merge commit's combined diff whole, and the old and new PR diffs compared. Files outside the merge's conflict set were not re-read. Nothing was run.
Need: yes · Size: merge only since last review · Reuse: one pushRoute helper for all seven routes · Simpler: no · Structure: fine
Risk: low; still inert until the editor arms it.
— Rames
What
Core half of #8935: the preview runtime can run canvas Delete and arrow-key nudges inside a sealed (opaque-origin) preview frame, and forward Studio's shortcuts back to it. All of it is gated on Studio sending
arm-canvas-keysover the editing port. Studio does not send it until #8935 lands, so this PR changes nothing users see.Why
In a sealed preview, Delete and nudge round-trip from Studio's window over the
MessagePortbefore the first frame paints, which adds visible lag in Firefox and WebKit. Running them in-frame removes that round trip. #8935 was about 2,000 changed lines; this splits it at the core/studio seam so each half can be reviewed on its own.Related work
Refs #8935 (the Studio half, stacked on this branch).
How
runtime/editing/canvasKeys.ts: a capture-first key shield plus armed actions. Once armed, a trusted Delete removes the armed elements in the same frame and posts acanvas-key-actionthat Studio commits or rolls back (resolve-canvas-key-action). Arrow combos draw the nudge in-frame and post cumulative steps. Other trusted keys are kept from the composition and forwarded to Studio. Inline text being edited, render, capture and export pages, and same-origin previews are never shielded.editingPort.ts/editingAgent.ts: the two new request kinds, with their params parsed at the port boundary. The agent's dispose also resets canvas-key state.domRealm.ts:isDomNode, so node checks work across realms (instanceof Nodeis banned in runtime code).removeElements.tsexports its removable-node and outermost-element checks,editingGestureStart.tsexportsgsapPosition, andtextEdit.tsaddsisActiveTextEditTarget, so the in-frame Delete, nudge and text carve-out run the same code as the port paths.generated/position-edits-render-inline.tsis rebuilt output.installPreviewKeyShield()call inentry.ts. With it, the shield would stop the editing agent's existing key-watch forwarding before Studio arms anything. It ships with feat(studio): handle canvas Delete and arrow-key nudge in opaque preview runtime #8935, so this PR stays inert until then.Test plan
canvasKeys.test.ts(shield, untrusted keys ignored, film-owned inputs blocked, same-origin and render pages never shielded, Delete commit/rollback, nudge steps), pluseditingPort.test.tsandeditingAgent.test.tsfor the new kinds.canvasKeys.test.ts> "blocks film listeners, ignores untrusted keys, and removes armed targets in the same frame" fails when the shield's stop call is removed fromonShieldEvent, and passes with it.test:hyperframe-runtime-ciexit 0.tsc --noEmitclean.