Skip to content

fix(studio): a timing drag moves the animation in place in a sealed preview - #8163

Merged
miguel-heygen merged 10 commits into
mainfrom
fix/studio-sealed-live-retime
Nov 20, 2026
Merged

miguel-heygen merged 10 commits into
mainfrom
fix/studio-sealed-live-retime

Conversation

@miguel-heygen

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

Copy link
Copy Markdown
Collaborator

What

In a sealed Studio preview, dragging a clip on the timeline now moves its animations in place, as in an unsealed preview. Before, a sealed preview re-ran the whole script (or reloaded) for every timing drag.

Why

Studio moved the live tweens by reading the preview frame's running script and reaching into its timeline, which a sealed frame does not allow. 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 the sealed scene swap PR, which is stacked on #8158. Same pattern as the earlier sealed preview units: the frame-side logic moves into core, Studio's unsealed path calls the same code, and the sealed path sends one editing port request and falls back when the reply says it did not apply.

How

  • The live move (pair each planned tween with the live one, check every element keeps its spacing and no other timeline animates it, move, replay to the playhead) moves from Studio into core, unchanged. Studio's unsealed path calls the same code.
  • New editing port request kind live-retime. For a sealed preview Studio plans the move from its own saved files only: the composition before the edit and after it. It never reads the frame's script. The frame first checks its live timeline sits exactly where the plan says each tween was, and moves nothing otherwise.
  • Like the sealed soft reload, the request carries the saved file's timing attributes; the frame puts them on the live clips and the film's root before the rebind, so clip windows and the film's length follow the moved tweens. A timed element of the saved file missing from the preview answers failed, with nothing moved.
  • The frame answers moved, unchanged (nothing moved: Studio re-runs the script in place instead) or failed (Studio reloads). Studio accepts only exactly { result } with one of those; anything else, no answer included, reloads.
  • The frame refuses unknown fields, more than 1,000 tweens, a script over 1,000,000 characters, and any start or length that is not a finite number.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

fails without the fix: packages/studio/src/utils/gsapLiveRetime.sealed.test.ts ("sends a sealed preview the move planned from the saved file before and after the edit") fails on the base, where a sealed preview cannot move its tweens. The same file checks that unchanged falls back to a re-run, that failed, no answer or an extra field reloads, and that nothing is sent when the file before the edit is unknown. packages/core/src/runtime/editing/liveRetime.test.ts runs real GSAP in the frame: the tween moves, the saved script is recorded and the playhead re-seeks, and a plan that does not match the live timeline moves nothing. Studio's existing real-GSAP live retime tests now run against the moved core code.

Before

Studio from main (012f2635), built with the preview sealed, on a 6 s film with one box clip (0 to 3 s) and one GSAP tween on it (0.5 to 2.5 s). The film's script counts its own runs. With the playhead at 1.5 s, the clip is dragged 0.5 s later on the timeline, twice. On the second drag the preview re-runs the film's script in place: no new document loads, and the script has now run twice. Shot after the second drag:

Before: a clip dragged 0.5 s later in a sealed preview on main

After

The same steps at this branch (2d1b4152): on the second drag the frame moves the tween with the clip (live-retime answers moved). No new document loads, the script has still run once, and the box sits where the moved tween puts it at 1.5 s (x 0, its start). The saved file has the clip at 1 s on both refs. Same moment:

After: the same drag on this branch

The first drag on this film reloads the whole preview on both refs: the film's elements have no Studio ids yet, the save writes them, and the live preview still carries the ids it was served with, so the frame cannot match the saved timing and answers failed. That happens on main the same way (in its sealed soft reload), so it is not from this change.

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 skipping the was-start check, the frame never re-seeking, no sealed path (the base), a reply with an extra field accepted, or no reload when the move failed, the matching test fails each time.

What I did NOT exercise

Selecting in a real sealed Studio session, for the same selection reason as the earlier sealed PRs (the captures above drag on the timeline only). A sealed preview whose running script differs from the saved file before the edit in something other than timing (an external edit not yet reloaded) is caught only when the timings or targets disagree; Studio cannot compare the scripts themselves without reading the frame's.

