Skip to content

Commit 7797c5e

Browse files
feat(studio): the timeline shows one row per top-level element and no child rows (#4132)
* feat(studio): the timeline shows one row per top-level element and no child rows * test(studio): cover the top-level id collection the timeline rows come from * chore(studio): shorten the row-elements comment * fix(studio): keep implicit layers as rows and say why a nested element cannot be hidden * refactor(studio): drop implicit layers; rows are exactly what topLevelElements returns * test(studio): untimed root wrappers are not timeline rows * fix(studio): an empty timeline message clears the rows; drop the unused implicit contract * fix(studio): an empty clip manifest reaches the timeline and clears the rows * fix(studio): an empty clip manifest does not shrink the transport to its 1s floor * chore(ci): allow deleting the child-row expansion hook and its test
1 parent 63d0ea4 commit 7797c5e

38 files changed

Lines changed: 194 additions & 1592 deletions

‎packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
afterEach(() => {
2525
document.body.innerHTML = "";
2626
// Wrapped in act: mounted harnesses subscribe to the store via
27-
// useExpandedTimelineElements, so the reset re-renders them.
27+
// useTimelineRowElements, so the reset re-renders them.
2828
act(() => usePlayerStore.getState().setElements([]));
2929
});
3030

‎packages/studio/src/components/nle/useCanvasZOrderTimelineMirror.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useRef } from "react";
22
import { usePlayerStore } from "../../player";
3-
import { useExpandedTimelineElements } from "../../player/hooks/useExpandedTimelineElements";
3+
import { useTimelineRowElements } from "../../player/hooks/useTimelineRowElements";
44
import { useTimelineEditContextOptional } from "../../contexts/TimelineEditContext";
55
import {
66
displayTrackOrder,
@@ -41,7 +41,7 @@ export interface MirrorZOrderInput {
4141
* commitZMirrorLaneMove) — the shared key is unique per gesture
4242
* (zReorderCoalesceKey's gesture seq), so the fold stays gesture-scoped.
4343
*
44-
* Element source: `useExpandedTimelineElements()` — the same expanded display
44+
* Element source: `useTimelineRowElements()` — the same expanded display
4545
* set the Timeline renders and the resolver expects (post-normalizeToZones
4646
* lanes, expanded sub-comp children on their synthetic rows). No new expansion
4747
* is built here.
@@ -141,7 +141,7 @@ function useMirrorLaneMoveCommit(): (
141141
coalesceKey: string,
142142
resolveMove: (element: TimelineElement, elements: TimelineElement[]) => ZMirrorLaneMove,
143143
) => Promise<boolean> {
144-
const elements = useExpandedTimelineElements();
144+
const elements = useTimelineRowElements();
145145
const elementsRef = useRef(elements);
146146
elementsRef.current = elements;
147147
const { onMoveElements } = useTimelineEditContextOptional();

‎packages/studio/src/hooks/timelineAudioGroupCreate.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { useCallback } from "react";
1010
import { usePlayerStore, type TimelineElement } from "../player";
11-
import { useExpandedTimelineElements } from "../player/hooks/useExpandedTimelineElements";
11+
import { useTimelineRowElements } from "../player/hooks/useTimelineRowElements";
1212
import { saveProjectFilesWithHistory } from "../utils/studioFileHistory";
1313
import { HF_AUDIO_GROUP_ATTR, HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
1414
import { runtimeAudioId } from "../player/lib/timelineElementHelpers";
@@ -272,7 +272,7 @@ export function useAudioGroupCarveAssignment({
272272
groupId: string,
273273
groupLabel?: string,
274274
) => Promise<void> {
275-
const expandedElements = useExpandedTimelineElements();
275+
const expandedElements = useTimelineRowElements();
276276
return useCallback(
277277
async (clipIds: readonly string[], groupId: string, groupLabel?: string) => {
278278
if (isRecordingRef?.current) {

‎packages/studio/src/hooks/timelineTrackVisibility.ts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback } from "react";
22
import { usePlayerStore, type TimelineElement } from "../player";
33
import { reseekPreviewAtTime } from "../player/hooks/timelineSyncHydration";
4-
import { useExpandedTimelineElements } from "../player/hooks/useExpandedTimelineElements";
4+
import { useTimelineRowElements } from "../player/hooks/useTimelineRowElements";
55
import { applySoftReloadFinalization } from "../utils/gsapSoftReload";
66
import {
77
timelineTrackOrder,
@@ -295,7 +295,7 @@ export function useTimelineTrackVisibilityEditing({
295295
// virtual sub-comp children carry their own (display.track + idx) track numbers,
296296
// so filtering the raw store list by a virtual track number would hide the wrong
297297
// outer-scene sibling sharing that index.
298-
const expandedElements = useExpandedTimelineElements();
298+
const expandedElements = useTimelineRowElements();
299299
return useCallback(
300300
async (track: number, hidden: boolean, displayNumber?: number | null) => {
301301
if (isRecordingRef?.current) {
@@ -354,15 +354,7 @@ export function useTimelineElementVisibilityEditing({
354354
elementKey: string | readonly string[],
355355
hidden: boolean,
356356
) => Promise<void> {
357-
// Resolve against the EXPANDED rows, not the raw store list — a nested
358-
// sub-composition child has no entry of its own in the raw list (only its
359-
// host does), so an elementKey for such a child (the
360-
// `sourceFile#domId`-shaped virtual key `resolveTimelineIdForSelection`
361-
// falls back to) would never match anything there and Hide All would
362-
// silently no-op for it. The expanded list synthesizes a real, patchable
363-
// TimelineElement (with matching key/domId/sourceFile) for each visible
364-
// child whenever its host is currently expanded.
365-
const expandedElements = useExpandedTimelineElements();
357+
const expandedElements = useTimelineRowElements();
366358
return useCallback(
367359
async (elementKey: string | readonly string[], hidden: boolean) => {
368360
if (isRecordingRef?.current) {
@@ -371,6 +363,11 @@ export function useTimelineElementVisibilityEditing({
371363
}
372364
const pid = projectIdRef.current;
373365
if (!pid) return;
366+
const keys = typeof elementKey === "string" ? [elementKey] : elementKey;
367+
if (!expandedElements.some((item) => keys.includes(item.key ?? item.id))) {
368+
showToast("This element is inside a sub-composition and has no timeline row to hide.");
369+
return;
370+
}
374371
try {
375372
await toggleTimelineElementHidden({
376373
projectId: pid,

‎packages/studio/src/hooks/useGroupCommits.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const timelineElement = (over: Partial<TimelineElement> = {}): TimelineElement =
1111
start: 0,
1212
duration: 4,
1313
track: 0,
14-
timingSource: "authored",
1514
sourceFile: "index.html",
1615
...over,
1716
});

‎packages/studio/src/hooks/useRazorSplit.history.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const element: TimelineElement = {
2929
track: 0,
3030
domId: "clip1",
3131
sourceFile: "index.html",
32-
timingSource: "authored",
3332
};
3433

3534
type Split = (element: TimelineElement, splitTime: number) => Promise<void>;

‎packages/studio/src/hooks/useRazorSplit.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const rootElement: TimelineElement = {
2424
track: 0,
2525
domId: "root-clip",
2626
sourceFile: ROOT_FILE,
27-
timingSource: "authored",
2827
};
2928

3029
// An expanded sub-comp child: `start` is in MASTER coordinates (offset by the
@@ -38,7 +37,6 @@ const expandedChild: TimelineElement = {
3837
track: 1,
3938
domId: "child-clip",
4039
sourceFile: SUBCOMP_FILE,
41-
timingSource: "authored",
4240
expandedParentStart: 2,
4341
};
4442

‎packages/studio/src/hooks/useRazorSplit.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe("useRazorSplit mutation versions", () => {
8282
start: 0,
8383
duration: 4,
8484
track: 0,
85-
timingSource: "authored",
8685
},
8786
2,
8887
);

‎packages/studio/src/hooks/useTimelineEditing.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function timelineElement(input: {
8686
parentCompositionId: null,
8787
compositionAncestors: ["root"],
8888
sourceFile: input.sourceFile ?? "index.html",
89-
timingSource: "authored",
9089
};
9190
}
9291

‎packages/studio/src/player/components/Timeline.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useRef, useMemo, useCallback, useState, memo } from "react";
22
import { useAdjustedBeatAnalysis, useMusicBeatAnalysis } from "../../hooks/useMusicBeatAnalysis";
33
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
4-
import { useExpandedTimelineElements } from "../hooks/useExpandedTimelineElements";
4+
import { useTimelineRowElements } from "../hooks/useTimelineRowElements";
55
import { defaultTimelineTheme } from "./timelineTheme";
66
import { useTimelineRangeSelection } from "./useTimelineRangeSelection";
77
import { useTimelinePlayhead } from "./useTimelinePlayhead";
@@ -111,7 +111,7 @@ export const Timeline = memo(function Timeline({
111111
const refreshAfterLaneMove = useTimelineLaneMoveRefresh();
112112
useMusicBeatAnalysis();
113113
const rawElements = usePlayerStore((s) => s.elements);
114-
const expandedElements = useExpandedTimelineElements();
114+
const expandedElements = useTimelineRowElements();
115115
const adjustedBeatAnalysis = useAdjustedBeatAnalysis();
116116
const duration = usePlayerStore((s) => s.duration);
117117
const timeDisplayMode = usePlayerStore((s) => s.timeDisplayMode);

0 commit comments

Comments
 (0)