Skip to content

Commit 1cf6411

Browse files
vanceingallsclaude
andcommitted
fix(studio): a muted audio clip greys at any width, and only slivers are skipped
- The clip carries data-audio-muted itself: the waveform set it, and a clip too narrow for a waveform drew as unmuted. - withoutHiddenSlivers hides only a clip drawn wider than it is long; one an author's shared transition label overlaps stays at any width. - MEDIA_TAGS no longer splits buildMissingCompositionElements from its doc. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dc84349 commit 1cf6411

7 files changed

Lines changed: 29 additions & 37 deletions

File tree

‎packages/studio/src/player/components/AudioWaveform.test.tsx‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -292,32 +292,6 @@ describe("AudioWaveform", () => {
292292
act(() => root.unmount());
293293
});
294294

295-
it("greys the clip in place when muted", () => {
296-
const host = document.createElement("div");
297-
host.className = "timeline-clip is-audio";
298-
document.body.append(host);
299-
const root = createRoot(host);
300-
301-
act(() => {
302-
root.render(
303-
<AudioWaveform
304-
audioUrl="/media/voice.wav"
305-
label=""
306-
labelColor="#fff"
307-
projectId="project-a"
308-
sessionEpoch={1}
309-
priority="visible"
310-
muted
311-
/>,
312-
);
313-
});
314-
315-
expect(host.getAttribute("data-audio-muted")).toBe("true");
316-
317-
act(() => root.unmount());
318-
expect(host.hasAttribute("data-audio-muted")).toBe(false);
319-
});
320-
321295
it("fills a short sound strip when the label band is dropped", () => {
322296
const heights = [16, 0].map((labelInset) => {
323297
const host = document.createElement("div");

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,6 @@ export const AudioWaveform = memo(function AudioWaveform({
309309

310310
useEffect(() => (near ? onThemeChange(draw) : undefined), [draw, near]);
311311

312-
useEffect(() => {
313-
const clip = root?.closest(".timeline-clip");
314-
if (!(clip instanceof HTMLElement)) return;
315-
if (muted) clip.setAttribute("data-audio-muted", "true");
316-
else clip.removeAttribute("data-audio-muted");
317-
return () => clip.removeAttribute("data-audio-muted");
318-
}, [muted, root]);
319-
320312
return (
321313
<div ref={setRoot} className="absolute inset-0">
322314
<div

‎packages/studio/src/player/components/TimelineClip.test.tsx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ describe("TimelineClip", () => {
241241
act(() => root.unmount());
242242
});
243243

244+
it("greys a muted audio clip at any width, with or without its waveform", () => {
245+
const muted = (pps: number, hidden: boolean) => {
246+
const { host, root } = renderClip({
247+
pps,
248+
element: { id: "a", label: "Voice", tag: "audio", start: 0, duration: 1, track: 0, hidden },
249+
});
250+
const value = host.querySelector(".timeline-clip")?.getAttribute("data-audio-muted");
251+
act(() => root.unmount());
252+
return value;
253+
};
254+
expect(muted(4, true)).toBe("true"); // 4 px: the frame tier, no waveform
255+
expect(muted(400, true)).toBe("true");
256+
expect(muted(4, false)).toBeNull();
257+
});
258+
244259
it("applies selected styling when rendered as selected", () => {
245260
const { host, root } = renderClip({
246261
element: { id: "selected", label: "Selected", tag: "div", start: 0, duration: 1, track: 0 },

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { linkLabelColor } from "./linkLabelColor";
1717
import { OutOfSyncBadge } from "./OutOfSyncBadge";
1818
import { clipSpeedSuffix } from "./clipToolAttrs";
1919
import { ClipPeakTooltip } from "./ClipPeakTooltip";
20+
import { audioPillFlags } from "./audioClipLink";
2021
import { timeLayerPercent } from "./TimelineTimeLayer";
2122

2223
interface TimelineClipProps {
@@ -152,6 +153,8 @@ export const TimelineClip = memo(function TimelineClip({
152153
data-clip-start={el.start}
153154
data-clip-end={el.start + el.duration}
154155
data-clip-hidden={el.hidden ? "true" : undefined}
156+
// On the clip, not its waveform: a clip too narrow for one still greys out.
157+
data-audio-muted={isAudioClip && audioPillFlags(el).muted ? "true" : undefined}
155158
data-link-color={linkColor ?? undefined}
156159
data-ladder={ladder}
157160
data-active={isActive ? "" : undefined}

‎packages/studio/src/player/components/timelineSlivers.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ describe("withoutHiddenSlivers", () => {
2828
const run = [clip("late", 1, 0.5), clip("early", 0, 0.5), clip("mid", 0.5, 0.5)];
2929
expect(ids(withoutHiddenSlivers(run, 1, () => false))).toEqual(["late", "early"]);
3030
});
31+
32+
it("keeps a wide clip that starts inside another, as one an author's shared transition label overlaps", () => {
33+
const overlapped = [clip("A", 0, 10), clip("B", 9, 10), clip("C", 18, 10)];
34+
expect(withoutHiddenSlivers(overlapped, 100, () => false)).toBe(overlapped);
35+
});
3136
});

‎packages/studio/src/player/components/timelineSlivers.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export function withoutHiddenSlivers(
2424
const right = left + clipWidthPx(el, pps);
2525
const next = byStart[i + 1];
2626
const endsRun = !next || next.start * pps >= right;
27-
if (left < edge && !endsRun && !keep(el)) {
27+
// Only a sliver: a clip drawn wider than it is long. A real overlap (two clips an author labels one transition)
28+
// stays, however it starts.
29+
const sliver = el.duration * pps < right - left;
30+
if (sliver && left < edge && !endsRun && !keep(el)) {
2831
hidden.add(el);
2932
continue;
3033
}

‎packages/studio/src/player/lib/timelineIframeHelpers.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,15 @@ function buildMissingCompositionEntry(params: {
475475
return attachCompositionSource(entry, element, compositionSrc);
476476
}
477477

478+
const MEDIA_TAGS = new Set(["video", "audio", "img"]);
479+
478480
/**
479481
* Scan the iframe DOM for composition hosts missing from the current
480482
* timeline elements and add them. The CDN runtime often fails to resolve
481483
* element-reference starts (`data-start="intro"`) so composition hosts
482484
* are silently dropped from `__clipManifest`. This pass reads the DOM +
483485
* GSAP timeline registry directly to fill the gaps.
484486
*/
485-
const MEDIA_TAGS = new Set(["video", "audio", "img"]);
486-
487487
export function buildMissingCompositionElements(
488488
doc: Document,
489489
iframeWin: IframeWindow,

0 commit comments

Comments
 (0)