@eddy-heygen eddy-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Eddy's agent) Reviewed by Eddy's Claude agent at commit e7a6bff.

Verdict: comment only, not approved (stacked PR, and lint is failing at this head). No open blocker found.

Summary. The PR adds one request kind, a live retime, to the editing port of a sealed preview, so a timeline drag moves the frame's existing tweens in place instead of re-running the script; the move logic is relocated from Studio into core and reused by the unsealed path. The full review was done at 17341fa. At that commit there was one blocking finding: a sealed in-place move ended with the frame's clip timing attributes at the old values and no reload. The head has since moved, and I read the change myself: the request now carries the saved file's timing, the frame refuses the request unless every entry is an allowlisted timing attribute with bounded size, and it writes those attributes before the rebind derives clip windows (packages/core/src/runtime/editing/liveRetime.ts:240-248), with a test for that order. By reading, that finding is addressed. I did not re-review the rest of the restacked diff line by line.

What holds from the review: the handshake and sender check are unchanged; the request needs an exact key set, bounded strings, at most 1,000 tweens and finite numbers; it adds no script execution or markup path; the frame pairs every planned tween with the live one and moves nothing on a mismatch; the editor builds the plan from saved files only and treats any reply other than a known result as a failure that reloads.

Blockers

None open.

Non-blockers

  1. packages/core/src/runtime/editing/liveRetime.ts:243-244: the frame checks for the rebind hook only after it has moved the tweens; a frame without the hook is left moved and answers "failed" (the editor then reloads, so the end state is correct). Checking first would leave nothing touched.
  2. packages/studio/src/utils/gsapLiveRetime.ts: a request the frame refuses outright, a timeout or a missing agent is treated like a half-moved failure and forces a full reload where a re-run would do. Edits made through the SDK session carry no "before" file, so they never take the new path and still fully reload.
  3. moveLiveTweens returns a boolean or a promise; a future caller that forgets to await would always take the handled branch in a sealed preview. Making it always async removes the trap.

CI: at this head 7 checks pass, 6 fail, 2 pending, 3 skipped. The failing lint job on this stack reports one lint error, "Unsafe usage of optional chaining" (I read the log on the PR below this one; it does not name the file). 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 17341fa; I then read the timing change at the current head myself. Nothing was built or run.

@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from e7a6bff to c3bc0ef Compare November 18, 2026 09:27
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch 2 times, most recently from c66fb25 to 9cee4cc Compare November 18, 2026 11:50
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from c3bc0ef to 2217910 Compare November 18, 2026 11:50
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from 9cee4cc to f72fee8 Compare November 18, 2026 12:36
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from 2217910 to 92f5aed Compare November 18, 2026 12:36
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from f72fee8 to 2539c18 Compare November 18, 2026 13:08
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from 92f5aed to 3eb25f9 Compare November 18, 2026 13:08
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from 2539c18 to 06fc384 Compare November 18, 2026 16:59
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from 3eb25f9 to cfd070a Compare November 18, 2026 16:59
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from 06fc384 to 6fc7a25 Compare November 18, 2026 17:12
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from cfd070a to 49197a2 Compare November 18, 2026 17:12
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from 6fc7a25 to 4791316 Compare November 18, 2026 19:53
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from 49197a2 to 3267840 Compare November 18, 2026 19:53
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-scenes branch from 4791316 to 34b2647 Compare November 18, 2026 22:14
@miguel-heygen
miguel-heygen force-pushed the fix/studio-sealed-live-retime branch from b98310c to 426f2f5 Compare November 18, 2026 22:15
# 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

