Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

refactor: handling onboarding better

Gabriel Stein67c77fd69a6a
diff --git a/assets/icon.icns b/assets/icon.icns
index 6cc523035..d3fab5306 100644
Binary files a/assets/icon.icns and b/assets/icon.icns differ
diff --git a/assets/icon.ico b/assets/icon.ico
index 367c4cc90..5b781368b 100644
Binary files a/assets/icon.ico and b/assets/icon.ico differ
diff --git a/assets/icon.png b/assets/icon.png
index 237a476ed..86d28e6c4 100644
Binary files a/assets/icon.png and b/assets/icon.png differ
diff --git a/main.js b/main.js
index 8a180d9b6..8cb8221aa 100644
--- a/main.js
+++ b/main.js
@@ -289,6 +289,13 @@ app.whenReady().then(async () => {
} catch (error) {
console.error('Error creating main window:', error);
}
+
+ // Auto-open control panel when app starts
+ try {
+ await createControlPanelWindow();
+ } catch (error) {
+ console.error('Error creating control panel window:', error);
+ }
// Create tray icon on macOS
if (process.platform === 'darwin') {
@@ -330,7 +337,29 @@ app.whenReady().then(async () => {
trayIcon = nativeImage.createFromPath(iconPath);
} else {
console.error('Could not find tray icon in any expected location');
- return; // Exit early if no icon found
+ console.log('Tried paths:', possiblePaths);
+
+ // Create a fallback tray icon if the file isn't found
+ try {
+ // Create a simple fallback icon programmatically
+ const { nativeImage } = require('electron');
+ const canvas = require('canvas');
+ const canvasInstance = canvas.createCanvas(16, 16);
+ const ctx = canvasInstance.getContext('2d');
+
+ // Draw a simple circle as fallback
+ ctx.fillStyle = '#000000';
+ ctx.beginPath();
+ ctx.arc(8, 8, 6, 0, 2 * Math.PI);
+ ctx.fill();
+
+ const buffer = canvasInstance.toBuffer('image/png');
+ trayIcon = nativeImage.createFromBuffer(buffer);
+ console.log('✅ Created fallback tray icon');
+ } catch (fallbackError) {
+ console.error('Failed to create fallback tray icon:', fallbackError);
+ return; // Exit early if fallback also fails
+ }
}
}
@@ -344,13 +373,28 @@ app.whenReady().then(async () => {
trayIcon.setTemplateImage(true);
tray = new Tray(trayIcon);
+
+ // Prevent tray from being garbage collected
+ tray.setIgnoreDoubleClickEvents(true);
+
const contextMenu = Menu.buildFromTemplate([
- { label: 'Show', click: () => { mainWindow.show(); } },
+ { label: 'Show Dictation Panel', click: () => {
+ if (!mainWindow.isVisible()) {
+ mainWindow.show();
+ }
+ mainWindow.focus();
+ }},
{ label: 'Open Control Panel', click: () => { createControlPanelWindow(); } },
- { label: 'Quit', click: () => { app.quit(); } }
+ { type: 'separator' },
+ { label: 'Quit OpenWispr', click: () => {
+ console.log('Quitting app via tray menu');
+ app.quit();
+ }}
]);
- tray.setToolTip('OpenWispr');
+
+ tray.setToolTip('OpenWispr - Voice Dictation');
tray.setContextMenu(contextMenu);
+
tray.on('click', () => {
// Always ensure the dictation panel is visible and focused
if (!mainWindow.isVisible()) {
@@ -358,6 +402,14 @@ app.whenReady().then(async () => {
}
mainWindow.focus();
});
+
+ // Handle tray destruction to prevent crashes
+ tray.on('destroyed', () => {
+ console.log('Tray icon destroyed');
+ tray = null;
+ });
+
+ console.log('✅ Tray icon created successfully');
} catch (error) {
console.error('Error creating tray icon:', error);
}
diff --git a/src/App.jsx b/src/App.jsx
index b5a8847ea..494b249bf 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -85,6 +85,7 @@ export default function App() {
};
mediaRecorderRef.current.onstop = async () => {
+ setIsProcessing(true);
const audioBlob = new Blob(audioChunksRef.current, { type: 'audio/wav' });
await processAudio(audioBlob);
stream.getTracks().forEach(track => track.stop());
@@ -102,7 +103,7 @@ export default function App() {
if (mediaRecorderRef.current && isRecording) {
mediaRecorderRef.current.stop();
setIsRecording(false);
- setIsProcessing(true);
+ // Don't set processing immediately - let the onstop handler do it
}
};
@@ -286,32 +287,33 @@ export default function App() {
// Get microphone button properties based on state
const getMicButtonProps = () => {
- const baseClasses = 'rounded-full transition-all duration-200 ease-in-out flex items-center justify-center relative overflow-hidden';
+ const baseClasses = 'rounded-full w-10 h-10 flex items-center justify-center relative overflow-hidden';
switch (micState) {
case 'idle':
return {
- className: `${baseClasses} w-8 h-8 bg-black/40 backdrop-blur-md border border-white/20 cursor-pointer`,
+ className: `${baseClasses} bg-black/40 backdrop-blur-md border border-white/20 cursor-pointer`,
tooltip: "Click to speak"
};
case 'hover':
return {
- className: `${baseClasses} w-8 h-8 bg-black/50 backdrop-blur-md border border-white/20 scale-110 cursor-pointer`,
+ className: `${baseClasses} bg-black/50 backdrop-blur-md border border-white/20 cursor-pointer`,
tooltip: "Click to speak"
};
case 'recording':
return {
- className: `${baseClasses} w-10 h-10 bg-blue-600 scale-110 cursor-pointer`,
+ className: `${baseClasses} bg-blue-600 cursor-pointer`,
tooltip: "Recording..."
};
case 'processing':
return {
- className: `${baseClasses} w-10 h-10 bg-purple-600 scale-105 cursor-not-allowed`,
+ className: `${baseClasses} bg-purple-600 cursor-not-allowed`,
tooltip: "Processing..."
};
default:
return {
- className: `${baseClasses} w-8 h-8 bg-black/40 backdrop-blur-md border border-white/20 cursor-pointer`,
+ className: `${baseClasses} bg-black/40 backdrop-blur-md border border-white/20 cursor-pointer`,
+ style: { transform: 'scale(0.8)' },
tooltip: "Click to speak"
};
}
@@ -334,7 +336,11 @@ export default function App() {
onBlur={() => setIsHovered(false)}
className={micProps.className}
disabled={micState === 'processing'}
- style={{ cursor: micState === 'processing' ? 'not-allowed !important' : 'pointer !important' }}
+ style={{
+ ...micProps.style,
+ cursor: micState === 'processing' ? 'not-allowed !important' : 'pointer !important',
+ transition: 'transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease-out'
+ }}
>
{/* Background effects */}
<div className="absolute inset-0 bg-gradient-to-br from-white/10 to-transparent transition-opacity duration-150" style={{ opacity: micState === 'hover' ? 0.8 : 0 }}></div>