Skip to content

Commit df57ad4

Browse files
vanceingallsclaude
andauthored
fix(studio): the shared-row follow-ups (#3215)
* 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 9b18fa7 commit df57ad4

18 files changed

Lines changed: 913 additions & 71 deletions

packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx

Lines changed: 161 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,15 +1114,21 @@ describe("AudioFxGroup carve source list", () => {
11141114
});
11151115

11161116
it("keeps the picker when the stored voice is not among the candidates", () => {
1117-
// The stored track was renamed, or classifies as music now. Reading the one
1118-
// remaining candidate out would quietly claim the carve listens to it.
1117+
// The stored track is still there but no longer classifies as a voice.
1118+
// Reading the one remaining candidate out would quietly claim the carve
1119+
// listens to it. (A stored track that is GONE is a different case — see the
1120+
// deleted-voice tests, which re-analyse rather than sit on a measurement of
1121+
// something that is not there.)
11191122
const bed = document.createElement("audio");
11201123
bed.id = "bed";
11211124
bed.setAttribute(
11221125
"data-fx-carve",
1123-
JSON.stringify({ enabled: true, sources: ["gone"], strength: 0.25 }),
1126+
JSON.stringify({ enabled: true, sources: ["backing-music"], strength: 0.25 }),
11241127
);
11251128
document.body.append(bed);
1129+
const stored = document.createElement("audio");
1130+
stored.id = "backing-music";
1131+
document.body.append(stored);
11261132
const voice = document.createElement("audio");
11271133
voice.id = "narration";
11281134
document.body.append(voice);
@@ -1136,7 +1142,7 @@ describe("AudioFxGroup carve source list", () => {
11361142
dataAttributes: {
11371143
"fx-carve": JSON.stringify({
11381144
enabled: true,
1139-
sources: ["gone"],
1145+
sources: ["backing-music"],
11401146
strength: 0.25,
11411147
}),
11421148
},
@@ -1310,3 +1316,154 @@ describe("AudioFxGroup carve across tracks", () => {
13101316
]);
13111317
});
13121318
});
1319+
1320+
/**
1321+
* The filters and envelopes a carve produces are a MEASUREMENT of specific
1322+
* tracks. Delete one and they describe something nobody can hear any more — the
1323+
* bed keeps ducking for a voice that is gone.
1324+
*/
1325+
describe("AudioFxGroup carve against a deleted voice", () => {
1326+
const CARVED_CHAIN = JSON.stringify({
1327+
version: 1,
1328+
nodes: [
1329+
{ type: "peaking", id: "c1", enabled: true, fromCarve: true, params: { frequency: 1000 } },
1330+
{ type: "lowpass", id: "k1", enabled: true, params: { frequency: 8000 } },
1331+
],
1332+
});
1333+
const CARVED_AUTOMATION = JSON.stringify({
1334+
version: 1,
1335+
lanes: [
1336+
{ target: "fx.c1.gain", points: [{ t: 0, v: -6 }] },
1337+
{ target: "fx.k1.frequency", points: [{ t: 0, v: 8000 }] },
1338+
],
1339+
});
1340+
1341+
/**
1342+
* A bed carving against `sources`, with only `present` still in the composition.
1343+
*
1344+
* The timeline is what says a track is gone — not the preview DOM, which keeps
1345+
* a deleted element around — so the store is seeded and the document is left
1346+
* holding every track, which is exactly the mismatch the studio produces.
1347+
*/
1348+
function mountCarved(sources: string[], present: string[]) {
1349+
const carve = JSON.stringify({ enabled: true, sources, strength: 0.25 });
1350+
const bed = document.createElement("audio");
1351+
bed.id = "bed";
1352+
document.body.append(bed);
1353+
for (const id of new Set([...sources, ...present])) {
1354+
const el = document.createElement("audio");
1355+
el.id = id;
1356+
document.body.append(el);
1357+
}
1358+
usePlayerStore.setState({
1359+
elements: [
1360+
{ id: "bed", tag: "audio", start: 0, duration: 10, track: 0 },
1361+
...present.map((id) => ({ id, tag: "audio", start: 0, duration: 10, track: 1 })),
1362+
] as never,
1363+
});
1364+
const onSetAttributeQuiet = vi.fn();
1365+
const host = document.createElement("div");
1366+
document.body.append(host);
1367+
act(() => {
1368+
createRoot(host).render(
1369+
<AudioFxGroup
1370+
element={
1371+
{
1372+
dataAttributes: {
1373+
"fx-carve": carve,
1374+
"fx-chain": CARVED_CHAIN,
1375+
automation: CARVED_AUTOMATION,
1376+
},
1377+
id: "bed",
1378+
element: bed,
1379+
} as unknown as DomEditSelection
1380+
}
1381+
onSetAttributeQuiet={onSetAttributeQuiet}
1382+
onSetAttributeLive={vi.fn()}
1383+
/>,
1384+
);
1385+
});
1386+
return { host, onSetAttributeQuiet };
1387+
}
1388+
1389+
it("re-analyses against the voices that are left", () => {
1390+
// Two voices were measured together into one set of bands. With one gone that
1391+
// set answers a question nobody asked; the survivor has to be measured again.
1392+
const { onSetAttributeQuiet } = mountCarved(["narration", "guest"], ["narration"]);
1393+
const write = writeTo(onSetAttributeQuiet.mock.calls, "data-fx-carve");
1394+
expect(JSON.parse(String(write![1]))).toMatchObject({
1395+
enabled: true,
1396+
sources: ["narration"],
1397+
});
1398+
});
1399+
1400+
it("leaves a carve alone while every voice it names is still there", () => {
1401+
const { onSetAttributeQuiet } = mountCarved(["narration", "guest"], ["narration", "guest"]);
1402+
expect(onSetAttributeQuiet.mock.calls.some((c) => c[0] === "data-fx-carve")).toBe(false);
1403+
});
1404+
1405+
it("does not fall back to carving against an effect when no voice is left", async () => {
1406+
// Found in the studio, not here: deleting the narration emptied the source
1407+
// list, and the panel filled it again with the only audio in the composition
1408+
// — a 200 ms explosion. The picker's fallback (offer everything rather than
1409+
// hide the track somebody needs) is for the AUTHOR to choose from. The panel
1410+
// choosing off it is the panel deciding, and that is never the answer.
1411+
const carve = JSON.stringify({ enabled: true, sources: [], strength: 0.25 });
1412+
const bed = document.createElement("audio");
1413+
bed.id = "bed";
1414+
bed.setAttribute("data-fx-carve", carve);
1415+
document.body.append(bed);
1416+
const sfx = document.createElement("audio");
1417+
sfx.id = "sfx-explosion";
1418+
document.body.append(sfx);
1419+
const onSetAttributeQuiet = vi.fn();
1420+
const host = document.createElement("div");
1421+
document.body.append(host);
1422+
act(() => {
1423+
createRoot(host).render(
1424+
<AudioFxGroup
1425+
element={
1426+
{
1427+
dataAttributes: { "fx-carve": carve },
1428+
id: "bed",
1429+
element: bed,
1430+
} as unknown as DomEditSelection
1431+
}
1432+
onSetAttributeQuiet={onSetAttributeQuiet}
1433+
onSetAttributeLive={vi.fn()}
1434+
/>,
1435+
);
1436+
});
1437+
await act(async () => {});
1438+
// Nothing written: the carve waits rather than picking the explosion.
1439+
expect(onSetAttributeQuiet.mock.calls.some((c) => c[0] === "data-fx-carve")).toBe(false);
1440+
// Still offered, so the author can say "actually, listen to that one".
1441+
expect(
1442+
Array.from(host.querySelectorAll("[data-carve-source]")).map((e) =>
1443+
e.getAttribute("data-carve-source"),
1444+
),
1445+
).toEqual(["sfx-explosion"]);
1446+
});
1447+
1448+
it("drops what it generated when the last voice goes and none is left to pick", async () => {
1449+
// Staying on with nothing to listen to is honest — a voice may come back, and
1450+
// "off" is a different thing the author chose. What cannot stay is the output:
1451+
// those filters and that envelope are making room for nobody.
1452+
const { onSetAttributeQuiet } = mountCarved(["narration"], []);
1453+
// The three writes are sequenced, not fired together: each is a
1454+
// read-modify-write against the same file, so the carve write lands only
1455+
// after the two that strip its output.
1456+
await act(async () => {});
1457+
const carve = writeTo(onSetAttributeQuiet.mock.calls, "data-fx-carve");
1458+
expect(JSON.parse(String(carve![1]))).toMatchObject({ enabled: true, sources: [] });
1459+
1460+
const chain = writeTo(onSetAttributeQuiet.mock.calls, "data-fx-chain");
1461+
// The hand-added low-pass survives; only what the carve minted goes.
1462+
expect(JSON.parse(String(chain![1])).nodes.map((n: { id: string }) => n.id)).toEqual(["k1"]);
1463+
1464+
const automation = writeTo(onSetAttributeQuiet.mock.calls, "data-automation");
1465+
expect(
1466+
JSON.parse(String(automation![1])).lanes.map((l: { target: string }) => l.target),
1467+
).toEqual(["fx.k1.frequency"]);
1468+
});
1469+
});

packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
} from "./propertyPanelAutomation";
4949
import type { DomEditSelection } from "./domEditingTypes";
5050
import { useLivePlayheadTime } from "../../hooks/useLivePlayheadTime";
51+
import { usePlayerStore } from "../../player";
5152

