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(editor): keep the placeholder duration on the asset, and off auto-zoom
超超超超超级喜欢你的达妮娅73c57565db35
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsxindex 3cb39c479..681a88031 100644--- a/src/components/ai-edition/NewEditorShell.tsx+++ b/src/components/ai-edition/NewEditorShell.tsx@@ -148,10 +148,17 @@ export async function runLoadedMetadataWrite(// a length something already measured. Auto-zoom is not fooled by it either --// `hasProbedDurationForPendingAsset` asks the CLIPS, not the asset, and a clip// still sitting at the placeholder reads as waiting.- const knownSec =- Number.isFinite(durationSec) && durationSec > 0 ? durationSec : PLACEHOLDER_DURATION_SEC;+ const finite = Number.isFinite(durationSec) && durationSec > 0;+ const knownSec = finite ? durationSec : PLACEHOLDER_DURATION_SEC;const state = useProjectStore.getState();- const next = documentAfterProbedDuration(state.document, assetId, knownSec, originatingProjectId);+ // The placeholder exists so the FIRST clip is not empty, nothing more. Once a+ // timeline is there, a length nothing measured has nothing to fold in -- and+ // re-applying it to a clip already sitting at it means a `history: false` write on+ // every metadata event for the same unmeasured take.+ const next =+ finite || state.document?.timeline.clips.length === 0+ ? documentAfterProbedDuration(state.document, assetId, knownSec, originatingProjectId)+ : null;if (next) {// `history: false`: this is the probed duration being folded into the document// on load, not something the user did — an undo landing on it would empty theirdiff --git a/src/components/ai-edition/recordingImport.ts b/src/components/ai-edition/recordingImport.tsindex a8e68beb6..cb5457e0f 100644--- a/src/components/ai-edition/recordingImport.ts+++ b/src/components/ai-edition/recordingImport.ts@@ -16,6 +16,7 @@import type { CursorTelemetryPoint } from "@/components/video-editor/types";import { createId } from "@/lib/ai-edition/document/ids";+import { clipAwaitsProbedDuration } from "@/lib/ai-edition/document/timeline";import type { AxcutDocument } from "@/lib/ai-edition/schema";import {DOCUMENT_SAVES_WAIT_TIMEOUT_MS,@@ -109,6 +110,15 @@ async function readAutoZoomPref(): Promise<boolean> {}}+function clipExtentSignature(document: AxcutDocument): string {+ return document.timeline.clips+ .map(+ (clip) =>+ `${clip.id}:${clip.assetId}:${clip.sourceStartSec}:${clip.sourceEndSec ?? ""}:${clip.timelineStartSec}:${clip.timelineEndSec}`,+ )+ .join("|");+}+function pendingFreshRecordingAsset(document: AxcutDocument) {if (pendingFreshRecordingAutoZoomPath) {return document.assets.find(@@ -119,23 +129,31 @@ function pendingFreshRecordingAsset(document: AxcutDocument) {return document.assets.find((asset) => asset.id === primaryId) ?? document.assets[0];}+/**+ * Whether the pending take's real length has landed yet.+ *+ * Not just `asset.durationSec != null`. A recording whose container reports no+ * duration (MediaRecorder WebM, until the EBML fix) still gets the placeholder+ * written to that field, because the timeline layer clamps every interval it+ * builds against `primaryAssetDuration` and would otherwise drop every clip. So+ * the asset says "60" for a take nothing has measured, and the clips are what+ * distinguish the two: one still sitting at the placeholder length is waiting.+ *+ * The cost is a take of exactly 60.000 s never being auto-zoomed. That is the+ * same ambiguity `applyProbedDuration` already lives with, and it is a far+ * smaller price than suggesting zooms against a length nothing measured.+ */function hasProbedDurationForPendingAsset(document: AxcutDocument): boolean {const asset = pendingFreshRecordingAsset(document);- return (- asset != null &&- asset.durationSec != null &&- Number.isFinite(asset.durationSec) &&- asset.durationSec > 0- );-}--function clipExtentSignature(document: AxcutDocument): string {- return document.timeline.clips- .map(- (clip) =>- `${clip.id}:${clip.assetId}:${clip.sourceStartSec}:${clip.sourceEndSec ?? ""}:${clip.timelineStartSec}:${clip.timelineEndSec}`,- )- .join("|");+ if (+ asset == null ||+ asset.durationSec == null ||+ !Number.isFinite(asset.durationSec) ||+ asset.durationSec <= 0+ ) {+ return false;+ }+ return !document.timeline.clips.some((clip) => clipAwaitsProbedDuration(clip, asset.id));}function canApplyFreshRecordingAutoZooms(document: AxcutDocument): boolean {diff --git a/src/lib/ai-edition/document/timeline.ts b/src/lib/ai-edition/document/timeline.tsindex 4754f4561..5f9cb402b 100644--- a/src/lib/ai-edition/document/timeline.ts+++ b/src/lib/ai-edition/document/timeline.ts@@ -481,7 +481,7 @@ function rederiveAnchoredRegion<* source extent at all (what `migrateProjectDataToAxcutDocument` produces — the* migration is pure, so it cannot probe the file for a duration), or it still sits at* the pre-probe placeholder length. Both mean "waiting for the real duration". */-function clipAwaitsProbedDuration(clip: AxcutClip, assetId: string): boolean {+export function clipAwaitsProbedDuration(clip: AxcutClip, assetId: string): boolean {if (clip.assetId !== assetId || clip.sourceStartSec !== 0) return false;const end = clip.sourceEndSec ?? 0;if (end <= clip.sourceStartSec) return true; // no extent at all (v2 migration)