Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(recording): write the cursor sidecar before publishing the session
EtienneLescot96dbe28b56df
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex c5100fe11..a9c00258b 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -3487,11 +3487,16 @@ export function registerIpcHandlers(...(cursorCaptureMode ? { cursorCaptureMode } : {}),}: { screenVideoPath, createdAt, ...(cursorCaptureMode ? { cursorCaptureMode } : {}) };+ // Sidecar BEFORE the session is published, as the three native stop paths already+ // do it. Publishing first opens a window where `getCurrentRecordingSession` hands+ // the editor a take whose `.cursor.json` is not on disk yet, and the editor's+ // fresh-take auto-zoom reads that file the moment it imports -- an empty read there+ // is indistinguishable from a take with no dwell, so the zooms are silently+ // skipped.+ await writePendingCursorTelemetry(screenVideoPath);setCurrentRecordingSessionState(session);currentProjectPath = null;- await writePendingCursorTelemetry(screenVideoPath);-const sessionManifestPath = path.join(RECORDINGS_DIR,`${path.parse(payload.screen.fileName).name}${RECORDING_SESSION_SUFFIX}`,diff --git a/src/components/ai-edition/recordingImport.test.ts b/src/components/ai-edition/recordingImport.test.tsindex ceb7590d6..123c954af 100644--- a/src/components/ai-edition/recordingImport.test.ts+++ b/src/components/ai-edition/recordingImport.test.ts@@ -232,6 +232,8 @@ function dwell(}));}+const RECORDING_PATH = "C:\\recordings\\rec.mp4";+function documentWithClip(durationSec = 10): AxcutDocument {const doc = createEmptyDocument({ projectId: "p_autozoom", title: "Recording" });return {@@ -241,7 +243,7 @@ function documentWithClip(durationSec = 10): AxcutDocument {id: "asset_1",kind: "video",label: "rec.mp4",- originalPath: "C:\\recordings\\rec.mp4",+ originalPath: RECORDING_PATH,cameraTrack: null,durationSec,},@@ -291,8 +293,8 @@ describe("fresh-recording auto-zoom", () => {});// A system-cursor take writes no `.cursor.json`, so there is never a dwell to- // find. Marking it pending anyway left the flag set for the life of the window- // and burned all three retries on an empty sidecar.+ // find. Marking it pending anyway armed the hand-off for a take that can never+ // spend it.it("does not mark a system-cursor take as waiting", async () => {stubElectronApi("C:\\recordings\\recording-1.mp4", "system");await importPendingRecording();@@ -306,7 +308,7 @@ describe("fresh-recording auto-zoom", () => {});it("applies cursor-dwell zooms once, after duration is known", async () => {- markFreshRecordingAutoZoomPending();+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const next = await applyPendingFreshRecordingAutoZooms(documentWithClip(), {enabled: true,getTelemetry: async () => dwell(4000, 0.4, 0.6),@@ -322,7 +324,7 @@ describe("fresh-recording auto-zoom", () => {});it("skips when the HUD toggle is off", async () => {- markFreshRecordingAutoZoomPending();+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const document = documentWithClip();const next = await applyPendingFreshRecordingAutoZooms(document, {enabled: false,@@ -332,25 +334,23 @@ describe("fresh-recording auto-zoom", () => {expect(next.zoomRanges).toEqual([]);});- it("keeps the pending flag when the sidecar is still empty, then applies on retry", async () => {- markFreshRecordingAutoZoomPending();+ // The stop handler awaits `writePendingCursorTelemetry` before it publishes the+ // session, so the sidecar is on disk by the time a take can be imported. An empty+ // read is therefore the take's real answer, not a mid-flush one, and leaving the+ // hand-off armed would let it fire on the next document loaded in this window.+ it("consumes the hand-off when the sidecar holds no dwell", async () => {+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const document = documentWithClip();const first = await applyPendingFreshRecordingAutoZooms(document, {enabled: true,getTelemetry: async () => [],});expect(first).toBe(document);- const next = await applyPendingFreshRecordingAutoZooms(document, {- enabled: true,- getTelemetry: async () => dwell(4000, 0.4, 0.6),- createId: (prefix) => `${prefix}_retry`,- });- expect(next.zoomRanges).toHaveLength(1);- expect(await applyPendingFreshRecordingAutoZooms(next, { enabled: true })).toBe(next);+ expect(consumeFreshRecordingAutoZoomPending()).toBe(false);});it("keeps the pending flag when clips are not on the document yet", async () => {- markFreshRecordingAutoZoomPending();+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const document = createEmptyDocument({ projectId: "p_empty", title: "Recording" });const next = await applyPendingFreshRecordingAutoZooms(document, {enabled: true,@@ -360,8 +360,8 @@ describe("fresh-recording auto-zoom", () => {expect(consumeFreshRecordingAutoZoomPending()).toBe(true);});- it("keeps pending when telemetry is present but no dwell has landed yet", async () => {- markFreshRecordingAutoZoomPending();+ it("consumes the hand-off when the cursor never sits still", async () => {+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const document = documentWithClip();const moving = Array.from({ length: 8 }, (_, i) => ({timeMs: 1000 + i * 80,@@ -373,16 +373,13 @@ describe("fresh-recording auto-zoom", () => {getTelemetry: async () => moving,});expect(first).toBe(document);- const next = await applyPendingFreshRecordingAutoZooms(document, {- enabled: true,- getTelemetry: async () => dwell(4000, 0.4, 0.6),- createId: (prefix) => `${prefix}_late`,- });- expect(next.zoomRanges).toHaveLength(1);+ expect(consumeFreshRecordingAutoZoomPending()).toBe(false);});+ // The one read that is not an answer: an error says nothing about whether the take+ // has a dwell, so the hand-off survives it.it("keeps pending when telemetry read throws", async () => {- markFreshRecordingAutoZoomPending();+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const document = documentWithClip();const next = await applyPendingFreshRecordingAutoZooms(document, {enabled: true,@@ -445,13 +442,16 @@ describe("fresh-recording auto-zoom", () => {getTelemetry: async (videoPath) => (videoPath === laterPath ? dwell(14000, 0.4, 0.6) : []),createId: (prefix) => `${prefix}_later`,});+ // The point of the test: the later clip's dwell is not read at all, so the fresh+ // take is never decorated with another asset's telemetry. Its own sidecar was+ // empty, which is a real answer, so the hand-off is spent either way.expect(next).toBe(withLater);expect(next.zoomRanges).toEqual([]);- expect(consumeFreshRecordingAutoZoomPending()).toBe(true);+ expect(consumeFreshRecordingAutoZoomPending()).toBe(false);});it("waits for a probed asset duration before generating zooms", async () => {- markFreshRecordingAutoZoomPending();+ markFreshRecordingAutoZoomPending(RECORDING_PATH);const placeholder = documentWithClip(60);placeholder.assets[0].durationSec = undefined;const first = await applyPendingFreshRecordingAutoZooms(placeholder, {@@ -585,10 +585,11 @@ describe("fresh-recording auto-zoom", () => {expect(stored?.zoomRanges).toHaveLength(1);});- // Contention is an exit, not a rebase: recomputing onto the document the other- // writer just produced only races that writer again. The attempt is dropped- // with pending intact so a retry runs against a settled document.- it("exits without writing when a user save lands mid-attempt", async () => {+ // Contention is never a rebase: writing the snapshot this attempt built from would+ // take the user's trim with it. The attempt is dropped whole and repeated once, from+ // scratch, after `waitForDocumentSaves` has seen that writer finish -- so the zooms+ // land ON the trim rather than over it.+ it("re-collects from scratch when a user save lands mid-attempt", async () => {const stale = documentWithClip(90);const trimmed = {...stale,@@ -619,12 +620,12 @@ describe("fresh-recording auto-zoom", () => {createId: (prefix) => `${prefix}_contended`,});- expect(result).toBe(false);+ expect(result).toBe(true);const stored = useProjectStore.getState().document;+ // The user's trim survived, and the zooms sit on top of it.expect(stored?.timeline.clips[0].sourceEndSec).toBe(80);- expect(stored?.zoomRanges).toEqual([]);- // Still pending: the retries are what eventually apply the zooms.- expect(consumeFreshRecordingAutoZoomPending()).toBe(true);+ expect(stored?.zoomRanges).toHaveLength(1);+ expect(consumeFreshRecordingAutoZoomPending()).toBe(false);});it("keeps pending when a later user save wipes zooms before they settle", async () => {diff --git a/src/components/ai-edition/recordingImport.ts b/src/components/ai-edition/recordingImport.tsindex 2c22d61fb..975a4a144 100644--- a/src/components/ai-edition/recordingImport.ts+++ b/src/components/ai-edition/recordingImport.ts@@ -26,62 +26,37 @@ import {} from "@/lib/ai-edition/store/projectStore";import {appendAutoZoomSuggestions,- clipExtentSignature,- collectAutoZoomSuggestionsForDocument,+ collectAutoZoomSuggestionsForLatestDocument,} from "@/lib/ai-edition/timeline/apply-auto-zooms";import { nativeBridgeClient } from "@/native/client";// Fresh recordings used to get cursor-dwell zooms on load (legacy editor// `autoZoomEnabled`, default on). The ai-edition import only seeded a clip, so// the wand still worked but a new take landed un-zoomed. This flag is the-// one-shot hand-off: set as soon as the asset is on the document, then taken-// only after a real apply attempt (clips exist, duration is probed, and-// telemetry was readable, or the toggle is off). Keeping it across an-// empty-clip / empty-sidecar / placeholder-duration pass is what lets metadata-// win the race against the helper flush. The path stops a leftover flag from-// decorating a later, unrelated project in the same window. A successful save-// records the project id so a later undo or delete cannot be silently re-seeded.+// one-shot hand-off: set as soon as the asset is on the document, then taken on+// the first pass that can give a real answer -- zooms written, no dwell in the+// sidecar, or the toggle is off. What keeps it set is only ever "not enough of+// the document yet" (no clips, still the placeholder duration), and the+// `loadedmetadata` write is what comes back when that resolves.+//+// The recording path is what scopes it: `importPendingRecording` always has one,+// and it is what stops a flag left over from a take with nothing to zoom from+// decorating the next document loaded in the same window. A successful save+// records the project id so a later undo or delete cannot silently re-seed it.let pendingFreshRecordingAutoZoom = false;let pendingFreshRecordingAutoZoomPath: string | null = null;let appliedFreshRecordingAutoZoomProjectId: string | null = null;-let pendingFreshRecordingAutoZoomTimers: ReturnType<typeof setTimeout>[] = [];let freshRecordingAutoZoomSaveChain: Promise<void> = Promise.resolve();-const FRESH_RECORDING_AUTO_ZOOM_RETRY_MS = [500, 1500, 3000];--function clearFreshRecordingAutoZoomTimers(): void {- for (const timer of pendingFreshRecordingAutoZoomTimers) {- clearTimeout(timer);- }- pendingFreshRecordingAutoZoomTimers = [];-}--function scheduleFreshRecordingAutoZoomRetries(): void {- clearFreshRecordingAutoZoomTimers();- for (const delayMs of FRESH_RECORDING_AUTO_ZOOM_RETRY_MS) {- pendingFreshRecordingAutoZoomTimers.push(- setTimeout(() => {- if (!pendingFreshRecordingAutoZoom) return;- const document = useProjectStore.getState().document;- if (document) {- void maybeSaveFreshRecordingAutoZooms(document);- }- }, delayMs),- );- }-}--export function markFreshRecordingAutoZoomPending(assetPath?: string): void {+export function markFreshRecordingAutoZoomPending(assetPath: string): void {pendingFreshRecordingAutoZoom = true;- pendingFreshRecordingAutoZoomPath = assetPath ?? null;+ pendingFreshRecordingAutoZoomPath = assetPath;appliedFreshRecordingAutoZoomProjectId = null;- scheduleFreshRecordingAutoZoomRetries();}function clearFreshRecordingAutoZoomPending(): void {pendingFreshRecordingAutoZoom = false;pendingFreshRecordingAutoZoomPath = null;- clearFreshRecordingAutoZoomTimers();}export function consumeFreshRecordingAutoZoomPending(): boolean {@@ -111,14 +86,12 @@ async function readAutoZoomPref(): Promise<boolean> {}}+function isPendingFreshRecordingAsset(asset: { originalPath?: string | null }): boolean {+ return asset.originalPath === pendingFreshRecordingAutoZoomPath;+}+function pendingFreshRecordingAsset(document: AxcutDocument) {- if (pendingFreshRecordingAutoZoomPath) {- return document.assets.find(- (asset) => asset.originalPath === pendingFreshRecordingAutoZoomPath,- );- }- const primaryId = document.project.primaryAssetId;- return document.assets.find((asset) => asset.id === primaryId) ?? document.assets[0];+ return document.assets.find(isPendingFreshRecordingAsset);}/**@@ -154,12 +127,15 @@ function canApplyFreshRecordingAutoZooms(document: AxcutDocument): boolean {if ((document.zoomRanges?.length ?? 0) > 0) return false;if ((document.timeline?.clips?.length ?? 0) === 0) return false;if (!hasProbedDurationForPendingAsset(document)) return false;- if (- pendingFreshRecordingAutoZoomPath &&- !document.assets.some((asset) => asset.originalPath === pendingFreshRecordingAutoZoomPath)- ) {- return false;- }+ return document.assets.some(isPendingFreshRecordingAsset);+}++/** Zooms are on the document already -- the wand ran, or a redo brought them back.+ * The take is decorated, so the hand-off is spent for this project. */+function markDecoratedIfZoomed(document: AxcutDocument): boolean {+ if ((document.zoomRanges?.length ?? 0) === 0) return false;+ clearFreshRecordingAutoZoomPending();+ appliedFreshRecordingAutoZoomProjectId = document.project.id;return true;}@@ -182,78 +158,70 @@ export async function applyPendingFreshRecordingAutoZooms(return liveDocument(document);}const start = liveDocument(document);- if ((start.zoomRanges?.length ?? 0) > 0) {- clearFreshRecordingAutoZoomPending();- appliedFreshRecordingAutoZoomProjectId = start.project.id;- return start;- }- if (!canApplyFreshRecordingAutoZooms(start)) {- return start;- }+ if (markDecoratedIfZoomed(start)) return start;+ if (!canApplyFreshRecordingAutoZooms(start)) return start;+const inner =deps.getTelemetry ?? ((videoPath: string) => nativeBridgeClient.cursor.getTelemetry(videoPath));+ let telemetryFailed = false;const getTelemetry = async (videoPath: string) => {try {return await inner(videoPath);} catch {- // Sidecar may not be readable yet. Keep pending for the delayed retries.+ // An unreadable sidecar is NOT the same answer as an empty one: it says+ // nothing about whether this take has a dwell, so pending survives it and a+ // later `loadedmetadata` for the same take gets another go.+ telemetryFailed = true;return [];}};- const collectFrom = async (source: AxcutDocument) => {- const scoped = pendingFreshRecordingAutoZoomPath- ? {- ...source,- assets: source.assets.filter(- (asset) => asset.originalPath === pendingFreshRecordingAutoZoomPath,- ),- }- : source;- return collectAutoZoomSuggestionsForDocument(scoped, getTelemetry);- };-- const firstSignature = clipExtentSignature(start);- let suggestions = await collectFrom(start);- let latest = liveDocument(start);- if (latest.project.id !== start.project.id) {- return latest;- }- if ((latest.zoomRanges?.length ?? 0) > 0) {- clearFreshRecordingAutoZoomPending();- appliedFreshRecordingAutoZoomProjectId = latest.project.id;- return latest;- }- if (!canApplyFreshRecordingAutoZooms(latest)) {- return latest;- }- if (clipExtentSignature(latest) !== firstSignature) {- suggestions = await collectFrom(latest);- latest = liveDocument(latest);- if (latest.project.id !== start.project.id) return latest;- if ((latest.zoomRanges?.length ?? 0) > 0) {- clearFreshRecordingAutoZoomPending();- appliedFreshRecordingAutoZoomProjectId = latest.project.id;- return latest;- }- if (!canApplyFreshRecordingAutoZooms(latest)) return latest;- }- if (suggestions.length === 0) {- // Do not consume: a mid-flush sidecar can have samples but no dwell yet- // (the qualifying sit is often the last second of the take).- return latest;+ // The wand's own collect path, scoped to the take this hand-off is about: read the+ // document, collect, and collect again if the clips moved while the telemetry was+ // being read. Sharing it is the point -- the suggestions carry TIMELINE spans and+ // `appendAutoZoomSuggestions` anchors them against whatever the store holds at write+ // time, so the two callers must agree on when a collected set has gone stale.+ //+ // The reader re-runs every guard, so a project switch, a wand run or a delete+ // landing during the wait ends the pass exactly where the retry would have started.+ const collected = await collectAutoZoomSuggestionsForLatestDocument(+ () => {+ const live = liveDocument(start);+ if (live.project.id !== start.project.id) return null;+ if (markDecoratedIfZoomed(live)) return null;+ return canApplyFreshRecordingAutoZooms(live) ? live : null;+ },+ getTelemetry,+ isPendingFreshRecordingAsset,+ );+ if (!collected) return liveDocument(start);+ if (collected.suggestions.length === 0) {+ // A real answer, not a race: the stop handler awaits `writePendingCursorTelemetry`+ // BEFORE it publishes the session, so by the time the editor can import the take+ // its sidecar is on disk. An empty read therefore means this take has no dwell to+ // zoom, and no amount of retrying changes that -- consume the hand-off rather than+ // leaving it armed for the next document loaded in this window.+ if (!telemetryFailed) clearFreshRecordingAutoZoomPending();+ return collected.document;}- return appendAutoZoomSuggestions(latest, suggestions, deps.createId ?? createId);+ return appendAutoZoomSuggestions(+ collected.document,+ collected.suggestions,+ deps.createId ?? createId,+ );}export async function maybeSaveFreshRecordingAutoZooms(document: AxcutDocument,deps: ApplyFreshRecordingAutoZoomsDeps = {},): Promise<boolean> {- const writeFreshRecordingAutoZooms = async (): Promise<boolean> => {+ /** `"contended"`: a user write landed on the snapshot this attempt built from, so+ * it decided nothing and is worth repeating against the settled document. */+ const writeFreshRecordingAutoZooms = async (): Promise<boolean | "contended"> => {try {// A wait that times out has told us nothing about what is on disk, so the- // only safe move is to abandon this attempt with pending still set: the- // retries below rebase onto whatever the stuck save eventually leaves.+ // only safe move is to abandon this attempt with pending still set, and let+ // a later `loadedmetadata` for this take rebase onto whatever the stuck save+ // eventually leaves.if ((await waitForDocumentSaves(deps.waitTimeoutMs)) === "timeout") return false;const latest = liveDocument(document);const next = await applyPendingFreshRecordingAutoZooms(latest, deps);@@ -265,31 +233,28 @@ export async function maybeSaveFreshRecordingAutoZooms(clearFreshRecordingAutoZoomPending();return false;}- // Contention means exit, not rebase. If the document moved while the+ // Contention means start over, not rebase. If the document moved while the// suggestion pass ran, this attempt is working from a snapshot that is- // already history — recomputing onto the newer one just races the writer- // that produced it. Drop the attempt with pending still set; the- // 500/1500/3000 ms retries run against a settled document instead.- if (current !== latest) return false;- const toSave = next;- const storedNow = liveDocument(document);- if (storedNow !== latest) return false;- if (toSave === latest || toSave === storedNow) return false;- if (storedNow.project.id !== latest.project.id) return false;+ // already history — writing `next` over the newer one would take the user's+ // edit with it. Drop it and let the repeat below re-collect from scratch,+ // after `waitForDocumentSaves` has seen that writer finish.+ if (current !== latest) return "contended";+ // Nothing to write: the pass returned the document it was given, because a+ // guard refused it or the take has no dwell.+ if (next === latest) return false;const saved = await saveWithDeadline(- useProjectStore.getState().saveDocument(toSave, { history: true }),+ useProjectStore.getState().saveDocument(next, { history: true }),deps.saveTimeoutMs ?? DOCUMENT_SAVES_WAIT_TIMEOUT_MS,);- // The write never answered. Keep pending and let go of the chain, so the- // retries get to run instead of queueing behind a promise that is not- // coming back.+ // The write never answered. Keep pending and let go of the chain, so nothing+ // queues behind a promise that is not coming back.if (saved === "timeout") return false;// A trim (or any other edit) can start after this save was submitted and// still be in flight when it returns: `waitForDocumentSaves` before the// write only sees saves that have already begun. Wait again, then look at// the store — if that later write landed on the unzoomed snapshot, keep- // pending so a retry can try again. A timeout here says the same thing for- // a different reason: we cannot tell what landed, so do not clear pending.+ // pending. A timeout here says the same thing for a different reason: we+ // cannot tell what landed, so do not clear pending.if ((await waitForDocumentSaves(deps.waitTimeoutMs)) === "timeout") return saved;const stored = useProjectStore.getState().document;if (saved && stored && (stored.zoomRanges?.length ?? 0) > 0) {@@ -299,15 +264,23 @@ export async function maybeSaveFreshRecordingAutoZooms(return saved;} catch (error) {// `saveDocument` reports failure by returning false, so anything thrown- // here came from the suggestion pass or a bridge call. Pending stays set- // and the retries fire silently — log it, or the whole path is invisible.+ // here came from the suggestion pass or a bridge call. Pending stays set and+ // the path goes quiet — log it, or it is invisible.console.warn("[recording] fresh-recording auto-zoom write failed:", error);return false;}};+ // One repeat, not a loop: a user who keeps editing through the telemetry wait keeps+ // invalidating the attempt, and the honest answer there is the wand, not spinning.+ const attemptFreshRecordingAutoZooms = async (): Promise<boolean> => {+ const first = await writeFreshRecordingAutoZooms();+ if (first !== "contended") return first;+ const second = await writeFreshRecordingAutoZooms();+ return second === "contended" ? false : second;+ };const done = freshRecordingAutoZoomSaveChain.then(- writeFreshRecordingAutoZooms,- writeFreshRecordingAutoZooms,+ attemptFreshRecordingAutoZooms,+ attemptFreshRecordingAutoZooms,);freshRecordingAutoZoomSaveChain = done.then(() => undefined,@@ -342,9 +315,9 @@ export async function importPendingRecording(): Promise<boolean> {//// Except for a system-cursor take, which writes no `.cursor.json` at all: the// toggle stays on in prefs (it is only disabled in the UI while that mode is- // picked), so without this the flag was set for a recording that can never- // produce a dwell, and all three retries ran against an empty sidecar. What- // governs is the mode THIS take was recorded in, not the current preference.+ // picked), so without this the flag is set for a recording that can never produce+ // a dwell. What governs is the mode THIS take was recorded in, not the current+ // preference.if (cursorCaptureMode !== "system") {markFreshRecordingAutoZoomPending(screenPath);}diff --git a/src/lib/ai-edition/timeline/apply-auto-zooms.ts b/src/lib/ai-edition/timeline/apply-auto-zooms.tsindex 3a6c5fac0..ae349f63d 100644--- a/src/lib/ai-edition/timeline/apply-auto-zooms.ts+++ b/src/lib/ai-edition/timeline/apply-auto-zooms.ts@@ -4,15 +4,21 @@import type { CursorTelemetryPoint } from "@/components/video-editor/types";import { createId } from "../document/ids";-import type { AxcutDocument } from "../schema";+import type { AxcutAsset, AxcutDocument } from "../schema";import { anchorRegionsWithDerivedMs } from "./timelineMap";import { type AutoZoomSuggestion, buildAutoZoomSuggestionsForClips } from "./zoom-suggestions";export const AUTO_ZOOM_DEFAULT_DURATION_MS = 2000;+/** Which assets to read telemetry for. The wand takes every video on the document;+ * the fresh-recording import narrows it to the take it is pending on, so a project+ * that already holds other footage does not pay an IPC round trip per asset. */+export type AutoZoomAssetFilter = (asset: AxcutAsset) => boolean;+export async function collectAutoZoomSuggestionsForDocument(document: AxcutDocument,getTelemetry: (videoPath: string) => Promise<CursorTelemetryPoint[] | null | undefined>,+ includeAsset: AutoZoomAssetFilter = () => true,): Promise<AutoZoomSuggestion[]> {const existingRegions = document.zoomRanges.map((region) => ({startMs: region.startMs,@@ -22,6 +28,7 @@ export async function collectAutoZoomSuggestionsForDocument((asset) =>asset.kind === "video" &&asset.originalPath &&+ includeAsset(asset) &&document.timeline.clips.some((clip) => clip.assetId === asset.id),);const perSource = await Promise.all(@@ -69,11 +76,16 @@ export function clipExtentSignature(document: AxcutDocument): string {export async function collectAutoZoomSuggestionsForLatestDocument(readDocument: () => AxcutDocument | null,getTelemetry: (videoPath: string) => Promise<CursorTelemetryPoint[] | null | undefined>,+ includeAsset?: AutoZoomAssetFilter,): Promise<{ document: AxcutDocument; suggestions: AutoZoomSuggestion[] } | null> {const start = readDocument();if (!start) return null;const startSignature = clipExtentSignature(start);- const suggestions = await collectAutoZoomSuggestionsForDocument(start, getTelemetry);+ const suggestions = await collectAutoZoomSuggestionsForDocument(+ start,+ getTelemetry,+ includeAsset,+ );const latest = readDocument();if (!latest) return null;if (clipExtentSignature(latest) === startSignature) {@@ -81,7 +93,7 @@ export async function collectAutoZoomSuggestionsForLatestDocument(}return {document: latest,- suggestions: await collectAutoZoomSuggestionsForDocument(latest, getTelemetry),+ suggestions: await collectAutoZoomSuggestionsForDocument(latest, getTelemetry, includeAsset),};}