Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
rendering on build
Gabriel Steinfa6e742fa011
diff --git a/assets/README.md b/assets/README.mdindex 2eac1d187..6eadc1030 100644--- a/assets/README.md+++ b/assets/README.md@@ -1,6 +1,6 @@# Assets Directory-This directory contains app icons and other assets for Open Scribe.+This directory contains app icons and other assets for OpenScribe.## Required Iconsdiff --git a/electron-builder.json b/electron-builder.jsonindex 22e926d77..dca146f17 100644--- a/electron-builder.json+++ b/electron-builder.json@@ -1,6 +1,6 @@{"appId": "com.openscribe.app",- "productName": "Open Scribe",+ "productName": "OpenScribe","directories": {"output": "dist"},@@ -10,7 +10,14 @@"package.json","node_modules/**/*","src/dist/**/*",- "!node_modules/.cache/**/*"+ "!node_modules/.cache/**/*",+ "!src/node_modules/**/*"+ ],+ "asarUnpack": [+ "assets/**/*"+ ],+ "extraResources": [+ "assets/**/*"],"mac": {"category": "public.app-category.productivity",@@ -46,7 +53,7 @@"createStartMenuShortcut": true},"dmg": {- "title": "Open Scribe",+ "title": "OpenScribe","icon": "assets/icon.icns","background": "assets/dmg-background.png","window": {diff --git a/main.js b/main.jsindex 52c08cac5..1f77f7106 100644--- a/main.js+++ b/main.js@@ -7,6 +7,24 @@ let mainWindowlet tray = nulllet controlPanelWindow = null+// Function to check if dev server is ready+async function waitForDevServer(url, maxAttempts = 30, delay = 1000) {+ for (let i = 0; i < maxAttempts; i++) {+ try {+ const response = await fetch(url);+ if (response.ok) {+ console.log(`Dev server ready after ${i + 1} attempts`);+ return true;+ }+ } catch (error) {+ console.log(`Waiting for dev server... attempt ${i + 1}/${maxAttempts}`);+ }+ await new Promise(resolve => setTimeout(resolve, delay));+ }+ console.error('Dev server failed to start within timeout');+ return false;+}+function getAppUrl(isControlPanel = false) {if (process.env.NODE_ENV === 'development') {// Vite dev server@@ -14,20 +32,33 @@ function getAppUrl(isControlPanel = false) {? 'http://localhost:5174/?panel=true': 'http://localhost:5174/';} else {- // Production build+ // Production build - files are in asar package+ // __dirname in packaged app points to the root of app.asar+ const htmlPath = path.join(__dirname, 'src', 'dist', 'index.html');++ console.log('Loading HTML from:', htmlPath);+ console.log('__dirname:', __dirname);+ console.log('process.resourcesPath:', process.resourcesPath);+return isControlPanel- ? `file://${path.join(__dirname, 'src', 'dist', 'index.html')}?panel=true`- : `file://${path.join(__dirname, 'src', 'dist', 'index.html')}`;+ ? `file://${htmlPath}?panel=true`+ : `file://${htmlPath}`;}}-function createWindow() {+async function createWindow() {// Always show window by defaultconst display = screen.getPrimaryDisplay();const width = 120;const height = 80;const x = display.bounds.x + Math.round((display.workArea.width - width) / 2);- const y = display.workArea.height; // Position above the dock/menu bar+ const y = Math.max(0, display.workArea.height); // Position above the dock/menu bar with padding++ console.log('Display info:', {+ bounds: display.bounds,+ workArea: display.workArea,+ windowPosition: { x, y, width, height }+ });mainWindow = new BrowserWindow({width,@@ -49,7 +80,39 @@ function createWindow() {})- mainWindow.loadURL(getAppUrl(false));+ // Load URL with retry logic for development+ const loadMainWindow = async () => {+ const appUrl = getAppUrl(false);+ console.log('Loading main window URL:', appUrl);++ if (process.env.NODE_ENV === 'development') {+ console.log('Development mode: waiting for dev server...');+ const isReady = await waitForDevServer('http://localhost:5174/');+ if (!isReady) {+ console.error('Dev server not ready, loading anyway...');+ }+ }++ mainWindow.loadURL(appUrl);+ };++ loadMainWindow();++ // Add error handling for failed loads with retry+ mainWindow.webContents.on('did-fail-load', async (event, errorCode, errorDescription, validatedURL) => {+ console.error('Failed to load main window:', errorCode, errorDescription, validatedURL);++ if (process.env.NODE_ENV === 'development' && validatedURL.includes('localhost:5174')) {+ console.log('Retrying connection to dev server in 2 seconds...');+ setTimeout(async () => {+ const isReady = await waitForDevServer('http://localhost:5174/');+ if (isReady) {+ console.log('Dev server ready, reloading...');+ mainWindow.reload();+ }+ }, 2000);+ }+ });// Pass environment variables to renderer processmainWindow.webContents.on('did-finish-load', () => {@@ -57,6 +120,15 @@ function createWindow() {window.OPENAI_API_KEY = '${process.env.OPENAI_API_KEY || ''}';console.log('API Key loaded:', window.OPENAI_API_KEY ? 'Present' : 'Missing');`);++ // Ensure window is visible after load+ setTimeout(() => {+ if (!mainWindow.isVisible()) {+ console.log('Window not visible, forcing show...');+ mainWindow.show();+ mainWindow.focus();+ }+ }, 1000);});// Remove all previous shortcuts@@ -95,7 +167,7 @@ function createWindow() {}}-function createControlPanelWindow() {+async function createControlPanelWindow() {if (controlPanelWindow) {controlPanelWindow.focus();return;@@ -114,32 +186,123 @@ function createControlPanelWindow() {resizable: true,show: true,});- controlPanelWindow.loadURL(getAppUrl(true));++ // Load control panel with same retry logic+ const loadControlPanel = async () => {+ const appUrl = getAppUrl(true);+ console.log('Loading control panel URL:', appUrl);++ if (process.env.NODE_ENV === 'development') {+ const isReady = await waitForDevServer('http://localhost:5174/');+ if (!isReady) {+ console.error('Dev server not ready for control panel, loading anyway...');+ }+ }++ controlPanelWindow.loadURL(appUrl);+ };++ loadControlPanel();+controlPanelWindow.on('closed', () => {controlPanelWindow = null;});}-app.whenReady().then(() => {- createWindow()+app.whenReady().then(async () => {+ console.log('Electron app ready, creating window...');+ console.log('__dirname:', __dirname);+ console.log('process.resourcesPath:', process.resourcesPath);+ console.log('NODE_ENV:', process.env.NODE_ENV);++ // In development, add a small delay to let Vite start properly+ if (process.env.NODE_ENV === 'development') {+ console.log('Development mode: waiting 2 seconds for Vite to stabilize...');+ await new Promise(resolve => setTimeout(resolve, 2000));+ }++ try {+ await createWindow();+ console.log('Main window created successfully');+ } catch (error) {+ console.error('Error creating main window:', error);+ }// Create tray icon on macOSif (process.platform === 'darwin') {- tray = new Tray(path.join(__dirname, 'assets/iconTemplate.png'));- const contextMenu = Menu.buildFromTemplate([- { label: 'Show', click: () => { mainWindow.show(); } },- { label: 'Open Control Panel', click: () => { createControlPanelWindow(); } },- { label: 'Quit', click: () => { app.quit(); } }- ]);- tray.setToolTip('OpenScribe');- tray.setContextMenu(contextMenu);- tray.on('click', () => {- if (mainWindow.isVisible()) {- mainWindow.hide();- } else {- mainWindow.show();+ try {+ // For Electron apps, use nativeImage to load from resources properly+ const { nativeImage } = require('electron');+ let trayIcon;++ if (process.env.NODE_ENV === 'development') {+ // Development mode - load from assets folder+ const iconPath = path.join(__dirname, 'assets', 'iconTemplate.png');+ console.log('Development: Loading tray icon from:', iconPath);+ trayIcon = nativeImage.createFromPath(iconPath);+ } else {+ // Production mode - try different locations for the icon+ const possiblePaths = [+ // First try extraResources (most likely for packaged app)+ path.join(process.resourcesPath, 'assets', 'iconTemplate.png'),+ // Then try asar.unpacked+ path.join(process.resourcesPath, 'app.asar.unpacked', 'assets', 'iconTemplate.png'),+ // Then try within app bundle+ path.join(__dirname, 'assets', 'iconTemplate.png'),+ // Legacy path+ path.join(process.resourcesPath, 'app', 'assets', 'iconTemplate.png')+ ];++ let iconPath = null;+ for (const testPath of possiblePaths) {+ try {+ if (require('fs').existsSync(testPath)) {+ iconPath = testPath;+ break;+ }+ } catch (e) {+ // Ignore and try next path+ }+ }++ if (iconPath) {+ console.log('Production: Loading tray icon from:', iconPath);+ trayIcon = nativeImage.createFromPath(iconPath);+ } else {+ console.error('Could not find tray icon in any expected location');+ return; // Exit early if no icon found+ }+ }++ // Check if the image loaded successfully+ if (trayIcon.isEmpty()) {+ console.error('Tray icon is empty - failed to load');+ return;}- });++ // Ensure it's marked as a template image for macOS+ trayIcon.setTemplateImage(true);++ tray = new Tray(trayIcon);+ const contextMenu = Menu.buildFromTemplate([+ { label: 'Show', click: () => { mainWindow.show(); } },+ { label: 'Open Control Panel', click: () => { createControlPanelWindow(); } },+ { label: 'Quit', click: () => { app.quit(); } }+ ]);+ tray.setToolTip('OpenScribe');+ tray.setContextMenu(contextMenu);+ tray.on('click', () => {+ // Always ensure the dictation panel is visible and focused+ if (!mainWindow.isVisible()) {+ mainWindow.show();+ }+ mainWindow.focus();+ });+ console.log('Tray icon created successfully');+ } catch (error) {+ console.error('Error creating tray icon:', error);+ console.log('Tray will not be available');+ }}})diff --git a/package.json b/package.jsonindex 15df0ff26..9ae5d8b48 100644--- a/package.json+++ b/package.json@@ -28,7 +28,7 @@"electron","desktop-app"],- "author": "Open Scribe Team",+ "author": "OpenScribe Team","license": "MIT","devDependencies": {"@eslint/js": "^9.25.0",diff --git a/src/index.html b/src/index.htmlindex 43f984286..50a8b663f 100644--- a/src/index.html+++ b/src/index.html@@ -2,7 +2,7 @@<html lang="en"><head><meta charset="UTF-8" />- <link rel="icon" type="image/png" href="/assets/icon.png" />+ <link rel="icon" type="image/png" href="./assets/icon.png" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>OpenScribe</title></head>diff --git a/src/vite.config.mjs b/src/vite.config.mjsindex 56cbc269a..1241aee31 100644--- a/src/vite.config.mjs+++ b/src/vite.config.mjs@@ -10,6 +10,7 @@ const __dirname = path.dirname(__filename)// https://vite.dev/config/export default defineConfig({plugins: [react(), tailwindcss()],+ base: './', // Use relative paths for file:// protocol in Electronresolve: {alias: {"@": path.resolve(__dirname, "."),