Skip to content

Commit 9b18fa7

Browse files
vanceingallsclaude
andauthored
feat(studio): give the clips on a track one automation lane row (#3214)
* fix(ci): allowlist the build-script consolidation in the no-main-deletions guard build-audio-fx-runtime.ts and build-position-edits-render.ts were merged into build-inline-artifact.ts to kill a fallow duplication finding; the deletion guard flagged that as an accidental loss since main still has both originals. * fix(core): dedupe the wet/dry mix math between delayFeedback and chorusLfo Both effect builders set wet.gain to the mix and dry.gain to its complement in identical two-line blocks; fallow kept re-flagging it as a 10-line clone on every unrelated change. Extracted setWetDryMix. * fix(core): remove the build-audio-fx-runtime.ts stray resurrected by a main merge An earlier merge with main brought this deleted file back (git's merge/delete handling on an unchanged-on-one-side file); package.json already points at build-inline-artifact.ts, so it sat unreachable and duplicating that file's config, both of which fallow flagged. * fix(studio): pull TimelineLanes under the 600-line cap TimelineLanes.tsx hit 620 lines. Extracted the three per-clip pointer gestures (resize-start, pointer-down move-arm, click/razor-split) into createClipGestureHandlers — one factory call per rendered clip instead of ~120 lines of inline handler bodies in the render loop. 529 lines now. * fix(studio): split the extracted pointerdown handler under the CRAP threshold Moving the ~120-line gesture logic into timelineClipGestureHandlers.ts concentrated it into two functions fallow flagged (onPointerDown at CRAP 63.6, onResizeStart at 31.6). Split the decision logic (which gesture a pointerdown implies) into a pure resolvePointerDownAction, then split its own intent-blocking check into isIntentBlocked. onResizeStart's guard moved into canStartResize. Every function now scores under 30. * fix(studio): drop the unused DomEditSelection import in PropertyPanelFlat CI caught it on PR #3026 (wa-12-panel-params); a later refactor in the stack removed the last use of the type here without removing the import. * fix(studio): close the typecheck and fallow gaps wa-18b-reschedule opened useAutomationLanes.ts's write() assumed gesture-scoped coalescing and a preview-only commit that useDomEditAttributeCommits.ts never grew — backported that option support from its own later commit so the two sides of the API agree. The paste path and its tests were missing the box selection's v0/v1 bounds a sibling commit added to AutomationSelection. The FX panel's carve controls still edited the six mechanism numbers (maxCutDb, bands, intelligibilityBias) after carveProfile() collapsed authoring to one Strength knob, so those fields no longer existed on HfCarveSettings; UI now edits strength, and analyseCarveBands is called with carveProfile(strength). Also closes fallow's complexity, dead-code and duplication findings on this PR's diff: extracted automationLaneDragMath.ts (pure group/point-move math) and useAutomationRangeDrag.ts (the marquee-select gesture) out of useAutomationLaneGestures.ts, pulled a couple of render-loop ternaries and a resolver into named functions, dropped an export nothing outside its file used, and shared a step-simplifier between audioCarve's two envelope builders. The edge-stretch vs. box-select priority test in TimelineAutomationLane.test was still pinning the pre-box-select rule (edge wins over a point sitting on it) that a sibling commit deliberately reversed — a point inside the box is now selected content, so grabbing it drags the group instead. Updated the test to the shipped rule instead of the old one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(core): cap the via conic's weight so an edge-clamped via point can't NaN A via point pulled out past the segment (viaX: 5, viaY: -3) clamps to (0.999, 0.001) — exactly on the steady region's edge, where edge - viaX is 0. viaConic divided by that zero to get an infinite weight, and shapeVia turned Infinity into NaN a few steps later (Infinity - Infinity in the quadratic coefficient). NaN reaching setValueCurveAtTime silences the automated parameter for the rest of the render. Capped the weight at 1e6 instead of leaving it unbounded — past that point the arc already reads as touching the via point, so nothing visible is lost. Also hardened shapeVia's existing denominator guard (`<= 0`) to `!(> 0)`, since NaN fails the original comparison and fell through it. Review by Miga (PR #3208). * fix(studio-server): fingerprint the proactive waveform cache key too The route already keys the waveform cache on the asset's size and mtime as well as its path, so a rebuilt-in-place file gets fresh peaks instead of stale ones. generateWaveformCache — the proactive path that runs on upload — still called buildWaveformCacheKey with the path alone, so it wrote to a different key than the route reads from (making the pre-generated cache never found) and kept the exact collision bug this fingerprint exists to fix on its own path. Review by Miga (PR #3211). * style(docs): run oxfmt on the /hyperframes-audio skill docs Table column widths had drifted out of alignment with oxfmt's own rules, failing format:check and blocking the Preflight gate every downstream branch inherits. Whitespace only, no content change. * fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration \b treats `_` as a word character, so \bbed\b never matched bed_01, music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap — an underscore-separated bed classified as "unknown" and could end up offered as its own carve source. Replaced the short hints with a boundary that actually excludes letters and digits on both sides. clipsOverlap computed end = start + duration without guarding sign, so a negative duration put end before start — an interval that does not describe anything, and one specific case showed it silently dropping a real overlap (a shorter, earlier broken end rejected a clip that genuinely contained the point). Duration clamps to zero instead: a clip cannot un-play time, and a zero-length clip at its start is the sane reading of "duration nobody wrote down as positive." Review by Miga (PR #3212). * fix(studio): widen PropertyPanel's resetModules render timeout again The 20s margin (already once widened for the same reason) is timing out in CI's full-monorepo Test run — the resetModules()+fresh-import render this test needs is uncached and competes with every other package's test suite for the same worker pool, and the same test passes in well under 2s standalone. Went to 45s rather than re-tuning to whatever number happens to clear the current CI load, since that number moves every time CI gains a package. * fix(studio): stop the single-candidate auto-apply carve firing twice Two auto-apply effects both fire when sourceOptions.length === 1: the multi-candidate effect only guards length === 0, so a single candidate passes it too, and the single-candidate effect passes its own guard right after — both compute the same sources list and both call setCarve, so the common case (one narrator, one bed) triggered two decodes, two FFT runs, and two concurrent attribute writes for one decision. The multi-candidate effect now defers to its sibling for exactly one candidate, which already has its own detailed handling for that case. Review by Miga (PR #3213). * feat(core): carve against every voice over a bed, always (#3212) * feat(core): carve against every voice over a bed, always dynamically A bed usually runs under a whole sequence — a narrator, an interview answer, a second presenter — and carving against one of them left the others fighting it. `source` becomes `sources`, and `mixCarveSources` sums every voice onto the BED's clock before anything is measured. That is what keeps one analysis sufficient: the chain is fixed, so there is no per-voice filter to switch between, and bands drawn from all the speech there is with envelopes that rise wherever any of it happens answer the actual question — where and when is speech masking this bed. Summed rather than averaged: two people talking at once mask more than either alone. Audio before the bed starts is dropped rather than folded in at zero, since it plays over nothing and shifting it would put a cut where there is no voice. `dynamic` is gone. A fixed depth thins the bed through every pause, and once both have been heard there is no reason to want it, so every carve follows the speech. Two helpers the panel and the headless script now share instead of each carrying a copy — two definitions of "what does this name suggest" drift, and then the two disagree about which track is the voice: - `classifyAudioName` reads a track's kind from its id and filename together. `unknown` is deliberately common: treating an unrecognised name as "not a voice" would hide the one track somebody needs to pick. - `clipsOverlap` keeps out a voice that never plays while the bed does. An unwritten duration counts as unbounded, not zero — refusing a clip whose length the composition leaves to the media would drop the commonest case there is. Files written before this still load: a single `source` reads as a one-voice list, a stored `dynamic` is ignored, and an absent attribute means the defaults whole. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration \b treats `_` as a word character, so \bbed\b never matched bed_01, music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap — an underscore-separated bed classified as "unknown" and could end up offered as its own carve source. Replaced the short hints with a boundary that actually excludes letters and digits on both sides. clipsOverlap computed end = start + duration without guarding sign, so a negative duration put end before start — an interval that does not describe anything, and one specific case showed it silently dropping a real overlap (a shorter, earlier broken end rejected a clip that genuinely contained the point). Duration clamps to zero instead: a clip cannot un-play time, and a zero-length clip at its start is the sane reading of "duration nobody wrote down as positive." Review by Miga (PR #3212). --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(studio): port the carve UI off the removed source/dynamic fields #3212 (accidentally squash-merged into this branch instead of main) changed HfCarveSettings from a single `source` + `dynamic` toggle to a `sources` list with dynamic mode removed outright — the multi-voice UI consumer that goes with that shape lands in the very next PR, so this branch was left with a type that no longer matched its own code. Minimal port, not the multi-voice redesign that PR does properly: the "Listen to" picker and analyse() treat sources[0] as the one voice this UI still understands, and every dynamic-mode branch (the automated envelope lanes, the toggle, the checkbox) is gone along with the field — a carve is now always the static value the analysis computes, matching what the type change made permanent. Test suite trimmed the same way: the automation-lane and toggle tests covered behavior that no longer exists. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d18cbcb commit 9b18fa7

12 files changed

Lines changed: 769 additions & 91 deletions

packages/studio/src/player/components/LayerDisclosureRow.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { CaretRight } from "@phosphor-icons/react";
2-
import type { TimelineElement } from "../store/playerStore";
32
import { TRACK_H } from "./timelineLayout";
43
import { TrackClipCount } from "./TrackClipCount";
54

65
// Layer row (Figma order: disclosure ▸/▾, diamond, name) — the disclosure lives
76
// here, not on the clip bar, and re-expands a collapsed layer.
87
export function LayerDisclosureRow({
9-
keyframeClip,
8+
name,
109
clipCount,
1110
isExpanded,
1211
gutterBackground,
@@ -15,7 +14,10 @@ export function LayerDisclosureRow({
1514
onToggleClipExpanded,
1615
children,
1716
}: {
18-
keyframeClip: TimelineElement;
17+
/** What this row is called. The active clip's own name when it is alone on the
18+
* track; the track itself once it holds several, since naming a shared row
19+
* after one of its clips reads as if the rows under it were that clip's. */
20+
name: string;
1921
clipCount: number;
2022
isExpanded: boolean;
2123
gutterBackground: string;
@@ -31,7 +33,6 @@ export function LayerDisclosureRow({
3133
/** Trailing controls that act on the LAYER (the visibility eye), not on a lane. */
3234
children?: React.ReactNode;
3335
}) {
34-
const name = keyframeClip.label ?? keyframeClip.domId ?? keyframeClip.id;
3536
return (
3637
<div
3738
className="absolute left-0 top-0 flex items-center gap-1.5 overflow-hidden px-1.5 text-[11px]"

packages/studio/src/player/components/Timeline.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
getTimelineLaneTop,
3838
createTimelineRowGeometry,
3939
} from "./timelineLayout";
40+
import { AUTOMATION_LANE_H } from "./automationLaneHeight";
4041
import { formatTime } from "../lib/time";
4142
import { usePlayerStore } from "../store/playerStore";
4243
import { TimelineEditProvider } from "../../contexts/TimelineEditContext";
@@ -578,6 +579,42 @@ describe("Timeline provider boundary", () => {
578579
act(() => root.unmount());
579580
});
580581

582+
// The caret belongs to the row, not to whichever clip on it is selected: the
583+
// automation lanes below it are the track's, shared per property. Toggling one
584+
// clip left the row's state depending on the selection, and a collapse that
585+
// only dropped the active clip left the row stuck open.
586+
it("expands and collapses every clip on a shared track together", () => {
587+
const host = createSizedTimelineHost(720);
588+
const automation = JSON.stringify({
589+
version: 1,
590+
lanes: [{ target: "volume", points: [{ t: 0, v: 1 }] }],
591+
});
592+
usePlayerStore.setState({
593+
duration: 8,
594+
timelineReady: true,
595+
elements: [
596+
{ id: "narration-1", tag: "audio", start: 0, duration: 4, track: 0, automation },
597+
{ id: "narration-2", tag: "audio", start: 4, duration: 4, track: 0, automation },
598+
],
599+
});
600+
const root = createRoot(host);
601+
act(() => root.render(React.createElement(Timeline)));
602+
603+
const row = host.querySelector<HTMLElement>('[data-el-id="narration-1"]')?.parentElement
604+
?.parentElement;
605+
// A row of several clips is named for the track, so the caret is too.
606+
const caret = () => host.querySelector<HTMLButtonElement>('button[aria-label$=" keyframes"]');
607+
expect(caret()?.getAttribute("aria-label")).toBe("Expand Track 1 keyframes");
608+
609+
act(() => caret()?.click());
610+
// One shared volume row, and BOTH clips hold it open.
611+
expectTrackExpansion(row, ["narration-1", "narration-2"], TRACK_H + AUTOMATION_LANE_H);
612+
613+
act(() => caret()?.click());
614+
expectTrackExpansion(row, [], TRACK_H);
615+
act(() => root.unmount());
616+
});
617+
581618
it("marks every clip in selectedElementIds as selected", () => {
582619
const host = createSizedTimelineHost(720);
583620

packages/studio/src/player/components/TimelineAutomationLane.tsx

Lines changed: 99 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ import { simplifyPoints } from "./automationSimplify";
4444
import { pointInSelection, pointsIn, replaceRange } from "./automationLaneSelection";
4545
import { getTimelineLaneTop } from "./timelineLayout";
4646
import { defaultTimelineTheme } from "./timelineTheme";
47+
import { groupAutomationLanes } from "./automationLaneData";
48+
import { isAudioTimelineElement } from "../../utils/timelineInspector";
49+
import { getTimelineElementIdentity } from "../lib/timelineElementHelpers";
4750
import type { TimelineElement } from "../store/playerStore";
4851
import type { UseAutomationLanesResult } from "./useAutomationLanes";
4952

@@ -497,35 +500,42 @@ export function TimelineAutomationLane({
497500
);
498501
}
499502

500-
export interface TimelineAutomationLaneSlotProps {
501-
element: TimelineElement;
502-
isSelected: boolean;
503-
lanes: UseAutomationLanesResult;
504-
pps: number;
505-
/** Keyframe lanes already stacked above, which automation sits under. */
506-
laneCount: number;
507-
accentColor: string;
508-
/** Composition-time playhead; the slot converts it to clip-local. */
509-
currentTime: number;
510-
/** Composition-time beat grid; the slot converts it to clip-local too. */
511-
beatTimes?: readonly number[];
503+
/** Which shared rows one clip draws into, and with which of its lanes. */
504+
interface ClipLaneRow {
505+
lane: HfAutomationLane;
506+
rowIndex: number;
512507
}
513508

514509
/**
515-
* Every automated parameter on this clip, one lane per row — the way a DAW
516-
* stacks them, so two envelopes can be read and edited without swapping a
517-
* control to see either.
510+
* One clip's envelopes, each in the shared row its property owns.
511+
*
512+
* Its own component because every clip on the row needs its own binding, its own
513+
* gestures and its own selection box — a shared row is a shared lane track, not a
514+
* shared envelope, and two clips' curves must never drag as one thing. Hooks
515+
* cannot run in a loop, so the loop is over components.
518516
*/
519-
export function TimelineAutomationLaneSlot({
517+
function ClipAutomationLanes({
520518
element,
519+
rows,
521520
isSelected,
522521
lanes,
523522
pps,
524-
laneCount,
523+
top,
525524
accentColor,
526525
currentTime,
527526
beatTimes,
528-
}: TimelineAutomationLaneSlotProps) {
527+
}: {
528+
element: TimelineElement;
529+
rows: readonly ClipLaneRow[];
530+
isSelected: boolean;
531+
lanes: UseAutomationLanesResult;
532+
pps: number;
533+
/** y of the first automation row on this track. */
534+
top: number;
535+
accentColor: string;
536+
currentTime: number;
537+
beatTimes?: readonly number[];
538+
}) {
529539
// Beats inside this clip, in the clip's own frame — the lane's times are
530540
// clip-local, and a beat outside the clip can never be snapped to anyway.
531541
const snapTimes = useMemo(
@@ -539,19 +549,19 @@ export function TimelineAutomationLaneSlot({
539549
// Stale-selection guard: the selected lane's target can vanish out from under
540550
// it (e.g. its effect got deleted from the chain, dropping the lane), leaving
541551
// a rectangle selecting nothing. Clear it rather than let it point at a
542-
// target that no longer draws.
552+
// target that no longer draws. Above the empty-rows return, because a clip
553+
// that draws nothing is exactly when a selection goes stale.
543554
useEffect(() => {
544555
const target = bound.selection?.target;
545556
if (target !== undefined && !bound.lanes.some((lane) => lane.target === target)) {
546557
bound.onRangeClear();
547558
}
548559
}, [bound]);
549-
if (bound.lanes.length === 0) return null;
560+
if (rows.length === 0) return null;
550561
const inClip = currentTime >= element.start && currentTime <= element.start + element.duration;
551-
const top = getTimelineLaneTop(laneCount);
552562
return (
553563
<>
554-
{bound.lanes.map((lane, index) => {
564+
{rows.map(({ lane, rowIndex }) => {
555565
const range = resolveAutomationRange(lane.target, bound.chain ?? undefined);
556566
// A lane whose target no longer resolves was already dropped upstream;
557567
// this is belt and braces so a row can never draw on the wrong axis.
@@ -562,7 +572,7 @@ export function TimelineAutomationLaneSlot({
562572
duration={element.duration}
563573
widthPx={Math.max(element.duration * pps, 4)}
564574
leftPx={element.start * pps}
565-
topPx={top + index * AUTOMATION_LANE_H}
575+
topPx={top + rowIndex * AUTOMATION_LANE_H}
566576
automation={bound.automation}
567577
target={lane.target}
568578
range={range}
@@ -591,3 +601,69 @@ export function TimelineAutomationLaneSlot({
591601
</>
592602
);
593603
}
604+
605+
export interface TimelineAutomationLaneSlotProps {
606+
/** Every clip on the track, in row order — not just the selected one. */
607+
elements: readonly TimelineElement[];
608+
isSelected: (element: TimelineElement) => boolean;
609+
lanes: UseAutomationLanesResult;
610+
pps: number;
611+
/** Keyframe lanes already stacked above, which automation sits under. */
612+
laneCount: number;
613+
accentColor: string;
614+
/** Composition-time playhead; the slot converts it to clip-local. */
615+
currentTime: number;
616+
/** Composition-time beat grid; the slot converts it to clip-local too. */
617+
beatTimes?: readonly number[];
618+
}
619+
620+
/**
621+
* Every automated parameter on this TRACK, one lane per row — the way a DAW
622+
* stacks them, so two envelopes can be read and edited without swapping a
623+
* control to see either.
624+
*
625+
* Rows belong to the track, not to a clip: clips sharing a row share a row per
626+
* property (see `groupAutomationLanes`), each drawing over its own span, and a
627+
* clip that does not automate that property leaves its stretch empty. Binding one
628+
* clip at a time is what made the visible envelopes change with the selection.
629+
*/
630+
export function TimelineAutomationLaneSlot({
631+
elements,
632+
isSelected,
633+
lanes,
634+
pps,
635+
laneCount,
636+
accentColor,
637+
currentTime,
638+
beatTimes,
639+
}: TimelineAutomationLaneSlotProps) {
640+
const clips = elements.filter(isAudioTimelineElement);
641+
const rowsByClip = new Map<string, ClipLaneRow[]>();
642+
groupAutomationLanes(clips).forEach((group, rowIndex) => {
643+
for (const entry of group.entries) {
644+
const key = getTimelineElementIdentity(entry.element);
645+
const rows = rowsByClip.get(key);
646+
if (rows) rows.push({ lane: entry.lane, rowIndex });
647+
else rowsByClip.set(key, [{ lane: entry.lane, rowIndex }]);
648+
}
649+
});
650+
const top = getTimelineLaneTop(laneCount);
651+
return (
652+
<>
653+
{clips.map((element) => (
654+
<ClipAutomationLanes
655+
key={getTimelineElementIdentity(element)}
656+
element={element}
657+
rows={rowsByClip.get(getTimelineElementIdentity(element)) ?? []}
658+
isSelected={isSelected(element)}
659+
lanes={lanes}
660+
pps={pps}
661+
top={top}
662+
accentColor={accentColor}
663+
currentTime={currentTime}
664+
beatTimes={beatTimes}
665+
/>
666+
))}
667+
</>
668+
);
669+
}

packages/studio/src/player/components/TimelineAutomationLaneSlot.test.tsx

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { act } from "react";
33
import { describe, expect, it, vi } from "vitest";
44
import { createRoot } from "react-dom/client";
55
import { TimelineAutomationLaneSlot } from "./TimelineAutomationLane";
6+
import { AUTOMATION_LANE_H } from "./automationLaneHeight";
7+
import { PAD_X } from "./automationLaneGeometry";
8+
import { getTimelineLaneTop } from "./timelineLayout";
9+
import { elementAutomation, elementAutomationLanes, elementFxChain } from "./automationLaneData";
610
import type { AutomationLaneBinding, UseAutomationLanesResult } from "./useAutomationLanes";
711
import type { TimelineElement } from "../store/timelineElement";
812

@@ -40,8 +44,8 @@ function mountSlot(binding: Partial<AutomationLaneBinding>) {
4044
act(() => {
4145
createRoot(host).render(
4246
<TimelineAutomationLaneSlot
43-
element={element}
44-
isSelected={false}
47+
elements={[element]}
48+
isSelected={() => false}
4549
lanes={lanes}
4650
pps={100}
4751
laneCount={0}
@@ -53,6 +57,106 @@ function mountSlot(binding: Partial<AutomationLaneBinding>) {
5357
return { onRangeClear };
5458
}
5559

60+
/** Two narration slices sharing a row, each with its own chain. */
61+
const chainOf = (nodes: unknown[]) => JSON.stringify({ version: 1, nodes });
62+
const lanesOf = (...targets: string[]) =>
63+
JSON.stringify({
64+
version: 1,
65+
lanes: targets.map((target) => ({ target, points: [{ t: 0, v: 1 }] })),
66+
});
67+
68+
const narration1: TimelineElement = {
69+
...element,
70+
id: "narration-1",
71+
key: "narration-1",
72+
start: 0,
73+
duration: 4,
74+
fxChain: chainOf([
75+
{ type: "lowpass", id: "n1", params: { frequency: 8000, q: 0.7, poles: "2" } },
76+
{ type: "peaking", id: "n2", params: { frequency: 1000, gain: -3, q: 1.4 } },
77+
]),
78+
automation: lanesOf("fx.n2.q"),
79+
};
80+
const narration2: TimelineElement = {
81+
...element,
82+
id: "narration-2",
83+
key: "narration-2",
84+
start: 4,
85+
duration: 4,
86+
fxChain: chainOf([{ type: "peaking", id: "n1", params: { frequency: 1000, gain: -6, q: 1.4 } }]),
87+
automation: lanesOf("fx.n1.q", "volume"),
88+
};
89+
90+
/** Reads what a clip really carries, the way the live binding does. */
91+
const readingBind = (element: TimelineElement, isSelected: boolean): AutomationLaneBinding => ({
92+
automation: elementAutomation(element),
93+
lanes: elementAutomationLanes(element),
94+
chain: elementFxChain(element),
95+
onPreview: vi.fn(),
96+
onCommit: vi.fn(),
97+
onSelect: vi.fn(),
98+
readOnly: !isSelected,
99+
commitTargetKey: null,
100+
selection: null,
101+
onRangeSelect: vi.fn(),
102+
onRangeClear: vi.fn(),
103+
});
104+
105+
/** Every drawn envelope as `row @ left`, which is the whole claim under test. */
106+
function mountRow(elements: readonly TimelineElement[], selectedKey?: string) {
107+
const host = document.createElement("div");
108+
document.body.append(host);
109+
act(() => {
110+
createRoot(host).render(
111+
<TimelineAutomationLaneSlot
112+
elements={elements}
113+
isSelected={(el) => el.key === selectedKey}
114+
lanes={{ bind: readingBind }}
115+
pps={100}
116+
laneCount={0}
117+
accentColor="#0af"
118+
currentTime={0}
119+
/>,
120+
);
121+
});
122+
return [...host.querySelectorAll<HTMLElement>(".hf-automation-lane")]
123+
.map((lane) => `${lane.style.top} @ ${lane.querySelector("svg")?.style.left}`)
124+
.sort();
125+
}
126+
127+
const ROW_0 = `${getTimelineLaneTop(0)}px`;
128+
const ROW_1 = `${getTimelineLaneTop(0) + AUTOMATION_LANE_H}px`;
129+
130+
describe("TimelineAutomationLaneSlot shared rows", () => {
131+
it("draws two clips' envelopes for one property in the same row", () => {
132+
// One lane track, two envelopes — same row, each over its own span. The
133+
// 1 kHz peaking Q is `fx.n2.q` on one clip and `fx.n1.q` on the other.
134+
expect(mountRow([narration1, narration2])).toEqual(
135+
[
136+
`${ROW_0} @ ${0 - PAD_X}px`,
137+
`${ROW_0} @ ${400 - PAD_X}px`,
138+
`${ROW_1} @ ${400 - PAD_X}px`,
139+
].sort(),
140+
);
141+
});
142+
143+
it("leaves a clip's stretch empty in a row it does not automate", () => {
144+
// Only narration-2 has a volume envelope, so row 1 carries one curve and
145+
// narration-1's half of it stays blank rather than drawing a flat line.
146+
expect(mountRow([narration1, narration2]).filter((row) => row.startsWith(ROW_1))).toEqual([
147+
`${ROW_1} @ ${400 - PAD_X}px`,
148+
]);
149+
});
150+
151+
it("keeps the same rows whichever clip is selected", () => {
152+
// The bug this replaces: the row listed only the selected clip's lanes, so
153+
// clicking a sibling swapped which envelopes existed.
154+
expect(mountRow([narration1, narration2], "narration-1")).toEqual(
155+
mountRow([narration1, narration2], "narration-2"),
156+
);
157+
});
158+
});
159+
56160
describe("TimelineAutomationLaneSlot stale-selection guard", () => {
57161
it("clears the selection when its lane's target no longer exists", () => {
58162
const { onRangeClear } = mountSlot({

0 commit comments

Comments
 (0)