Skip to content

Write HTML. Render video. Built for agents.

feat(studio): the FX panel, generated from the registry (#3022)

Vance Ingallsc2996c862613
diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc
index bb892426a1..89e1b21d2f 100644
--- a/.fallowrc.jsonc
+++ b/.fallowrc.jsonc
@@ -654,6 +654,28 @@
// inherited clone; consistent with the norm above of leaving parallel
// command-test cases unabstracted.
"packages/cli/src/commands/check.test.ts",
+ // canary.test.ts: rawFnv is a deliberate independent re-implementation of
+ // canary.ts's fnv1a32, not copy-paste — its own docstring explains why:
+ // the test re-derives the hash so it can cross-check canaryBucket against
+ // a copy that owes it nothing, rather than importing the function under
+ // test. Importing fnv1a32 here would defeat the point of the assertion.
+ "packages/core/src/canary.test.ts",
+ // The audio FX property-panel test files (and the two siblings outside
+ // this stack, propertyPanelFlatMotionSection.test.tsx and
+ // propertyPanelFlatEffectsSection.test.tsx) share a `renderInto` React
+ // mount helper — pre-existing across nine files, not introduced here.
+ // The FxSection/FlatTextSection `mount()` wrappers additionally look
+ // alike because both build a props-with-overrides harness for their own
+ // component; the prop shapes differ per component, so a shared mount
+ // abstraction would obscure more than it dedupes (same rationale as
+ // slideshowPanelHelpers.ts above).
+ "packages/studio/src/components/editor/PropertyPanelEmptyState.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFlatColorGradingSection.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFlatLayoutSection.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFlatPrimitives.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFlatTextSection.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFlatToggle.test.tsx",
+ "packages/studio/src/components/editor/propertyPanelFxSection.test.tsx",
],
},
"health": {
diff --git a/packages/core/package.json b/packages/core/package.json
index cd9d6aed06..95f8d81cb8 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -546,9 +546,9 @@
"typecheck": "tsc --noEmit && bun run typecheck:runtime",
"typecheck:runtime": "tsc --noEmit -p tsconfig.runtime.json",
"lint:runtime-preview-guards": "bun scripts/lint-runtime-preview-guards.ts",
- "build:audio-fx-runtime": "tsx scripts/build-audio-fx-runtime.ts",
+ "build:audio-fx-runtime": "tsx scripts/build-inline-artifact.ts audio-fx",
"build:hyperframes-runtime": "tsx scripts/build-hyperframes-runtime-artifact.ts",
- "build:position-edits-render": "tsx scripts/build-position-edits-render.ts",
+ "build:position-edits-render": "tsx scripts/build-inline-artifact.ts position-edits",
"check:position-edits-render": "bun run build:position-edits-render && git diff --exit-code -- src/generated/position-edits-render-inline.ts",
"build:hyperframes-runtime:modular": "SANDBOX_RUNTIME_VARIANT=modular tsx scripts/build-hyperframes-runtime-artifact.ts",
"build:hyperframe-runtime": "tsx scripts/build-hyperframes-runtime-artifact.ts",
diff --git a/packages/core/scripts/build-audio-fx-runtime.ts b/packages/core/scripts/build-audio-fx-runtime.ts
deleted file mode 100644
index eb6c841a51..0000000000
--- a/packages/core/scripts/build-audio-fx-runtime.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-/** Build the injectable audio-FX runtime artifact from the canonical runtime. */
-
-import { mkdirSync, writeFileSync } from "node:fs";
-import { dirname, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
-import { buildSync } from "esbuild";
-import { execFileSync } from "node:child_process";
-
-const thisDir = dirname(fileURLToPath(import.meta.url));
-const repoRoot = resolve(thisDir, "..");
-const entry = resolve(repoRoot, "stubs/audio-fx-runtime-entry.ts");
-const generatedDir = resolve(repoRoot, "src/generated");
-const outPath = resolve(generatedDir, "audio-fx-runtime-inline.ts");
-
-const result = buildSync({
- entryPoints: [entry],
- bundle: true,
- write: false,
- platform: "browser",
- format: "iife",
- target: ["es2020"],
- minify: true,
- legalComments: "none",
-});
-const iife = result.outputFiles[0]?.text ?? "";
-if (!iife) throw new Error("esbuild produced no output for audio-fx-runtime-entry.ts");
-
-mkdirSync(generatedDir, { recursive: true });
-writeFileSync(
- outPath,
- [
- "// AUTO-GENERATED by scripts/build-audio-fx-runtime.ts - do not edit",
- `const AUDIO_FX_RUNTIME_IIFE: string = ${JSON.stringify(iife)};`,
- "",
- "/** Returns the pre-built audio-FX runtime IIFE as a string constant. */",
- "export function getAudioFxRuntimeScript(): string {",
- " return AUDIO_FX_RUNTIME_IIFE;",
- "}",
- "",
- ].join("\n"),
- "utf8",
-);
-
-try {
- execFileSync("bun", ["x", "oxfmt", outPath], { stdio: "ignore" });
-} catch {
- // Formatting is best effort when the generator runs in a minimal environment.
-}
-
-console.log(JSON.stringify({ event: "audio_fx_runtime_generated", outPath, bytes: iife.length }));
diff --git a/packages/core/scripts/build-inline-artifact.ts b/packages/core/scripts/build-inline-artifact.ts
new file mode 100644
index 0000000000..a506bf8017
--- /dev/null
+++ b/packages/core/scripts/build-inline-artifact.ts
@@ -0,0 +1,97 @@
+/**
+ * Bundle one canonical-runtime entry to a minified IIFE with esbuild and write
+ * it into `src/generated` as a string constant behind a getter.
+ *
+ * One script handles both inline artifacts — the audio-FX runtime and the
+ * position-edits render — since they differ only in the entry, output names,
+ * and log event. Keeping them as separate files produced a byte-for-byte
+ * clone that fallow kept re-flagging on every unrelated line shift.
+ */
+
+import { mkdirSync, writeFileSync } from "node:fs";
+import { dirname, resolve } from "node:path";
+import { fileURLToPath } from "node:url";
+import { buildSync } from "esbuild";
+import { execFileSync } from "node:child_process";
+
+interface InlineArtifactTarget {
+ entryRelPath: string;
+ generatedFileName: string;
+ constName: string;
+ getterName: string;
+ /** Filename shown in the esbuild-failure error. */
+ entryLabel: string;
+ /** Human phrase for the generated getter's doc comment, e.g. "audio-FX runtime". */
+ docLabel: string;
+ event: string;
+}
+
+const TARGETS: Record<string, InlineArtifactTarget> = {
+ "audio-fx": {
+ entryRelPath: "stubs/audio-fx-runtime-entry.ts",
+ generatedFileName: "audio-fx-runtime-inline.ts",
+ constName: "AUDIO_FX_RUNTIME_IIFE",
+ getterName: "getAudioFxRuntimeScript",
+ entryLabel: "audio-fx-runtime-entry.ts",
+ docLabel: "audio-FX runtime",
+ event: "audio_fx_runtime_generated",
+ },
+ "position-edits": {
+ entryRelPath: "stubs/position-edits-render-entry.ts",
+ generatedFileName: "position-edits-render-inline.ts",
+ constName: "POSITION_EDITS_RENDER_IIFE",
+ getterName: "getPositionEditsRenderScript",
+ entryLabel: "position-edits-render-entry.ts",
+ docLabel: "position-edits render",
+ event: "position_edits_render_generated",
+ },
+};
+
+const key = process.argv[2] ?? "";
+const target = TARGETS[key];
+if (!target) {
+ throw new Error(`Usage: build-inline-artifact.ts <${Object.keys(TARGETS).join("|")}>`);
+}
+
+const thisDir = dirname(fileURLToPath(import.meta.url));
+const repoRoot = resolve(thisDir, "..");
+const entry = resolve(repoRoot, target.entryRelPath);
+const generatedDir = resolve(repoRoot, "src/generated");
+const outPath = resolve(generatedDir, target.generatedFileName);
+
+const result = buildSync({
+ entryPoints: [entry],
+ bundle: true,
+ write: false,
+ platform: "browser",
+ format: "iife",
+ target: ["es2020"],
+ minify: true,
+ legalComments: "none",
+});
+const iife = result.outputFiles[0]?.text ?? "";
+if (!iife) throw new Error(`esbuild produced no output for ${target.entryLabel}`);
+
+mkdirSync(generatedDir, { recursive: true });
+writeFileSync(
+ outPath,
+ [
+ "// AUTO-GENERATED by scripts/build-inline-artifact.ts - do not edit",
+ `const ${target.constName}: string = ${JSON.stringify(iife)};`,
+ "",
+ `/** Returns the pre-built ${target.docLabel} IIFE as a string constant. */`,
+ `export function ${target.getterName}(): string {`,
+ ` return ${target.constName};`,
+ "}",
+ "",
+ ].join("\n"),
+ "utf8",
+);
+
+try {
+ execFileSync("bun", ["x", "oxfmt", outPath], { stdio: "ignore" });
+} catch {
+ // Formatting is best effort when the generator runs in a minimal environment.
+}
+
+console.log(JSON.stringify({ event: target.event, outPath, bytes: iife.length }));
diff --git a/packages/core/scripts/build-position-edits-render.ts b/packages/core/scripts/build-position-edits-render.ts
deleted file mode 100644
index e4ed0ef981..0000000000
--- a/packages/core/scripts/build-position-edits-render.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-/** Build the injectable position-edits render artifact from the canonical runtime. */
-
-import { mkdirSync, writeFileSync } from "node:fs";
-import { dirname, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
-import { buildSync } from "esbuild";
-import { execFileSync } from "node:child_process";
-
-const thisDir = dirname(fileURLToPath(import.meta.url));
-const repoRoot = resolve(thisDir, "..");
-const entry = resolve(repoRoot, "stubs/position-edits-render-entry.ts");
-const generatedDir = resolve(repoRoot, "src/generated");
-const outPath = resolve(generatedDir, "position-edits-render-inline.ts");
-
-const result = buildSync({
- entryPoints: [entry],
- bundle: true,
- write: false,
- platform: "browser",
- format: "iife",
- target: ["es2020"],
- minify: true,
- legalComments: "none",
-});
-const iife = result.outputFiles[0]?.text ?? "";
-if (!iife) throw new Error("esbuild produced no output for position-edits-render-entry.ts");
-
-mkdirSync(generatedDir, { recursive: true });
-writeFileSync(
- outPath,
- [
- "// AUTO-GENERATED by scripts/build-position-edits-render.ts - do not edit",
- `const POSITION_EDITS_RENDER_IIFE: string = ${JSON.stringify(iife)};`,
- "",
- "/** Returns the pre-built position-edits render IIFE as a string constant. */",
- "export function getPositionEditsRenderScript(): string {",
- " return POSITION_EDITS_RENDER_IIFE;",
- "}",
- "",
- ].join("\n"),
- "utf8",
-);
-
-try {
- execFileSync("bun", ["x", "oxfmt", outPath], { stdio: "ignore" });
-} catch {
- // Formatting is best effort when the generator runs in a minimal environment.
-}
-
-console.log(
- JSON.stringify({ event: "position_edits_render_generated", outPath, bytes: iife.length }),
-);
diff --git a/packages/core/src/canary.test.ts b/packages/core/src/canary.test.ts
index e58441c927..477c22a2b6 100644
--- a/packages/core/src/canary.test.ts
+++ b/packages/core/src/canary.test.ts
@@ -426,3 +426,29 @@ describe("canary reason property", () => {
expect(canaryReasonKey("de-parallel-router")).toBe("canary_reason_de_parallel_router");
});
});
+
+/**
+ * The audio FX rack ships dark.
+ *
+ * Pinned as a test rather than trusted to review: the registry's own procedure
+ * is "start at percentage: 0 and merge that", and the whole point of landing a
+ * 47-PR stack behind a canary is defeated if the entry reaches main at anything
+ * else. A ramp is a deliberate edit to this number, and it should have to break
+ * a test that says so.
+ */
+describe("the audio-fx-rack canary", () => {
+ const entry = CANARIES.find((c) => c.name === "audio-fx-rack");
+
+ it("is registered", () => {
+ expect(entry, "audio-fx-rack missing from the registry").toBeDefined();
+ });
+
+ it("ships at 0%", () => {
+ expect(entry?.percentage).toBe(0);
+ });
+
+ it("carries a sunset date, so the fork cannot outlive the rollout", () => {
+ expect(entry?.sunsetAfter).toMatch(/^\d{4}-\d{2}-\d{2}$/);
+ expect(Date.parse(`${entry?.sunsetAfter}T00:00:00Z`)).toBeGreaterThan(Date.parse("2026-08-12"));
+ });
+});
diff --git a/packages/core/src/canaryRegistry.ts b/packages/core/src/canaryRegistry.ts
index bd948a0c5e..ce3c0ee7ec 100644
--- a/packages/core/src/canaryRegistry.ts
+++ b/packages/core/src/canaryRegistry.ts
@@ -80,6 +80,15 @@ export const CANARIES: readonly CanaryDefinition[] = [
owner: "vance",
sunsetAfter: "2026-09-15",
},
+ // ── Audio FX ─────────────────────────────────────────────────────────────
+ {
+ name: "audio-fx-rack",
+ percentage: 0,
+ description:
+ "Show the Audio FX rack on audio tracks in Studio — effects, presets, the voiceover carve and levelling. Gates the AUTHORING surface only: a composition that already carries data-fx-chain still plays and renders it, because a canary should stage who can reach a feature, not make a written attribute silently inert.",
+ owner: "vance",
+ sunsetAfter: "2026-11-15",
+ },
] as const;
export function findCanary(name: string): CanaryDefinition | undefined {
diff --git a/packages/core/src/editing/affordances.test.ts b/packages/core/src/editing/affordances.test.ts
index b975dd64bf..409d3780be 100644
--- a/packages/core/src/editing/affordances.test.ts
+++ b/packages/core/src/editing/affordances.test.ts
@@ -198,3 +198,14 @@ describe("resolveEditingSections (sections-only export)", () => {
expect(s).toMatchObject({ timing: true, animation: true });
});
});
+
+describe("audioFx section", () => {
+ it("applies to an audio element", () => {
+ expect(resolveEditingSections(baseFacts({ tag: "audio" })).audioFx).toBe(true);
+ });
+
+ it("does not apply to video, whose sound lives on a separate audio element", () => {
+ expect(resolveEditingSections(baseFacts({ tag: "video" })).audioFx).toBe(false);
+ expect(resolveEditingSections(baseFacts({ tag: "div" })).audioFx).toBe(false);
+ });
+});
diff --git a/packages/core/src/editing/affordances.ts b/packages/core/src/editing/affordances.ts
index 272fb028fb..f0e3be6ae9 100644
--- a/packages/core/src/editing/affordances.ts
+++ b/packages/core/src/editing/affordances.ts
@@ -34,6 +34,9 @@ export interface EditingSectionApplicability {
/** Position/size/rotation/stacking — meaningless on an element with no
* rendered box (e.g. `<audio>`, which never paints a visual frame). */
layout: boolean;
+ /** Audio FX chain and voiceover carve — `<audio>` only. Video carries its
+ * sound on a separate `<audio>` element, so this never applies to it. */
+ audioFx: boolean;
/** Fill/radius/stroke/shadow/blend-mode/clip — same "no rendered box" gate
* as `layout`, kept separate since a future tag could need one without
* the other. */
@@ -207,6 +210,7 @@ export function resolveEditingSections(facts: EditableElementFacts): EditingSect
return {
text: facts.hasEditableText && !facts.isCompositionHost && !facts.isInsideLockedComposition,
media: facts.tag === "video" || facts.tag === "audio" || facts.tag === "img",
+ audioFx: facts.tag === "audio",
colorGrading: facts.tag === "video" || facts.tag === "img",
timing: facts.hasTimingStart || facts.animationCount > 0,
animation: facts.animationCount > 0,
diff --git a/packages/core/src/generated/position-edits-render-inline.ts b/packages/core/src/generated/position-edits-render-inline.ts
index 82cac49a9a..0004bc6d49 100644
--- a/packages/core/src/generated/position-edits-render-inline.ts
+++ b/packages/core/src/generated/position-edits-render-inline.ts
@@ -1,4 +1,4 @@
-// AUTO-GENERATED by scripts/build-position-edits-render.ts - do not edit
+// AUTO-GENERATED by scripts/build-inline-artifact.ts - do not edit
const POSITION_EDITS_RENDER_IIFE: string =
'"use strict";(()=>{function A(){return globalThis}function P(e,t){if(typeof window>"u")return;let n=A(),r=n.__hf?.onSwallowed;if(r)try{r({label:e,error:t})}catch(i){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${e} swallowed:`,t)}var T=null;function R(e,t){if(T)try{T({source:"hf-preview",type:"analytics",event:e,properties:t??{}})}catch(n){P("runtime.analytics.site1",n)}}var w="data-hf-edit-base-x",k="data-hf-edit-base-y",y="data-hf-edit-original-translate",S=e=>{let t=parseFloat(e??"");return Number.isFinite(t)?t:0},V=e=>{let t=[],n=0,r="";for(let i of e.trim())i==="("&&(n+=1),i===")"&&(n=Math.max(0,n-1)),/\\s/.test(i)&&n===0?(r&&t.push(r),r=""):r+=i;return r&&t.push(r),t},$=/^-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)px$/,E=(e,t)=>$.test(e)&&$.test(t)?`${parseFloat(e)+parseFloat(t)}px`:`calc(${e} + ${t})`,I=(e,t,n)=>{if(!e||e==="none")return`${t} ${n}`;let[r,i,u]=V(e);if(r===void 0)return`${t} ${n}`;if(i===void 0)return`${E(r,t)} ${n}`;let d=u===void 0?"":` ${u}`;return`${E(r,t)} ${E(i,n)}${d}`},O=e=>{try{e.ownerDocument.defaultView?.gsap?.getProperty?.(e,"x")}catch{}},G=e=>{let t=e.style.getPropertyValue("translate").trim();if(t)return t==="none"?"":t;try{let n=e.ownerDocument.defaultView,r=n?n.getComputedStyle(e).getPropertyValue("translate").trim():"";return r==="none"?"":r}catch{return""}},h=new WeakMap;function H(e,t){let n=h.get(e);if(!t?.force&&n!==void 0&&e.style.getPropertyValue("translate")!==n){R("position_edit_fold_skipped",{hfId:e.getAttribute("data-hf-id")});return}let r=S(e.getAttribute("data-x"))-S(e.getAttribute(w)),i=S(e.getAttribute("data-y"))-S(e.getAttribute(k));e.hasAttribute(y)||e.setAttribute(y,G(e)),n===void 0&&O(e);let u=e.getAttribute(y)??"",d=I(u,`${r}px`,`${i}px`);e.style.setProperty("translate",d),h.set(e,e.style.getPropertyValue("translate"))}function v(e,t){let n=e.defaultView?.HTMLElement,r=e.defaultView?.SVGElement,i=a=>n||r?n!==void 0&&a instanceof n||r!==void 0&&a instanceof r:typeof a.style?.setProperty=="function",u=e.querySelectorAll(`[${y}]:not([${w}]):not([${k}])`);for(let a=0;a<u.length;a++){let l=u[a];if(l===void 0||!i(l))continue;let b=l.getAttribute(y)??"";b===""?l.style.removeProperty("translate"):l.style.setProperty("translate",b),l.removeAttribute(y),h.delete(l)}let d=e.querySelectorAll(`[${w}], [${k}]`),m=0;for(let a=0;a<d.length;a++){let l=d[a];l===void 0||!i(l)||(H(l,t),m+=1)}return m}var x="__hfPositionEditsSeekReapplyWrapped",D=new WeakSet,F=new WeakMap,W=new WeakMap;function L(e){let t=e,n=()=>{try{v(t.document)}catch{}},r=o=>typeof o=="function"&&(D.has(o)||!!o[x]),i=o=>{D.add(o);try{Object.defineProperty(o,x,{value:!0})}catch{}},u=o=>{if(typeof o!="function"||r(o))return o;let s=function(...c){let f=o.apply(this,c);return n(),f};return i(s),s},d=(o,s)=>{let c=F.get(o);if(c?.has(s))return!0;let f=Object.getOwnPropertyDescriptor(o,s);if(f?.configurable===!1){let p=o[s];return typeof p=="function"&&(o[s]=u(p),n()),!1}let g=o[s],_=f?.set;return Object.defineProperty(o,s,{configurable:!0,enumerable:f?.enumerable??!0,get:()=>g,set:p=>{g=u(p),_?.call(o,p)}}),g=u(g),c??(c=new Set),c.add(s),F.set(o,c),n(),!0},m=(o,s)=>{let c=W.get(t),f=Object.getOwnPropertyDescriptor(t,o);if(!c?.has(o)){if(f?.configurable===!1){let p=t[o];return p?d(p,s):!1}let _=t[o];Object.defineProperty(t,o,{configurable:!0,enumerable:f?.enumerable??!0,get:()=>_,set:p=>{_=p,_&&d(_,s)}}),c??(c=new Set),c.add(o),W.set(t,c)}let g=t[o];return g?d(g,s):!1},a=()=>{let o=m("__hf","seek"),s=m("__player","renderSeek");return o&&s};if(a())return;let l=120,b=t.setInterval(()=>{if(a()){t.clearInterval(b);return}l-=1,l<=0&&t.clearInterval(b)},50)}function M(){document.querySelector(`[${w}], [${k}]`)&&(v(document),L(window))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M,{once:!0}):M();})();\n';
diff --git a/packages/studio/src/components/editor/PropertyPanelFlat.tsx b/packages/studio/src/components/editor/PropertyPanelFlat.tsx
index 7d8e98dc26..3d267ed5f6 100644
--- a/packages/studio/src/components/editor/PropertyPanelFlat.tsx
+++ b/packages/studio/src/components/editor/PropertyPanelFlat.tsx
@@ -13,7 +13,22 @@ import { FlatTextSection } from "./propertyPanelFlatTextSection";
import { FlatStyleSection } from "./propertyPanelFlatStyleSections";
import { FlatLayoutSection } from "./propertyPanelFlatLayoutSection";
import { FlatMotionSection } from "./propertyPanelFlatMotionSection";
+import {
+ HF_AUDIO_FX_ATTR,
+ parseAudioFxChain,
+ serializeAudioFxChain,
+ type HfAudioFxChain,
+} from "@hyperframes/core/audio-fx";
+import {
+ HF_AUDIO_CARVE_ATTR,
+ normalizeCarveSettings,
+ type HfCarveSettings,
+} from "@hyperframes/core/audio-carve";
+import { isCanaryEnabled } from "../../telemetry/canary";
+import { audioFxSummary } from "./audioFxSummary";
import { FlatMediaSection } from "./propertyPanelFlatMediaSection";
+import type { DomEditSelection } from "./domEditing";
+import { FxSection, type AudioTrackOption } from "./propertyPanelFxSection";
import { deriveElementTiming } from "./propertyPanelFlatTimingDerivation";
import { createGsapLivePreview } from "./gsapLivePreview";
import { formatTextFieldPreview } from "./propertyPanelSections";
@@ -420,6 +435,17 @@ export function PropertyPanelFlat({
});
}
}
+ // Behind `audio-fx-rack`, at 0%. Gates the AUTHORING surface only: the runtime
+ // and render still honour a `data-fx-chain` already on an element, so a
+ // composition written through the skill does not go silently dry off-cohort.
+ if (sections.audioFx && isCanaryEnabled("audio-fx-rack")) {
+ groups.push({
+ id: "audio-fx",
+ title: "Audio FX",
+ summary: audioFxSummary(element),
+ content: <AudioFxGroup element={element} onSetAttribute={onSetAttribute} />,
+ });
+ }
if (sections.media) {
groups.push({
id: "media",
@@ -514,3 +540,60 @@ export function PropertyPanelFlat({
</DesignPanelInputProvider>
);
}
+
+/**
+ * Bridges the FX panel to the element/attribute world. Chain and carve are
+ * serialised onto the element the way colour grading carries its config, so
+ * persistence is an ordinary attribute write with no new server route.
+ */
+function AudioFxGroup({
+ element,
+ onSetAttribute,
+}: {
+ element: DomEditSelection;
+ onSetAttribute: (attr: string, value: string) => void | Promise<void>;
+}) {
+ const chain = ((): HfAudioFxChain => {
+ const raw = element.dataAttributes?.["fx-chain"];
+ if (!raw) return { version: 1, nodes: [] };
+ try {
+ return parseAudioFxChain(raw);
+ } catch {
+ // Show an unreadable chain as empty rather than breaking the panel; the
+ // attribute is left untouched until the user changes something.
+ return { version: 1, nodes: [] };
+ }
+ })();
+
+ const carve = ((): HfCarveSettings | null => {
+ const raw = element.dataAttributes?.["fx-carve"];
+ if (!raw) return null;
+ try {
+ return normalizeCarveSettings(JSON.parse(raw));
+ } catch {
+ return null;
+ }
+ })();
+
+ const sourceOptions: AudioTrackOption[] = (() => {
+ const doc = element.element?.ownerDocument;
+ if (!doc) return [];
+ return Array.from(doc.querySelectorAll<HTMLAudioElement>("audio[id]"))
+ .filter((a) => a.id !== element.id)
+ .map((a) => ({ id: a.id, label: a.id }));
+ })();
+
+ return (
+ <FxSection
+ chain={chain}
+ onChainChange={(next) =>
+ onSetAttribute(HF_AUDIO_FX_ATTR, next.nodes.length ? serializeAudioFxChain(next) : "")
+ }
+ carve={carve}
+ onCarveChange={(next) =>
+ onSetAttribute(HF_AUDIO_CARVE_ATTR, next ? JSON.stringify(next) : "")
+ }
+ sourceOptions={sourceOptions}
+ />
+ );
+}
diff --git a/packages/studio/src/components/editor/audioFxSummary.ts b/packages/studio/src/components/editor/audioFxSummary.ts
new file mode 100644
index 0000000000..9accb8cfad
--- /dev/null
+++ b/packages/studio/src/components/editor/audioFxSummary.ts
@@ -0,0 +1,27 @@
+/**
+ * What the collapsed Audio FX group says it holds.
+ *
+ * Its own module because `PropertyPanelFlat.tsx` is at the repo's 600-line
+ * budget, and this is the piece with no dependency on the panel around it.
+ */
+
+import { parseAudioFxChain } from "@hyperframes/core/audio-fx";
+import type { DomEditSelection } from "./domEditing";
+
+/** Chain length at a glance, so the collapsed group says whether anything is on. */
+export function audioFxSummary(element: DomEditSelection): string {
+ const raw = element.dataAttributes?.["fx-chain"];
+ const carve = element.dataAttributes?.["fx-carve"];
+ let count = 0;
+ if (raw) {
+ try {
+ count = parseAudioFxChain(raw).nodes.filter((n) => n.enabled !== false).length;
+ } catch {
+ return "unreadable";
+ }
+ }
+ const parts: string[] = [];
+ if (count > 0) parts.push(`${count} effect${count === 1 ? "" : "s"}`);
+ if (carve) parts.push("carve");
+ return parts.length > 0 ? parts.join(" + ") : "none";
+}
diff --git a/packages/studio/src/components/editor/propertyPanelFxControls.tsx b/packages/studio/src/components/editor/propertyPanelFxControls.tsx
new file mode 100644
index 0000000000..2181e2451f
--- /dev/null
+++ b/packages/studio/src/components/editor/propertyPanelFxControls.tsx
@@ -0,0 +1,146 @@
+/**
+ * Controls for one effect, generated from its registry entry.
+ *
+ * Nothing here knows what a compressor is. The registry declares each
+ * parameter's range, step, unit and scale, and this renders whatever it finds —
+ * so adding an effect or a knob upstream needs no change in the panel, and the
+ * panel cannot offer a value the renderer would reject.
+ */
+
+import { useCallback } from "react";
+import type {
+ HfAudioFxDef,
+ HfAudioFxNumberParam,
+ HfAudioFxParam,
+ HfAudioFxParamValues,
+} from "@hyperframes/core/audio-fx";
+
+/**
+ * Frequency and time controls span three or four decades, so a linear slider
+ * spends most of its travel somewhere useless. Those declare `scale: "log"` and
+ * the slider position maps exponentially instead.
+ */
+function toSlider(p: HfAudioFxNumberParam, value: number): number {
+ if (p.scale !== "log" || p.min <= 0) return value;
+ const t = (Math.log(value) - Math.log(p.min)) / (Math.log(p.max) - Math.log(p.min));
+ return p.min + t * (p.max - p.min);
+}
+
+function fromSlider(p: HfAudioFxNumberParam, position: number): number {
+ if (p.scale !== "log" || p.min <= 0) return position;
+ const t = (position - p.min) / (p.max - p.min);
+ return Math.exp(Math.log(p.min) + t * (Math.log(p.max) - Math.log(p.min)));
+}
+
+/** Enough precision to be honest without showing float noise. */
+function display(p: HfAudioFxNumberParam, value: number): string {
+ const decimals = p.step >= 1 ? 0 : p.step >= 0.1 ? 1 : 2;
+ return value.toFixed(decimals);
+}
+
+interface ParamRowProps {
+ param: HfAudioFxParam;
+ value: number | string;
+ onChange(key: string, value: number | string): void;
+ disabled?: boolean;
+}
+
+export function FxParamRow({ param, value, onChange, disabled }: ParamRowProps) {
+ const handleNumber = useCallback(
+ (raw: number) => {
+ const p = param as HfAudioFxNumberParam;
+ onChange(param.key, Math.min(p.max, Math.max(p.min, raw)));
+ },
+ [param, onChange],
+ );
+
+ if (param.kind === "enum") {
+ return (
+ <label className="hf-fx-row flex min-h-6 items-center gap-2" title={param.hint}>
+ <span className="hf-fx-label w-[86px] flex-shrink-0 truncate text-[10px] text-panel-text-4">
+ {param.label}
+ </span>
+ <select
+ className="hf-fx-select min-w-0 flex-1 rounded-[3px] bg-panel-surface px-1 py-0.5 font-mono text-[10px] text-panel-text-0"
+ value={String(value)}
+ disabled={disabled}
+ onChange={(e) => onChange(param.key, e.target.value)}
+ >
+ {param.options.map((o) => (
+ <option key={o.value} value={o.value}>
+ {o.label}
+ </option>
+ ))}
+ </select>
+ </label>
+ );
+ }
+
+ const numeric = typeof value === "number" ? value : Number(value);
+ const current = Number.isFinite(numeric) ? numeric : param.default;
+
+ return (
+ <label className="hf-fx-row flex min-h-6 items-center gap-2" title={param.hint}>
+ <span className="hf-fx-label w-[86px] flex-shrink-0 truncate text-[10px] text-panel-text-4">
+ {param.label}
+ </span>
+ <input
+ className="hf-fx-slider h-1 min-w-0 flex-1 accent-panel-accent"
+ type="range"
+ min={param.min}
+ max={param.max}
+ step={(param.max - param.min) / 1000}
+ value={toSlider(param, current)}
+ disabled={disabled}
+ aria-label={param.label}
+ onChange={(e) => handleNumber(fromSlider(param, Number(e.target.value)))}
+ />
+ <input
+ className="hf-fx-number w-[54px] flex-shrink-0 rounded-[3px] bg-panel-surface px-1 py-0.5 text-right font-mono text-[10px] text-panel-text-0"
+ type="number"
+ min={param.min}
+ max={param.max}
+ step={param.step}
+ value={display(param, current)}
+ disabled={disabled}
+ onChange={(e) => {
+ const next = Number(e.target.value);
+ if (Number.isFinite(next)) handleNumber(next);
+ }}
+ />
+ {param.unit ? (
+ <span className="hf-fx-unit w-[22px] flex-shrink-0 font-mono text-[9px] text-panel-text-4">
+ {param.unit}
+ </span>
+ ) : null}
+ </label>
+ );
+}
+
+interface FxParamsProps {
+ def: HfAudioFxDef;
+ params: HfAudioFxParamValues;
+ onChange(params: HfAudioFxParamValues): void;
+ disabled?: boolean;
+}
+
+/** Every knob the effect declares, in registry order. */
+export function FxParams({ def, params, onChange, disabled }: FxParamsProps) {
+ const set = useCallback(
+ (key: string, value: number | string) => onChange({ ...params, [key]: value }),
+ [params, onChange],
+ );
+ return (
+ <div className="hf-fx-params space-y-0.5 border-t border-panel-border-input px-1.5 py-1.5">
+ {def.params.map((p) => (
+ <FxParamRow
+ key={p.key}
+ param={p}
+ value={params[p.key] ?? p.default}
+ onChange={set}
+ disabled={disabled}
+ />
+ ))}
+ </div>
+ );
+}
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
new file mode 100644
index 0000000000..e702b5b84e
--- /dev/null
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
@@ -0,0 +1,211 @@
+// @vitest-environment happy-dom
+import { act } from "react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import {
+ defaultAudioFxParams,
+ getAudioFxDef,
+ HF_AUDIO_FX,
+ type HfAudioFxChain,
+} from "@hyperframes/core/audio-fx";
+import { DEFAULT_CARVE } from "@hyperframes/core/audio-carve";
+import { createRoot } from "react-dom/client";
+import { FxSection } from "./propertyPanelFxSection.js";
+
+(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+function renderInto(node: React.ReactElement) {
+ const host = document.createElement("div");
+ document.body.append(host);
+ const root = createRoot(host);
+ act(() => {
+ root.render(node);
+ });
+ return { host, root };
+}
+
+const chainOf = (...types: string[]): HfAudioFxChain => ({
+ version: 1,
+ nodes: types.map((t) => ({ type: t, enabled: true, params: defaultAudioFxParams(t) })),
+});
+
+const noop = () => {};
+
+function mount(overrides: Partial<Parameters<typeof FxSection>[0]> = {}) {
+ const onChainChange = vi.fn();
+ const onCarveChange = vi.fn();
+ const { host } = renderInto(
+ <FxSection
+ chain={overrides.chain ?? { version: 1, nodes: [] }}
+ onChainChange={overrides.onChainChange ?? onChainChange}
+ carve={overrides.carve ?? null}
+ onCarveChange={overrides.onCarveChange ?? onCarveChange}
+ sourceOptions={overrides.sourceOptions ?? [{ id: "vo", label: "Voiceover" }]}
+ onAnalyseCarve={overrides.onAnalyseCarve ?? noop}
+ analysing={overrides.analysing}
+ disabled={overrides.disabled}
+ />,
+ );
+ return { host, onChainChange, onCarveChange };
+}
+
+const click = (el: Element | null | undefined) => {
+ if (!el) throw new Error("element not found");
+ act(() => {
+ (el as HTMLElement).click();
+ });
+};
+const byText = (host: HTMLElement, sel: string, text: string) =>
+ Array.from(host.querySelectorAll(sel)).find((e) => e.textContent?.trim() === text);
+
+const openAddMenuItems = (host: HTMLElement) => {
+ click(host.querySelector(".hf-fx-add"));
+ return Array.from(host.querySelectorAll(".hf-fx-add-item")).map((e) => e.textContent?.trim());
+};
+
+/**
+ * React tracks an input's value on the DOM node, so assigning `.value` and
+ * dispatching looks like a no-op change and the handler never fires. Going
+ * through the native setter clears that tracker.
+ */
+const typeInto = (input: HTMLInputElement, value: string) => {
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
+ act(() => {
+ setter?.call(input, value);
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ });
+};
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ document.body.innerHTML = "";
+});
+
+describe("FxSection chain", () => {
+ it("says so when the track has no effects", () => {
+ const { host } = mount();
+ expect(host.querySelector(".hf-fx-empty")?.textContent).toMatch(/No effects/);
+ });
+
+ it("offers every effect in the registry, grouped", () => {
+ // The add menu is generated, so a new effect upstream appears here with no
+ // change to the panel.
+ const { host } = mount();
+ const items = openAddMenuItems(host);
+ expect(items).toHaveLength(HF_AUDIO_FX.length);
+ for (const def of HF_AUDIO_FX) expect(items).toContain(def.label);
+ });
+
+ it("adds an effect seeded with its declared defaults", () => {
+ const { host, onChainChange } = mount();
+ click(host.querySelector(".hf-fx-add"));
+ click(byText(host, ".hf-fx-add-item", "Compressor"));
+ expect(onChainChange).toHaveBeenCalledTimes(1);
+ const next = onChainChange.mock.calls[0]![0] as HfAudioFxChain;
+ expect(next.nodes).toHaveLength(1);
+ expect(next.nodes[0]!.type).toBe("compressor");
+ expect(next.nodes[0]!.params).toEqual(defaultAudioFxParams("compressor"));
+ });
+
+ it("renders a control for every parameter the effect declares", () => {
+ const { host } = mount({ chain: chainOf("compressor") });
+ const def = getAudioFxDef("compressor")!;
+ const labels = Array.from(host.querySelectorAll(".hf-fx-label")).map((e) =>
+ e.textContent?.trim(),
+ );
+ for (const p of def.params) expect(labels).toContain(p.label);
+ });
+
+ it("uses a select for an enum parameter and a slider for a number", () => {
+ const { host } = mount({ chain: chainOf("saturate") });
+ expect(host.querySelector(".hf-fx-select")).toBeTruthy();
+ expect(host.querySelector(".hf-fx-slider")).toBeTruthy();
+ });
+
+ it("bypasses without removing, so the settings survive", () => {
+ const { host, onChainChange } = mount({ chain: chainOf("peaking") });
+ click(host.querySelector(".hf-fx-bypass"));
+ const next = onChainChange.mock.calls[0]![0] as HfAudioFxChain;
+ expect(next.nodes).toHaveLength(1);
+ expect(next.nodes[0]!.enabled).toBe(false);
+ expect(next.nodes[0]!.params).toEqual(defaultAudioFxParams("peaking"));
+ });
+
+ it("reorders, because chain order changes the sound", () => {
+ const { host, onChainChange } = mount({ chain: chainOf("peaking", "reverb") });
+ const downs = Array.from(host.querySelectorAll('.hf-fx-move[title="Move down"]'));
+ click(downs[0]);
+ const next = onChainChange.mock.calls[0]![0] as HfAudioFxChain;
+ expect(next.nodes.map((n) => n.type)).toEqual(["reverb", "peaking"]);
+ });
+
+ it("cannot move the ends past themselves", () => {
+ const { host } = mount({ chain: chainOf("peaking", "reverb") });
+ const ups = host.querySelectorAll('.hf-fx-move[title="Move up"]');
+ const downs = host.querySelectorAll('.hf-fx-move[title="Move down"]');
+ expect((ups[0] as HTMLButtonElement).disabled).toBe(true);
+ expect((downs[1] as HTMLButtonElement).disabled).toBe(true);
+ });
+
+ it("removes an effect", () => {
+ const { host, onChainChange } = mount({ chain: chainOf("peaking", "reverb") });
+ click(host.querySelector(".hf-fx-remove"));
+ const next = onChainChange.mock.calls[0]![0] as HfAudioFxChain;
+ expect(next.nodes.map((n) => n.type)).toEqual(["reverb"]);
+ });
+
+ it("clamps a typed value into the renderable range", () => {
+ const { host, onChainChange } = mount({ chain: chainOf("peaking") });
+ typeInto(host.querySelector<HTMLInputElement>(".hf-fx-number")!, "999999");
+ const next = onChainChange.mock.calls.at(-1)![0] as HfAudioFxChain;
+ expect(next.nodes[0]!.params!.frequency).toBe(20000);
+ });
+});
+
+describe("FxSection carve", () => {
+ it("is off by default and is not an entry in the chain", () => {
+ const { host } = mount();
+ expect(host.querySelector(".hf-fx-carve")).toBeTruthy();
+ const items = openAddMenuItems(host);
+ expect(items).not.toContain("Voiceover carve");
+ });
+
+ it("turns on with defaults", () => {
+ const { host, onCarveChange } = mount();
+ click(host.querySelector(".hf-fx-carve .hf-fx-bypass"));
+ expect(onCarveChange).toHaveBeenCalledWith({ ...DEFAULT_CARVE });
+ });
+
+ it("lists the other audio tracks as carve sources", () => {
+ const { host } = mount({
+ carve: { ...DEFAULT_CARVE },
+ sourceOptions: [
+ { id: "vo", label: "Voiceover" },
+ { id: "nar", label: "Narration" },
+ ],
+ });
+ const options = Array.from(host.querySelectorAll(".hf-fx-carve select option")).map((o) =>
+ o.textContent?.trim(),
+ );
+ expect(options).toContain("Voiceover");
+ expect(options).toContain("Narration");
+ });
+
+ it("will not analyse until a source is chosen", () => {
+ const { host } = mount({ carve: { ...DEFAULT_CARVE, source: "" } });
+ expect(host.querySelector<HTMLButtonElement>(".hf-fx-analyse")!.disabled).toBe(true);
+ });
+
+ it("analyses once a source is chosen", () => {
+ const onAnalyseCarve = vi.fn();
+ const { host } = mount({ carve: { ...DEFAULT_CARVE, source: "vo" }, onAnalyseCarve });
+ click(host.querySelector(".hf-fx-analyse"));
+ expect(onAnalyseCarve).toHaveBeenCalledTimes(1);
+ });
+
+ it("disables everything when the panel is read-only", () => {
+ const { host } = mount({ chain: chainOf("peaking"), disabled: true });
+ for (const b of Array.from(host.querySelectorAll("button.hf-fx-bypass, .hf-fx-remove"))) {
+ expect((b as HTMLButtonElement).disabled).toBe(true);
+ }
+ });
+});
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
new file mode 100644
index 0000000000..efdc1a2288
--- /dev/null
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
@@ -0,0 +1,387 @@
+/**
+ * The FX section for an audio element: the chain, plus the voiceover carve.
+ *
+ * Carve is deliberately not an entry in the chain. It is a relationship between
+ * two tracks — it analyses a voice and dips *this* bed where that voice sits —
+ * so it gets its own block with a source picker, the way a sidechain control
+ * lives on the track being processed. What it produces is an ordinary chain of
+ * peaking filters, so it composes with whatever else is on the track.
+ */
+
+import { useCallback, useMemo, useState } from "react";
+import {
+ defaultAudioFxParams,
+ getAudioFxDef,
+ HF_AUDIO_FX,
+ type HfAudioFxChain,
+ type HfAudioFxGroup,
+ type HfAudioFxNode,
+ type HfAudioFxParamValues,
+} from "@hyperframes/core/audio-fx";
+import { DEFAULT_CARVE, type HfCarveSettings } from "@hyperframes/core/audio-carve";
+import { FxParams, FxParamRow } from "./propertyPanelFxControls.js";
+
+const GROUP_ORDER: HfAudioFxGroup[] = ["filter", "dynamics", "nonlinear", "time"];
+const GROUP_LABEL: Record<HfAudioFxGroup, string> = {
+ filter: "Filters",
+ dynamics: "Dynamics",
+ nonlinear: "Non-linear",
+ time: "Time",
+};
+
+export interface AudioTrackOption {
+ id: string;
+ label: string;
+}
+
+export interface FxSectionProps {
+ chain: HfAudioFxChain;
+ onChainChange(chain: HfAudioFxChain): void;
+ carve: HfCarveSettings | null;
+ onCarveChange(carve: HfCarveSettings | null): void;
+ /** Other audio elements that could act as the carve source. */
+ sourceOptions: AudioTrackOption[];
+ /** Re-run analysis against the current source audio. */
+ onAnalyseCarve?(): void;
+ analysing?: boolean;
+ disabled?: boolean;
+}
+
+function FxNodeControls({
+ label,
+ index,
+ total,
+ open,
+ bypassed,
+ disabled,
+ onToggleOpen,
+ onToggleBypass,
+ onMove,
+ onRemove,
+}: {
+ label: string;
+ index: number;
+ total: number;
+ open: boolean;
+ bypassed: boolean;
+ disabled?: boolean;
+ onToggleOpen(): void;
+ onToggleBypass(): void;
+ onMove(delta: number): void;
+ onRemove(): void;
+}) {
+ return (
+ <div className="hf-fx-node-head flex min-h-7 items-center gap-1 px-1.5">
+ <button
+ type="button"
+ className="hf-fx-node-name flex-1 truncate text-left text-[11px] font-semibold text-panel-text-1 hover:text-panel-text-0"
+ aria-expanded={open}
+ onClick={onToggleOpen}
+ >
+ {label}
+ </button>
+ <button
+ type="button"
+ className="hf-fx-bypass rounded-[3px] border border-panel-border-input px-1.5 py-0.5 font-mono text-[9px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
+ aria-pressed={bypassed}
+ title={bypassed ? "Enable" : "Bypass"}
+ disabled={disabled}
+ onClick={onToggleBypass}
+ >
+ {bypassed ? "Off" : "On"}
+ </button>
+ <button
+ type="button"
+ className="hf-fx-move px-1 font-mono text-[10px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-25"
+ title="Move up"
+ disabled={disabled || index === 0}
+ onClick={() => onMove(-1)}
+ >
+ &uarr;
+ </button>
+ <button
+ type="button"
+ className="hf-fx-move px-1 font-mono text-[10px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-25"
+ title="Move down"
+ disabled={disabled || index === total - 1}
+ onClick={() => onMove(1)}
+ >
+ &darr;
+ </button>
+ <button
+ type="button"
+ className="hf-fx-remove px-1 font-mono text-[11px] text-panel-text-4 hover:text-red-400 disabled:opacity-40"
+ title="Remove"
+ disabled={disabled}
+ onClick={onRemove}
+ >
+ &times;
+ </button>
+ </div>
+ );
+}
+
+function FxNodeRow({
+ node,
+ index,
+ total,
+ open,
+ disabled,
+ onToggleOpen,
+ onUpdate,
+ onMove,
+ onRemove,
+}: {
+ node: HfAudioFxNode;
+ index: number;
+ total: number;
+ open: boolean;
+ disabled?: boolean;
+ onToggleOpen(): void;
+ onUpdate(index: number, patch: Partial<HfAudioFxNode>): void;
+ onMove(index: number, delta: number): void;
+ onRemove(index: number): void;
+}) {
+ const def = getAudioFxDef(node.type);
+ if (!def) return null;
+ const bypassed = node.enabled === false;
+ return (
+ <div
+ className={`hf-fx-node rounded-[4px] border border-panel-border-input${bypassed ? " opacity-50" : ""}`}
+ data-fx-node={node.type}
+ >
+ <FxNodeControls
+ label={def.label}
+ index={index}
+ total={total}
+ open={open}
+ bypassed={bypassed}
+ disabled={disabled}
+ onToggleOpen={onToggleOpen}
+ onToggleBypass={() => onUpdate(index, { enabled: bypassed })}
+ onMove={(delta) => onMove(index, delta)}
+ onRemove={() => onRemove(index)}
+ />
+ {open ? (
+ <FxParams
+ def={def}
+ params={node.params ?? defaultAudioFxParams(node.type)}
+ disabled={disabled || bypassed}
+ onChange={(params: HfAudioFxParamValues) => onUpdate(index, { params })}
+ />
+ ) : null}
+ </div>
+ );
+}
+
+export function FxSection({
+ chain,
+ onChainChange,
+ carve,
+ onCarveChange,
+ sourceOptions,
+ onAnalyseCarve,
+ analysing,
+ disabled,
+}: FxSectionProps) {
+ const [adding, setAdding] = useState(false);
+ const [openNode, setOpenNode] = useState<number | null>(0);
+
+ const grouped = useMemo(
+ () => GROUP_ORDER.map((g) => ({ group: g, defs: HF_AUDIO_FX.filter((d) => d.group === g) })),
+ [],
+ );
+
+ const mutate = useCallback(
+ (nodes: HfAudioFxNode[]) => onChainChange({ ...chain, nodes }),
+ [chain, onChainChange],
+ );
+
+ const addEffect = useCallback(
+ (type: string) => {
+ mutate([...chain.nodes, { type, enabled: true, params: defaultAudioFxParams(type) }]);
+ setOpenNode(chain.nodes.length);
+ setAdding(false);
+ },
+ [chain.nodes, mutate],
+ );
+
+ const updateNode = useCallback(
+ (index: number, patch: Partial<HfAudioFxNode>) =>
+ mutate(chain.nodes.map((n, i) => (i === index ? { ...n, ...patch } : n))),
+ [chain.nodes, mutate],
+ );
+
+ const removeNode = useCallback(
+ (index: number) => {
+ mutate(chain.nodes.filter((_, i) => i !== index));
+ setOpenNode(null);
+ },
+ [chain.nodes, mutate],
+ );
+
+ const moveNode = useCallback(
+ (index: number, delta: number) => {
+ const target = index + delta;
+ if (target < 0 || target >= chain.nodes.length) return;
+ const next = [...chain.nodes];
+ const [moved] = next.splice(index, 1);
+ next.splice(target, 0, moved!);
+ mutate(next);
+ setOpenNode(target);
+ },
+ [chain.nodes, mutate],
+ );
+
+ return (
+ <div className="hf-fx-section space-y-2">
+ <div className="hf-fx-chain space-y-1">
+ {chain.nodes.length === 0 ? (
+ <p className="hf-fx-empty py-1 text-[11px] text-panel-text-4">
+ No effects on this track.
+ </p>
+ ) : (
+ chain.nodes.map((node, i) => (
+ <FxNodeRow
+ key={`${node.type}-${i}`}
+ node={node}
+ index={i}
+ total={chain.nodes.length}
+ open={openNode === i}
+ disabled={disabled}
+ onToggleOpen={() => setOpenNode(openNode === i ? null : i)}
+ onUpdate={updateNode}
+ onMove={moveNode}
+ onRemove={removeNode}
+ />
+ ))
+ )}
+ </div>
+
+ {adding ? (
+ <div className="hf-fx-add-menu space-y-1.5 rounded-[4px] border border-panel-border-input p-1.5">
+ {grouped.map(({ group, defs }) => (
+ <div key={group} className="hf-fx-add-group flex flex-wrap items-center gap-1">
+ <span className="hf-fx-add-group-label w-full font-mono text-[9px] uppercase tracking-wide text-panel-text-4">
+ {GROUP_LABEL[group]}
+ </span>
+ {defs.map((d) => (
+ <button
+ key={d.id}
+ type="button"
+ className="hf-fx-add-item rounded-[3px] bg-panel-surface px-1.5 py-0.5 text-[10px] text-panel-text-1 hover:text-panel-text-0"
+ title={d.description}
+ onClick={() => addEffect(d.id)}
+ >
+ {d.label}
+ </button>
+ ))}
+ </div>
+ ))}
+ </div>
+ ) : (
+ <button
+ type="button"
+ className="hf-fx-add w-full rounded-[4px] border border-dashed border-panel-border-input py-1 text-[11px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
+ disabled={disabled}
+ onClick={() => setAdding(true)}
+ >
+ Add effect
+ </button>
+ )}
+
+ <div className="hf-fx-carve space-y-1 rounded-[4px] border border-panel-border-input p-1.5">
+ <div className="hf-fx-carve-head flex min-h-6 items-center justify-between">
+ <span className="hf-fx-carve-title text-[11px] font-semibold text-panel-text-1">
+ Voiceover carve
+ </span>
+ <button
+ type="button"
+ className="hf-fx-bypass rounded-[3px] border border-panel-border-input px-1.5 py-0.5 font-mono text-[9px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
+ aria-pressed={carve !== null}
+ disabled={disabled}
+ onClick={() => onCarveChange(carve ? null : { ...DEFAULT_CARVE })}
+ >
+ {carve ? "On" : "Off"}
+ </button>
+ </div>
+ {carve ? (
+ <>
+ <label className="hf-fx-row flex min-h-6 items-center gap-2">
+ <span className="hf-fx-label w-[86px] flex-shrink-0 truncate text-[10px] text-panel-text-4">
+ Listen to
+ </span>
+ <select
+ className="hf-fx-select min-w-0 flex-1 rounded-[3px] bg-panel-surface px-1 py-0.5 font-mono text-[10px] text-panel-text-0"
+ value={carve.source}
+ disabled={disabled}
+ onChange={(e) => onCarveChange({ ...carve, source: e.target.value })}
+ >
+ <option value="">Select a voice track…</option>
+ {sourceOptions.map((o) => (
+ <option key={o.id} value={o.id}>
+ {o.label}
+ </option>
+ ))}
+ </select>
+ </label>
+ <FxParamRow
+ param={{
+ kind: "number",
+ key: "maxCutDb",
+ label: "Depth",
+ unit: "dB",
+ min: 0,
+ max: 24,
+ step: 0.5,
+ default: DEFAULT_CARVE.maxCutDb,
+ }}
+ value={carve.maxCutDb}
+ disabled={disabled}
+ onChange={(_k, v) => onCarveChange({ ...carve, maxCutDb: Number(v) })}
+ />
+ <FxParamRow
+ param={{
+ kind: "number",
+ key: "bands",
+ label: "Bands",
+ unit: "",
+ min: 1,
+ max: 6,
+ step: 1,
+ default: DEFAULT_CARVE.bands,
+ }}
+ value={carve.bands}
+ disabled={disabled}
+ onChange={(_k, v) => onCarveChange({ ...carve, bands: Number(v) })}
+ />
+ <FxParamRow
+ param={{
+ kind: "number",
+ key: "intelligibilityBias",
+ label: "Speech bias",
+ unit: "",
+ min: 0,
+ max: 1,
+ step: 0.05,
+ default: DEFAULT_CARVE.intelligibilityBias,
+ hint: "At 0 the deepest cuts follow raw voice energy, which lands on the fundamental. Higher weights selection toward 1-3 kHz, where a bed actually masks a voice.",
+ }}
+ value={carve.intelligibilityBias}
+ disabled={disabled}
+ onChange={(_k, v) => onCarveChange({ ...carve, intelligibilityBias: Number(v) })}
+ />
+ <button
+ type="button"
+ className="hf-fx-analyse mt-1 w-full rounded-[3px] bg-panel-surface py-1 text-[10px] text-panel-text-1 hover:text-panel-text-0 disabled:opacity-40"
+ disabled={disabled || analysing || !carve.source || !onAnalyseCarve}
+ onClick={() => onAnalyseCarve?.()}
+ >
+ {analysing ? "Analysing…" : "Analyse and apply"}
+ </button>
+ </>
+ ) : null}
+ </div>
+ </div>
+ );
+}
diff --git a/scripts/check-no-main-deletions.mjs b/scripts/check-no-main-deletions.mjs
index 4c21c323e3..e23c339699 100644
--- a/scripts/check-no-main-deletions.mjs
+++ b/scripts/check-no-main-deletions.mjs
@@ -49,6 +49,14 @@ export const ALLOWED_DELETIONS = new Map([
"skills/embedded-captions/themes/PORTING.md",
"#3219: same, zero inbound references; a theme-authoring procedure whose inputs (cap_fx3 demos, frame corpora, CONTRACT.md) are not distributed with the skill",
],
+ [
+ "packages/core/scripts/build-audio-fx-runtime.ts",
+ "merged into build-inline-artifact.ts: this and build-position-edits-render.ts were a byte-for-byte clone differing only in five names, which fallow's duplication check kept re-flagging on every unrelated line shift",
+ ],
+ [
+ "packages/core/scripts/build-position-edits-render.ts",
+ "merged into build-inline-artifact.ts, same reason as build-audio-fx-runtime.ts above",
+ ],
]);
export function parseBase(argv, fallback = "origin/main") {