Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
e209583
fix(studio): a sealed undo of a GSAP-animated layer's style shows in …
miguel-heygen Nov 20, 2026
4df4f85
fix(studio): a sealed undo refused after a later one reloads instead …
miguel-heygen Nov 20, 2026
9942b8f
fix(studio): a sealed undo's script re-run travels in its restore req…
miguel-heygen Nov 20, 2026
d765735
fix(studio): import the sealed re-run builder where the undo sends it
miguel-heygen Nov 20, 2026
7ad9ba8
refactor(studio): one shape guard for the restore parser and a named …
miguel-heygen Nov 20, 2026
0aa67f5
refactor(studio): the sealed undo attaches its re-run in one helper
miguel-heygen Nov 20, 2026
23fa4fa
test(studio): count only the restore's own requests to the sealed frame
miguel-heygen Nov 20, 2026
5822316
fix(studio): a sealed re-run keeps a newer scrub and an unusable re-r…
miguel-heygen Nov 20, 2026
5e7506d
fix(studio): a deferred re-run keeps a newer scrub and a newer edit; …
miguel-heygen Nov 20, 2026
a1dd52e
refactor(studio): name a soft reload's mark and its script run
miguel-heygen Nov 20, 2026
3294ecd
test(studio): share the Chrome bundle's node shim and read the compos…
miguel-heygen Nov 20, 2026
3948815
fix(studio): a waiting re-run leaves the composition's script until i…
miguel-heygen Nov 21, 2026
f7bc831
fix(studio): the soft-reload wait only swaps timelines a newer run le…
miguel-heygen Nov 21, 2026
29af019
test(studio): the soft-reload wait tables drive each step from one map
miguel-heygen Nov 21, 2026
b567c9b
fix(studio): one MotionPath loader settles every waiting re-run when …
miguel-heygen Nov 21, 2026
cdabe44
test(core): a failed MotionPath load is retried by the next re-run
miguel-heygen Nov 21, 2026
d77be52
Merge remote-tracking branch 'origin/main' into fix/sealed-undo-gsap-…
miguel-heygen Nov 21, 2026
a665227
test(studio): a wait-table step after the swap waits for the swap's r…
miguel-heygen Nov 21, 2026
009751d
fix(studio): only the newest soft-reload run may swap, reload or move…
miguel-heygen Nov 21, 2026
9cbce03
fix(studio): a refused sealed tween patch re-runs the script instead …
miguel-heygen Nov 21, 2026
d9b8cae
test(studio): the playing-through-the-wait row allows the player's fr…
miguel-heygen Nov 21, 2026
bfe5b46
fix(studio): a late preview answer acts only when no later re-run car…
miguel-heygen Nov 21, 2026
0290a6d
test(studio): held-answer rows release a still-waiting run when the p…
miguel-heygen Nov 21, 2026
b8a3637
test(core): a restore says whether it re-ran the script
miguel-heygen Nov 21, 2026
a76d842
test(studio): sealed preview equals a fresh load after late answers i…
miguel-heygen Nov 21, 2026
c88cb28
fix(studio): a late refusal recovers with the whole saved snapshot, a…
miguel-heygen Nov 21, 2026
ff5b30c
fix(studio): only an explicit refusal keeps an undo's attributes from…
miguel-heygen Nov 21, 2026
8adae37
test(studio): ordering table holds a refusal until its request posts,…
miguel-heygen Nov 21, 2026
dded8a3
test(studio): ordering fixture carries the hf ids Studio's server serves
miguel-heygen Nov 21, 2026
bee7229
fix(studio): a refused retime is never covered by a script-only re-run
miguel-heygen Nov 21, 2026
adaab5a
test(studio): ordering table keeps the title undo and restores safe a…
miguel-heygen Nov 21, 2026
7db94f0
refactor(studio): a restore's snapshot comes from one helper
miguel-heygen Nov 21, 2026
a72a2ec
test(studio): a refused request is answered at its own step, as in th…
miguel-heygen Nov 21, 2026
6487c6a
test(studio): the ordering runner lives in a shared sequence harness
miguel-heygen Nov 21, 2026
8366bab
test(studio): a patch recovery after a live retime carries the retime…
miguel-heygen Nov 21, 2026
ea50b77
test(studio): the ordering fixture sends its own script instead of pa…
miguel-heygen Nov 21, 2026
441bbe5
test(studio): the sequence harness keeps its refusal table private
miguel-heygen Nov 21, 2026
02a4169
test(studio): ordering table generates live retimes, scrubs and port …
miguel-heygen Nov 21, 2026
9c30243
test(studio): a harness reload shows the new load at Studio's playhead
miguel-heygen Nov 21, 2026
698f36d
test(studio): the ordering table carries the reviewer's round-8 seque…
miguel-heygen Nov 21, 2026
4ea445e
test(studio): the first round-8 sequence holds the live retime's refusal
miguel-heygen Nov 21, 2026
9505d67
test(studio): the ordering table pins the seeds that found each round…
miguel-heygen Nov 21, 2026
4b1d9c5
fix(studio): sealed recoveries keep saved timing, the live playhead a…
miguel-heygen Nov 21, 2026
29a8a79
test(studio): sealed mocks answer through previewAnswer; channel row …
miguel-heygen Nov 21, 2026
44edda9
test(studio): the timing sync and script commit mocks answer through …
miguel-heygen Nov 21, 2026
961b71b
refactor(studio): a late live retime's recovery is its own step
miguel-heygen Nov 21, 2026
968d210
test(studio): ordering table generates two-script files, missed deadl…
miguel-heygen Nov 21, 2026
4c4eaa7
test(studio): the data-start undo restores a clip no script animates
miguel-heygen Nov 21, 2026
d2fd995
test(studio): a save that reloads at once counts as one nothing can a…
miguel-heygen Nov 21, 2026
432bb75
fix(studio): sealed writes count as covered only by a newer applied r…
miguel-heygen Nov 21, 2026
d8aee14
test(studio): the ordering table pins the seeds that found each round…
miguel-heygen Nov 21, 2026
6b091d9
fix(studio): a sealed re-run covers from its send only what it carried
miguel-heygen Nov 21, 2026
96793e8
test(studio): the ordering fixture marks each save as Studio's write …
miguel-heygen Nov 21, 2026
12e6fb7
test(studio): a two-script sequence may recover only by reloading
miguel-heygen Nov 21, 2026
c4fd71a
test(studio): the harness reload loads again after a save, as Studio'…
miguel-heygen Nov 21, 2026
4c904a1
test(studio): the ordering table splits its fixed rows from fresh see…
miguel-heygen Nov 21, 2026
2fedba8
test(studio): the ordering fixture keeps its generator private
miguel-heygen Nov 21, 2026
71defaf
fix(studio): a sealed write's file version is its save's, and timing …
miguel-heygen Nov 21, 2026
9858453
fix(studio): the ledger keeps each timeline's newest snapshot by its …
miguel-heygen Nov 21, 2026
ddd4b3d
test(studio): soft-reload expectations name the save revision where a…
miguel-heygen Nov 21, 2026
c12ab10
test(studio): the ordering table pins the seeds that found reversed s…
miguel-heygen Nov 21, 2026
f34553c
refactor(studio): a sealed restore's send moves to its own module und…
miguel-heygen Nov 21, 2026
d36028b
test(studio): the wait table settles two waiting runs and a pause bef…
miguel-heygen Nov 21, 2026
056777d
test(studio): the ordering table reverses older timing writes behind …
miguel-heygen Nov 21, 2026
c2d50de
fix(studio): a sealed write older than a file already sent to the pre…
miguel-heygen Nov 21, 2026
9492f80
test(studio): mocked preview channels run the send gate as the real o…
miguel-heygen Nov 21, 2026
1b0f7c1
test(studio): the patch request names its default deadline
miguel-heygen Nov 21, 2026
ab72e56
test(studio): the ledger pins an older live retime sent after a newer…
miguel-heygen Nov 21, 2026
50b93da
fix(studio): a sealed tween patch carries its save's version without …
miguel-heygen Nov 21, 2026
0b0e114
test(studio): the undo row expects the in-place re-run of the undone …
miguel-heygen Nov 21, 2026
5ff8649
test(studio): the ordering table loads the newer file between reverse…
miguel-heygen Nov 21, 2026
848d02c
fix(studio): a new sealed preview load refuses writes older than the …
miguel-heygen Nov 21, 2026
0847d49
refactor(studio): the sequence runner plays a reversed step in its ow…
miguel-heygen Nov 21, 2026
8bd3b87
Merge remote-tracking branch 'origin/main' into fix/sealed-undo-gsap-…
miguel-heygen Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/runtime/editing/liveRetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
parseSavedTiming,
planSavedTiming,
scriptsRegistering,
swapWaiting,
type SavedTiming,
type SoftReloadWindow,
} from "./softReload";
Expand Down Expand Up @@ -242,6 +243,7 @@ export function parseLiveRetime(params: unknown): LiveRetimeParams | null {
/** The frame moving its own tweens to the plan Studio made from the saved scripts, then re-seeking. */
export function liveRetime(params: LiveRetimeParams): { result: LiveRetimeResult } {
const win = window as SoftReloadWindow;
if (swapWaiting(win)) return { result: "unchanged" };
const [script, ...extra] = scriptsRegistering(findGsapScriptElements(document), [params.key]);
if (!script || extra.length > 0) return { result: "unchanged" };
const timing = planSavedTiming(document, compositionFile(document, [params.key]), params.timing);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/runtime/editing/patchTween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// confidently returns false and the caller reloads. Studio runs it on a frame it can reach,
// a sealed frame on itself through the editing port.
import { applyAuthoredInlineOpacity, readStampedAuthoredOpacity } from "../../colorGrading";
import { recordLiveSet } from "./softReload";
import { recordLiveSet, swapWaiting } from "./softReload";

export interface SetPatchProps {
x?: number;
Expand Down Expand Up @@ -450,6 +450,7 @@ export function patchTweens({ patches, seek }: PatchTweensParams): { patched: bo
gsap: win.gsap,
player: win.__player,
};
if (swapWaiting()) return { patched: false };
const renderAt = lastTweenPatch(patches);
const missed = patches.find(({ selector, change }, index) => {
if (change.kind === "global-set")
Expand Down
30 changes: 14 additions & 16 deletions packages/core/src/runtime/editing/restoreAttributes.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { parseRestoreAttributes, restoreAttributes } from "./restoreAttributes";
import { parseRestoreAttributes, restoreInPlace } from "./restoreAttributes";

type TestWindow = Window & Record<string, unknown>;
const win = window as TestWindow;
Expand Down Expand Up @@ -38,7 +38,7 @@ describe("restore-attributes", () => {
["data-hf-id", "box"],
["style", "left: 0px"],
]);
expect(restoreAttributes(params)).toEqual({ applied: true });
expect(restoreInPlace(params)).toBe("applied");
const box = document.querySelector('[data-hf-id="box"]')!;
expect(box.getAttribute("style")).toBe("left: 0px");
expect(box.hasAttribute("class")).toBe(false);
Expand All @@ -51,7 +51,7 @@ describe("restore-attributes", () => {
.join("");
player();
const params = restore("hf:box", [["data-hf-id", "box"]], "sub.html");
expect(restoreAttributes(params)).toEqual({ applied: true });
expect(restoreInPlace(params)).toBe("applied");
expect(document.querySelectorAll("[style]")).toHaveLength(0);
});

Expand All @@ -61,7 +61,7 @@ describe("restore-attributes", () => {
document.body.innerHTML = html;
player();
const before = document.body.innerHTML;
expect(restoreAttributes(params)).toEqual({ applied: false });
expect(restoreInPlace(params)).toBe("refused");
expect(document.body.innerHTML).toBe(before);
};
refused('<div data-hf-id="other"></div>');
Expand All @@ -72,9 +72,9 @@ describe("restore-attributes", () => {
const rebind = vi.fn();
player();
win.__hfForceTimelineRebind = rebind;
expect(restoreAttributes({ ...restore("hf:box", attributes), scripted: true })).toEqual({
applied: false,
});
expect(restoreInPlace({ ...restore("hf:box", attributes), scripted: true })).toBe(
"gsap-parsed",
);
expect(rebind).not.toHaveBeenCalled();
});

Expand All @@ -87,7 +87,7 @@ describe("restore-attributes", () => {
["data-hf-studio-original-inline-translate", ""],
["style", "translate: 130px 90px"],
]);
expect(restoreAttributes(params)).toEqual({ applied: true });
expect(restoreInPlace(params)).toBe("applied");
const box = document.querySelector('[data-hf-id="box"]')!;
expect(box.getAttribute("data-hf-studio-original-inline-translate")).toBe("");
expect(box.getAttribute("style")).toBe("translate: 130px 90px");
Expand All @@ -98,32 +98,30 @@ describe("restore-attributes", () => {
document.body.innerHTML = '<div data-hf-id="box"></div><i data-hf-studio-rotation="true"></i>';
player();
const sized = () =>
restoreAttributes(
restoreInPlace(
restore("hf:box", [
["data-hf-id", "box"],
["data-hf-studio-box-size", "true"],
]),
);
expect(sized()).toEqual({ applied: false });
expect(sized()).toBe("refused");
win.__hfStudioSeekReapplyStarted = true;
expect(sized()).toEqual({ applied: true });
expect(sized()).toBe("applied");
});

// fails without the fix: dropping a motion mark in place left its timeline running.
it("reloads to take a motion mark away", () => {
document.body.innerHTML = '<div data-hf-id="box" data-hf-studio-motion="{}"></div>';
player();
expect(restoreAttributes(restore("hf:box", [["data-hf-id", "box"]]))).toEqual({
applied: false,
});
expect(restoreInPlace(restore("hf:box", [["data-hf-id", "box"]]))).toBe("refused");
});

it("changes no handler, URL or sandbox-style attribute, and leaves an unchanged one alone", () => {
const refused = (html: string, attributes: [string, string][]) => {
document.body.innerHTML = html;
player();
const before = document.body.innerHTML;
expect(restoreAttributes(restore("hf:box", attributes))).toEqual({ applied: false });
expect(restoreInPlace(restore("hf:box", attributes))).toBe("refused");
expect(document.body.innerHTML).toBe(before);
};
const box = '<div data-hf-id="box"></div>';
Expand All @@ -143,7 +141,7 @@ describe("restore-attributes", () => {
const img = document.querySelector("img")!;
const setAttribute = vi.spyOn(img, "setAttribute");
const params = restore("hf:box", [id, ["src", "a.png"], ["style", "left: 0px"]]);
expect(restoreAttributes(params)).toEqual({ applied: true });
expect(restoreInPlace(params)).toBe("applied");
expect(setAttribute.mock.calls).toEqual([["style", "left: 0px"]]);
expect(img.hasAttribute("loading")).toBe(false);
});
Expand Down
39 changes: 24 additions & 15 deletions packages/core/src/runtime/editing/restoreAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
STUDIO_REAPPLIED_MARKS,
STUDIO_SEEK_REAPPLY_STARTED,
} from "../../studioReappliedMarks";
import type { SoftReloadRerun } from "./softReload";

/** `hf:<data-hf-id>` or `id:<id>`, the key the parent's restore diff uses. */
export type RestoreElementKey = string;
Expand All @@ -15,7 +16,12 @@ export type RestoreScope = {
elements: { key: RestoreElementKey; attributes: RestoreAttribute[] }[];
};
/** `scripted`: the files keep an unchanged GSAP script, so an element GSAP has parsed needs a re-run instead. */
export type RestoreAttributesParams = { scopes: RestoreScope[]; scripted: boolean; time: number };
export type RestoreAttributesParams = {
scopes: RestoreScope[];
scripted: boolean;
time: number;
rerun?: SoftReloadRerun;
};

const MAX_SCOPES = 64;
const MAX_ELEMENTS = 2_000;
Expand Down Expand Up @@ -55,10 +61,11 @@ const reapplyScriptMissing = (plan: RestorePlan) =>
plan.some(([, , set]) => set.some(([name]) => REAPPLIED.has(name))) &&
(window as unknown as Record<string, unknown>)[STUDIO_SEEK_REAPPLY_STARTED] !== true;

const isRecord = (value: unknown): value is Record<string, unknown> =>
Object.prototype.toString.call(value) === "[object Object]";
const keysAre = (value: Record<string, unknown>, keys: string) =>
Object.keys(value).sort().join() === keys;
const hasKeys = (value: unknown, keys: string): value is Record<string, unknown> =>
Object.prototype.toString.call(value) === "[object Object]" &&
Object.keys(value as object)
.sort()
.join() === keys;

function attribute(value: unknown): RestoreAttribute | null {
if (!Array.isArray(value) || value.length !== 2) return null;
Expand All @@ -72,7 +79,7 @@ function attribute(value: unknown): RestoreAttribute | null {
}

function element(value: unknown): RestoreScope["elements"][number] | null {
if (!isRecord(value) || !keysAre(value, "attributes,key")) return null;
if (!hasKeys(value, "attributes,key")) return null;
const { key, attributes } = value;
if (typeof key !== "string" || key.length > MAX_KEY_LENGTH || !/^(hf|id):./.test(key))
return null;
Expand All @@ -85,7 +92,7 @@ const isScopeFile = (file: unknown): file is string | null =>
file === null || (typeof file === "string" && file.length > 0 && file.length <= MAX_KEY_LENGTH);

function scope(value: unknown): RestoreScope | null {
if (!isRecord(value) || !keysAre(value, "elements,file")) return null;
if (!hasKeys(value, "elements,file")) return null;
const { file, elements } = value;
if (!isScopeFile(file) || !Array.isArray(elements) || !elements.length) return null;
const parsed = elements.map(element);
Expand All @@ -101,7 +108,7 @@ export function parseRestoreScopes(scopes: unknown): RestoreScope[] | null {
}

export function parseRestoreAttributes(params: unknown): RestoreAttributesParams | null {
if (!isRecord(params) || !keysAre(params, "scopes,scripted,time")) return null;
if (!hasKeys(params, "scopes,scripted,time")) return null;
const { scripted, time } = params;
if (typeof scripted !== "boolean") return null;
if (typeof time !== "number" || !Number.isFinite(time) || time < 0) return null;
Expand Down Expand Up @@ -196,15 +203,17 @@ function rebindAt(win: RestoreWindow, time: number): void {
else finalize();
}

/** Applies the restore in place; `applied: false` changes nothing, and the parent reloads instead. */
export function restoreAttributes({ scopes, scripted, time }: RestoreAttributesParams): {
applied: boolean;
} {
/** Applies the restore in place, or nothing: refused, or an element GSAP has parsed needs a re-run. */
export function restoreInPlace({
scopes,
scripted,
time,
}: RestoreAttributesParams): "applied" | "refused" | "gsap-parsed" {
const win = window as RestoreWindow;
const plan = planRestore(scopes);
if (!plan || typeof win.__player?.seek !== "function") return { applied: false };
if (scripted && plan.some(([el]) => "_gsap" in el)) return { applied: false };
if (!plan || typeof win.__player?.seek !== "function") return "refused";
if (scripted && plan.some(([el]) => "_gsap" in el)) return "gsap-parsed";
applyRestorePlan(plan);
rebindAt(win, time);
return { applied: true };
return "applied";
}
Loading
Loading