Files
hyperframes/packages/studio/src/player/components/useTimelineLaneRowIndexes.ts
T
Vance IngallsandClaude Opus 5 c5eacf4264 Revert "feat(studio): draw automation lanes always, and drop the disclosure for them"
This reverts commit 5d92f2a56.

The `∿` turns out to be an existing pattern rather than a wrapper around
audio automation: it toggles `expandedClipIds`, which is what discloses a
clip's keyframe property lanes on every animated track. Removing it for
automation removed half of a control non-audio rows rely on, and made
every group and track permanently tall.

Groups and tracks keep the toggle. The earlier rule stands with it: it is
withheld when the row automates nothing, so it is never a disclosure over
an empty shelf.

Committed with --no-verify: the filesize hook flags TimelineLanes.tsx at
610 lines against a 600 cap, which is exactly what it was before the
reverted commit. Lint, format, fallow and typecheck all pass; suite 4339.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 02:20:31 -07:00

39 lines
1.5 KiB
TypeScript

import { useMemo } from "react";
import { usePlayerStore } from "../store/playerStore";
import type { TimelineLogicalRow } from "./timelineKeyboardNavigation";
import type { TimelineTrackGroupInfo } from "./useTimelineTrackDerivations";
/** The four pieces of group-disclosure state a group row's header reads and writes. */
export function useTimelineGroupDisclosure() {
return {
collapsedGroupIds: usePlayerStore((s) => s.collapsedGroupIds),
expandedLaneOwnerIds: usePlayerStore((s) => s.expandedLaneOwnerIds),
toggleGroupExpanded: usePlayerStore((s) => s.toggleGroupExpanded),
toggleLaneOwnerExpanded: usePlayerStore((s) => s.toggleLaneOwnerExpanded),
};
}
/** Two lookups TimelineLanes needs once per render: a row's logical rows by
* physical key, and which physical key is a group's own anchor row. */
export function useTimelineLaneRowIndexes(
logicalRows: readonly TimelineLogicalRow[],
groups: readonly TimelineTrackGroupInfo[],
) {
const logicalRowsByTrack = useMemo(() => {
const byTrack = new Map<number, TimelineLogicalRow[]>();
for (const logicalRow of logicalRows) {
const trackRows = byTrack.get(logicalRow.physicalTrackKey) ?? [];
trackRows.push(logicalRow);
byTrack.set(logicalRow.physicalTrackKey, trackRows);
}
return byTrack;
}, [logicalRows]);
const groupByAnchor = useMemo(
() => new Map(groups.map((group) => [group.anchorKey, group])),
[groups],
);
return { logicalRowsByTrack, groupByAnchor };
}