Skip to content

Write HTML. Render video. Built for agents.

feat(studio): the timeline shows one row per top-level element and no child rows (#4132)

Miguel Ángel7797c5ead4c0
diff --git a/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx b/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx
index e4c041053f..0c41fc6bab 100644
--- a/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx
+++ b/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx
@@ -24,7 +24,7 @@ import {
afterEach(() => {
document.body.innerHTML = "";
// Wrapped in act: mounted harnesses subscribe to the store via
- // useExpandedTimelineElements, so the reset re-renders them.
+ // useTimelineRowElements, so the reset re-renders them.
act(() => usePlayerStore.getState().setElements([]));
});
diff --git a/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.ts b/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.ts
index 994e58da87..8bcf1bbb0f 100644
--- a/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.ts
+++ b/packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.ts
@@ -1,6 +1,6 @@
import { useCallback, useRef } from "react";
import { usePlayerStore } from "../../player";
-import { useExpandedTimelineElements } from "../../player/hooks/useExpandedTimelineElements";
+import { useTimelineRowElements } from "../../player/hooks/useTimelineRowElements";
import { useTimelineEditContextOptional } from "../../contexts/TimelineEditContext";
import {
displayTrackOrder,
@@ -41,7 +41,7 @@ export interface MirrorZOrderInput {
* commitZMirrorLaneMove) — the shared key is unique per gesture
* (zReorderCoalesceKey's gesture seq), so the fold stays gesture-scoped.
*
- * Element source: `useExpandedTimelineElements()` — the same expanded display
+ * Element source: `useTimelineRowElements()` — the same expanded display
* set the Timeline renders and the resolver expects (post-normalizeToZones
* lanes, expanded sub-comp children on their synthetic rows). No new expansion
* is built here.
@@ -141,7 +141,7 @@ function useMirrorLaneMoveCommit(): (
coalesceKey: string,
resolveMove: (element: TimelineElement, elements: TimelineElement[]) => ZMirrorLaneMove,
) => Promise<boolean> {
- const elements = useExpandedTimelineElements();
+ const elements = useTimelineRowElements();
const elementsRef = useRef(elements);
elementsRef.current = elements;
const { onMoveElements } = useTimelineEditContextOptional();
diff --git a/packages/studio/src/hooks/timelineAudioGroupCreate.ts b/packages/studio/src/hooks/timelineAudioGroupCreate.ts
index 3046d28b8c..af492e34e6 100644
--- a/packages/studio/src/hooks/timelineAudioGroupCreate.ts
+++ b/packages/studio/src/hooks/timelineAudioGroupCreate.ts
@@ -8,7 +8,7 @@
import { useCallback } from "react";
import { usePlayerStore, type TimelineElement } from "../player";
-import { useExpandedTimelineElements } from "../player/hooks/useExpandedTimelineElements";
+import { useTimelineRowElements } from "../player/hooks/useTimelineRowElements";
import { saveProjectFilesWithHistory } from "../utils/studioFileHistory";
import { HF_AUDIO_GROUP_ATTR, HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
import { runtimeAudioId } from "../player/lib/timelineElementHelpers";
@@ -272,7 +272,7 @@ export function useAudioGroupCarveAssignment({
groupId: string,
groupLabel?: string,
) => Promise<void> {
- const expandedElements = useExpandedTimelineElements();
+ const expandedElements = useTimelineRowElements();
return useCallback(
async (clipIds: readonly string[], groupId: string, groupLabel?: string) => {
if (isRecordingRef?.current) {
diff --git a/packages/studio/src/hooks/timelineTrackVisibility.ts b/packages/studio/src/hooks/timelineTrackVisibility.ts
index 9b53bcd2c5..c7f71b8c59 100644
--- a/packages/studio/src/hooks/timelineTrackVisibility.ts
+++ b/packages/studio/src/hooks/timelineTrackVisibility.ts
@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { usePlayerStore, type TimelineElement } from "../player";
import { reseekPreviewAtTime } from "../player/hooks/timelineSyncHydration";
-import { useExpandedTimelineElements } from "../player/hooks/useExpandedTimelineElements";
+import { useTimelineRowElements } from "../player/hooks/useTimelineRowElements";
import { applySoftReloadFinalization } from "../utils/gsapSoftReload";
import {
timelineTrackOrder,
@@ -295,7 +295,7 @@ export function useTimelineTrackVisibilityEditing({
// virtual sub-comp children carry their own (display.track + idx) track numbers,
// so filtering the raw store list by a virtual track number would hide the wrong
// outer-scene sibling sharing that index.
- const expandedElements = useExpandedTimelineElements();
+ const expandedElements = useTimelineRowElements();
return useCallback(
async (track: number, hidden: boolean, displayNumber?: number | null) => {
if (isRecordingRef?.current) {
@@ -354,15 +354,7 @@ export function useTimelineElementVisibilityEditing({
elementKey: string | readonly string[],
hidden: boolean,
) => Promise<void> {
- // Resolve against the EXPANDED rows, not the raw store list — a nested
- // sub-composition child has no entry of its own in the raw list (only its
- // host does), so an elementKey for such a child (the
- // `sourceFile#domId`-shaped virtual key `resolveTimelineIdForSelection`
- // falls back to) would never match anything there and Hide All would
- // silently no-op for it. The expanded list synthesizes a real, patchable
- // TimelineElement (with matching key/domId/sourceFile) for each visible
- // child whenever its host is currently expanded.
- const expandedElements = useExpandedTimelineElements();
+ const expandedElements = useTimelineRowElements();
return useCallback(
async (elementKey: string | readonly string[], hidden: boolean) => {
if (isRecordingRef?.current) {
@@ -371,6 +363,11 @@ export function useTimelineElementVisibilityEditing({
}
const pid = projectIdRef.current;
if (!pid) return;
+ const keys = typeof elementKey === "string" ? [elementKey] : elementKey;
+ if (!expandedElements.some((item) => keys.includes(item.key ?? item.id))) {
+ showToast("This element is inside a sub-composition and has no timeline row to hide.");
+ return;
+ }
try {
await toggleTimelineElementHidden({
projectId: pid,
diff --git a/packages/studio/src/hooks/useGroupCommits.test.ts b/packages/studio/src/hooks/useGroupCommits.test.ts
index dc3c57fad8..7af4cbc14c 100644
--- a/packages/studio/src/hooks/useGroupCommits.test.ts
+++ b/packages/studio/src/hooks/useGroupCommits.test.ts
@@ -11,7 +11,6 @@ const timelineElement = (over: Partial<TimelineElement> = {}): TimelineElement =
start: 0,
duration: 4,
track: 0,
- timingSource: "authored",
sourceFile: "index.html",
...over,
});
diff --git a/packages/studio/src/hooks/useRazorSplit.history.test.tsx b/packages/studio/src/hooks/useRazorSplit.history.test.tsx
index ff3cc84270..2665f14bef 100644
--- a/packages/studio/src/hooks/useRazorSplit.history.test.tsx
+++ b/packages/studio/src/hooks/useRazorSplit.history.test.tsx
@@ -29,7 +29,6 @@ const element: TimelineElement = {
track: 0,
domId: "clip1",
sourceFile: "index.html",
- timingSource: "authored",
};
type Split = (element: TimelineElement, splitTime: number) => Promise<void>;
diff --git a/packages/studio/src/hooks/useRazorSplit.test.ts b/packages/studio/src/hooks/useRazorSplit.test.ts
index 7e3472b096..5d230fabb2 100644
--- a/packages/studio/src/hooks/useRazorSplit.test.ts
+++ b/packages/studio/src/hooks/useRazorSplit.test.ts
@@ -24,7 +24,6 @@ const rootElement: TimelineElement = {
track: 0,
domId: "root-clip",
sourceFile: ROOT_FILE,
- timingSource: "authored",
};
// An expanded sub-comp child: `start` is in MASTER coordinates (offset by the
@@ -38,7 +37,6 @@ const expandedChild: TimelineElement = {
track: 1,
domId: "child-clip",
sourceFile: SUBCOMP_FILE,
- timingSource: "authored",
expandedParentStart: 2,
};
diff --git a/packages/studio/src/hooks/useRazorSplit.test.tsx b/packages/studio/src/hooks/useRazorSplit.test.tsx
index 1d629b7f72..feb25bf4f5 100644
--- a/packages/studio/src/hooks/useRazorSplit.test.tsx
+++ b/packages/studio/src/hooks/useRazorSplit.test.tsx
@@ -82,7 +82,6 @@ describe("useRazorSplit mutation versions", () => {
start: 0,
duration: 4,
track: 0,
- timingSource: "authored",
},
2,
);
diff --git a/packages/studio/src/hooks/useTimelineEditing.test.tsx b/packages/studio/src/hooks/useTimelineEditing.test.tsx
index 5472392a44..945633688e 100644
--- a/packages/studio/src/hooks/useTimelineEditing.test.tsx
+++ b/packages/studio/src/hooks/useTimelineEditing.test.tsx
@@ -86,7 +86,6 @@ function timelineElement(input: {
parentCompositionId: null,
compositionAncestors: ["root"],
sourceFile: input.sourceFile ?? "index.html",
- timingSource: "authored",
};
}
diff --git a/packages/studio/src/player/components/Timeline.tsx b/packages/studio/src/player/components/Timeline.tsx
index 1a03ab72bd..fcc8d61bc9 100644
--- a/packages/studio/src/player/components/Timeline.tsx
+++ b/packages/studio/src/player/components/Timeline.tsx
@@ -1,7 +1,7 @@
import { useRef, useMemo, useCallback, useState, memo } from "react";
import { useAdjustedBeatAnalysis, useMusicBeatAnalysis } from "../../hooks/useMusicBeatAnalysis";
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
-import { useExpandedTimelineElements } from "../hooks/useExpandedTimelineElements";
+import { useTimelineRowElements } from "../hooks/useTimelineRowElements";
import { defaultTimelineTheme } from "./timelineTheme";
import { useTimelineRangeSelection } from "./useTimelineRangeSelection";
import { useTimelinePlayhead } from "./useTimelinePlayhead";
@@ -111,7 +111,7 @@ export const Timeline = memo(function Timeline({
const refreshAfterLaneMove = useTimelineLaneMoveRefresh();
useMusicBeatAnalysis();
const rawElements = usePlayerStore((s) => s.elements);
- const expandedElements = useExpandedTimelineElements();
+ const expandedElements = useTimelineRowElements();
const adjustedBeatAnalysis = useAdjustedBeatAnalysis();
const duration = usePlayerStore((s) => s.duration);
const timeDisplayMode = usePlayerStore((s) => s.timeDisplayMode);
diff --git a/packages/studio/src/player/components/timelineAuthoredMoveTarget.ts b/packages/studio/src/player/components/timelineAuthoredMoveTarget.ts
index bf045b2c98..c1690b9530 100644
--- a/packages/studio/src/player/components/timelineAuthoredMoveTarget.ts
+++ b/packages/studio/src/player/components/timelineAuthoredMoveTarget.ts
@@ -3,7 +3,7 @@ import { getTimelineElementIdentity } from "../lib/timelineElementHelpers";
import { getTimelineEditCapabilities } from "./timelineEditing";
import type { DraggedClipState } from "./timelineClipDragTypes";
-/** Whether Studio may write timing to this clip (false for locked/implicit rows). */
+/** Whether Studio may write timing to this clip (false for locked rows). */
export function canMoveTimelineElement(element: TimelineElement): boolean {
return getTimelineEditCapabilities({
tag: element.tag,
@@ -16,7 +16,6 @@ export function canMoveTimelineElement(element: TimelineElement): boolean {
playbackStart: element.playbackStart,
playbackStartAttr: element.playbackStartAttr,
sourceDuration: element.sourceDuration,
- timingSource: element.timingSource,
timelineLocked: element.timelineLocked,
}).canMove;
}
diff --git a/packages/studio/src/player/components/timelineClipDragCommit.ts b/packages/studio/src/player/components/timelineClipDragCommit.ts
index 30aea90075..e8bcc409f3 100644
--- a/packages/studio/src/player/components/timelineClipDragCommit.ts
+++ b/packages/studio/src/player/components/timelineClipDragCommit.ts
@@ -176,8 +176,8 @@ export function persistMoveEdits(
/**
* Build the time-shift resolver for a multi-selection drag: every member of the
* selection moves by the dragged clip's delta (clamped ≥ 0); non-members are
- * untouched. Returns null when this is not a multi-selection drag. A locked /
- * implicit member is dropped from the moving set (a marquee can sweep one in).
+ * untouched. Returns null when this is not a multi-selection drag. A locked
+ * member is dropped from the moving set (a marquee can sweep one in).
*/
function resolveMultiSelection(
drag: DraggedClipState,
diff --git a/packages/studio/src/player/components/timelineEditCapabilities.ts b/packages/studio/src/player/components/timelineEditCapabilities.ts
index d06d7fd5de..ff3c55fe12 100644
--- a/packages/studio/src/player/components/timelineEditCapabilities.ts
+++ b/packages/studio/src/player/components/timelineEditCapabilities.ts
@@ -42,10 +42,9 @@ export function getTimelineEditCapabilities(input: {
playbackStart?: number;
playbackStartAttr?: "media-start" | "playback-start";
sourceDuration?: number;
- timingSource?: "authored" | "implicit";
timelineLocked?: boolean;
}): TimelineEditCapabilities {
- if (input.timingSource === "implicit" || input.timelineLocked) {
+ if (input.timelineLocked) {
return { canMove: false, canTrimStart: false, canTrimEnd: false };
}
diff --git a/packages/studio/src/player/components/timelineEditing.test.ts b/packages/studio/src/player/components/timelineEditing.test.ts
index 50b749c153..49757c2eb9 100644
--- a/packages/studio/src/player/components/timelineEditing.test.ts
+++ b/packages/studio/src/player/components/timelineEditing.test.ts
@@ -412,21 +412,6 @@ describe("getTimelineEditCapabilities", () => {
});
});
- it("keeps implicit layout layers selectable but not timeline-editable", () => {
- expect(
- getTimelineEditCapabilities({
- duration: 8,
- selector: ".scene-shell",
- tag: "div",
- timingSource: "implicit",
- }),
- ).toEqual({
- canMove: false,
- canTrimStart: false,
- canTrimEnd: false,
- });
- });
-
it("allows move and both trims for patchable media clips with offset support", () => {
expect(
getTimelineEditCapabilities({
@@ -496,7 +481,6 @@ describe("getTimelineEditCapabilities", () => {
tag: "div",
duration: 4,
selector: "#hero-card",
- timingSource: "authored",
}),
).toEqual({
canMove: true,
diff --git a/packages/studio/src/player/components/timelineGroupEditing.test.ts b/packages/studio/src/player/components/timelineGroupEditing.test.ts
index ef4d356bf0..71437e14cf 100644
--- a/packages/studio/src/player/components/timelineGroupEditing.test.ts
+++ b/packages/studio/src/player/components/timelineGroupEditing.test.ts
@@ -34,11 +34,9 @@ describe("buildTimelineGroupResizeMembers (legacy 36413da7f semantics)", () => {
expect(buildTimelineGroupResizeMembers([a, locked], keys("a", "b"), "a", "end")).toBeNull();
});
- it("degrades when a member is implicitly timed or has no patch target", () => {
+ it("degrades when a member has no patch target", () => {
const a = el("a");
- const implicit = el("b", { timingSource: "implicit" });
const noTarget = el("c", { domId: undefined, selector: undefined });
- expect(buildTimelineGroupResizeMembers([a, implicit], keys("a", "b"), "a", "end")).toBeNull();
expect(buildTimelineGroupResizeMembers([a, noTarget], keys("a", "c"), "a", "end")).toBeNull();
});
diff --git a/packages/studio/src/player/components/timelineGroupEditing.ts b/packages/studio/src/player/components/timelineGroupEditing.ts
index c632cc78ff..e5ec36d7ca 100644
--- a/packages/studio/src/player/components/timelineGroupEditing.ts
+++ b/packages/studio/src/player/components/timelineGroupEditing.ts
@@ -198,7 +198,6 @@ function canTrimEdge(element: TimelineElement, edge: TimelineGroupResizeEdge): b
playbackStart: element.playbackStart,
playbackStartAttr: element.playbackStartAttr,
sourceDuration: element.sourceDuration,
- timingSource: element.timingSource,
timelineLocked: element.timelineLocked,
});
return edge === "start" ? caps.canTrimStart : caps.canTrimEnd;
diff --git a/packages/studio/src/player/components/timelineTrackDisplay.ts b/packages/studio/src/player/components/timelineTrackDisplay.ts
index 5e1af3f6c1..25e1377b4e 100644
--- a/packages/studio/src/player/components/timelineTrackDisplay.ts
+++ b/packages/studio/src/player/components/timelineTrackDisplay.ts
@@ -3,7 +3,7 @@
*
* `TimelineElement.track` is a z-order SORT key, not a row number: an expanded
* sub-composition child gets a synthesized fractional key (`host.track + n /
- * (siblings + 2)`, see `useExpandedTimelineElements`), so putting it in a string
+ * (siblings + 2)`, see `useTimelineRowElements`), so putting it in a string
* announces "Hide track 0.16666666666666666". Every user-visible track number,
* whether it is rendered by a component or baked into an undo-history label,
* routes through here; the raw key stays in callbacks and lookups only.
diff --git a/packages/studio/src/player/components/timelineTrackPersistPipeline.test.ts b/packages/studio/src/player/components/timelineTrackPersistPipeline.test.ts
index c6b48c3118..fe2b55adba 100644
--- a/packages/studio/src/player/components/timelineTrackPersistPipeline.test.ts
+++ b/packages/studio/src/player/components/timelineTrackPersistPipeline.test.ts
@@ -2,7 +2,6 @@ import { describe, expect, it, vi } from "vitest";
import type { TimelineElement } from "../store/playerStore";
import type { ClipManifestClip } from "../lib/playbackTypes";
import { createTimelineElementFromManifestClip } from "../lib/timelineDOM";
-import { buildExpandedElements } from "../hooks/useExpandedTimelineElements";
import { normalizeToZones } from "./timelineZones";
import { commitDraggedClipMove, type TimelineMoveEdit } from "./timelineClipDragCommit";
import type { DraggedClipState } from "./useTimelineClipDrag";
@@ -113,56 +112,4 @@ describe("track persist pipeline (manifest → factory → lanes → drag commit
const up = commitLaneChange(byId.get("g")!, 0, elements, [0, 1, 2]);
expect(up[0].updates.track).toBe(3); // authored, NOT display lane 0
});
-
- it("an expanded sub-comp child's lane change persists the sibling's authored track from ITS file", () => {
- // Host timeline: the sub-comp host plus a root clip, discovered through the
- // factory and lane-normalized like the store does.
- const hostManifest = [
- manifestClip({
- id: "scene",
- kind: "composition",
- tagName: "div",
- track: 0,
- start: 0,
- duration: 10,
- compositionId: "scene",
- compositionSrc: "scene.html",
- }),
- manifestClip({ id: "root-clip", kind: "video", tagName: "video", track: 1, start: 0 }),
- ];
- // scene.html has SPARSE authored tracks 3 and 7.
- const childClips = [
- manifestClip({ id: "c3", track: 3, start: 1, duration: 2, parentCompositionId: "scene" }),
- manifestClip({ id: "c7", track: 7, start: 4, duration: 2, parentCompositionId: "scene" }),
- ];
- const storeElements = normalizeToZones(fromManifest(hostManifest));
- const parentMap = new Map([
- ["c3", "scene"],
- ["c7", "scene"],
- ]);
- const expanded = buildExpandedElements(
- storeElements,
- [...hostManifest, ...childClips],
- parentMap,
- "scene",
- "scene",
- );
-
- // The children replaced the host row: synthetic display lanes, but the
- // authored track (in scene.html's coordinate space) survived the expansion.
- const c3 = expanded.find((e) => e.domId === "c3")!;
- const c7 = expanded.find((e) => e.domId === "c7")!;
- expect(c3).toMatchObject({ authoredTrack: 3, sourceFile: "scene.html" });
- expect(c7).toMatchObject({ authoredTrack: 7, sourceFile: "scene.html" });
- expect(c3.stackingContextId).toBe("root");
- expect(c3.track).not.toBe(3); // display row is synthetic
-
- // Drag c3 onto c7's display lane: the persist target is c3's OWN file, so
- // the written track must be c7's authored 7 — not the display-lane integer.
- const trackOrder = [...new Set(expanded.map((e) => e.track))].sort((a, b) => a - b);
- const edits = commitLaneChange(c3, c7.track, expanded, trackOrder);
- expect(edits).toHaveLength(1);
- expect(edits[0].updates.track).toBe(7);
- expect(edits[0].updates.track).not.toBe(c7.track);
- });
});
diff --git a/packages/studio/src/player/components/useTimelineTrackDerivations.ts b/packages/studio/src/player/components/useTimelineTrackDerivations.ts
index 97d9534bb4..6fb2853cbb 100644
--- a/packages/studio/src/player/components/useTimelineTrackDerivations.ts
+++ b/packages/studio/src/player/components/useTimelineTrackDerivations.ts
@@ -98,7 +98,7 @@ function buildGroupInfo(
id: groupId,
label: membership.labelByGroup.get(groupId) ?? groupId,
// Exactly x.5, which sub-composition child rows are now kept strictly below
- // (`useExpandedTimelineElements`) — they used to be able to land here and
+ // (`useTimelineRowElements`) — they used to be able to land here and
// collide, duplicating the group header.
anchorKey: (memberTracks[0] ?? fallbackTrackNum) - 0.5,
memberTracks,
diff --git a/packages/studio/src/player/hooks/timelineDomBinding.test.ts b/packages/studio/src/player/hooks/timelineDomBinding.test.ts
index 56737d3de2..15f17622b3 100644
--- a/packages/studio/src/player/hooks/timelineDomBinding.test.ts
+++ b/packages/studio/src/player/hooks/timelineDomBinding.test.ts
@@ -73,9 +73,6 @@ describe("live DOM manifest hydration", () => {
canTrimEnd: true,
});
expect(getTimelineEditCapabilities({ ...input, timelineLocked: true }).canMove).toBe(false);
- expect(getTimelineEditCapabilities({ ...input, timingSource: "implicit" }).canTrimEnd).toBe(
- false,
- );
});
it("uses at most one fallback candidate snapshot per hydration pass", () => {
const doc = documentWith(
diff --git a/packages/studio/src/player/hooks/timelineSyncHydration.test.ts b/packages/studio/src/player/hooks/timelineSyncHydration.test.ts
index bd763f4493..902c390ca0 100644
--- a/packages/studio/src/player/hooks/timelineSyncHydration.test.ts
+++ b/packages/studio/src/player/hooks/timelineSyncHydration.test.ts
@@ -3,6 +3,7 @@
import { describe, expect, it } from "vitest";
import {
collectSubCompositionDomChildren,
+ collectTopLevelElementIds,
collectSubCompositionHostState,
} from "./timelineSyncHydration";
import type { ClipManifestClip } from "../lib/playbackTypes";
@@ -94,3 +95,20 @@ describe("collectSubCompositionHostState", () => {
expect(state.size).toBe(0);
});
});
+
+describe("collectTopLevelElementIds", () => {
+ const docOf = (html: string) => new DOMParser().parseFromString(html, "text/html");
+
+ it("names the sub-composition host and a timed element, not what is nested inside them", () => {
+ const doc = docOf(`<div data-composition-id="root">
+ <div id="wrap"><div id="a" data-start="0" data-duration="2"><div id="inner" data-start="0"></div></div></div>
+ <div id="scene" data-composition-id="scene" data-composition-src="scene.html"><div id="box" data-start="0"></div></div>
+ </div>`);
+ expect([...collectTopLevelElementIds(doc)!].sort()).toEqual(["a", "scene"]);
+ });
+
+ it("is null when the document has no composition root", () => {
+ expect(collectTopLevelElementIds(docOf("<p>hi</p>"))).toBeNull();
+ expect(collectTopLevelElementIds(null)).toBeNull();
+ });
+});
diff --git a/packages/studio/src/player/hooks/timelineSyncHydration.ts b/packages/studio/src/player/hooks/timelineSyncHydration.ts
index bc79f05b03..9ef45baddc 100644
--- a/packages/studio/src/player/hooks/timelineSyncHydration.ts
+++ b/packages/studio/src/player/hooks/timelineSyncHydration.ts
@@ -14,12 +14,12 @@ import { usePlayerStore } from "../store/playerStore";
import type { TimelineElement, DomClipChild, SubCompositionHostState } from "../store/playerStore";
import { resolveCssStackingContextId } from "@hyperframes/core/runtime/stacking-context";
import type { ClipTree } from "@hyperframes/core/runtime/clipTree";
+import { topLevelElements, type StructureNode } from "@hyperframes/parsers/top-level-elements";
import { HF_AUDIO_GROUP_ATTR } from "@hyperframes/core/audio-groups";
import { groupInfoFor } from "../lib/timelineGroupInfo";
import type { PlaybackAdapter, ClipManifestClip, IframeWindow } from "../lib/playbackTypes";
import {
buildStandaloneRootTimelineElement,
- createImplicitTimelineLayersFromDOM,
createTimelineElementFromManifestClip,
getTimelineElementSelector,
parseTimelineFromDOM,
@@ -137,6 +137,28 @@ export function collectSubCompositionDomChildren(
return out;
}
+interface DomStructureNode extends StructureNode<DomStructureNode> {
+ id: string;
+}
+
+function toStructureNode(el: Element): DomStructureNode {
+ const attrs: Record<string, string> = {};
+ for (const attr of Array.from(el.attributes)) attrs[attr.name] = attr.value;
+ return {
+ tag: el.tagName,
+ attrs,
+ id: el.id,
+ children: Array.from(el.children).map(toStructureNode),
+ };
+}
+
+/** DOM ids of the timeline's rows, by the definition the structure lint shares; null when there is no readable root. */
+export function collectTopLevelElementIds(doc: Document | null): Set<string> | null {
+ const root = doc?.querySelector("[data-composition-id]");
+ if (!root) return null;
+ return new Set(topLevelElements(toStructureNode(root)).flatMap((n) => (n.id ? [n.id] : [])));
+}
+
/** The host-element `data-*` state one element carries, or null when it has none. */
function readSubCompositionHostState(el: Element): SubCompositionHostState | null {
const state: SubCompositionHostState = {};
@@ -214,28 +236,25 @@ export function buildTimelineElementsFromClips(
});
}
-/**
- * The clamped manifest elements plus the layers that exist only in the DOM.
- * Both halves need the same resolved duration, which is why they land together.
- */
-export function withImplicitDomLayers(
- els: readonly TimelineElement[],
- iframeDoc: Document | null,
- effectiveDuration: number,
-): TimelineElement[] {
- const clamped = clampElementsToDuration(els, effectiveDuration);
- if (!iframeDoc || effectiveDuration <= 0) return clamped;
- return [
- ...clamped,
- ...createImplicitTimelineLayersFromDOM(iframeDoc, effectiveDuration, clamped),
- ];
-}
-
/**
* Drop elements that start past the composition's end and trim the ones that
* straddle it. A non-positive duration means "not known yet" — pass through
* untouched rather than clamping everything to nothing.
*/
+/** Commits the manifest elements, including none. An empty manifest carries a 1s floor, not a duration. */
+export function syncManifestTimeline(
+ els: readonly TimelineElement[],
+ manifestDuration: number,
+ storeDuration: number,
+ sync: (els: TimelineElement[], duration?: number) => void,
+): void {
+ const hasDuration = manifestDuration > 0 && els.length > 0;
+ sync(
+ clampElementsToDuration(els, hasDuration ? manifestDuration : storeDuration),
+ hasDuration ? manifestDuration : undefined,
+ );
+}
+
function clampElementsToDuration(
els: readonly TimelineElement[],
effectiveDuration: number,
diff --git a/packages/studio/src/player/hooks/useExpandedTimelineElements.test.ts b/packages/studio/src/player/hooks/useExpandedTimelineElements.test.ts
deleted file mode 100644
index e883cc875c..0000000000
--- a/packages/studio/src/player/hooks/useExpandedTimelineElements.test.ts
+++ /dev/null
@@ -1,774 +0,0 @@
-// @vitest-environment happy-dom
-
-import React, { act, useEffect } from "react";
-import { createRoot } from "react-dom/client";
-import { afterEach, describe, expect, it } from "vitest";
-import {
- buildExpandedElements,
- resolveTimelineExpansionRawId,
- useExpandedTimelineElements,
-} from "./useExpandedTimelineElements";
-import { buildTimelineElementKey } from "../lib/timelineElementHelpers";
-import { usePlayerStore, type TimelineElement } from "../store/playerStore";
-import type { ClipManifestClip } from "../lib/playbackTypes";
-
-globalThis.IS_REACT_ACT_ENVIRONMENT = true;
-
-const clip = (over: Partial<ClipManifestClip>): ClipManifestClip => ({
- id: "x",
- label: "x",
- start: 0,
- duration: 1,
- track: 0,
- kind: "element",
- tagName: "div",
- compositionId: null,
- parentCompositionId: null,
- compositionSrc: null,
- assetUrl: null,
- ...over,
-});
-
-const el = (over: Partial<TimelineElement>): TimelineElement => ({
- id: "x",
- start: 0,
- duration: 1,
- track: 0,
- tag: "div",
- ...over,
-});
-
-function TimelineExpansionHarness({ onValue }: { onValue: (value: TimelineElement[]) => void }) {
- const value = useExpandedTimelineElements();
- useEffect(() => {
- onValue(value);
- }, [onValue, value]);
- return null;
-}
-
-afterEach(() => {
- document.body.innerHTML = "";
- usePlayerStore.getState().reset();
-});
-
-describe("buildExpandedElements", () => {
- it("rebases a 1-level child onto its sub-comp host (start + sourceFile)", () => {
- // host s3 at absolute 16 → stats-panel.html; children live in that file.
- const elements = [el({ id: "s3", start: 16, duration: 7, compositionSrc: "stats.html" })];
- const manifest = [
- clip({ id: "s3", start: 16, duration: 7, compositionSrc: "stats.html" }),
- clip({ id: "stat-1", start: 16.5, duration: 5 }),
- clip({ id: "stat-2", start: 16.9, duration: 5 }),
- ];
- const parentMap = new Map([
- ["stat-1", "s3"],
- ["stat-2", "s3"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "s3", "s3");
- const child = out.find((e) => e.domId === "stat-1")!;
- expect(child.expandedParentStart).toBe(16);
- expect(child.expandedHostKey).toBe("s3");
- expect(child.sourceFile).toBe("stats.html");
- });
-
- it("keeps repeated same-source composition hosts as distinct move identities", () => {
- const elements = [
- el({
- id: "host-a",
- key: "index.html#host-a",
- start: 0,
- duration: 5,
- compositionSrc: "scene.html",
- }),
- el({
- id: "host-b",
- key: "index.html#host-b",
- start: 8,
- duration: 5,
- compositionSrc: "scene.html",
- }),
- ];
- const manifest = [
- clip({ id: "host-a", start: 0, duration: 5, compositionSrc: "scene.html" }),
- clip({ id: "child-a", start: 1, duration: 2 }),
- clip({ id: "host-b", start: 8, duration: 5, compositionSrc: "scene.html" }),
- clip({ id: "child-b", start: 9, duration: 2 }),
- ];
- const parentMap = new Map([
- ["child-a", "host-a"],
- ["child-b", "host-b"],
- ]);
-
- const childA = buildExpandedElements(elements, manifest, parentMap, "host-a", "host-a").find(
- (element) => element.domId === "child-a",
- );
- const childB = buildExpandedElements(elements, manifest, parentMap, "host-b", "host-b").find(
- (element) => element.domId === "child-b",
- );
-
- expect(childA?.sourceFile).toBe("scene.html");
- expect(childB?.sourceFile).toBe("scene.html");
- expect(childA?.expandedHostKey).toBe("index.html#host-a");
- expect(childB?.expandedHostKey).toBe("index.html#host-b");
- });
-
- // fallow-ignore-next-line code-duplication
- it("rebases a 2-level child onto its NESTED host, not the top-level scene", () => {
- // top host A@10 (a.html) embeds host B@12 (b.html); child C lives in b.html.
- // Edits must rebase onto B (12 / b.html), not A (10 / a.html).
- const elements = [el({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" })];
- const manifest = [
- clip({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- clip({ id: "B", start: 12, duration: 4, compositionSrc: "b.html" }),
- clip({ id: "C", start: 13, duration: 2 }),
- clip({ id: "C2", start: 14, duration: 1 }),
- ];
- const parentMap = new Map([
- ["B", "A"],
- ["C", "B"],
- ["C2", "B"],
- ]);
-
- // Expanding C's siblings: topLevel A, immediate parent B.
- const out = buildExpandedElements(elements, manifest, parentMap, "A", "B");
- const child = out.find((e) => e.domId === "C")!;
- expect(child.expandedParentStart).toBe(12); // B's start, not A's 10
- expect(child.sourceFile).toBe("b.html"); // B's file, not a.html
- });
-
- // fallow-ignore-next-line code-duplication
- it("rebases a 3-level child onto its deepest host, not intermediate or top", () => {
- // A@10 (a.html) → B@12 (b.html) → C@13 (c.html); leaf D lives in c.html.
- // Edits must rebase onto C (13 / c.html), not B (12 / b.html) or A (10 / a.html).
- const elements = [el({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" })];
- const manifest = [
- clip({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- clip({ id: "B", start: 12, duration: 5, compositionSrc: "b.html" }),
- clip({ id: "C", start: 13, duration: 3, compositionSrc: "c.html" }),
- clip({ id: "D", start: 13.5, duration: 1 }),
- clip({ id: "D2", start: 14, duration: 1 }),
- ];
- const parentMap = new Map([
- ["B", "A"],
- ["C", "B"],
- ["D", "C"],
- ["D2", "C"],
- ]);
-
- // Expanding D's siblings: topLevel A, immediate parent C.
- const out = buildExpandedElements(elements, manifest, parentMap, "A", "C");
- const child = out.find((e) => e.domId === "D")!;
- expect(child.expandedParentStart).toBe(13); // C's start, not B's 12 or A's 10
- expect(child.sourceFile).toBe("c.html"); // C's file, not b.html or a.html
- });
-
- it("keeps the middle host's row when drilling two levels deep", () => {
- // A embeds B; C lives in B. Drilling into B must leave BOTH host rows
- // standing: sparing only the top-level one drops B's row, and its keyframe
- // lane goes with it because diamonds render per row.
- const elements = [
- el({ id: "A", domId: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- el({ id: "B", domId: "B", start: 12, duration: 4, track: 1, compositionSrc: "b.html" }),
- ];
- const manifest = [
- clip({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- clip({ id: "B", start: 12, duration: 4, compositionSrc: "b.html" }),
- clip({ id: "C", start: 13, duration: 2 }),
- ];
- const parentMap = new Map([
- ["B", "A"],
- ["C", "B"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "A", "B");
- const rows = out.map((e) => e.domId ?? e.id);
- expect(rows).toContain("B");
- // The child sits under its own host, not under the top-level row.
- expect(rows.indexOf("C")).toBeGreaterThan(rows.indexOf("B"));
- });
-
- it("still drills a host that exists only in the manifest, without a row for it", () => {
- // Same shape, but B has no store element, so there is no row to spare. The
- // children stay anchored to the top-level row rather than vanishing.
- const elements = [
- el({ id: "A", domId: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- ];
- const manifest = [
- clip({ id: "A", start: 10, duration: 8, compositionSrc: "a.html" }),
- clip({ id: "B", start: 12, duration: 4, compositionSrc: "b.html" }),
- clip({ id: "C", start: 13, duration: 2 }),
- ];
- const parentMap = new Map([
- ["B", "A"],
- ["C", "B"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "A", "B");
- expect(out.map((e) => e.domId ?? e.id)).toEqual(["A", "C"]);
- });
-
- // Regression: an expanded child must share one identity (`key`) with the flat
- // store element for the same DOM id. Before the fix the child key fell back to
- // the colon form (`index.html:eyebrow:N`) while the store/selection used the
- // hash form (`index.html#eyebrow`), so clicking an expanded child never
- // highlighted it (isSelected compares the two keys).
- it("keys expanded children in hash form, matching the flat store element", () => {
- // Single composition (no sub-comps): scene `s1` with same-file children.
- const elements = [el({ id: "s1", domId: "s1", start: 0, duration: 14 })];
- const manifest = [
- clip({ id: "s1", start: 0, duration: 14 }),
- clip({ id: "eyebrow", start: 0, duration: 14 }),
- clip({ id: "title", start: 0, duration: 14 }),
- ];
- const parentMap = new Map([
- ["eyebrow", "s1"],
- ["title", "s1"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "s1", "s1");
- const child = out.find((e) => e.domId === "eyebrow")!;
-
- const expectedStoreKey = buildTimelineElementKey({
- id: "eyebrow",
- fallbackIndex: 0,
- domId: "eyebrow",
- selector: "#eyebrow",
- sourceFile: undefined,
- });
- expect(expectedStoreKey).toBe("index.html#eyebrow");
- expect(child.key).toBe("index.html#eyebrow");
- expect(child.key).toBe(expectedStoreKey);
- });
-
- // Regression: a child row is built from a manifest clip, which carries none of
- // the host element's attributes. Reading hidden off the manifest left every
- // expanded row reporting itself visible, so the eye wrote data-hidden a second
- // time instead of removing it and the element could never be shown again.
- it("inherits hidden and locked state from the flat store element", () => {
- const elements = [
- el({ id: "s1", domId: "s1", start: 0, duration: 14 }),
- el({
- id: "eyebrow",
- key: "index.html#eyebrow",
- domId: "eyebrow",
- start: 0,
- duration: 14,
- hidden: true,
- timelineLocked: true,
- }),
- ];
- const manifest = [
- clip({ id: "s1", start: 0, duration: 14 }),
- clip({ id: "eyebrow", start: 0, duration: 14 }),
- ];
- const parentMap = new Map([["eyebrow", "s1"]]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "s1", "s1");
- const child = out.find((e) => e.domId === "eyebrow")!;
- expect(child.hidden).toBe(true);
- expect(child.timelineLocked).toBe(true);
- });
-
- // The test above only covers a host with no compositionSrc, where the child's
- // key falls back to the `index.html` scope and a flat store twin can exist. A
- // REAL sub-composition scopes the child key to the sub-comp file, and clips
- // whose parent composition is itself in the manifest are filtered out of the
- // flat store before it is built (`processTimelineMessage`). So the twin never
- // exists there and the inheritance above is dead code for the one case it was
- // written for: the eye reported every hidden child visible, clicking it
- // rewrote data-hidden, and nothing could be shown again.
- it("reads hidden and locked off the live element when the child has no flat twin", () => {
- // Only the host is in the flat store — exactly what the manifest filter leaves.
- const elements = [
- el({
- id: "scene-2",
- domId: "scene-2",
- start: 3.25,
- duration: 3.5,
- compositionSrc: "scene-2.html",
- }),
- ];
- const manifest = [
- clip({ id: "scene-2", start: 3.25, duration: 3.5, compositionSrc: "scene-2.html" }),
- clip({ id: "scene-2-video", start: 3.25, duration: 3.5, parentCompositionId: "scene-2" }),
- ];
- const parentMap = new Map([["scene-2-video", "scene-2"]]);
- const hostState = new Map([["scene-2-video", { hidden: true, timelineLocked: true }]]);
-
- const out = buildExpandedElements(
- elements,
- manifest,
- parentMap,
- "scene-2",
- "scene-2",
- [],
- hostState,
- );
- const child = out.find((e) => e.domId === "scene-2-video")!;
- // The child key is scoped to the sub-comp file, so no store element can match it.
- expect(child.key).toBe("scene-2.html#scene-2-video");
- expect(elements.some((element) => element.key === child.key)).toBe(false);
- expect(child.hidden).toBe(true);
- expect(child.timelineLocked).toBe(true);
- });
-
- // Sub-comp internals (group + pills) have no data-start, so they're not in the
- // manifest. They arrive as DOM children and must still expand under their host.
- it("expands DOM-only sub-comp children (no manifest clip) under the host", () => {
- const elements = [
- el({ id: "scene-host", start: 5, duration: 6, compositionSrc: "scene.html" }),
- ];
- const manifest = [
- clip({ id: "scene-host", start: 5, duration: 6, compositionSrc: "scene.html" }),
- ];
- // pill-3 selected → parent group-1 → host scene-host. None of group-1/pills
- // are in the manifest; they're DOM children with parent links.
- const parentMap = new Map([
- ["group-1", "scene-host"],
- ["pill-1", "group-1"],
- ["pill-2", "group-1"],
- ["pill-3", "group-1"],
- ]);
- const domClipChildren = [
- {
- id: "group-1",
- parentId: "scene-host",
- hostId: "scene-host",
- label: "Group 1",
- stackingContextId: "css:0",
- },
- {
- id: "pill-1",
- parentId: "group-1",
- hostId: "scene-host",
- label: "pill-1",
- stackingContextId: "css:0.0",
- },
- {
- id: "pill-2",
- parentId: "group-1",
- hostId: "scene-host",
- label: "pill-2",
- stackingContextId: "css:0.1",
- },
- {
- id: "pill-3",
- parentId: "group-1",
- hostId: "scene-host",
- label: "pill-3",
- stackingContextId: "css:0.1",
- },
- ];
-
- // Expanding pill-3's siblings: topLevel scene-host, immediate parent group-1.
- const out = buildExpandedElements(
- elements,
- manifest,
- parentMap,
- "scene-host",
- "group-1",
- domClipChildren,
- );
- const pills = out.filter((e) => e.domId?.startsWith("pill-"));
- expect(pills).toHaveLength(3);
- // Children span the host's bounds and rebase onto the host's file.
- expect(pills[0]!.start).toBe(5);
- expect(pills[0]!.duration).toBe(6);
- expect(pills[0]!.sourceFile).toBe("scene.html");
- expect(pills.map((pill) => pill.stackingContextId)).toEqual(["css:0.0", "css:0.1", "css:0.1"]);
- // The host row survives the expansion; its children are added under it.
- expect(out.some((e) => e.id === "scene-host")).toBe(true);
- });
-
- // fallow-ignore-next-line code-duplication
- it("keeps the host row and appends its children directly below it", () => {
- const elements = [
- el({
- id: "s3",
- domId: "s3",
- key: "index.html#s3",
- start: 16,
- duration: 7,
- compositionSrc: "stats.html",
- }),
- el({ id: "outro", start: 23, duration: 3, track: 1 }),
- ];
- const manifest = [
- clip({ id: "s3", start: 16, duration: 7, compositionSrc: "stats.html" }),
- clip({ id: "stat-1", start: 16.5, duration: 5 }),
- clip({ id: "stat-2", start: 16.9, duration: 5 }),
- ];
- const parentMap = new Map([
- ["stat-1", "s3"],
- ["stat-2", "s3"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "s3", "s3");
-
- const hostIndex = out.findIndex((e) => e.id === "s3");
- expect(hostIndex).toBeGreaterThanOrEqual(0);
- // Host row untouched (same key → same keyframe lane), children nested under it.
- expect(out[hostIndex]!.key).toBe("index.html#s3");
- expect(out[hostIndex]!.track).toBe(0);
- expect(out[hostIndex + 1]!.domId).toBe("stat-1");
- expect(out[hostIndex + 2]!.domId).toBe("stat-2");
- // Exactly one more row than the old substitution behaviour (host + 2 children + outro).
- expect(out).toHaveLength(4);
- });
-
- it("keeps the host row present at every playhead position (keyframe lane repro)", () => {
- // Live repro with no drag at all: seek 0 gave 3 diamonds, seek 7.68 gave 0,
- // seek 0.2 gave 3. Diamonds render per row from keyframeCache.get(elementKey),
- // so the whole lane went with the host row whenever the store-time drill-in
- // substituted it for its children.
- const elements = [
- el({ id: "scene", domId: "scene", key: "index.html#scene", start: 0, duration: 12 }),
- ];
- const manifest = [
- clip({ id: "scene", start: 0, duration: 12, compositionSrc: "scene.html" }),
- clip({ id: "headline", start: 0, duration: 12 }),
- ];
- const parentMap = new Map([["headline", "scene"]]);
-
- for (const currentTime of [0, 7.68, 0.2]) {
- const rawId = resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime,
- manifest,
- parentMap,
- });
- const rows = rawId
- ? buildExpandedElements(elements, manifest, parentMap, rawId, rawId)
- : elements;
- expect(rows.map((row) => row.key)).toContain("index.html#scene");
- }
- });
-
- // Regression: DOM-only children were synthesized against the TOP-LEVEL element
- // instead of the sub-comp host they actually live in, so every child row read
- // the whole top-level window rather than its host's.
- it("spans DOM-only children over their nested host's window, not the top-level one", () => {
- const elements = [
- el({ id: "scene-host", start: 0, duration: 20, compositionSrc: "scene.html" }),
- ];
- const manifest = [
- clip({ id: "scene-host", start: 0, duration: 20, compositionSrc: "scene.html" }),
- clip({ id: "sub-host", start: 5, duration: 6, compositionSrc: "sub.html" }),
- ];
- const parentMap = new Map([
- ["sub-host", "scene-host"],
- ["pill-1", "sub-host"],
- ]);
- const domClipChildren = [
- {
- id: "pill-1",
- parentId: "sub-host",
- hostId: "sub-host",
- label: "pill-1",
- stackingContextId: "css:0.0",
- },
- ];
-
- const out = buildExpandedElements(
- elements,
- manifest,
- parentMap,
- "scene-host",
- "sub-host",
- domClipChildren,
- );
- const pill = out.find((e) => e.domId === "pill-1")!;
- expect(pill.start).toBe(5);
- expect(pill.duration).toBe(6);
- expect(pill.sourceFile).toBe("sub.html");
- });
-});
-
-describe("resolveTimelineExpansionRawId", () => {
- it("returns null inside a childless top-level clip", () => {
- const manifest = [clip({ id: "title", start: 0, duration: 4 })];
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 2,
- manifest,
- parentMap: new Map(),
- }),
- ).toBeNull();
- });
-
- it("auto-expands an active composition with children when nothing is selected", () => {
- const manifest = [
- clip({ id: "scene", start: 1, duration: 5 }),
- clip({ id: "headline", start: 1.5, duration: 2 }),
- ];
- const parentMap = new Map([["headline", "scene"]]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 2,
- manifest,
- parentMap,
- }),
- ).toBe("scene");
- });
-
- it("THE BUG: keeps a composition expanded with the playhead parked on its end", () => {
- // Clip windows are half-open, so at the very end of the timeline the
- // playhead was inside nothing and every expanded row collapsed.
- const manifest = [
- clip({ id: "scene", start: 0, duration: 12 }),
- clip({ id: "headline", start: 0, duration: 12 }),
- ];
- const parentMap = new Map([["headline", "scene"]]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 12,
- manifest,
- parentMap,
- }),
- ).toBe("scene");
- });
-
- it("prefers the starting clip over the ending one on a shared seam", () => {
- const manifest = [
- clip({ id: "first", start: 0, duration: 5 }),
- clip({ id: "first-child", start: 0, duration: 5 }),
- clip({ id: "second", start: 5, duration: 5 }),
- clip({ id: "second-child", start: 5, duration: 5 }),
- ];
- const parentMap = new Map([
- ["first-child", "first"],
- ["second-child", "second"],
- ]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 5,
- manifest,
- parentMap,
- }),
- ).toBe("second");
- });
-
- it("auto-expands the innermost active nested composition", () => {
- const manifest = [
- clip({ id: "outer", start: 0, duration: 10 }),
- clip({ id: "inner", start: 2, duration: 5 }),
- clip({ id: "leaf", start: 3, duration: 1 }),
- ];
- const parentMap = new Map([
- ["inner", "outer"],
- ["leaf", "inner"],
- ]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 3.5,
- manifest,
- parentMap,
- }),
- ).toBe("inner");
- });
-
- it("resolves an active composition from the current store time", () => {
- const manifest = [
- clip({ id: "scene", start: 0, duration: 5 }),
- clip({ id: "headline", start: 1, duration: 2 }),
- ];
- const parentMap = new Map([["headline", "scene"]]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: null,
- currentTime: 2,
- manifest,
- parentMap,
- }),
- ).toBe("scene");
- });
-
- it("keeps inline children visible when the master timeline is playing", () => {
- const elements = [
- el({ id: "scene", domId: "scene", key: "index.html#scene", start: 0, duration: 5 }),
- ];
- const manifest = [
- clip({ id: "scene", start: 0, duration: 5, compositionSrc: "scene.html" }),
- clip({ id: "headline", start: 1, duration: 2 }),
- ];
- const parentMap = new Map([["headline", "scene"]]);
- let rows: TimelineElement[] | undefined;
- const host = document.createElement("div");
- document.body.append(host);
- const root = createRoot(host);
-
- act(() => {
- usePlayerStore.setState({
- elements,
- clipManifest: manifest,
- clipParentMap: parentMap,
- currentTime: 2,
- isPlaying: true,
- });
- root.render(
- React.createElement(TimelineExpansionHarness, {
- onValue: (value) => (rows = value),
- }),
- );
- });
-
- expect(usePlayerStore.getState().isPlaying).toBe(true);
- expect(rows?.map((row) => row.domId ?? row.id)).toEqual(["scene", "headline"]);
-
- act(() => root.unmount());
- });
-
- it("keeps selected elements ahead of active composition auto-expansion", () => {
- const manifest = [
- clip({ id: "scene", start: 0, duration: 6 }),
- clip({ id: "headline", start: 1, duration: 2 }),
- clip({ id: "caption", start: 4, duration: 1 }),
- ];
- const parentMap = new Map([
- ["headline", "scene"],
- ["caption", "scene"],
- ]);
-
- expect(
- resolveTimelineExpansionRawId({
- selectedElementId: "caption",
- currentTime: 1.5,
- manifest,
- parentMap,
- }),
- ).toBe("caption");
- });
-});
-
-describe("buildExpandedElements — collision-free synthetic rows (cross-file lane safety)", () => {
- it("expanded children NEVER share a display track with an unrelated top-level clip", () => {
- // The Deepwork regression: host on track 0 with two children used to put
- // child #2 on integer track 1 — the same lane as index.html#foreign. Lane
- // grouping merges purely by track number, so a gap-close on that "one"
- // lane batch-persisted a foreign file's clip.
- const elements = [
- el({ id: "host", start: 0, duration: 20, track: 0, compositionSrc: "scene.html" }),
- el({ id: "foreign", start: 20, duration: 5, track: 1 }),
- ];
- const manifest = [
- clip({ id: "host", start: 0, duration: 20, compositionSrc: "scene.html" }),
- clip({ id: "c1", start: 0, duration: 5 }),
- clip({ id: "c2", start: 10, duration: 5 }),
- ];
- const parentMap = new Map([
- ["c1", "host"],
- ["c2", "host"],
- ]);
-
- const out = buildExpandedElements(elements, manifest, parentMap, "host", "host");
- const foreign = out.find((e) => e.id === "foreign")!;
- const children = out.filter((e) => e.domId === "c1" || e.domId === "c2");
- expect(children).toHaveLength(2);
- for (const child of children) {
- // No lane sharing with the foreign clip…
- expect(child.track).not.toBe(foreign.track);
- // …and structurally impossible to collide with ANY normalized (integer)
- // lane: synthetic rows are strict fractions under the host's lane.
- expect(Number.isInteger(child.track)).toBe(false);
- expect(child.track).toBeGreaterThan(0);
- expect(child.track).toBeLessThan(1);
- }
- // Distinct ordered rows per child.
- expect(children[0].track).not.toBe(children[1].track);
- });
-
- /**
- * A sub-composition that declares BOTH a group and its members keeps those
- * members out of the flat store entirely — the store holds only the host.
- * So "inherit membership from the flat twin" had nothing to inherit from,
- * and the group produced no timeline row at all, for exactly the case group
- * support was extended to cover. Verified against a real studio session
- * before this test was written: the flat store held three elements (the
- * panel, the sub-comp host and an ungrouped bed) and neither voice.
- */
- it("takes group membership from the DOM child when there is no flat store twin", () => {
- const elements = [
- el({ id: "voices-host", start: 0, duration: 12, compositionSrc: "voices.html" }),
- ];
- const manifest = [
- clip({ id: "voices-host", start: 0, duration: 12, compositionSrc: "voices.html" }),
- ];
- const parentMap = new Map([
- ["voice-1", "voices-host"],
- ["voice-2", "voices-host"],
- ]);
- const domClipChildren = [
- {
- id: "voice-1",
- parentId: "voices-host",
- hostId: "voices-host",
- label: "voice-1",
- stackingContextId: "css:0",
- audioGroup: "voiceover",
- audioGroupLabel: "Voiceover",
- audioGroupVolume: 0.8,
- audioGroupHidden: false,
- },
- {
- id: "voice-2",
- parentId: "voices-host",
- hostId: "voices-host",
- label: "voice-2",
- stackingContextId: "css:0",
- audioGroup: "voiceover",
- audioGroupLabel: "Voiceover",
- audioGroupVolume: 0.8,
- audioGroupHidden: false,
- },
- ];
-
- const out = buildExpandedElements(
- elements,
- manifest,
- parentMap,
- "voices-host",
- "voices-host",
- domClipChildren,
- );
-
- const voices = out.filter((e) => e.domId?.startsWith("voice-"));
- expect(voices).toHaveLength(2);
- for (const voice of voices) {
- expect(voice.audioGroup).toBe("voiceover");
- expect(voice.audioGroupLabel).toBe("Voiceover");
- expect(voice.audioGroupVolume).toBeCloseTo(0.8, 6);
- }
- });
-});
-
-describe("sub-comp child rows never collide with a group anchor", () => {
- /**
- * A group row anchors at exactly `firstMemberTrack - 0.5`. The old child
- * scheme `k / (n + 2)` hit 0.5 dead on for a host with TWO children (2/4),
- * producing a duplicate row key and a duplicated group header.
- */
- it("keeps every child strictly below the host's half-lane", () => {
- for (const childCount of [1, 2, 3, 4, 7]) {
- const fractions = Array.from(
- { length: childCount },
- (_unused, i) => (0.5 * (i + 1)) / (childCount + 1),
- );
- expect(fractions.every((f) => f > 0 && f < 0.5)).toBe(true);
- // Still distinct and ordered, which is what makes them usable as rows.
- expect(new Set(fractions).size).toBe(childCount);
- expect([...fractions].sort((a, b) => a - b)).toEqual(fractions);
- }
- });
-});
diff --git a/packages/studio/src/player/hooks/useExpandedTimelineElements.ts b/packages/studio/src/player/hooks/useExpandedTimelineElements.ts
deleted file mode 100644
index ac4218a2b5..0000000000
--- a/packages/studio/src/player/hooks/useExpandedTimelineElements.ts
+++ /dev/null
@@ -1,460 +0,0 @@
-import { useMemo } from "react";
-import {
- usePlayerStore,
- type TimelineElement,
- type DomClipChild,
- type SubCompositionHostState,
-} from "../store/playerStore";
-import type { ClipManifestClip } from "../lib/playbackTypes";
-import { createTimelineElementFromManifestClip } from "../lib/timelineDOM";
-import { buildTimelineElementKey, splitTimelineElementKey } from "../lib/timelineElementHelpers";
-
-function findTopLevelAncestor(id: string, parentMap: Map<string, string>): string | null {
- let current = parentMap.get(id);
- if (!current) return null;
- const visited = new Set<string>();
- visited.add(id);
- while (parentMap.has(current)) {
- if (visited.has(current)) return current;
- visited.add(current);
- const parent = parentMap.get(current);
- if (!parent) return current;
- current = parent;
- }
- return current;
-}
-
-function resolveRawId(
- selectedId: string | null,
- manifest: ClipManifestClip[],
- parentMap: Map<string, string>,
-): string | null {
- if (!selectedId) return null;
- const rawId = splitTimelineElementKey(selectedId).domId;
- if (parentMap.has(rawId)) return rawId;
- if (parentMap.has(selectedId)) return selectedId;
- const clip = manifest.find((c) => c.label === selectedId || c.label === rawId);
- if (clip?.id && parentMap.has(clip.id)) return clip.id;
- return null;
-}
-
-interface TimelineExpansionRawIdInput {
- selectedElementId: string | null;
- currentTime: number;
- manifest: ClipManifestClip[];
- parentMap: Map<string, string>;
-}
-
-function clipContainsTime(clip: ClipManifestClip, time: number): boolean {
- return Number.isFinite(time) && time >= clip.start && time < clip.start + clip.duration;
-}
-
-/** Half-open containment plus the closing boundary — see the fallback below. */
-function clipTouchesTime(clip: ClipManifestClip, time: number): boolean {
- return Number.isFinite(time) && time >= clip.start && time <= clip.start + clip.duration;
-}
-
-function getActiveParentDepth(id: string, parentMap: Map<string, string>, activeIds: Set<string>) {
- let depth = 0;
- let parent = parentMap.get(id);
- const visited = new Set<string>();
- visited.add(id);
- while (parent) {
- if (visited.has(parent)) return depth;
- visited.add(parent);
- if (activeIds.has(parent)) depth += 1;
- parent = parentMap.get(parent);
- }
- return depth;
-}
-
-function findActiveExpandableCompositionId(
- currentTime: number,
- manifest: ClipManifestClip[],
- parentMap: Map<string, string>,
-): string | null {
- const parentIds = new Set(parentMap.values());
- const collect = (matches: (clip: ClipManifestClip, time: number) => boolean) => {
- const ids = new Set<string>();
- for (const clip of manifest) {
- if (clip.id && parentIds.has(clip.id) && matches(clip, currentTime)) ids.add(clip.id);
- }
- return ids;
- };
- // Clip windows are half-open, so a playhead parked exactly on a clip's end is
- // inside nothing — at the end of the timeline that collapsed every expanded
- // sub-composition row and its keyframe lanes. Only when the strict pass finds
- // nothing do we accept the closing boundary, so a playhead landing on the seam
- // between two adjacent clips still expands the one that is starting.
- const strict = collect(clipContainsTime);
- const activeIds = strict.size > 0 ? strict : collect(clipTouchesTime);
- let bestId: string | null = null;
- let bestDepth = -1;
- for (const id of activeIds) {
- const depth = getActiveParentDepth(id, parentMap, activeIds);
- if (depth <= bestDepth) continue;
- bestId = id;
- bestDepth = depth;
- }
- return bestId;
-}
-
-export function resolveTimelineExpansionRawId({
- selectedElementId,
- currentTime,
- manifest,
- parentMap,
-}: TimelineExpansionRawIdInput): string | null {
- const selectedRawId = resolveRawId(selectedElementId, manifest, parentMap);
- if (selectedRawId) return selectedRawId;
- return findActiveExpandableCompositionId(currentTime, manifest, parentMap);
-}
-
-function filterToTopLevel(
- elements: TimelineElement[],
- parentMap: Map<string, string>,
-): TimelineElement[] {
- if (parentMap.size === 0) return elements;
- return elements.filter((el) => !parentMap.has(el.domId ?? el.id));
-}
-
-function clampChildToParent(
- child: ClipManifestClip,
- parentStart: number,
- parentEnd: number,
-): { start: number; duration: number } | null {
- const childEnd = child.start + child.duration;
- if (child.start >= parentEnd || childEnd <= parentStart) return null;
- const clampedStart = Math.max(child.start, parentStart);
- const clampedDuration = Math.min(childEnd, parentEnd) - clampedStart;
- return clampedDuration > 0 ? { start: clampedStart, duration: clampedDuration } : null;
-}
-
-interface DisplayBounds {
- start: number;
- end: number;
- track: number;
-}
-
-/**
- * Audio-group membership for an expanded child, from whichever source has it.
- *
- * The flat store twin when there is one; otherwise the `DomClipChild` record,
- * which carried it off the live element during the DOM walk. That fallback is
- * the ONLY source for a sub-composition that declares both a group and its
- * members: those members never enter the flat store, so "inherit from the flat
- * twin" silently produced no membership and therefore no group row — for
- * exactly the case group support was extended to cover.
- */
-function childGroupState(
- flat: TimelineElement | undefined,
- domChild: DomClipChild | undefined,
-): Partial<TimelineElement> {
- const source = flat?.audioGroup ? flat : domChild?.audioGroup ? domChild : null;
- if (!source) return {};
- return {
- audioGroup: source.audioGroup,
- audioGroupLabel: source.audioGroupLabel,
- audioGroupVolume: source.audioGroupVolume,
- audioGroupHidden: source.audioGroupHidden,
- audioGroupFxChain: source.audioGroupFxChain,
- audioGroupAutomation: source.audioGroupAutomation,
- };
-}
-
-/**
- * State that lives on the live host element, not in the clip manifest:
- * `data-hidden`, `data-timeline-locked`, `data-timeline-role`, `data-fx-chain`,
- * `data-automation`. A child row is built from a manifest clip with no hostEl to
- * read, so createTimelineElementFromManifestClip cannot see any of it.
- *
- * `live` is the reading taken off the element itself and is authoritative. For a
- * child of a REAL sub-composition it is also the only source: such a clip is
- * filtered out of the manifest before the flat store is built, so no twin exists
- * to inherit from. The flat twin still covers the phantom-wrapper case, where
- * the child does keep a store entry of its own.
- *
- * Without a reading of the element, the eye on an expanded child always reported
- * the row visible, so clicking it wrote data-hidden again instead of removing
- * it, and a hidden child could never be shown again (not even after a reload,
- * since the attribute is in the source). Missing fxChain and automation, an
- * audio child inside a sub-composition reserved no automation height and drew no
- * lanes, while the property panel, which reads the live DOM selection rather
- * than this row, still showed the chain and its toggles.
- */
-function hostElementState(
- flat: TimelineElement | undefined,
- live: SubCompositionHostState | undefined,
-): Partial<TimelineElement> {
- if (!flat) return { ...live };
- const { hidden, timelineLocked, timelineRole, fxChain, automation } = flat;
- // `live` last: it is the reading off the element, so it wins wherever it has one.
- return { hidden, timelineLocked, timelineRole, fxChain, automation, ...live };
-}
-
-// `display` bounds come from the top-level scene clip (where the expanded row is
-// drawn). `editBasis` comes from the child's immediate sub-comp host: its absolute
-// start anchors local-time edits and its compositionSrc is the file edits write to.
-// They differ only for sub-comp-inside-sub-comp nesting.
-function buildChildElements(
- siblings: ClipManifestClip[],
- display: DisplayBounds,
- editBasis: { start: number; sourceFile: string | undefined },
- expandedHostKey: string,
- elements: readonly TimelineElement[],
- domChildrenById: ReadonlyMap<string, DomClipChild>,
- hostStateById: ReadonlyMap<string, SubCompositionHostState>,
-): TimelineElement[] {
- const result: TimelineElement[] = [];
- for (const child of siblings) {
- const clamped = clampChildToParent(child, display.start, display.end);
- if (!clamped) continue;
- const base = createTimelineElementFromManifestClip({
- clip: child,
- fallbackIndex: result.length,
- });
- const domId = child.id ?? undefined;
- const selector = child.id ? `#${child.id}` : undefined;
- // `base.key` was built without a hostEl, so it fell back to the colon form
- // (`index.html:<id>:<idx>`) even though we set domId below. Recompute it from
- // the same inputs the store uses (`<sourceFile>#<domId>`) so an expanded
- // child shares one identity with its flat store element — otherwise selecting
- // it sets `selectedElementId` to the store's hash key while the rendered row
- // is keyed by the colon form, and `isSelected` never matches (no highlight).
- const key = buildTimelineElementKey({
- id: base.id,
- fallbackIndex: result.length,
- domId,
- selector,
- selectorIndex: base.selectorIndex,
- sourceFile: editBasis.sourceFile,
- });
- result.push({
- ...base,
- ...hostElementState(
- elements.find((element) => element.key === key),
- domId ? hostStateById.get(domId) : undefined,
- ),
- ...childGroupState(
- elements.find((element) => element.key === key),
- domId ? domChildrenById.get(domId) : undefined,
- ),
- key,
- start: clamped.start,
- duration: clamped.duration,
- // `track` becomes a synthetic display row under the expanded host, but the
- // factory-set `authoredTrack` (the child's data-track-index in ITS OWN
- // file's coordinate space) and the runtime-computed `stackingContextId`
- // must survive verbatim — lane persists and z-sync read them, they are
- // never reconstructed from display lanes.
- //
- // COLLISION-FREE synthetic rows: the old `display.track + index` scheme
- // could equal a REAL clip's integer lane (host on track 0 with two
- // children puts child #2 on track 1 — where an unrelated top-level clip
- // may live). Lane grouping merges purely by track number, so that
- // collision fused clips from DIFFERENT source files into one display
- // lane, and lane-scoped actions (gap close) then batch-persisted foreign
- // clips. Fractions strictly between the host's lane and the next integer
- // can never equal a normalized (integer) lane, while still rendering the
- // children as their own ordered rows directly under the host.
- //
- // Confined to the LOWER half of that gap, because a GROUP row anchors at
- // exactly `firstMemberTrack - 0.5` (`useTimelineTrackDerivations`) — and
- // the old `k / (n + 2)` hit 0.5 dead on for a host with two children
- // (2/4), producing a duplicate row key and a duplicated group header. This
- // scheme's maximum is `0.5 * n / (n + 1)`, strictly under 0.5 for every n.
- track: display.track + (0.5 * (result.length + 1)) / (siblings.length + 1),
- authoredTrack: base.authoredTrack,
- stackingContextId: base.stackingContextId,
- expandedParentStart: editBasis.start,
- expandedHostKey,
- domId,
- selector,
- sourceFile: editBasis.sourceFile,
- timingSource: "authored",
- });
- }
- return result;
-}
-
-// Sub-comp DOM children (groups/pills) aren't manifest clips and have no timing
-// of their own — they're "always on" within their sub-comp host, so synthesize
-// clips spanning the host's full bounds. The host element supplies start/duration
-// and the composition file edits write to.
-function domSiblingClips(
- domClipChildren: DomClipChild[],
- siblingParentId: string,
- host: {
- id: string | null;
- start: number;
- duration: number;
- track: number;
- compositionSrc?: string | null;
- },
-): ClipManifestClip[] {
- return domClipChildren
- .filter((c) => c.parentId === siblingParentId)
- .map(
- (c): ClipManifestClip => ({
- id: c.id,
- label: c.label,
- start: host.start,
- duration: host.duration,
- track: host.track,
- kind: "element",
- tagName: null,
- compositionId: null,
- parentCompositionId: host.id ?? null,
- compositionSrc: host.compositionSrc ?? null,
- assetUrl: null,
- stackingContextId: c.stackingContextId,
- }),
- );
-}
-
-// Exported for tests.
-export function buildExpandedElements(
- elements: TimelineElement[],
- manifest: ClipManifestClip[],
- parentMap: Map<string, string>,
- topLevelId: string,
- siblingParentId: string,
- domClipChildren: DomClipChild[] = [],
- subCompositionHostState: ReadonlyMap<string, SubCompositionHostState> = new Map(),
-): TimelineElement[] {
- const topLevelElement = elements.find((el) => el.id === topLevelId || el.domId === topLevelId);
- if (!topLevelElement) return filterToTopLevel(elements, parentMap);
-
- // The sub-comp host the children actually live in: top-level host for 1-level
- // nesting, a nested host for deeper nesting. Its start/file anchor edits.
- const parentHost = manifest.find((c) => c.id === siblingParentId);
-
- // Prefer real manifest children; fall back to DOM-only sub-comp children
- // (groups/pills) that have no data-start and thus never enter the manifest.
- // Those are synthesized against the host they actually live in, not the
- // top-level element, or every child row reads the whole top-level window.
- const siblings = (() => {
- const fromManifest = manifest.filter(
- (c) => c.id != null && parentMap.get(c.id) === siblingParentId,
- );
- if (fromManifest.length > 0) return fromManifest;
- return domSiblingClips(domClipChildren, siblingParentId, parentHost ?? topLevelElement);
- })();
- if (siblings.length === 0) return filterToTopLevel(elements, parentMap);
-
- const editBasis = {
- start: parentHost?.start ?? topLevelElement.start,
- sourceFile: parentHost?.compositionSrc ?? topLevelElement.compositionSrc ?? undefined,
- };
-
- const parentKey = topLevelElement.key ?? topLevelElement.id;
- const domChildrenById = new Map(domClipChildren.map((child) => [child.id, child]));
- const expanded = buildChildElements(
- siblings,
- {
- start: topLevelElement.start,
- end: topLevelElement.start + topLevelElement.duration,
- track: topLevelElement.track,
- },
- editBasis,
- parentKey,
- elements,
- domChildrenById,
- subCompositionHostState,
- );
- if (expanded.length === 0) return filterToTopLevel(elements, parentMap);
-
- // Every host between the drilled one and the top level owns a row, so the
- // drill has to spare all of them, not just the top. A middle host is still a
- // host: dropping its row drops its keyframe lane with it.
- const drillPath = new Set<string>();
- for (let cursor: string | undefined = siblingParentId; cursor; ) {
- if (drillPath.has(cursor)) break;
- drillPath.add(cursor);
- if (cursor === topLevelId) break;
- cursor = parentMap.get(cursor);
- }
- // Children hang under the DEEPEST host on that path, so anchor them there
- // when it has a row of its own and fall back to the top-level row when it
- // does not (a host that lives only in the manifest never had one).
- const anchorsChildren = (el: TimelineElement): boolean =>
- drillPath.has(siblingParentId) && elements.some((e) => (e.domId ?? e.id) === siblingParentId)
- ? (el.domId ?? el.id) === siblingParentId
- : (el.key ?? el.id) === parentKey;
-
- // ADDITIVE drill-in: the host row stays and its children are appended under
- // it. Expansion is also triggered by the playhead alone (active auto-expand),
- // so substituting the host row made it vanish on an ordinary seek, and with
- // it the host's keyframe lane, since diamonds render per row from
- // `keyframeCache.get(elementKey)`. The synthetic fractional lanes above sit
- // strictly between the host's lane and the next integer, so the children have
- // their own rows without the host having to give up its own.
- return elements
- .filter(
- (el) =>
- (el.key ?? el.id) === parentKey ||
- drillPath.has(el.domId ?? el.id) ||
- !parentMap.has(el.domId ?? el.id),
- )
- .flatMap((el) => (anchorsChildren(el) ? [el, ...expanded] : [el]));
-}
-
-export function useExpandedTimelineElements(): TimelineElement[] {
- const elements = usePlayerStore((s) => s.elements);
- const clipManifest = usePlayerStore((s) => s.clipManifest);
- const clipParentMap = usePlayerStore((s) => s.clipParentMap);
- const domClipChildren = usePlayerStore((s) => s.domClipChildren);
- const subCompositionHostState = usePlayerStore((s) => s.subCompositionHostState);
- const selectedElementId = usePlayerStore((s) => s.selectedElementId);
- const currentTime = usePlayerStore((s) => s.currentTime);
-
- // Resolve which raw clip drives expansion from the store's committed playhead
- // time. The RAF loop keeps live time out of React and Zustand during playback,
- // so this target deliberately stays stable until the loop commits or a seek /
- // pause updates the store. The scan re-runs on scrub ticks, but its RESULT only
- // changes when the playhead crosses a composition boundary. Keying the expensive
- // build below on these ids (not raw currentTime) avoids re-allocating
- // expandedElements — and cascading TimelineClip re-renders — on every tick.
- const { rawId, selectedRawId } = useMemo(() => {
- if (!clipManifest || clipManifest.length === 0 || clipParentMap.size === 0) {
- return { rawId: null as string | null, selectedRawId: null as string | null };
- }
- return {
- rawId: resolveTimelineExpansionRawId({
- selectedElementId,
- currentTime,
- manifest: clipManifest,
- parentMap: clipParentMap,
- }),
- selectedRawId: resolveRawId(selectedElementId, clipManifest, clipParentMap),
- };
- }, [clipManifest, clipParentMap, selectedElementId, currentTime]);
-
- return useMemo(() => {
- if (!clipManifest || clipManifest.length === 0 || clipParentMap.size === 0) {
- return elements;
- }
- if (!rawId) return filterToTopLevel(elements, clipParentMap);
-
- const immediateParent = selectedRawId ? clipParentMap.get(rawId) : rawId;
- if (!immediateParent) return filterToTopLevel(elements, clipParentMap);
- const topLevel = findTopLevelAncestor(rawId, clipParentMap) ?? immediateParent;
- return buildExpandedElements(
- elements,
- clipManifest,
- clipParentMap,
- topLevel,
- immediateParent,
- domClipChildren,
- subCompositionHostState,
- );
- }, [
- elements,
- clipManifest,
- clipParentMap,
- domClipChildren,
- subCompositionHostState,
- rawId,
- selectedRawId,
- ]);
-}
diff --git a/packages/studio/src/player/hooks/useTimelinePlayer.test.ts b/packages/studio/src/player/hooks/useTimelinePlayer.test.ts
index 81830f1c21..b45c46d0c8 100644
--- a/packages/studio/src/player/hooks/useTimelinePlayer.test.ts
+++ b/packages/studio/src/player/hooks/useTimelinePlayer.test.ts
@@ -330,34 +330,17 @@ describe("findTimelineDomNodeForClip", () => {
});
describe("anonymous timeline identity", () => {
- it("adds root-level untimed DOM layers as implicit full-duration layers", () => {
+ it("does not invent rows for root-level untimed wrappers", () => {
const doc = createDocument(`
<div data-composition-id="compare" data-start="0" data-duration="18">
- <link rel="stylesheet" href="styles.css" />
- <div class="scene-shell">
- <div class="topline">Title</div>
- </div>
+ <div class="scene-shell"><div class="topline">Title</div></div>
<video id="main-video" class="clip main-video" data-start="0" data-duration="18" data-track-index="1"></video>
- <script></script>
</div>
`);
const elements = parseTimelineFromDOM(doc, 18);
- expect(elements).toEqual(
- expect.arrayContaining([
- expect.objectContaining({
- duration: 18,
- label: "Scene Shell",
- selector: ".scene-shell",
- start: 0,
- tag: "div",
- timingSource: "implicit",
- }),
- ]),
- );
- expect(elements.find((element) => element.tag === "link")).toBeUndefined();
- expect(elements.find((element) => element.tag === "script")).toBeUndefined();
+ expect(elements.map((element) => element.tag)).toEqual(["video"]);
});
it("keeps fallback-parsed anonymous clips distinct when labels match", () => {
diff --git a/packages/studio/src/player/hooks/useTimelineRowElements.test.ts b/packages/studio/src/player/hooks/useTimelineRowElements.test.ts
new file mode 100644
index 0000000000..a0664e5cd5
--- /dev/null
+++ b/packages/studio/src/player/hooks/useTimelineRowElements.test.ts
@@ -0,0 +1,28 @@
+import { describe, expect, it } from "vitest";
+import type { TimelineElement } from "../store/playerStore";
+import { selectTimelineRowElements } from "./useTimelineRowElements";
+
+const el = (id: string, domId?: string): TimelineElement => ({
+ id,
+ domId,
+ start: 0,
+ duration: 1,
+ track: 0,
+ tag: "div",
+});
+
+describe("selectTimelineRowElements", () => {
+ it("drops an element the shared definition does not call top-level", () => {
+ const rows = selectTimelineRowElements([el("a", "a"), el("b", "b")], new Set(["a"]));
+ expect(rows.map((r) => r.id)).toEqual(["a"]);
+ });
+
+ it("keeps everything until the document has been read", () => {
+ const all = [el("a", "a"), el("b", "b")];
+ expect(selectTimelineRowElements(all, null)).toBe(all);
+ });
+
+ it("keeps an element with no DOM id", () => {
+ expect(selectTimelineRowElements([el("k")], new Set())).toHaveLength(1);
+ });
+});
diff --git a/packages/studio/src/player/hooks/useTimelineRowElements.ts b/packages/studio/src/player/hooks/useTimelineRowElements.ts
new file mode 100644
index 0000000000..beae7fa591
--- /dev/null
+++ b/packages/studio/src/player/hooks/useTimelineRowElements.ts
@@ -0,0 +1,17 @@
+import { useMemo } from "react";
+import { usePlayerStore, type TimelineElement } from "../store/playerStore";
+
+/** Rows are the ids `topLevelElements` names, as the lint does; id-less ones are kept. */
+export function selectTimelineRowElements(
+ elements: TimelineElement[],
+ topLevelIds: ReadonlySet<string> | null,
+): TimelineElement[] {
+ if (!topLevelIds) return elements;
+ return elements.filter((el) => el.domId === undefined || topLevelIds.has(el.domId));
+}
+
+export function useTimelineRowElements(): TimelineElement[] {
+ const elements = usePlayerStore((s) => s.elements);
+ const topLevelIds = usePlayerStore((s) => s.topLevelIds);
+ return useMemo(() => selectTimelineRowElements(elements, topLevelIds), [elements, topLevelIds]);
+}
diff --git a/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx
new file mode 100644
index 0000000000..c039a6690a
--- /dev/null
+++ b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx
@@ -0,0 +1,41 @@
+// @vitest-environment happy-dom
+
+import React, { act } from "react";
+import { createRoot } from "react-dom/client";
+import { describe, expect, it, vi } from "vitest";
+import type { TimelineElement } from "../store/playerStore";
+import { useTimelineSyncCallbacks } from "./useTimelineSyncCallbacks";
+
+(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe("processTimelineMessage with an empty manifest", () => {
+ it("commits zero rows without adopting the runtime 1s floor as the duration", () => {
+ const sync = vi.fn<(els: TimelineElement[], duration?: number) => void>();
+ let processTimelineMessage: ReturnType<
+ typeof useTimelineSyncCallbacks
+ >["processTimelineMessage"];
+ function Harness() {
+ ({ processTimelineMessage } = useTimelineSyncCallbacks({
+ iframeRef: { current: null },
+ probeIntervalRef: { current: undefined },
+ pendingSeekRef: { current: null },
+ isRefreshingRef: { current: false },
+ getAdapter: () => null,
+ syncTimelineElements: sync,
+ setDuration: () => {},
+ setCurrentTime: () => {},
+ requestTimelineReady: () => {},
+ setIsPlaying: () => {},
+ attachIframeShortcutListeners: () => {},
+ applyPreviewAudioState: () => {},
+ }));
+ return null;
+ }
+ const host = document.createElement("div");
+ act(() => createRoot(host).render(<Harness />));
+
+ processTimelineMessage!({ clips: [], durationInFrames: 30 });
+
+ expect(sync).toHaveBeenCalledWith([], undefined);
+ });
+});
diff --git a/packages/studio/src/player/hooks/useTimelineSyncCallbacks.ts b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.ts
index 31e6b76617..b3bc33b341 100644
--- a/packages/studio/src/player/hooks/useTimelineSyncCallbacks.ts
+++ b/packages/studio/src/player/hooks/useTimelineSyncCallbacks.ts
@@ -17,7 +17,9 @@ import { buildMissingCompositionElements } from "../lib/timelineIframeHelpers";
import { acceptedRuntimeMessageFps } from "../lib/runtimeProtocol";
import {
buildTimelineElementsFromClips,
+ syncManifestTimeline,
clipTreeParentMap,
+ collectTopLevelElementIds,
collectSubCompositionDomChildren,
collectSubCompositionHostState,
hydrateTimelineFromPreview,
@@ -26,7 +28,6 @@ import {
sanitizeDurationSeconds,
seekAdapterToRestorePoint,
syncAdapterDuration,
- withImplicitDomLayers,
type RuntimeTimelineMessage,
} from "./timelineSyncHydration";
@@ -114,9 +115,7 @@ export function useTimelineSyncCallbacks({
// Convert a runtime timeline message (from iframe postMessage) into TimelineElements
const processTimelineMessage = useCallback(
(data: RuntimeTimelineMessage) => {
- if (!data.clips || data.clips.length === 0) {
- return;
- }
+ if (!data.clips) return;
usePlayerStore.getState().setClipManifest(data.clips);
@@ -131,11 +130,13 @@ export function useTimelineSyncCallbacks({
const parentMap = clipTreeParentMap(iframeRef.current?.contentWindow ?? null);
const domClipChildren = collectSubCompositionDomChildren(iframeDoc, data.clips, parentMap);
usePlayerStore.getState().setClipParentMap(parentMap);
+ usePlayerStore.getState().setTopLevelIds(collectTopLevelElementIds(iframeDoc));
usePlayerStore.getState().setDomClipChildren(domClipChildren);
usePlayerStore
.getState()
.setSubCompositionHostState(collectSubCompositionHostState(iframeDoc, data.clips));
} catch {
+ usePlayerStore.getState().setTopLevelIds(null);
// cross-origin or __clipTree not available — maps stay empty
}
@@ -150,14 +151,12 @@ export function useTimelineSyncCallbacks({
manifestDurationSeconds: data.durationInFrames / acceptedRuntimeMessageFps(data),
authoredRootDurationSeconds: readTimelineDurationFromDocument(iframeDoc),
});
- const timelineEls = withImplicitDomLayers(
+ syncManifestTimeline(
els,
- iframeDoc,
- newDuration > 0 ? newDuration : usePlayerStore.getState().duration,
+ newDuration,
+ usePlayerStore.getState().duration,
+ syncTimelineElements,
);
- if (timelineEls.length > 0) {
- syncTimelineElements(timelineEls, newDuration > 0 ? newDuration : undefined);
- }
},
[iframeRef, syncTimelineElements],
);
diff --git a/packages/studio/src/player/lib/timelineDOM.test.ts b/packages/studio/src/player/lib/timelineDOM.test.ts
index b33c81244b..4e47b7450d 100644
--- a/packages/studio/src/player/lib/timelineDOM.test.ts
+++ b/packages/studio/src/player/lib/timelineDOM.test.ts
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest";
import {
createTimelineElementFromManifestClip,
parseTimelineFromDOM,
- createImplicitTimelineLayersFromDOM,
mergeTimelineElementsPreservingDowngrades,
} from "./timelineDOM";
import { isTimelineIgnoredElement } from "./timelineElementHelpers";
@@ -302,19 +301,6 @@ describe("createTimelineElementFromManifestClip — source-scoped selector ident
// implicit-layer fallback happily gave it a track. Draggable and trimmable, and
// writing timing onto a bus means nothing.
describe("<hf-audio-group> is not a timeline layer", () => {
- it("gets no implicit row of its own", () => {
- const doc = makeDoc(`
- <div data-composition-id="root">
- <audio id="voice-1" data-start="0" data-duration="6" data-audio-group="voiceover"></audio>
- <hf-audio-group id="voiceover" data-label="Voiceover"></hf-audio-group>
- </div>
- `);
-
- const implicit = createImplicitTimelineLayersFromDOM(doc, 12, []);
-
- expect(implicit.map((el) => el.domId)).not.toContain("voiceover");
- });
-
it("is excluded by the shared ignore predicate", () => {
const doc = makeDoc(`<hf-audio-group id="vo"></hf-audio-group><div id="panel"></div>`);
expect(isTimelineIgnoredElement(doc.getElementById("vo") as Element)).toBe(true);
@@ -322,72 +308,6 @@ describe("<hf-audio-group> is not a timeline layer", () => {
});
});
-describe("createImplicitTimelineLayersFromDOM — hfId from data-hf-id", () => {
- it("uses the runtime root paint scope for implicit siblings of manifest clips", () => {
- const doc = makeDoc(`
- <div data-composition-id="root">
- <div id="timed" data-start="0" data-duration="5"></div>
- <div id="implicit"></div>
- </div>
- `);
- const timedHost = doc.getElementById("timed");
- const timed = createTimelineElementFromManifestClip({
- clip: {
- id: "timed",
- label: "Timed",
- start: 0,
- duration: 5,
- track: 0,
- stackingContextId: "css:root",
- kind: "element",
- tagName: "div",
- compositionId: null,
- parentCompositionId: null,
- compositionSrc: null,
- assetUrl: null,
- },
- fallbackIndex: 0,
- doc,
- hostEl: timedHost,
- });
- const implicit = createImplicitTimelineLayersFromDOM(doc, 5, [timed])[0];
-
- expect(implicit?.stackingContextId).toBe("css:root");
- expect(implicit?.stackingContextId).toBe(timed.stackingContextId);
- });
-
- it("harvests hfId from an implicit layer child that has data-hf-id", () => {
- const doc = makeDoc(`
- <div data-composition-id="root">
- <div id="layer" class="clip" data-hf-id="hf-xyz789"></div>
- </div>
- `);
-
- const layers = createImplicitTimelineLayersFromDOM(doc, 10);
- const layer = layers.find((el) => el.domId === "layer");
-
- expect(layer).toBeDefined();
- expect(layer?.hfId).toBe("hf-xyz789");
- });
-
- it("ignores runtime-owned color grading canvases as implicit layers", () => {
- const doc = makeDoc(`
- <div data-composition-id="root" data-duration="5">
- <img id="photo" class="clip" data-start="0" data-duration="5" />
- <canvas
- class="__hf_color_grading_canvas__"
- data-hf-color-grading-canvas="true"
- data-hyperframes-ignore
- ></canvas>
- </div>
- `);
-
- const layers = createImplicitTimelineLayersFromDOM(doc, 5);
-
- expect(layers).toEqual([]);
- });
-});
-
describe("mergeTimelineElementsPreservingDowngrades — genuine removal vs transient downgrade", () => {
it("drops a removed TOP-LEVEL element (undo of a split) instead of ghosting it", () => {
const current = [el("a"), el("a-split")]; // post-split store: original + clone
diff --git a/packages/studio/src/player/lib/timelineDOM.ts b/packages/studio/src/player/lib/timelineDOM.ts
index 0131ffe604..6b8748c7f1 100644
--- a/packages/studio/src/player/lib/timelineDOM.ts
+++ b/packages/studio/src/player/lib/timelineDOM.ts
@@ -17,8 +17,6 @@ import {
resolveMediaElement,
applyMediaMetadataFromElement,
getTimelineElementDisplayLabel,
- getImplicitTimelineLayerLabel,
- isImplicitTimelineLayerCandidate,
getTimelineElementSelector,
getTimelineElementSourceFile,
getTimelineElementSelectorIndex,
@@ -203,63 +201,6 @@ export function createTimelineElementFromManifestClip(params: {
return entry;
}
-export function createImplicitTimelineLayersFromDOM(
- doc: Document,
- rootDuration: number,
- existingElements: readonly TimelineElement[] = [],
-): TimelineElement[] {
- if (!Number.isFinite(rootDuration) || rootDuration <= 0) return [];
- const rootComp = doc.querySelector("[data-composition-id]");
- if (!rootComp) return [];
-
- const existingKeys = new Set(existingElements.map(getTimelineElementIdentity));
- const maxTrack = existingElements.reduce(
- (max, element) => Math.max(max, Number.isFinite(element.track) ? element.track : 0),
- -1,
- );
- const layers: TimelineElement[] = [];
-
- for (const child of Array.from(rootComp.children)) {
- if (!isImplicitTimelineLayerCandidate(rootComp, child)) continue;
-
- const selector = getTimelineElementSelector(child);
- if (!selector) continue;
- const selectorIndex = getTimelineElementSelectorIndex(doc, child, selector);
- const sourceFile = getTimelineElementSourceFile(child);
- const label = getImplicitTimelineLayerLabel(child);
- const identity = buildTimelineElementIdentity({
- preferredId: child.id || null,
- label,
- fallbackIndex: existingElements.length + layers.length,
- domId: child.id || undefined,
- selector,
- selectorIndex,
- sourceFile,
- });
- if (existingKeys.has(identity.key) || existingKeys.has(identity.id)) continue;
-
- layers.push({
- domId: child.id || undefined,
- hfId: child.getAttribute("data-hf-id") || undefined,
- zIndex: readTimelineElementZIndex(child),
- duration: rootDuration,
- id: identity.id,
- key: identity.key,
- label,
- selector,
- selectorIndex,
- sourceFile,
- stackingContextId: resolveCssStackingContextId(child),
- start: 0,
- tag: child.tagName.toLowerCase(),
- timingSource: "implicit",
- track: maxTrack + 1 + layers.length,
- });
- }
-
- return layers;
-}
-
/**
* Parse [data-start] elements from a Document into TimelineElement[].
* Shared helper — used by onIframeLoad fallback, handleMessage, and enrichMissingCompositions.
@@ -330,7 +271,6 @@ export function parseTimelineFromDOM(doc: Document, rootDuration: number): Timel
selectorIndex,
sourceFile,
stackingContextId: resolveCssStackingContextId(el),
- timingSource: "authored",
zIndex: readTimelineElementZIndex(el),
};
@@ -399,7 +339,7 @@ export function parseTimelineFromDOM(doc: Document, rootDuration: number): Timel
els.push(entry);
});
- return [...els, ...createImplicitTimelineLayersFromDOM(doc, rootDuration, els)];
+ return els;
}
// ---------------------------------------------------------------------------
diff --git a/packages/studio/src/player/lib/timelineElementHelpers.ts b/packages/studio/src/player/lib/timelineElementHelpers.ts
index f4983c7aa7..33ade8655a 100644
--- a/packages/studio/src/player/lib/timelineElementHelpers.ts
+++ b/packages/studio/src/player/lib/timelineElementHelpers.ts
@@ -2,7 +2,7 @@
* Low-level helpers for building and identifying TimelineElement objects.
*
* Covers: duration reading, media-element metadata extraction, selector/key/
- * identity builders, DOM node lookup, and implicit layer detection. These are
+ * identity builders, and DOM node lookup. These are
* intentionally dependency-free (no store, no hooks) so they can be used in
* both the React hook and test environments.
*/
@@ -82,13 +82,7 @@ function normalizePlaybackRate(raw: number): number {
}
export function isTimelineIgnoredElement(el: Element): boolean {
- // An `<hf-audio-group>` is a mixer bus, not a clip: it carries the group's
- // label, fader, mute and FX chain, has no timing of its own, and is drawn as
- // a GROUP ROW by the group derivation. Left in, the implicit-layer fallback
- // also gave it an ordinary full-duration track — so a grouped composition
- // showed "Voiceover • 0.0s – 12.0s" as a phantom clip directly above the real
- // group header. Harmless-looking, but that row is draggable and trimmable,
- // and writing timing onto the bus is meaningless.
+ // An `<hf-audio-group>` is a mixer bus with no timing of its own, drawn as a group row, never a clip.
if (el.tagName.toLowerCase() === HF_AUDIO_GROUP_TAG) return true;
return Boolean(
el.closest(
@@ -223,37 +217,6 @@ export function getTimelineElementDisplayLabel(input: {
return tag ? `${tag} clip` : "Timeline clip";
}
-const IMPLICIT_TIMELINE_LAYER_SKIP_TAGS = new Set([
- "base",
- "link",
- "meta",
- "noscript",
- "script",
- "style",
- "template",
-]);
-
-function humanizeTimelineIdentifier(value: string): string {
- return value
- .trim()
- .replace(/[_-]+/g, " ")
- .replace(/\s+/g, " ")
- .replace(/\b\w/g, (match) => match.toUpperCase());
-}
-
-export function getImplicitTimelineLayerLabel(el: HTMLElement): string {
- const explicitLabel =
- el.getAttribute("data-timeline-label") ??
- el.getAttribute("data-label") ??
- el.getAttribute("aria-label");
- if (explicitLabel?.trim()) return explicitLabel.trim();
- if (el.id.trim()) return humanizeTimelineIdentifier(el.id);
- const classes = el.className.split(/\s+/).filter(Boolean);
- const className = classes.find((value) => value !== "clip") ?? classes[0];
- if (className) return humanizeTimelineIdentifier(className);
- return getTimelineElementDisplayLabel({ tag: el.tagName });
-}
-
// ---------------------------------------------------------------------------
// Selector / identity / key builders
// ---------------------------------------------------------------------------
@@ -475,17 +438,3 @@ export function createTimelineDomNodeResolver(doc: Document) {
return node;
};
}
-
-// ---------------------------------------------------------------------------
-// Implicit layer detection
-// ---------------------------------------------------------------------------
-
-export function isImplicitTimelineLayerCandidate(root: Element, el: Element): el is HTMLElement {
- if (!isHtmlElement(el)) return false;
- if (isTimelineIgnoredElement(el)) return false;
- if (el.parentElement !== root) return false;
- const tagName = el.tagName.toLowerCase();
- if (IMPLICIT_TIMELINE_LAYER_SKIP_TAGS.has(tagName)) return false;
- if (el.hasAttribute("data-start") || el.hasAttribute("data-track-index")) return false;
- return Boolean(getTimelineElementSelector(el));
-}
diff --git a/packages/studio/src/player/store/playerStore.ts b/packages/studio/src/player/store/playerStore.ts
index 0ee7ee3af2..636c182b40 100644
--- a/packages/studio/src/player/store/playerStore.ts
+++ b/packages/studio/src/player/store/playerStore.ts
@@ -200,6 +200,8 @@ interface PlayerState extends PlayerStoreSlices {
clipManifest: ClipManifestClip[] | null;
setClipManifest: (clips: ClipManifestClip[] | null) => void;
clipParentMap: Map<string, string>;
+ topLevelIds: ReadonlySet<string> | null;
+ setTopLevelIds: (ids: ReadonlySet<string> | null) => void;
setClipParentMap: (map: Map<string, string>) => void;
/**
* Sub-composition DOM descendants (groups + their children) that have no
@@ -288,6 +290,7 @@ export function createTimelineResetState() {
beatPersist: null,
clipManifest: null,
clipParentMap: new Map<string, string>(),
+ topLevelIds: null,
domClipChildren: [],
subCompositionHostState: new Map<string, SubCompositionHostState>(),
};
@@ -434,6 +437,8 @@ export const usePlayerStore = create<PlayerState>((set, get) => ({
setClipManifest: (clips) => set({ clipManifest: clips }),
clipParentMap: new Map(),
setClipParentMap: (map) => set({ clipParentMap: map }),
+ topLevelIds: null,
+ setTopLevelIds: (ids) => set({ topLevelIds: ids }),
domClipChildren: [],
setDomClipChildren: (children) => set({ domClipChildren: children }),
subCompositionHostState: new Map(),
diff --git a/packages/studio/src/player/store/timelineElement.ts b/packages/studio/src/player/store/timelineElement.ts
index c38fe7505b..09532bdd58 100644
--- a/packages/studio/src/player/store/timelineElement.ts
+++ b/packages/studio/src/player/store/timelineElement.ts
@@ -59,8 +59,6 @@ export interface TimelineElement {
automation?: string;
/** Path from data-composition-src — identifies sub-composition elements */
compositionSrc?: string;
- /** Whether this row came from authored clip timing or Studio's full-duration layer fallback. */
- timingSource?: "authored" | "implicit";
/** Set by data-timeline-locked on the host element — disables move and trim in Studio. */
timelineLocked?: boolean;
/** Set by data-hidden on the host element — hides the clip in preview and render. */
@@ -79,7 +77,7 @@ export interface TimelineElement {
audioGroupFxChain?: string;
audioGroupAutomation?: string;
/**
- * Set by useExpandedTimelineElements on an inline-expanded sub-composition
+ * Set by useTimelineRowElements on an inline-expanded sub-composition
* child: the absolute master-timeline start of the sub-comp host the child
* lives in. Presence marks the element as expanded; edits subtract it to get
* the child's local (sourceFile-relative) time. Works at any nesting depth.
diff --git a/packages/studio/src/utils/razorSplitTransaction.test.ts b/packages/studio/src/utils/razorSplitTransaction.test.ts
index 53b4676d3c..9e4a2dfebd 100644
--- a/packages/studio/src/utils/razorSplitTransaction.test.ts
+++ b/packages/studio/src/utils/razorSplitTransaction.test.ts
@@ -10,7 +10,6 @@ const element = (over: Partial<TimelineElement> = {}): TimelineElement => ({
start: 0,
duration: 4,
track: 0,
- timingSource: "authored",
sourceFile: "index.html",
...over,
});
diff --git a/packages/studio/src/utils/timelineElementSplit.test.ts b/packages/studio/src/utils/timelineElementSplit.test.ts
index 210c6fc3a9..dd97c8beaa 100644
--- a/packages/studio/src/utils/timelineElementSplit.test.ts
+++ b/packages/studio/src/utils/timelineElementSplit.test.ts
@@ -78,9 +78,8 @@ describe("canSplitElementAt", () => {
).toBe(false);
});
- it("rejects locked and implicit elements while allowing identified compositions", () => {
+ it("rejects locked elements while allowing identified compositions", () => {
expect(canSplitElementAt(element({ timelineLocked: true }), 3)).toBe(false);
- expect(canSplitElementAt(element({ timingSource: "implicit" }), 3)).toBe(false);
expect(
canSplitElementAt(
element({ kind: "composition", compositionSrc: "child.html", playbackRate: 2 }),
diff --git a/packages/studio/src/utils/timelineElementSplit.ts b/packages/studio/src/utils/timelineElementSplit.ts
index c1d483d9d2..61402656d7 100644
--- a/packages/studio/src/utils/timelineElementSplit.ts
+++ b/packages/studio/src/utils/timelineElementSplit.ts
@@ -27,7 +27,6 @@ export function canSplitElement(el: TimelineElement): boolean {
el.playbackRate == null || (Number.isFinite(el.playbackRate) && el.playbackRate > 0);
return (
!el.timelineLocked &&
- el.timingSource !== "implicit" &&
hasStableIdentity &&
hasValidRate &&
!!el.duration &&
diff --git a/scripts/check-no-main-deletions.mjs b/scripts/check-no-main-deletions.mjs
index b366a77441..801645fdd9 100644
--- a/scripts/check-no-main-deletions.mjs
+++ b/scripts/check-no-main-deletions.mjs
@@ -169,6 +169,14 @@ export const ALLOWED_DELETIONS = new Map([
"docs/public/catalog/components/texture-mask-text.json",
"the item's directory exceeds the host budget and now falls back to its recorded video; the stale payload had no <base href> and dead relative asset references, so removing it is the fix, not the regression",
],
+ [
+ "packages/studio/src/player/hooks/useExpandedTimelineElements.ts",
+ "the timeline shows top-level rows only, so the child-row expansion hook is replaced by useTimelineRowElements",
+ ],
+ [
+ "packages/studio/src/player/hooks/useExpandedTimelineElements.test.ts",
+ "tests for the removed child-row expansion hook",
+ ],
]);
export function parseBase(argv, fallback = "origin/main") {