@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 426f2f50. I found no blockers.

  • Lane rule: met. fails without the fix: names gsapLiveRetime.sealed.test.ts ("sends a sealed preview the move planned from the saved file before and after the edit"). On the base, moveLiveTweens has no sealed path and never calls previewRequest.
  • Eddy's blocker at e7a6bff8 (stale clip timing after a sealed move) is fixed. liveRetime runs applyTimingPlan before finalizeSoftReload, and the test pins the order (seen == ["1.5"]).
  • Frame side: retimeLiveTweens pairs every planned tween with a live one (target, start − delay, duration) before moving any of them. Any mismatch moves nothing and answers unchanged, and a test pins that the timing attributes stay untouched.
  • Port: live-retime appears once in each of EDITING_REQUEST_KINDS, EditingRequests, PARAM_PARSERS and HANDLERS, and the kind-list tests are updated. The parser takes an exact key set, at most 1,000 tweens, a script of at most 1M characters, finite numbers, and no negative duration or time.
  • Studio side: it accepts exactly { result }. failed, no reply or an extra field reloads, and unchanged re-runs. Tests cover each case, plus a missing before-file.
  • Unsealed previews: the move logic moves into core unchanged, and the existing real-GSAP tests run against it. currentTime() is read before the await.
  • Cancel and undo: the only caller is syncTimingEditPreview, after a saved commit, so a cancelled drag leaves no partial state. Undo and redo aren't touched.

CI: the only red job is "Heavy films: Safari vs Chrome", a Safari WebDriver execute/sync 60 s timeout in the perf harness. It's unrelated, and the same workflow fails on main at 592a9fe. Preflight, regression shards, preview-regression and Perf are green. The unit-test and typecheck workflow only runs on main-based PRs, so this stacked PR's new tests haven't run in CI yet. Please make sure they run once it retargets to main.

Non-blocking:

  1. parseLiveRetime requires tweens.length >= 1, so a zero-tween plan comes back null and does a full reload where a re-run would do.
  2. The parser doesn't check start >= 0. That's fine while the planner only reads saved-file values.
  3. Eddy's earlier notes still stand. They're harmless, because every bad path ends in a reload.
  4. The Before/After captures and the manual sealed-session walk are still unchecked in the body.

…ix/studio-sealed-live-retime

# 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
vanceingalls
vanceingalls previously approved these changes Nov 20, 2026

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

Re-approving at 89b57f62. This head only merges the parent branch and main. The PR's own net diff (12 files) is identical to 426f2f50, which I approved, and every check is green on this head, including the Safari vs Chrome heavy-films job.

Base automatically changed from fix/studio-sealed-scenes to main November 20, 2026 02:14
@miguel-heygen
miguel-heygen dismissed vanceingalls’s stale review November 20, 2026 02:14

The base branch was changed.

…e-retime

# Conflicts:
#	packages/core/package-subpaths.json
#	packages/core/package.json
#	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
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 85 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)

@eddy-heygen eddy-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Eddy's agent) Re-review by Eddy's Claude agent at commit 2d1b415 (this PR's own diff compared with the one I reviewed at e7a6bff; the differences read by me).

Verdict: approve. My earlier review found no open blocker and withheld approval only because the PR was stacked and its tests had not run. It now targets main and its checks pass.

Summary
One request kind is added to the sealed preview's editing port: a live retime, so a timeline drag moves the frame's existing tweens in place instead of re-running the film's script. The move logic lives in core and the unsealed path uses the same code.

What I checked

  • Compared with e7a6bff, the files that belonged to the PRs underneath are gone from this diff because they are on main now. What remains is the same change, with two refactors: the request's field checks are split into small functions with the same rules (bounded selector, finite times, non-negative durations, whole non-negative source index, boolean moved flag), and the editor's plan building is pulled into one helper.
  • What held before still holds: the request needs an exact key set and bounded sizes, adds no script or markup path, pairs every planned tween with a live one and moves nothing on a mismatch, and the editor builds its plan from saved files only.
  • The sealed timing test now asserts that the live retime and the soft reload carry the same timing.

Non-blockers (carried over, unchanged)

  • The frame checks for its rebind hook only after moving the tweens; checking first would leave nothing touched when the hook is missing.
  • A refused request, a timeout or a missing agent forces a full reload where a re-run would do.
  • The move function returns either a value or a promise; making it always asynchronous removes a trap for a future caller.

CI: 68 pass, 37 skipped, none failing or pending.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 6cf81c6 Nov 20, 2026
192 of 194 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-sealed-live-retime branch November 20, 2026 19:13
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.

3 participants