Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mcp): read no click telemetry when getFrames renders from the main process

EtienneLescot9dc48b5c76f8
diff --git a/src/lib/ai-edition/clickSound.test.ts b/src/lib/ai-edition/clickSound.test.ts
index 0dffa2343..35e118f08 100644
--- a/src/lib/ai-edition/clickSound.test.ts
+++ b/src/lib/ai-edition/clickSound.test.ts
@@ -326,6 +326,26 @@ describe("playClickHits", () => {
});
});
+describe("clickSoundForDocument outside a renderer", () => {
+ it("reads no sidecar where there is no bridge to read it through", () => {
+ // This file runs in node, like the main process when getFrames renders from the document.
+ const getTelemetry = vi.spyOn(nativeBridgeClient.cursor, "getTelemetry");
+ try {
+ const unread = {
+ project: { primaryAssetId: "asset_1" },
+ assets: [{ ...asset, originalPath: "/never-read.mp4" }],
+ audioTracks: [],
+ timeline: { clips: [clip()], trimRanges: [], speedRanges: [] },
+ legacyEditor: { speedRegions: [] },
+ } as never;
+ expect(clickSoundForDocument(unread, { clickSound: true, clickSoundGainDb: 0 })).toBeNull();
+ expect(getTelemetry).not.toHaveBeenCalled();
+ } finally {
+ getTelemetry.mockRestore();
+ }
+ });
+});
+
describe("ensureClickHitPaths", () => {
it("stages the two samples once when two callers ask at the same time", async () => {
const stage = vi.fn(async (name: string) => ({ success: true, path: `/sfx/${name}` }));
diff --git a/src/lib/ai-edition/clickSound.ts b/src/lib/ai-edition/clickSound.ts
index 369da2530..b307a0022 100644
--- a/src/lib/ai-edition/clickSound.ts
+++ b/src/lib/ai-edition/clickSound.ts
@@ -217,7 +217,9 @@ export function clickSoundForDocument(
}
// A take never read before is read now, in the background: the scene build cannot await.
// `loadClickCues` feeds the preview when it lands; an export awaits `prepareClickSound`.
- if (!cueCache.has(takePath)) void loadClickCues(takePath);
+ // The main process builds scenes too (getFrames renders from the document) and has no renderer
+ // bridge to read the sidecar through. It renders pictures, never this sound, so it skips the read.
+ if (!cueCache.has(takePath) && typeof window !== "undefined") void loadClickCues(takePath);
const cues = levelClickCues(cueCache.get(takePath) || [], cursor.clickSoundGainDb);
stashPreviewCues(document, take, cues);
if (!hitPaths || cues.length === 0) return null;