diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts index 38ac8701..cad0d8b4 100644 --- a/electron/electron-env.d.ts +++ b/electron/electron-env.d.ts @@ -75,10 +75,6 @@ interface Window { ) => Promise<{ success: boolean; enabled: boolean }>; getSources: (opts: Electron.SourcesOptions) => Promise; switchToEditor: () => Promise; - openEditorEarly: () => Promise; - isRecordingFinalizing: () => Promise; - notifyRecordingFinalized: () => Promise; - onRecordingFinalized: (callback: () => void) => () => void; openSourceSelector: () => Promise; selectSource: (source: any) => Promise; showSourceHighlight: (source: any) => Promise<{ success: boolean }>; diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts index a1e59a4e..c70d2e77 100644 --- a/electron/ipc/handlers.ts +++ b/electron/ipc/handlers.ts @@ -4102,12 +4102,8 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh} } createSourceSelectorWindow() }) - - let recordingFinalizing = false - ipcMain.handle('switch-to-editor', () => { console.log('[switch-to-editor] Opening editor window') - recordingFinalizing = false const sourceSelectorWin = getSourceSelectorWindow() if (sourceSelectorWin && !sourceSelectorWin.isDestroyed()) { sourceSelectorWin.close() @@ -4115,31 +4111,6 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh} createEditorWindow() }) - ipcMain.handle('open-editor-early', () => { - console.log('[open-editor-early] Opening editor window while recording finalizes') - recordingFinalizing = true - const sourceSelectorWin = getSourceSelectorWindow() - if (sourceSelectorWin && !sourceSelectorWin.isDestroyed()) { - sourceSelectorWin.close() - } - createEditorWindow() - }) - - ipcMain.handle('is-recording-finalizing', () => { - return recordingFinalizing - }) - - ipcMain.handle('notify-recording-finalized', () => { - console.log('[notify-recording-finalized] Recording finalization complete') - recordingFinalizing = false - const allWindows = BrowserWindow.getAllWindows() - for (const win of allWindows) { - if (!win.isDestroyed()) { - win.webContents.send('recording-finalized') - } - } - }) - ipcMain.handle('start-native-screen-recording', async (_, source: SelectedSource, options?: NativeMacRecordingOptions) => { // Windows native capture path if (process.platform === 'win32') { diff --git a/electron/preload.ts b/electron/preload.ts index 6bcd27c5..6cd715c0 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -167,20 +167,6 @@ contextBridge.exposeInMainWorld("electronAPI", { switchToEditor: () => { return ipcRenderer.invoke("switch-to-editor"); }, - openEditorEarly: () => { - return ipcRenderer.invoke("open-editor-early"); - }, - isRecordingFinalizing: () => { - return ipcRenderer.invoke("is-recording-finalizing") as Promise; - }, - notifyRecordingFinalized: () => { - return ipcRenderer.invoke("notify-recording-finalized"); - }, - onRecordingFinalized: (callback: () => void) => { - const listener = () => callback(); - ipcRenderer.on("recording-finalized", listener); - return () => ipcRenderer.removeListener("recording-finalized", listener); - }, openSourceSelector: () => { return ipcRenderer.invoke("open-source-selector"); }, diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx index cea4d784..f79ead6d 100644 --- a/src/components/video-editor/VideoEditor.tsx +++ b/src/components/video-editor/VideoEditor.tsx @@ -453,7 +453,6 @@ export default function VideoEditor() { const [projectLibraryEntries, setProjectLibraryEntries] = useState([]); const [projectBrowserOpen, setProjectBrowserOpen] = useState(false); const [loading, setLoading] = useState(true); - const [recordingFinalizing, setRecordingFinalizing] = useState(false); const [error, setError] = useState(null); const [isPlaying, setIsPlaying] = useState(false); const [currentTime, setCurrentTime] = useState(0); @@ -1523,7 +1522,6 @@ export default function VideoEditor() { useEffect(() => { async function loadInitialData() { - let waitingForFinalize = false; try { if (smokeExportConfig.enabled) { if (!smokeExportConfig.inputPath) { @@ -1601,76 +1599,17 @@ export default function VideoEditor() { sourcePath: null, })); } else { - const finalizing = await window.electronAPI?.isRecordingFinalizing?.(); - if (finalizing) { - waitingForFinalize = true; - setRecordingFinalizing(true); - return; - } setError("No video to load. Please record or select a video."); } } catch (err) { setError("Error loading video: " + String(err)); } finally { - if (!waitingForFinalize) setLoading(false); + setLoading(false); } } - // Subscribe to the finalized event BEFORE loadInitialData checks - // isRecordingFinalizing, so we never miss the event if it fires - // between the check and the subscription. - const cleanupFinalized = window.electronAPI?.onRecordingFinalized?.(() => { - setRecordingFinalizing((wasFinalizing) => { - if (!wasFinalizing) return false; - setLoading(true); - (async () => { - try { - const sessionResult = await window.electronAPI.getCurrentRecordingSession?.(); - if (sessionResult?.success && sessionResult.session?.videoPath) { - const sourcePath = fromFileUrl(sessionResult.session.videoPath); - const sourceVideoUrl = toFileUrl(sourcePath); - setVideoSourcePath(sourcePath); - setVideoPath(sourceVideoUrl); - setCurrentProjectPath(null); - setLastSavedSnapshot(null); - pendingFreshRecordingAutoZoomPathRef.current = sourceVideoUrl; - setWebcam((prev) => ({ - ...prev, - enabled: Boolean(sessionResult.session?.webcamPath), - sourcePath: sessionResult.session?.webcamPath ?? null, - })); - } else { - const result = await window.electronAPI.getCurrentVideoPath(); - if (result.success && result.path) { - const sourcePath = fromFileUrl(result.path); - const sourceVideoUrl = toFileUrl(sourcePath); - setVideoSourcePath(sourcePath); - setVideoPath(sourceVideoUrl); - setCurrentProjectPath(null); - setLastSavedSnapshot(null); - pendingFreshRecordingAutoZoomPathRef.current = sourceVideoUrl; - setWebcam((prev) => ({ - ...prev, - enabled: false, - sourcePath: null, - })); - } else { - setError("Recording finished but no video found."); - } - } - } catch (err) { - setError("Error loading video: " + String(err)); - } finally { - setLoading(false); - } - })(); - return false; - }); - }); - loadInitialData(); - return () => { cleanupFinalized?.(); }; }, [applyLoadedProject, smokeExportConfig.enabled, smokeExportConfig.inputPath]); useEffect(() => { @@ -3823,7 +3762,7 @@ export default function VideoEditor() { if (loading) { return (
-
{recordingFinalizing ? "Finalizing recording..." : "Loading video..."}
+
Loading video...
{projectBrowser}
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts index 074c5b6e..b9db5c23 100644 --- a/src/hooks/useScreenRecorder.ts +++ b/src/hooks/useScreenRecorder.ts @@ -371,7 +371,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn { } clearRecordingFinalizationToast(); - await window.electronAPI.notifyRecordingFinalized(); + await window.electronAPI.switchToEditor(); }, [clearRecordingFinalizationToast]); const stopWebcamRecorder = useCallback(async () => { @@ -402,8 +402,6 @@ export function useScreenRecorder(): UseScreenRecorderReturn { return null; } - // Open editor early so it shows "Finalizing recording..." while we finalize - await window.electronAPI.openEditorEarly?.(); const webcamPath = await stopWebcamRecorder(); await finalizeRecordingSession(result.path, webcamPath); return result.path; @@ -561,11 +559,6 @@ export function useScreenRecorder(): UseScreenRecorderReturn { let finalPath = result.path; - // Open the editor window immediately so the user sees a - // "Finalizing recording…" screen instead of staring at the - // recorder UI while mux/IO completes. - await window.electronAPI.openEditorEarly(); - if (isNativeWindows) { const muxResult = await window.electronAPI.muxNativeWindowsRecording(pauseSegments); if (!muxResult?.success) { @@ -1019,9 +1012,6 @@ export function useScreenRecorder(): UseScreenRecorderReturn { showRecordingFinalizationToast(); - // Open editor window immediately while we process the recording - await window.electronAPI.openEditorEarly?.(); - const duration = getRecordingDurationMs(Date.now()); const recordedChunks = chunks.current; const buggyBlob = new Blob(recordedChunks, { type: mimeType });