Repository navigation
fix(studio): a scene edit swaps in place and a far scene mounts for selection in a sealed preview - #8162
Conversation
24df97c to
88dca71
Compare
eddy-heygen
left a comment
There was a problem hiding this comment.
(Eddy's agent) Reviewed by Eddy's Claude agent at commit 88dca71.
Verdict: comment only, not approved (stacked PR, and lint is failing at this head). No blocker found in this PR's own diff.
Summary. The PR adds three request kinds to the editing port a sealed preview frame serves to its parent editor: hold scenes, mark scenes stale, swap scenes. The editor fetches the rebuilt preview document from its own preview server and sends it to the sealed frame to swap edited scenes in place; anything other than exactly { swapped: true } makes the editor reload the whole film. The review was done at 24df97c; the head then moved in a restack, and I compared the two: this PR's own diff is identical file for file. The port handshake and sender check are unchanged, the new requests require an exact key set and are bounded (packages/core/src/runtime/editing/scenes.ts:54-70), and nothing from the frame's reply is executed, inserted as markup or used as a path (packages/studio/src/player/sceneSwap.ts:117-120, which I read myself).
Blockers
None in this PR's own diff.
Non-blockers
packages/studio/src/player/sceneSwap.ts:129: a sealed preview whose film has no scene windows now fetches and posts the whole preview document, gets a refusal, and only then reloads, on every edit (up to 5 tries while the file keeps changing). The end state is correct; the edit loop is slower. Learning once per frame load that the frame cannot swap would avoid it.packages/studio/src/player/sceneSwap.ts:110: the sealed swap drops the editor's cancel signal and sends the full timeout rather than the time left, so a superseded swap keeps running in the frame and can force an avoidable full reload. Both cases end in a correct reload.packages/core/src/runtime/editing/scenes.test.ts:88: the refusal tests do not cover the upper bounds (document size, deadline over a minute, name count and length).
CI: at this head 7 checks pass, 6 fail, 2 pending, 3 skipped. I read the failing lint job's log: one lint error, "Unsafe usage of optional chaining"; the log does not name the file. Every PR in this stack fails the same way since the restack, so it most likely comes from a lower branch, but I could not confirm which file from the log. The workflow that runs type checks and unit tests only triggers for pull requests based on the default branch, so this PR's own new tests have not been run by CI.
How this was reviewed: a code-review pass and a security-review pass by a reviewer agent in an isolated checkout of 24df97c; I compared that commit with the current head and read the cited swap code myself. Nothing was built or run.
88dca71 to
c66fb25
Compare
b9def7d to
2623310
Compare
c66fb25 to
9cee4cc
Compare
2623310 to
8943bc0
Compare
9cee4cc to
f72fee8
Compare
8943bc0 to
2052ab1
Compare
f72fee8 to
2539c18
Compare
2052ab1 to
bd2430c
Compare
6fc7a25 to
4791316
Compare
Edit accuracy: accurate 271 (base branch 271), smooth 73 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
4791316 to
34b2647
Compare
# Conflicts: # packages/core/src/runtime/editingAgent.test.ts # packages/core/src/runtime/editingAgent.ts # packages/core/src/runtime/editingPort.test.ts # packages/core/src/runtime/editingPort.ts
eddy-heygen
left a comment
There was a problem hiding this comment.
(Eddy's agent) Re-reviewed by Eddy's Claude agent at commit 5208512 (the PR is now based on the default branch; full diff reviewed in an isolated checkout, core read by me).
Verdict: comment only for now; no blocker found in the code. One check on this PR is failing (the captures check on the PR description), so I am not approving yet; I will approve once it passes.
Summary. A sealed preview can now swap edited scenes in place, hold scenes for selection and mark scenes stale, through three new request kinds on the editing channel between the editor and the sealed frame. The editor fetches the rebuilt preview document from its own preview address and posts it into the frame.
Blockers
None in the code.
What I checked
- What the editor accepts back from the frame (
packages/studio/src/player/sceneSwap.ts:110-123): only an answer that is exactly "swapped: true" with no other key. Anything else, including no answer, throws, and the caller reloads the whole film. The frame's stated reason is used only as a truncated string in an error message. Answers to the hold and mark-stale requests are discarded. So an answer from the frame cannot make the editor do more than reload. - What the frame accepts (
packages/core/src/runtime/editing/scenes.ts:54-70): the three kinds are registered in the same parser table as the existing kinds, with exact key sets and bounds on document size, timeout, and the count and length of names and files. The handshake and sender check are untouched. - What is sent into the frame: the same document a full reload would load, fetched from the editor's own preview address with a cache-buster; no value from the frame enters that address.
- The merge with the default branch: the scene requests sit beside the default branch's newer handling, and the request-kind lists in code and tests agree.
- An unsealed preview keeps calling the frame's swap function directly, as before.
Non-blockers (all three still open from my earlier review)
- A sealed film that cannot swap still fetches and posts the whole document on every edit before reloading. Learning once per frame load that it cannot swap would avoid the extra fetch and large message.
- The sealed swap ignores the editor's cancel signal, so a swap superseded by a newer edit keeps running in the frame and ends in an avoidable full reload. The outcome is correct.
- The refusal tests cover only one upper bound (file count); the document size cap, the timeout cap, the name count and the name and file length caps are untested.
For the author to check in a real sealed session
- The existing "would this swap replace a node under a live gesture" check is skipped when the frame's document is unreachable. A sealed preview used to reload at that point and now swaps. I did not trace how gestures are protected under the seal.
CI: my own count at this head: 88 passing, 1 failing, none pending, 12 skipped. The failing check is "Studio and player captures": its log says the PR description's Before and After sections have no image or video. It runs none of this PR's code. The runtime and studio test jobs ran the new test files and passed.
# Conflicts: # packages/core/src/runtime/editingPort.ts
eddy-heygen
left a comment
There was a problem hiding this comment.
(Eddy's agent) Re-review by Eddy's Claude agent at commit cbcc013.
Verdict: approve.
The default branch was merged in with one import conflict resolved. I compared every file of this PR against the head I reviewed before (5208512): all fifteen are unchanged, so my earlier read stands. The conflict with the default branch is gone and the captures check passes.
CI: 89 pass, 11 skipped, none failing or pending.
What
In a sealed Studio preview, an edit inside one scene of a long film now swaps that scene in place, and selecting an element in a scene that is not mounted mounts it first, as in an unsealed preview. Before, every such edit reloaded the whole film, and selecting an element in a far scene found nothing.
Why
Studio swapped scenes, held them mounted, and marked them stale by reaching into the preview frame's window and document, which a sealed frame does not allow. A sealed preview fell back to a full reload for each edit and never held the scene a selected element lives in. This is one of the remaining writers to move onto the editing port before Studio's preview can run sealed by default.
Related work
Stacked on #8158 (a script edit re-runs in place). Same pattern as the earlier sealed preview units: the frame-side logic lives in core, Studio's unsealed path calls the same code where it can reach the frame, and the sealed path sends one editing port request and reloads when the reply says it did not apply.
How
hold-scenes,swap-scenesandmark-scenes-stale, incore/runtime/editing/scenes.ts.swap-scenescarries the rebuilt preview document Studio fetched from its own server, the same document a full reload would load, and a deadline; the frame aborts a swap that outlasts it. The frame answers{ swapped: true }or{ swapped: false, reason }; Studio accepts only exactly{ swapped: true }, and anything else, no answer included, reloads the film. The page is host-sourced composition text: Studio fetches it from its own preview server, it is size-capped, it runs only inside the sealed frame, and it is never taken from a frame message.hold-sceneswaits until the runtime has mounted the named scenes. Selecting an element in a sealed preview now holds its scenes before asking the frame for the element.mark-scenes-staleto a sealed one.Test plan
fails without the fix:
packages/studio/src/player/sceneSwap.sealed.test.ts("swaps a sealed preview's scenes from the document Studio fetched") fails on the base, where a sealed preview has no scene swap and every edit reloads the film. The same file checks that a refusal, no answer, or a reply with an extra field makes the film reload, that nothing is sent once a newer edit superseded the fetch, and that stale marks go through the frame.packages/studio/src/utils/sceneHold.sealed.test.tsfails on the base, where a sealed preview's scenes are never held.packages/core/src/runtime/editing/scenes.test.tscovers the frame side: the hold waits for the mount, a runtime refusal comes back as data, an overdue swap is aborted, stale marks clear the right hashes, and the parsers refuse extra fields and unbounded input.editingAgent.test.tssends a hold and a swap through the real port. The existingsceneSwap.test.tscase for an opaque frame now expects a swap.Before
Studio from main (
4a11e46c), built with the preview sealed, on a 12 s film of three scenes (each a sub-composition). With the playhead at 00:06 in scene 2, scene 2's file is saved with a new title and colour. The whole film reloads: one new preview document loads, and the edit shows 428 ms after the save. The restore seek puts the playhead back at 00:06.After
The same steps at this branch (
5208512d): only scene 2 is swapped in place. No preview document loads, the edit shows 104 ms after the save, and the playhead stays at 00:06.What I measured
Measured on the whole stack (scene swap, live retime, gesture hold together) after building core so Studio reads it: core 191 tests in the touched files plus the new port test, Studio 311 tests across 21 files (scene swap and hold, live retime including the real-GSAP tests, timing sync, gesture holds, shadow reload and retry, undo history, selection and drafts); core, core runtime and Studio type checks pass, and the subpaths check verifies the new export. With the frame answering before its scenes mount, the hold parser taking extra fields, the sealed swap refused (the base), a swap reply with an extra field accepted, the sealed stale marks dropped, or no sealed hold (the base), the matching test fails each time.
What I did NOT exercise
Selecting an element in a far scene in a real sealed Studio session: selection in a sealed preview is broken on main right now (being fixed separately). The captures above cover the scene swap only. The selection hook's call order (hold, then find) is covered by reading, not by a test of the hook.