5253
/**
5354
* Rate the carve source is decoded at. Analysis is self-consistent because it
@@ -199,10 +200,12 @@ export function AudioFxGroup({
199200
* commit, which does not exist yet.
200201
*/
201202
const setCarve = async (next: HfCarveSettings | null): Promise<void> => {
202-
// Envelopes the carve wrote outlive it otherwise, and an automated gain
203-
// ignores the panel's own depth — so switching dynamic off would leave the
204-
// filters still following the voice with nothing saying they do.
205-
if (!next?.enabled) {
203+
// What the carve generated is only justified by the voices it was measured
204+
// from: switched off, or left naming none — every source deleted, say —
205+
// there is nothing those filters are making room for. Left behind they keep
206+
// dipping the bed with nothing in the panel to explain them.
207+
const generatedOutputStands = Boolean(next?.enabled) && (next?.sources.length ?? 0) > 0;
208+
if (!generatedOutputStands) {
206209
const carriedOver = withoutCarveLanes(automation, chain);
207210
if (carriedOver.lanes.length !== automation.lanes.length) {
208211
await onSetAttributeQuiet(
@@ -211,7 +214,7 @@ export function AudioFxGroup({
211214
);
212215
}
213216
}
214-
if (!next?.enabled) {
217+
if (!generatedOutputStands) {
215218
const kept = chain.nodes.filter((n) => !n.fromCarve);
216219
if (kept.length !== chain.nodes.length) {
217220
await onSetAttributeQuiet(
@@ -300,9 +303,12 @@ export function AudioFxGroup({
300303
* first, and if filtering would leave nothing at all every track comes back. A
301304
* picker that hides the track somebody needs is worse than a long one.
302305
*/
303-
const sourceOptions: AudioTrackOption[] = (() => {
306+
const { sourceOptions, autoSourceIds } = ((): {
307+
sourceOptions: AudioTrackOption[];
308+
autoSourceIds: string[];
309+
} => {
304310
const doc = element.element?.ownerDocument;
305-
if (!doc) return [];
311+
if (!doc) return { sourceOptions: [], autoSourceIds: [] };
306312
const others = Array.from(doc.querySelectorAll<HTMLAudioElement>("audio[id]")).filter(
307313
(a) => a.id !== element.id,
308314
);
@@ -324,11 +330,75 @@ export function AudioFxGroup({
324330
}));
325331
const plausible = described.filter((t) => t.kind === "voice" || t.kind === "unknown");
326332
const offered = plausible.length > 0 ? plausible : described;
327-
return offered
328-
.sort((a, b) => (a.kind === "voice" ? 0 : 1) - (b.kind === "voice" ? 0 : 1))
329-
.map(({ id, label }) => ({ id, label }));
333+
const byVoiceFirst = (list: typeof described) =>
334+
[...list].sort((a, b) => (a.kind === "voice" ? 0 : 1) - (b.kind === "voice" ? 0 : 1));
335+
return {
336+
sourceOptions: byVoiceFirst(offered).map(({ id, label }) => ({ id, label })),
337+
// What the panel may pick WITHOUT being asked — never the fallback. The
338+
// fallback exists so the picker can still show a track whose name reads as
339+
// music or as an effect, because a name is a hint and the author may know
340+
// better. Choosing off that list is a different act: it is the panel
341+
// deciding, and "the only audio left is a 200 ms explosion" is not a voice
342+
// to make room for. A bed surrounded by nothing plausible waits instead.
343+
autoSourceIds: byVoiceFirst(plausible).map((t) => t.id),
344+
};
330345
})();
331346

347+
/**
348+
* The voices this carve names that are still in the composition.
349+
*
350+
* Existence, not the candidate list: a voice can stop being offered without
351+
* being gone (it stopped overlapping the bed), and dropping it then would
352+
* quietly rewrite a relationship the author set. Deleted is the case that has
353+
* to be noticed, because what the carve produced was measured from that track.
354+
*
355+
* Asked of the timeline rather than of `element.element.ownerDocument`, which
356+
* is the preview's DOM and outlives a delete: measured in the studio, a bed
357+
* selected right after its voice was deleted still found that voice through
358+
* the document, so the carve sat on a measurement of a track the timeline had
359+
* already dropped. The store is what the delete actually edited.
360+
*/
361+
const timelineElements = usePlayerStore((s) => s.elements);
362+
const survivingSources = ((): string[] => {
363+
if (!carve) return [];
364+
const present = new Set(timelineElements.map((el) => el.domId ?? el.id));
365+
// Absence only means deletion once the timeline is known to describe THIS
366+
// composition, and the bed being in it is the proof. Without that check a
367+
// store that is empty — not loaded yet, or a panel mounted outside the
368+
// player — reads as "every voice was deleted" and throws away a carve that
369+
// is perfectly fine. Unchanged sources are what the prune treats as nothing
370+
// to do.
371+
if (!element.id || !present.has(element.id)) return carve.sources;
372+
return carve.sources.filter((id) => present.has(id));
373+
})();
374+
375+
/**
376+
* A deleted voice re-analyses the bed.
377+
*
378+
* The filters and envelopes are a measurement of specific tracks, so losing one
379+
* makes them a measurement of something that is no longer there — the bed keeps
380+
* ducking for a voice nobody can hear. `analyse` already skips a source it
381+
* cannot find, but nothing asked it to run again.
382+
*
383+
* Pruning is the whole trigger: `setCarve` re-analyses when the source list
384+
* changes, so the surviving voices are re-measured together. Losing the LAST
385+
* one leaves an empty list, which the effects below repoint at whatever
386+
* candidates remain — and if there are none, `setCarve` drops what the carve
387+
* generated, since there is nothing left it could be making room for.
388+
*
389+
* Keyed on the survivors rather than on the candidates: a voice that had
390+
* stopped overlapping was never in the candidate list, so its deletion would
391+
* not change that identity and this would never fire.
392+
*/
393+
useEffect(() => {
394+
if (carvedAgainstBy || !carve?.enabled) return;
395+
if (survivingSources.length === carve.sources.length) return;
396+
void setCarve({ ...carve, sources: survivingSources });
397+
// Keyed on the identity of the decision, not on setCarve — which is rebuilt
398+
// every render and would re-fire this.
399+
// eslint-disable-next-line react-hooks/exhaustive-deps
400+
}, [carve, carvedAgainstBy, survivingSources.join(" ")]);
401+
332402
/**
333403
* A bed with voices above it carves itself.
334404
*
@@ -346,14 +416,14 @@ export function AudioFxGroup({
346416
* off stores `enabled: false`, which is also a configured carve. That is the whole
347417
* reason the flag exists rather than "off" being an absent attribute.
348418
*/
349-
const candidateIds = sourceOptions.map((o) => o.id).join("\u0000");
419+
const candidateIds = autoSourceIds.join("\u0000");
350420
useEffect(() => {
351421
// Exactly one candidate is the sibling effect's case below, not this one's:
352422
// both guards passing for a single candidate fired two setCarve calls with
353423
// the same result — two decodes, two FFT runs, two concurrent attribute
354424
// writes.
355-
if (carvedAgainstBy || sourceOptions.length <= 1) return;
356-
const all = sourceOptions.map((o) => o.id);
425+
if (carvedAgainstBy || autoSourceIds.length <= 1) return;
426+
const all = autoSourceIds;
357427
// Nothing configured: the default carve, pointed at everything it could hear.
358428
if (carve === null) {
359429
void setCarve({ ...DEFAULT_CARVE, sources: all });
@@ -387,24 +457,23 @@ export function AudioFxGroup({
387457
* reason the flag exists rather than "off" being an absent attribute.
388458
*/
389459
useEffect(() => {
390-
if (carvedAgainstBy || sourceOptions.length !== 1) return;
391-
const only = sourceOptions[0];
460+
if (carvedAgainstBy || autoSourceIds.length !== 1) return;
461+
const only = autoSourceIds[0];
392462
if (!only) return;
393463
// Nothing configured: the default carve, pointed at the one candidate.
394464
if (carve === null) {
395-
void setCarve({ ...DEFAULT_CARVE, sources: [only.id] });
465+
void setCarve({ ...DEFAULT_CARVE, sources: [only] });
396466
return;
397467
}
398468
// Configured but with no voice yet — a carve switched on before there was
399469
// anything to listen to, or one whose source was cleared. The panel reads the
400470
// sole candidate out as the source, so it has to be the stored one too;
401471
// otherwise the card claims a relationship the attribute does not record.
402-
if (carve.enabled && carve.sources.length === 0)
403-
void setCarve({ ...carve, sources: [only.id] });
472+
if (carve.enabled && carve.sources.length === 0) void setCarve({ ...carve, sources: [only] });
404473
// Deliberately keyed on the identity of the decision, not on setCarve — which
405474
// is rebuilt every render and would re-fire this.
406475
// eslint-disable-next-line react-hooks/exhaustive-deps
407-
}, [carve, carvedAgainstBy, sourceOptions.length, sourceOptions[0]?.id]);
476+
}, [carve, carvedAgainstBy, autoSourceIds.length, autoSourceIds[0]]);
408477

409478
const [analysing, setAnalysing] = useState(false);
410479

packages/studio/src/hooks/useElementLifecycleOps.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ export function useElementLifecycleOps({
142142
kind: "timeline",
143143
files: { [targetPath]: patchedContent },
144144
readFile: async () => originalContent,
145+
// remove-element already wrote the removal, so disk holds THAT — not
146+
// the content read at the top. Undo still goes back to the original.
147+
diskContent: { [targetPath]: patchedContent },
145148
writeFile: writeProjectFile,
146149
recordEdit: editHistory.recordEdit,
147150
});

packages/studio/src/hooks/useTimelineEditing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ export function useTimelineEditing({
449449
kind: "timeline",
450450
files: { [targetPath]: patchedContent },
451451
readFile: async () => originalContent,
452+
// remove-element already wrote the removal, so disk holds THAT — not the
453+
// content read at the top. Undo still goes back to the original.
454+
diskContent: { [targetPath]: removedContent },
452455
writeFile: writeProjectFile,
453456
recordEdit,
454457
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function AutomationValueInput({
2828
}: AutomationValueInputProps) {
2929
return (
3030
<input
31-
className="hf-automation-value absolute rounded-[3px] border border-panel-border-input bg-panel-bg-2 px-1 font-mono text-[9px] text-panel-text-1"
31+
// pointer-events-auto: the lane band around it takes none, so that clips
32+
// sharing the row do not cover each other's envelopes (see the lane).
33+
className="hf-automation-value pointer-events-auto absolute rounded-[3px] border border-panel-border-input bg-panel-bg-2 px-1 font-mono text-[9px] text-panel-text-1"
3234
style={{ left: leftPx, top: 1, width: 44, zIndex: 4 }}
3335
// The lane is a pointer surface, and the timeline above it owns single-key
3436
// shortcuts. Without stopping both, a press lands on the lane instead of

0 commit comments

Comments
 (0)