Skip to content

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

Merge branch 'main' into feature/reveal-export-folder

SaiVaraprasad Medapati60d3dfaef595
diff --cc electron/electron-env.d.ts
index 15c12f9eb,dac1169dc..cedf2f8a4
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@@ -32,15 -32,23 +32,24 @@@ interface Window
storeRecordedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string }>
getRecordedVideoPath: () => Promise<{ success: boolean; path?: string; message?: string }>
setRecordingState: (recording: boolean) => Promise<void>
+ getCursorTelemetry: (videoPath?: string) => Promise<{ success: boolean; samples: CursorTelemetryPoint[]; message?: string; error?: string }>
onStopRecordingFromTray: (callback: () => void) => () => void
openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>
- saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string; cancelled?: boolean }>
- openVideoFilePicker: () => Promise<{ success: boolean; path?: string; cancelled?: boolean }>
- saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>
- openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>
- setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>
- getCurrentVideoPath: () => Promise<{ success: boolean; path?: string }>
- clearCurrentVideoPath: () => Promise<{ success: boolean }>
- saveProjectFile: (projectData: unknown, suggestedName?: string, existingProjectPath?: string) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean; error?: string }>
- loadProjectFile: () => Promise<{ success: boolean; path?: string; project?: unknown; message?: string; canceled?: boolean; error?: string }>
- loadCurrentProjectFile: () => Promise<{ success: boolean; path?: string; project?: unknown; message?: string; canceled?: boolean; error?: string }>
- onMenuLoadProject: (callback: () => void) => () => void
++ saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>
++ openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>
+ setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>
+ getCurrentVideoPath: () => Promise<{ success: boolean; path?: string }>
+ clearCurrentVideoPath: () => Promise<{ success: boolean }>
++ saveProjectFile: (projectData: unknown, suggestedName?: string, existingProjectPath?: string) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean; error?: string }>
++ loadProjectFile: () => Promise<{ success: boolean; path?: string; project?: unknown; message?: string; canceled?: boolean; error?: string }>
++ loadCurrentProjectFile: () => Promise<{ success: boolean; path?: string; project?: unknown; message?: string; canceled?: boolean; error?: string }>
++ onMenuLoadProject: (callback: () => void) => () => void
+ onMenuSaveProject: (callback: () => void) => () => void
+ onMenuSaveProjectAs: (callback: () => void) => () => void
getPlatform: () => Promise<string>
+ revealInFolder: (filePath: string) => Promise<{ success: boolean; error?: string; message?: string }>,
+ getShortcuts: () => Promise<Record<string, unknown> | null>
+ saveShortcuts: (shortcuts: unknown) => Promise<{ success: boolean; error?: string }>
hudOverlayHide: () => void;
hudOverlayClose: () => void;
}
diff --cc electron/ipc/handlers.ts
index 4936dc68d,54325617d..307d95624
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@@ -198,34 -333,131 +333,156 @@@ export function registerIpcHandlers
}
});
+ ipcMain.handle('reveal-in-folder', async (_, filePath: string) => {
+ try {
+ // shell.showItemInFolder doesn't return a value, it throws on error
+ shell.showItemInFolder(filePath);
+ return { success: true };
+ } catch (error) {
+ console.error(`Error revealing item in folder: ${filePath}`, error);
+ // Fallback to open the directory if revealing the item fails
+ // This might happen if the file was moved or deleted after export,
+ // or if the path is somehow invalid for showItemInFolder
+ try {
+ const openPathResult = await shell.openPath(path.dirname(filePath));
+ if (openPathResult) {
+ // openPath returned an error message
+ return { success: false, error: openPathResult };
+ }
+ return { success: true, message: 'Could not reveal item, but opened directory.' };
+ } catch (openError) {
+ console.error(`Error opening directory: ${path.dirname(filePath)}`, openError);
+ return { success: false, error: String(error) };
+ }
+ }
+ });
+
+ let currentVideoPath: string | null = null;
+ ipcMain.handle('save-project-file', async (_, projectData: unknown, suggestedName?: string, existingProjectPath?: string) => {
+ try {
+ const trustedExistingProjectPath = isTrustedProjectPath(existingProjectPath)
+ ? existingProjectPath
+ : null
+
+ if (trustedExistingProjectPath) {
+ await fs.writeFile(trustedExistingProjectPath, JSON.stringify(projectData, null, 2), 'utf-8')
+ currentProjectPath = trustedExistingProjectPath
+ return {
+ success: true,
+ path: trustedExistingProjectPath,
+ message: 'Project saved successfully'
+ }
+ }
+
+ const safeName = (suggestedName || `project-${Date.now()}`).replace(/[^a-zA-Z0-9-_]/g, '_')
+ const defaultName = safeName.endsWith(`.${PROJECT_FILE_EXTENSION}`)
+ ? safeName
+ : `${safeName}.${PROJECT_FILE_EXTENSION}`
+
+ const result = await dialog.showSaveDialog({
+ title: 'Save OpenScreen Project',
+ defaultPath: path.join(RECORDINGS_DIR, defaultName),
+ filters: [
+ { name: 'OpenScreen Project', extensions: [PROJECT_FILE_EXTENSION] },
+ { name: 'JSON', extensions: ['json'] }
+ ],
+ properties: ['createDirectory', 'showOverwriteConfirmation']
+ })
+
+ if (result.canceled || !result.filePath) {
+ return {
+ success: false,
+ canceled: true,
+ message: 'Save project canceled'
+ }
+ }
+
+ await fs.writeFile(result.filePath, JSON.stringify(projectData, null, 2), 'utf-8')
+ currentProjectPath = result.filePath
+ return {
+ success: true,
+ path: result.filePath,
+ message: 'Project saved successfully'
+ }
+ } catch (error) {
+ console.error('Failed to save project file:', error)
+ return {
+ success: false,
+ message: 'Failed to save project file',
+ error: String(error)
+ }
+ }
+ })
+
+ ipcMain.handle('load-project-file', async () => {
+ try {
+ const result = await dialog.showOpenDialog({
+ title: 'Open OpenScreen Project',
+ defaultPath: RECORDINGS_DIR,
+ filters: [
+ { name: 'OpenScreen Project', extensions: [PROJECT_FILE_EXTENSION] },
+ { name: 'JSON', extensions: ['json'] },
+ { name: 'All Files', extensions: ['*'] }
+ ],
+ properties: ['openFile']
+ })
+
+ if (result.canceled || result.filePaths.length === 0) {
+ return { success: false, canceled: true, message: 'Open project canceled' }
+ }
+
+ const filePath = result.filePaths[0]
+ const content = await fs.readFile(filePath, 'utf-8')
+ const project = JSON.parse(content)
+ currentProjectPath = filePath
+ if (project && typeof project === 'object' && typeof project.videoPath === 'string') {
+ currentVideoPath = project.videoPath
+ }
+
+ return {
+ success: true,
+ path: filePath,
+ project
+ }
+ } catch (error) {
+ console.error('Failed to load project file:', error)
+ return {
+ success: false,
+ message: 'Failed to load project file',
+ error: String(error)
+ }
+ }
+ })
+
+ ipcMain.handle('load-current-project-file', async () => {
+ try {
+ if (!currentProjectPath) {
+ return { success: false, message: 'No active project' }
+ }
+
+ const content = await fs.readFile(currentProjectPath, 'utf-8')
+ const project = JSON.parse(content)
+ if (project && typeof project === 'object' && typeof project.videoPath === 'string') {
+ currentVideoPath = project.videoPath
+ }
+ return {
+ success: true,
+ path: currentProjectPath,
+ project,
+ }
+ } catch (error) {
+ console.error('Failed to load current project file:', error)
+ return {
+ success: false,
+ message: 'Failed to load current project file',
+ error: String(error),
+ }
+ }
+ })
ipcMain.handle('set-current-video-path', (_, path: string) => {
currentVideoPath = path;
+ currentProjectPath = null
return { success: true };
});
diff --cc electron/preload.ts
index 667965cf7,c0efd9db6..a771b53ad
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@@ -63,7 -90,10 +90,14 @@@ contextBridge.exposeInMainWorld('electr
getPlatform: () => {
return ipcRenderer.invoke('get-platform')
},
+ revealInFolder: (filePath: string) => {
+ return ipcRenderer.invoke('reveal-in-folder', filePath)
+ },
- })
++})
+ getShortcuts: () => {
+ return ipcRenderer.invoke('get-shortcuts')
+ },
+ saveShortcuts: (shortcuts: unknown) => {
+ return ipcRenderer.invoke('save-shortcuts', shortcuts)
+ },
+ })
diff --cc src/components/video-editor/VideoEditor.tsx
index c116825cc,769e88e24..e238574d6
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@@ -65,7 -82,7 +82,8 @@@ export default function VideoEditor()
const [gifFrameRate, setGifFrameRate] = useState<GifFrameRate>(15);
const [gifLoop, setGifLoop] = useState(true);
const [gifSizePreset, setGifSizePreset] = useState<GifSizePreset>('medium');
+ const [exportedFilePath, setExportedFilePath] = useState<string | undefined>(undefined);
+ const [lastSavedSnapshot, setLastSavedSnapshot] = useState<string | null>(null);
const videoPlaybackRef = useRef<VideoPlaybackRef>(null);
const nextZoomIdRef = useRef(1);
@@@ -509,11 -882,10 +883,15 @@@
const saveResult = await window.electronAPI.saveExportedVideo(arrayBuffer, fileName);
+ if (saveResult.cancelled) {
+ toast.info('Export cancelled');
+ } else if (saveResult.success && saveResult.path) {
+ showExportSuccessToast(saveResult.path);
+ setExportedFilePath(saveResult.path);
+ if (saveResult.canceled) {
+ toast.info('Export canceled');
+ } else if (saveResult.success) {
+ toast.success(`GIF exported successfully to ${saveResult.path}`);
} else {
setExportError(saveResult.message || 'Failed to save GIF');
toast.error(saveResult.message || 'Failed to save GIF');
@@@ -635,11 -1008,10 +1014,15 @@@
const saveResult = await window.electronAPI.saveExportedVideo(arrayBuffer, fileName);
+ if (saveResult.cancelled) {
+ toast.info('Export cancelled');
+ } else if (saveResult.success && saveResult.path) {
+ showExportSuccessToast(saveResult.path);
+ setExportedFilePath(saveResult.path);
+ if (saveResult.canceled) {
+ toast.info('Export canceled');
+ } else if (saveResult.success) {
+ toast.success(`Video exported successfully to ${saveResult.path}`);
} else {
setExportError(saveResult.message || 'Failed to save video');
toast.error(saveResult.message || 'Failed to save video');