Create polished demo videos without editing skills. Mac/Windows/Linux
fix: harden export cancellation cleanup
webadderall6ebb6e57226f
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsxindex 514ef0dc..586e09d2 100644--- a/src/components/video-editor/SettingsPanel.tsx+++ b/src/components/video-editor/SettingsPanel.tsx@@ -1172,7 +1172,9 @@ export function SettingsPanel({!isBackgroundPanel &&activeEffectSection !== "scene" &&activeEffectSection !== "frame" &&- activeEffectSection !== "crop"+ activeEffectSection !== "crop" &&+ activeEffectSection !== "extensions" &&+ !activeEffectSection.startsWith("ext:")) {return;}diff --git a/src/components/video-editor/export/useExportDialogActions.ts b/src/components/video-editor/export/useExportDialogActions.tsindex 02cc8c25..0c7bc87f 100644--- a/src/components/video-editor/export/useExportDialogActions.ts+++ b/src/components/video-editor/export/useExportDialogActions.ts@@ -84,6 +84,7 @@ export function useExportDialogActions({const handleCancelExport = useCallback(() => {if (!session.isExporting) return;+ session.cancelledExportRunIdRef.current = session.exportRunIdRef.current;session.exportRunIdRef.current += 1;session.exporterRef.current?.cancel();session.exporterRef.current = null;diff --git a/src/components/video-editor/export/useExportRunner.ts b/src/components/video-editor/export/useExportRunner.tsindex f36e70b5..37edbdba 100644--- a/src/components/video-editor/export/useExportRunner.ts+++ b/src/components/video-editor/export/useExportRunner.ts@@ -67,6 +67,7 @@ export function useExportRunner(input: ExportRunnerInput) {clearPendingExportSave,markExportAsSaving,exportRunIdRef,+ cancelledExportRunIdRef,} = exportSession;if (!videoPath) {toast.error("No video loaded");@@ -81,7 +82,16 @@ export function useExportRunner(input: ExportRunnerInput) {const exportRunId = exportRunIdRef.current + 1;exportRunIdRef.current = exportRunId;+ cancelledExportRunIdRef.current = null;const exportWasCancelled = () => exportRunIdRef.current !== exportRunId;+ const exportWasExplicitlyCancelled = () =>+ cancelledExportRunIdRef.current === exportRunId;+ const discardCancelledTemp = async (pending: PendingExportSave) => {+ if (!pending.tempFilePath) return;+ await window.electronAPI+ .discardExportedTemp?.(pending.tempFilePath)+ .catch(() => undefined);+ };setIsExporting(true);setExportProgress(null);@@ -90,10 +100,10 @@ export function useExportRunner(input: ExportRunnerInput) {const smokeExportStartedAt = smokeExportConfig.enabled ? performance.now() : null;let keepExportDialogOpen = false;+ const wasPlaying = isPlaying;+ const restoreTime = video.currentTime;try {- const wasPlaying = isPlaying;- const restoreTime = video.currentTime;if (wasPlaying) {videoPlaybackRef.current?.pause();}@@ -136,6 +146,7 @@ export function useExportRunner(input: ExportRunnerInput) {previewHeight,shadowIntensity: effectiveShadowIntensity,onProgress: (progress) => {+ if (exportWasCancelled()) return;recordSmokeProgress(progress);setExportProgress(progress);},@@ -159,6 +170,10 @@ export function useExportRunner(input: ExportRunnerInput) {fileName,smokeExportConfig.enabled ? smokeExportConfig.outputPath : null,);+ if (exportWasCancelled()) {+ await discardCancelledTemp(pendingSave);+ return;+ }if (saveResult.canceled) {pendingExportSaveRef.current = pendingSave;@@ -277,6 +292,7 @@ export function useExportRunner(input: ExportRunnerInput) {previewHeight,shadowIntensity: effectiveShadowIntensity,onProgress: (progress) => {+ if (exportWasCancelled()) return;recordSmokeProgress(progress);setExportProgress(progress);},@@ -338,6 +354,14 @@ export function useExportRunner(input: ExportRunnerInput) {: null,captionSidecar: sidecarForThisExport,});+ if (exportWasCancelled()) {+ await discardCancelledTemp({+ fileName,+ tempFilePath: result.tempFilePath,+ captionSidecar: sidecarForThisExport,+ });+ return;+ }pendingOnCancel = {fileName,tempFilePath: result.tempFilePath,@@ -353,6 +377,10 @@ export function useExportRunner(input: ExportRunnerInput) {smokeExportConfig.enabled ? smokeExportConfig.outputPath : null,sidecarForThisExport,);+ if (exportWasCancelled()) {+ await discardCancelledTemp(blobSave.pendingSave);+ return;+ }saveResult = blobSave.saveResult;pendingOnCancel = blobSave.pendingSave;} else {@@ -496,7 +524,12 @@ export function useExportRunner(input: ExportRunnerInput) {window.close();}} finally {- if (!exportWasCancelled()) {+ if (exportWasExplicitlyCancelled() && exportRunIdRef.current === exportRunId + 1) {+ video.currentTime = restoreTime;+ if (wasPlaying) {+ await videoPlaybackRef.current?.play().catch(() => undefined);+ }+ } else if (!exportWasCancelled()) {setIsExporting(false);exporterRef.current = null;setShowExportDropdown(keepExportDialogOpen);diff --git a/src/components/video-editor/export/useExportSession.ts b/src/components/video-editor/export/useExportSession.tsindex a922c049..a36ac629 100644--- a/src/components/video-editor/export/useExportSession.ts+++ b/src/components/video-editor/export/useExportSession.ts@@ -14,6 +14,7 @@ export function useExportSession() {const [hasPendingExportSave, setHasPendingExportSave] = useState(false);const exporterRef = useRef<CancelableExporter | null>(null);const exportRunIdRef = useRef(0);+ const cancelledExportRunIdRef = useRef<number | null>(null);const pendingExportSaveRef = useRef<PendingExportSave | null>(null);const clearPendingExportSave = useCallback(() => {@@ -44,6 +45,7 @@ export function useExportSession() {setHasPendingExportSave,exporterRef,exportRunIdRef,+ cancelledExportRunIdRef,pendingExportSaveRef,clearPendingExportSave,markExportAsSaving,