diff --git a/packages/studio/src/components/editor/PropertyPanel.test.tsx b/packages/studio/src/components/editor/PropertyPanel.test.tsx index 84080056a2..89c34a8f14 100644 --- a/packages/studio/src/components/editor/PropertyPanel.test.tsx +++ b/packages/studio/src/components/editor/PropertyPanel.test.tsx @@ -675,6 +675,52 @@ function audioElement() { }; } +describe("PropertyPanel — STUDIO_VST_ENABLED gate", () => { + it( + "does not render the VST FX section for an audio element by default (flag off)", + async () => { + const { host, root } = await renderPanel(false, audioElement() as never); + expect(host.querySelector('[data-vst-install-hint="true"]')).toBeNull(); + expect(host.querySelector("[data-vst-add-effect]")).toBeNull(); + act(() => root.unmount()); + }, + RENDER_TIMEOUT_MS, + ); + + it( + "renders the VST FX section for an audio element once STUDIO_VST_ENABLED is on", + async () => { + vi.doMock("./manualEditingAvailability", async () => { + const actual = await vi.importActual( + "./manualEditingAvailability", + ); + return { ...actual, STUDIO_FLAT_INSPECTOR_ENABLED: false, STUDIO_VST_ENABLED: true }; + }); + vi.resetModules(); + const { PropertyPanel } = await import("./PropertyPanel"); + const host = document.createElement("div"); + document.body.append(host); + const root = createRoot(host); + const props = { + element: audioElement(), + assets: [], + onSetStyle: vi.fn(), + onSetText: vi.fn(), + onSetAttributeLive: vi.fn(), + } as unknown as PropertyPanelProps; + act(() => { + root.render(); + }); + expect( + host.querySelector('[data-vst-install-hint="true"]') || + host.querySelector("[data-vst-add-effect]"), + ).not.toBeNull(); + act(() => root.unmount()); + }, + RENDER_TIMEOUT_MS, + ); +}); + // All FlatGroup titles currently mounted (open row + every collapsed row). function flatGroupTitles(host: HTMLElement): string[] { const open = Array.from( diff --git a/packages/studio/src/components/editor/PropertyPanel.tsx b/packages/studio/src/components/editor/PropertyPanel.tsx index 13e5edda01..42dad8eb93 100644 --- a/packages/studio/src/components/editor/PropertyPanel.tsx +++ b/packages/studio/src/components/editor/PropertyPanel.tsx @@ -30,6 +30,7 @@ import { STUDIO_FLAT_INSPECTOR_ENABLED, STUDIO_GSAP_PANEL_ENABLED, STUDIO_KEYFRAMES_ENABLED, + STUDIO_VST_ENABLED, } from "./manualEditingAvailability"; import { PropertyPanelFlat } from "./PropertyPanelFlat"; import { createGsapLivePreview } from "./gsapLivePreview"; @@ -374,7 +375,7 @@ export const PropertyPanel = memo(function PropertyPanel(props: PropertyPanelPro /> )} - {sections.vstFx && ( + {STUDIO_VST_ENABLED && sections.vstFx && ( ({ + STUDIO_VST_ENABLED: true, +})); + (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true; // ── Fake Web Audio (this environment has none at all) ─────────────────────── diff --git a/packages/studio/src/player/hooks/useVstPreview.ts b/packages/studio/src/player/hooks/useVstPreview.ts index 8bff0785a4..874c9d3b9d 100644 --- a/packages/studio/src/player/hooks/useVstPreview.ts +++ b/packages/studio/src/player/hooks/useVstPreview.ts @@ -1,6 +1,7 @@ import { useEffect, useRef, type RefObject } from "react"; import { liveTime, usePlayerStore } from "../store/playerStore"; import type { TransportMsg, UseVstHostResult } from "../../hooks/useVstHost"; +import { STUDIO_VST_ENABLED } from "../../components/editor/manualEditingAvailability"; import { collectVstChainAudioEls, dbg, @@ -121,6 +122,7 @@ export function useVstPreview( // ── Lazily start the sidecar once a vst-chain track appears ───────────── useEffect(() => { + if (!STUDIO_VST_ENABLED) return; if (!projectId || status !== "idle") return; const doc = iframeRef.current?.contentDocument; if (!doc) return;