Skip to content

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

feat: added auto update, refactored titlebar

Gabriel Steind0d2d020a54a
diff --git a/main.js b/main.js
index a24705071..eb54b3435 100644
--- a/main.js
+++ b/main.js
@@ -4,6 +4,7 @@ const { spawn } = require("child_process")
const Database = require('better-sqlite3')
const fs = require('fs')
const os = require('os')
+const UpdateManager = require('./src/updater')
// Load .env file with better error handling and production support
function loadEnvironmentVariables() {
@@ -40,6 +41,9 @@ function loadEnvironmentVariables() {
// Load environment variables
loadEnvironmentVariables();
+// Initialize update manager
+const updateManager = new UpdateManager();
+
let mainWindow
let tray = null
let controlPanelWindow = null
@@ -371,6 +375,10 @@ await new Promise((resolve, reject) => {
} catch (error) {
console.error('Error creating control panel window:', error);
}
+
+ // Set windows for update manager and check for updates
+ updateManager.setWindows(mainWindow, controlPanelWindow);
+ updateManager.checkForUpdatesOnStartup();
// Create tray icon on macOS
if (process.platform === 'darwin') {
@@ -1530,3 +1538,4 @@ ipcMain.handle('cleanup-app', async (event) => {
throw error;
}
});
+
diff --git a/package.json b/package.json
index 4da7bab8c..ba5ab8978 100644
--- a/package.json
+++ b/package.json
@@ -56,6 +56,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"dotenv": "^16.3.1",
+ "electron-updater": "^6.6.2",
"lucide-react": "^0.518.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
diff --git a/preload.js b/preload.js
index 926790523..386505e3d 100644
--- a/preload.js
+++ b/preload.js
@@ -38,4 +38,18 @@ contextBridge.exposeInMainWorld('electronAPI', {
// Cleanup function
cleanupApp: () => ipcRenderer.invoke('cleanup-app'),
+
+ // Update functions
+ checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
+ downloadUpdate: () => ipcRenderer.invoke('download-update'),
+ installUpdate: () => ipcRenderer.invoke('install-update'),
+ getAppVersion: () => ipcRenderer.invoke('get-app-version'),
+ getUpdateStatus: () => ipcRenderer.invoke('get-update-status'),
+
+ // Update event listeners
+ onUpdateAvailable: (callback) => ipcRenderer.on('update-available', callback),
+ onUpdateNotAvailable: (callback) => ipcRenderer.on('update-not-available', callback),
+ onUpdateDownloaded: (callback) => ipcRenderer.on('update-downloaded', callback),
+ onUpdateDownloadProgress: (callback) => ipcRenderer.on('update-download-progress', callback),
+ onUpdateError: (callback) => ipcRenderer.on('update-error', callback),
});
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index 249bfefb1..c8bfe34e6 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -21,6 +21,7 @@ import {
ChevronRight,
} from "lucide-react";
import SettingsPage from "./SettingsPage";
+import TitleBar from "./TitleBar";
// Type declaration for electronAPI
declare global {
@@ -101,6 +102,29 @@ declare global {
windowMaximize: () => Promise<void>;
windowClose: () => Promise<void>;
windowIsMaximized: () => Promise<boolean>;
+ // Update functions
+ checkForUpdates: () => Promise<{
+ updateAvailable: boolean;
+ version?: string;
+ releaseDate?: string;
+ files?: any[];
+ releaseNotes?: string;
+ message?: string;
+ }>;
+ downloadUpdate: () => Promise<{ success: boolean; message: string }>;
+ installUpdate: () => Promise<{ success: boolean; message: string }>;
+ getAppVersion: () => Promise<{ version: string }>;
+ getUpdateStatus: () => Promise<{
+ updateAvailable: boolean;
+ updateDownloaded: boolean;
+ isDevelopment: boolean;
+ }>;
+ // Update event listeners
+ onUpdateAvailable: (callback: (event: any, info: any) => void) => void;
+ onUpdateNotAvailable: (callback: (event: any, info: any) => void) => void;
+ onUpdateDownloaded: (callback: (event: any, info: any) => void) => void;
+ onUpdateDownloadProgress: (callback: (event: any, progressObj: any) => void) => void;
+ onUpdateError: (callback: (event: any, error: any) => void) => void;
};
}
}
@@ -116,10 +140,40 @@ export default function ControlPanel() {
const [history, setHistory] = useState<TranscriptionItem[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [showSettings, setShowSettings] = useState(false);
+ const [updateAvailable, setUpdateAvailable] = useState(false);
+ const [updateDownloaded, setUpdateDownloaded] = useState(false);
+ const [isDevelopment, setIsDevelopment] = useState(false);
useEffect(() => {
// Load transcription history from database
loadTranscriptions();
+
+ // Initialize update status
+ const initializeUpdateStatus = async () => {
+ try {
+ const status = await window.electronAPI.getUpdateStatus();
+ setUpdateAvailable(status.updateAvailable);
+ setUpdateDownloaded(status.updateDownloaded);
+ setIsDevelopment(status.isDevelopment);
+ } catch (error) {
+ console.error('Error initializing update status:', error);
+ }
+ };
+
+ initializeUpdateStatus();
+
+ // Set up update event listeners
+ window.electronAPI.onUpdateAvailable((event, info) => {
+ setUpdateAvailable(true);
+ });
+
+ window.electronAPI.onUpdateDownloaded((event, info) => {
+ setUpdateDownloaded(true);
+ });
+
+ window.electronAPI.onUpdateError((event, error) => {
+ console.error('Update error:', error);
+ });
}, []);
const loadTranscriptions = async () => {
@@ -189,20 +243,15 @@ export default function ControlPanel() {
return (
<div className="min-h-screen bg-white">
- {/* Custom Title Bar */}
- <div className="bg-white border-b border-gray-100 select-none">
- <div
- className="flex items-center justify-between h-12 px-4"
- style={{ WebkitAppRegion: "drag" }}
- >
- {/* Left section - empty for drag area */}
- <div></div>
-
- {/* Right section - settings control */}
- <div
- className="flex items-center gap-2"
- style={{ WebkitAppRegion: "no-drag" }}
- >
+ <TitleBar
+ actions={
+ <>
+ {/* Update notification badge */}
+ {!isDevelopment && (updateAvailable || updateDownloaded) && (
+ <div className="relative">
+ <div className="absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full"></div>
+ </div>
+ )}
<Tooltip content="Open settings">
<Button
variant="ghost"
@@ -212,9 +261,9 @@ export default function ControlPanel() {
<Settings size={16} />
</Button>
</Tooltip>
- </div>
- </div>
- </div>
+ </>
+ }
+ />
{/* Main content */}
<div className="p-6">
diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsx
index b7c7a5c25..f34fd8606 100644
--- a/src/components/OnboardingFlow.tsx
+++ b/src/components/OnboardingFlow.tsx
@@ -24,6 +24,7 @@ import {
ArrowRight,
X,
} from "lucide-react";
+import TitleBar from "./TitleBar";
// Type declaration for electronAPI
declare global {
@@ -932,20 +933,15 @@ case 2:
{/* Left margin line for entire page */}
<div className="fixed left-6 md:left-12 top-0 bottom-0 w-px bg-red-300/40 z-0"></div>
- {/* Header */}
- <div className="bg-white backdrop-blur-xl border-b border-stone-200/60 px-6 md:pl-16 md:pr-6 py-4 relative z-10 flex-shrink-0">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-3">
- {/* <div className="w-8 h-8 bg-gradient-to-br from-blue-500 to-blue-600 rounded-lg flex items-center justify-center">
- <span className="text-white font-bold text-sm" style={{ fontFamily: 'Noto Sans, sans-serif' }}>OW</span>
- </div> */}
- <h1 className="text-sm font-semibold text-stone-900" style={{ fontFamily: 'Noto Sans, sans-serif' }}>OpenWispr Setup</h1>
- </div>
- <div className="text-sm text-stone-500" style={{ fontFamily: 'Noto Sans, sans-serif' }}>
- Step {currentStep + 1} of {steps.length}
- </div>
+ <TitleBar
+ title="OpenWispr Setup"
+ showTitle={true}
+ className="bg-white backdrop-blur-xl border-b border-stone-200/60 relative z-10 flex-shrink-0"
+ >
+ <div className="text-sm text-stone-500" style={{ fontFamily: 'Noto Sans, sans-serif' }}>
+ Step {currentStep + 1} of {steps.length}
</div>
- </div>
+ </TitleBar>
{/* Progress Bar */}
<div className="bg-white backdrop-blur-xl border-b border-stone-200/60 px-6 md:pl-16 md:pr-6 py-2 relative z-10 flex-shrink-0">
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index d3a999fab..b3c239856 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -2,7 +2,6 @@ import React, { useState, useEffect } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
import { Button } from "./ui/button";
import { Input } from "./ui/input";
-import { Tooltip } from "./ui/tooltip";
import {
RefreshCw,
Download,
@@ -10,7 +9,9 @@ import {
Keyboard,
Info,
Trash2,
+ ArrowLeft,
} from "lucide-react";
+import TitleBar from "./TitleBar";
// Type declaration for electronAPI
declare global {
@@ -93,6 +94,31 @@ declare global {
windowIsMaximized: () => Promise<boolean>;
// Cleanup functions
cleanupApp: () => Promise<void>;
+ // Update functions
+ checkForUpdates: () => Promise<{
+ updateAvailable: boolean;
+ version?: string;
+ releaseDate?: string;
+ files?: any[];
+ releaseNotes?: string;
+ message?: string;
+ }>;
+ downloadUpdate: () => Promise<{ success: boolean; message: string }>;
+ installUpdate: () => Promise<{ success: boolean; message: string }>;
+ getAppVersion: () => Promise<{ version: string }>;
+ getUpdateStatus: () => Promise<{
+ updateAvailable: boolean;
+ updateDownloaded: boolean;
+ isDevelopment: boolean;
+ }>;
+ // Update event listeners
+ onUpdateAvailable: (callback: (event: any, info: any) => void) => void;
+ onUpdateNotAvailable: (callback: (event: any, info: any) => void) => void;
+ onUpdateDownloaded: (callback: (event: any, info: any) => void) => void;
+ onUpdateDownloadProgress: (
+ callback: (event: any, progressObj: any) => void
+ ) => void;
+ onUpdateError: (callback: (event: any, error: any) => void) => void;
};
}
}
@@ -104,7 +130,11 @@ interface TranscriptionItem {
created_at: string;
}
-export default function SettingsPage({ onClose }) {
+interface SettingsPageProps {
+ onBack: () => void;
+}
+
+export default function SettingsPage({ onBack }: SettingsPageProps) {
const [key, setKey] = useState("");
const [apiKey, setApiKey] = useState("");
const [useLocalWhisper, setUseLocalWhisper] = useState(false);
@@ -121,6 +151,22 @@ export default function SettingsPage({ onClose }) {
const [installingWhisper, setInstallingWhisper] = useState(false);
const [installProgress, setInstallProgress] = useState<string>("");
+ // Update state
+ const [currentVersion, setCurrentVersion] = useState<string>("");
+ const [updateStatus, setUpdateStatus] = useState<{
+ updateAvailable: boolean;
+ updateDownloaded: boolean;
+ isDevelopment: boolean;
+ }>({ updateAvailable: false, updateDownloaded: false, isDevelopment: false });
+ const [checkingForUpdates, setCheckingForUpdates] = useState(false);
+ const [downloadingUpdate, setDownloadingUpdate] = useState(false);
+ const [updateDownloadProgress, setUpdateDownloadProgress] = useState(0);
+ const [updateInfo, setUpdateInfo] = useState<{
+ version?: string;
+ releaseDate?: string;
+ releaseNotes?: string;
+ }>({});
+
useEffect(() => {
// Load saved settings
const savedKey = localStorage.getItem("dictationKey");
@@ -129,7 +175,8 @@ export default function SettingsPage({ onClose }) {
// Load Whisper settings
const savedUseLocal = localStorage.getItem("useLocalWhisper") === "true";
const savedModel = localStorage.getItem("whisperModel") || "base";
- const savedAllowFallback = localStorage.getItem("allowOpenAIFallback") === "true";
+ const savedAllowFallback =
+ localStorage.getItem("allowOpenAIFallback") === "true";
setUseLocalWhisper(savedUseLocal);
setWhisperModel(savedModel);
setAllowOpenAIFallback(savedAllowFallback);
@@ -152,7 +199,6 @@ export default function SettingsPage({ onClose }) {
loadApiKey();
-
// Check Whisper installation
checkWhisperInstallation();
@@ -174,8 +220,49 @@ export default function SettingsPage({ onClose }) {
setDownloadProgress(0);
}
});
- }, []);
+ // Initialize update functionality
+ const initializeUpdateData = async () => {
+ try {
+ // Get current app version
+ const versionResult = await window.electronAPI.getAppVersion();
+ setCurrentVersion(versionResult.version);
+
+ // Get update status
+ const statusResult = await window.electronAPI.getUpdateStatus();
+ setUpdateStatus(statusResult);
+ } catch (error) {
+ console.error("Error initializing update data:", error);
+ }
+ };
+
+ initializeUpdateData();
+
+ // Set up update event listeners
+ window.electronAPI.onUpdateAvailable((event, info) => {
+ setUpdateStatus((prev) => ({ ...prev, updateAvailable: true }));
+ setUpdateInfo({
+ version: info.version,
+ releaseDate: info.releaseDate,
+ releaseNotes: info.releaseNotes,
+ });
+ });
+
+ window.electronAPI.onUpdateDownloaded((event, info) => {
+ setUpdateStatus((prev) => ({ ...prev, updateDownloaded: true }));
+ setDownloadingUpdate(false);
+ });
+
+ window.electronAPI.onUpdateDownloadProgress((event, progressObj) => {
+ setUpdateDownloadProgress(progressObj.percent || 0);
+ });
+
+ window.electronAPI.onUpdateError((event, error) => {
+ setCheckingForUpdates(false);
+ setDownloadingUpdate(false);
+ console.error("Update error:", error);
+ });
+ }, []);
const checkWhisperInstallation = async () => {
try {
@@ -305,23 +392,23 @@ export default function SettingsPage({ onClose }) {
localStorage.setItem("useLocalWhisper", useLocalWhisper.toString());
localStorage.setItem("whisperModel", whisperModel);
localStorage.setItem("allowOpenAIFallback", allowOpenAIFallback.toString());
-
+
// Also save API key if fallback is enabled and key is provided
if (allowOpenAIFallback && apiKey.trim()) {
localStorage.setItem("openaiApiKey", apiKey);
}
-
+
alert(
`Whisper settings saved! ${
useLocalWhisper
- ? `Using local model: ${whisperModel}${allowOpenAIFallback ? ' with OpenAI fallback' : ''}`
+ ? `Using local model: ${whisperModel}${
+ allowOpenAIFallback ? " with OpenAI fallback" : ""
+ }`
: "Using OpenAI API"
}`
);
};
-
-
const requestPermissions = async () => {
try {
await navigator.mediaDevices.getUserMedia({ audio: true });
@@ -361,8 +448,6 @@ export default function SettingsPage({ onClose }) {
}
};
-
-
// Enhanced keyboard paste handler for API key input
const handleApiKeyKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
// Handle Cmd+V on Mac or Ctrl+V on Windows/Linux
@@ -390,21 +475,15 @@ export default function SettingsPage({ onClose }) {
return (
<div className="min-h-screen bg-white">
- {/* Custom Title Bar - matching Wispr Flow style */}
- <div className="bg-white border-b border-gray-100 select-none">
- <div
- className="flex items-center justify-between h-12 px-4"
- style={{ WebkitAppRegion: "drag" }}
- >
- {/* Right section - minimal controls */}
- <div
- className="flex items-center gap-2"
- style={{ WebkitAppRegion: "no-drag" }}
- >
- {/* Could add settings or other controls here if needed */}
- </div>
- </div>
- </div>
+ <TitleBar
+ title="Settings"
+ showTitle={true}
+ actions={
+ <Button variant="ghost" size="icon" onClick={onBack}>
+ <ArrowLeft size={16} />
+ </Button>
+ }
+ />
{/* Main content */}
<div
@@ -611,17 +690,31 @@ export default function SettingsPage({ onClose }) {
type="checkbox"
className="sr-only"
checked={allowOpenAIFallback}
- onChange={(e) => setAllowOpenAIFallback(e.target.checked)}
+ onChange={(e) =>
+ setAllowOpenAIFallback(e.target.checked)
+ }
/>
- <div className={`w-11 h-6 bg-gray-200 rounded-full peer peer-focus:ring-2 peer-focus:ring-purple-300 ${allowOpenAIFallback ? 'bg-purple-600' : 'bg-gray-300'} transition-colors duration-200`}>
- <div className={`absolute top-0.5 left-0.5 bg-white border border-gray-300 rounded-full h-5 w-5 transition-transform duration-200 ${allowOpenAIFallback ? 'translate-x-5' : 'translate-x-0'}`}></div>
+ <div
+ className={`w-11 h-6 bg-gray-200 rounded-full peer peer-focus:ring-2 peer-focus:ring-purple-300 ${
+ allowOpenAIFallback
+ ? "bg-purple-600"
+ : "bg-gray-300"
+ } transition-colors duration-200`}
+ >
+ <div
+ className={`absolute top-0.5 left-0.5 bg-white border border-gray-300 rounded-full h-5 w-5 transition-transform duration-200 ${
+ allowOpenAIFallback
+ ? "translate-x-5"
+ : "translate-x-0"
+ }`}
+ ></div>
</div>
</label>
</div>
<p className="text-xs text-purple-700">
If local processing fails, try OpenAI API as backup
</p>
-
+
{/* API Key field - only show if fallback is enabled */}
{allowOpenAIFallback && (
<div className="p-3 bg-purple-50 border border-purple-200 rounded-lg">
@@ -641,11 +734,13 @@ export default function SettingsPage({ onClose }) {
size="sm"
onClick={async () => {
try {
- const text = await window.electronAPI.readClipboard();
+ const text =
+ await window.electronAPI.readClipboard();
if (text && text.trim()) {
setApiKey(text.trim());
} else {
- const webText = await navigator.clipboard.readText();
+ const webText =
+ await navigator.clipboard.readText();
setApiKey(webText.trim());
}
} catch (err) {
@@ -903,6 +998,171 @@ export default function SettingsPage({ onClose }) {
</CardContent>
</Card>
+ {/* Updates Card */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <RefreshCw size={18} className="text-indigo-600" />
+ App Updates
+ </CardTitle>
+ <p className="text-sm text-neutral-600 mt-2 leading-relaxed">
+ Keep OpenWispr up to date with the latest features and
+ improvements.
+ </p>
+ </CardHeader>
+ <CardContent className="space-y-4">
+ <div className="flex items-center justify-between p-4 bg-neutral-50 rounded-lg">
+ <div>
+ <p className="text-sm font-medium text-neutral-800">
+ Current Version
+ </p>
+ <p className="text-xs text-neutral-600">
+ {currentVersion || "Loading..."}
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {updateStatus.isDevelopment ? (
+ <span className="text-xs text-amber-600 bg-amber-100 px-2 py-1 rounded-full">
+ Development Mode
+ </span>
+ ) : updateStatus.updateAvailable ? (
+ <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
+ Update Available
+ </span>
+ ) : (
+ <span className="text-xs text-neutral-600 bg-neutral-100 px-2 py-1 rounded-full">
+ Up to Date
+ </span>
+ )}
+ </div>
+ </div>
+
+ <div className="space-y-3">
+ <Button
+ onClick={async () => {
+ setCheckingForUpdates(true);
+ try {
+ const result = await window.electronAPI.checkForUpdates();
+ if (result.updateAvailable) {
+ setUpdateInfo({
+ version: result.version,
+ releaseDate: result.releaseDate,
+ releaseNotes: result.releaseNotes,
+ });
+ setUpdateStatus((prev) => ({
+ ...prev,
+ updateAvailable: true,
+ }));
+ alert(`Update available: v${result.version}`);
+ } else {
+ alert(result.message || "No updates available");
+ }
+ } catch (error) {
+ alert(`Error checking for updates: ${error.message}`);
+ } finally {
+ setCheckingForUpdates(false);
+ }
+ }}
+ disabled={checkingForUpdates || updateStatus.isDevelopment}
+ className="w-full"
+ >
+ {checkingForUpdates ? (
+ <>
+ <RefreshCw size={16} className="animate-spin mr-2" />
+ Checking for Updates...
+ </>
+ ) : (
+ <>
+ <RefreshCw size={16} className="mr-2" />
+ Check for Updates
+ </>
+ )}
+ </Button>
+
+ {updateStatus.updateAvailable &&
+ !updateStatus.updateDownloaded && (
+ <Button
+ onClick={async () => {
+ setDownloadingUpdate(true);
+ try {
+ await window.electronAPI.downloadUpdate();
+ setUpdateStatus((prev) => ({
+ ...prev,
+ updateDownloaded: true,
+ }));
+ alert(
+ "Update downloaded successfully! You can now install it."
+ );
+ } catch (error) {
+ alert(`Error downloading update: ${error.message}`);
+ } finally {
+ setDownloadingUpdate(false);
+ }
+ }}
+ disabled={downloadingUpdate || updateStatus.isDevelopment}
+ className="w-full"
+ >
+ {downloadingUpdate ? (
+ <>
+ <Download size={16} className="animate-bounce mr-2" />
+ Downloading Update...
+ </>
+ ) : (
+ <>
+ <Download size={16} className="mr-2" />
+ Download Update
+ </>
+ )}
+ </Button>
+ )}
+
+ {updateStatus.updateDownloaded && (
+ <Button
+ onClick={async () => {
+ try {
+ await window.electronAPI.installUpdate();
+ } catch (error) {
+ alert(`Error installing update: ${error.message}`);
+ }
+ }}
+ disabled={updateStatus.isDevelopment}
+ className="w-full bg-green-600 hover:bg-green-700"
+ >
+ <span className="mr-2">πŸ”„</span>
+ Install Update & Restart
+ </Button>
+ )}
+
+ {updateInfo.version && (
+ <div className="p-3 bg-blue-50 border border-blue-200 rounded-lg">
+ <h4 className="font-medium text-blue-900 mb-1">
+ Update Details
+ </h4>
+ <p className="text-sm text-blue-800 mb-1">
+ Version: {updateInfo.version}
+ </p>
+ {updateInfo.releaseDate && (
+ <p className="text-sm text-blue-700 mb-2">
+ Released:{" "}
+ {new Date(updateInfo.releaseDate).toLocaleDateString()}
+ </p>
+ )}
+ {updateInfo.releaseNotes && (
+ <details className="text-sm text-blue-700">
+ <summary className="cursor-pointer font-medium">
+ Release Notes
+ </summary>
+ <div className="mt-2 whitespace-pre-wrap">
+ {updateInfo.releaseNotes}
+ </div>
+ </details>
+ )}
+ </div>
+ )}
+ </div>
+ </CardContent>
+ </Card>
+
{/* About Card */}
<Card className="bg-white relative z-10">
<CardHeader>
@@ -963,7 +1223,7 @@ export default function SettingsPage({ onClose }) {
<span className="mr-2">πŸ”„</span>
Reset Onboarding
</Button>
-
+
{/* Cleanup App Data */}
<Button
onClick={() => {
@@ -972,14 +1232,19 @@ export default function SettingsPage({ onClose }) {
"⚠️ DANGER: This will permanently delete ALL OpenWispr data including:\n\nβ€’ Database and transcriptions\nβ€’ Local storage settings\nβ€’ Downloaded Whisper models\nβ€’ Environment files\n\nYou will need to manually remove app permissions in System Settings.\n\nThis action cannot be undone. Are you sure?"
)
) {
- window.electronAPI.cleanupApp().then(() => {
- alert("βœ… Cleanup completed! All app data has been removed.");
- setTimeout(() => {
- window.location.reload();
- }, 1000);
- }).catch((error) => {
- alert(`❌ Cleanup failed: ${error.message}`);
- });
+ window.electronAPI
+ .cleanupApp()
+ .then(() => {
+ alert(
+ "βœ… Cleanup completed! All app data has been removed."
+ );
+ setTimeout(() => {
+ window.location.reload();
+ }, 1000);
+ })
+ .catch((error) => {
+ alert(`❌ Cleanup failed: ${error.message}`);
+ });
}
}}
variant="outline"
diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx
new file mode 100644
index 000000000..39f61b45e
--- /dev/null
+++ b/src/components/TitleBar.tsx
@@ -0,0 +1,44 @@
+import React from "react";
+import { Button } from "./ui/button";
+import { Tooltip } from "./ui/tooltip";
+
+interface TitleBarProps {
+ title?: string;
+ showTitle?: boolean;
+ children?: React.ReactNode;
+ className?: string;
+ actions?: React.ReactNode;
+}
+
+export default function TitleBar({
+ title = "",
+ showTitle = false,
+ children,
+ className = "",
+ actions
+}: TitleBarProps) {
+ return (
+ <div className={`bg-white border-b border-gray-100 select-none ${className}`}>
+ <div
+ className="flex items-center justify-between h-12 px-4"
+ style={{ WebkitAppRegion: "drag" }}
+ >
+ {/* Left section - title or custom content */}
+ <div className="flex items-center gap-2">
+ {showTitle && title && (
+ <h1 className="text-sm font-semibold text-gray-900">{title}</h1>
+ )}
+ {children}
+ </div>
+
+ {/* Right section - actions */}
+ <div
+ className="flex items-center gap-2"
+ style={{ WebkitAppRegion: "no-drag" }}
+ >
+ {actions}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
index d893e0960..07d46dc5f 100644
--- a/src/components/ui/button.tsx
+++ b/src/components/ui/button.tsx
@@ -1,11 +1,11 @@
-import * as React from "react"
-import { Slot } from "@radix-ui/react-slot"
-import { cva, type VariantProps } from "class-variance-authority"
+import * as React from "react";
+import { Slot } from "@radix-ui/react-slot";
+import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "../lib/utils"
+import { cn } from "../lib/utils";
const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-all duration-150 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-indigo-500/30 focus-visible:ring-offset-1",
+ "inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-all duration-150 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-indigo-500/30 focus-visible:ring-offset-1",
{
variants: {
variant: {
@@ -33,7 +33,7 @@ const buttonVariants = cva(
size: "default",
},
}
-)
+);
function Button({
className,
@@ -43,9 +43,9 @@ function Button({
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
- asChild?: boolean
+ asChild?: boolean;
}) {
- const Comp = asChild ? Slot : "button"
+ const Comp = asChild ? Slot : "button";
return (
<Comp
@@ -53,7 +53,7 @@ function Button({
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
- )
+ );
}
-export { Button, buttonVariants }
+export { Button, buttonVariants };
diff --git a/src/updater.js b/src/updater.js
new file mode 100644
index 000000000..611f97fe7
--- /dev/null
+++ b/src/updater.js
@@ -0,0 +1,210 @@
+const { autoUpdater } = require('electron-updater');
+const { ipcMain } = require('electron');
+
+class UpdateManager {
+ constructor() {
+ this.mainWindow = null;
+ this.controlPanelWindow = null;
+ this.updateAvailable = false;
+ this.updateDownloaded = false;
+
+ this.setupAutoUpdater();
+ this.setupIPCHandlers();
+ }
+
+ setWindows(mainWindow, controlPanelWindow) {
+ this.mainWindow = mainWindow;
+ this.controlPanelWindow = controlPanelWindow;
+ }
+
+ setupAutoUpdater() {
+ // Only configure auto-updater in production
+ if (process.env.NODE_ENV === 'development') {
+ console.log('⚠️ Auto-updater disabled in development mode');
+ return;
+ }
+
+ // Configure auto-updater for GitHub releases
+ autoUpdater.setFeedURL({
+ provider: 'github',
+ owner: 'openwispr',
+ repo: 'open-wispr',
+ private: false
+ });
+
+ // Auto-updater logging
+ autoUpdater.logger = console;
+
+ // Set up event handlers
+ this.setupEventHandlers();
+ }
+
+ setupEventHandlers() {
+ autoUpdater.on('checking-for-update', () => {
+ console.log('πŸ” Checking for updates...');
+ });
+
+ autoUpdater.on('update-available', (info) => {
+ console.log('πŸ“₯ Update available:', info);
+ this.updateAvailable = true;
+
+ // Send notification to renderer processes
+ this.notifyRenderers('update-available', info);
+ });
+
+ autoUpdater.on('update-not-available', (info) => {
+ console.log('βœ… Update not available:', info);
+ this.updateAvailable = false;
+
+ // Send notification to renderer processes
+ this.notifyRenderers('update-not-available', info);
+ });
+
+ autoUpdater.on('error', (err) => {
+ console.error('❌ Auto-updater error:', err);
+ this.updateAvailable = false;
+ this.updateDownloaded = false;
+
+ // Send error notification to renderer processes
+ this.notifyRenderers('update-error', err);
+ });
+
+ autoUpdater.on('download-progress', (progressObj) => {
+ let logMessage = `πŸ“Š Download speed: ${progressObj.bytesPerSecond}`;
+ logMessage += ` - Downloaded ${progressObj.percent}%`;
+ logMessage += ` (${progressObj.transferred}/${progressObj.total})`;
+ console.log(logMessage);
+
+ // Send progress to renderer processes
+ this.notifyRenderers('update-download-progress', progressObj);
+ });
+
+ autoUpdater.on('update-downloaded', (info) => {
+ console.log('βœ… Update downloaded:', info);
+ this.updateDownloaded = true;
+
+ // Send notification to renderer processes
+ this.notifyRenderers('update-downloaded', info);
+ });
+ }
+
+ notifyRenderers(channel, data) {
+ if (this.mainWindow && this.mainWindow.webContents) {
+ this.mainWindow.webContents.send(channel, data);
+ }
+ if (this.controlPanelWindow && this.controlPanelWindow.webContents) {
+ this.controlPanelWindow.webContents.send(channel, data);
+ }
+ }
+
+ setupIPCHandlers() {
+ // Check for updates manually
+ ipcMain.handle('check-for-updates', async () => {
+ try {
+ if (process.env.NODE_ENV === 'development') {
+ console.log('⚠️ Update check skipped in development mode');
+ return {
+ updateAvailable: false,
+ message: 'Update checks are disabled in development mode'
+ };
+ }
+
+ console.log('πŸ” Manual update check requested...');
+ const result = await autoUpdater.checkForUpdates();
+
+ if (result && result.updateInfo) {
+ console.log('πŸ“‹ Update check result:', result.updateInfo);
+ return {
+ updateAvailable: true,
+ version: result.updateInfo.version,
+ releaseDate: result.updateInfo.releaseDate,
+ files: result.updateInfo.files,
+ releaseNotes: result.updateInfo.releaseNotes
+ };
+ } else {
+ console.log('βœ… No updates available');
+ return { updateAvailable: false, message: 'You are running the latest version' };
+ }
+ } catch (error) {
+ console.error('❌ Update check error:', error);
+ throw error;
+ }
+ });
+
+ // Download update
+ ipcMain.handle('download-update', async () => {
+ try {
+ if (process.env.NODE_ENV === 'development') {
+ console.log('⚠️ Update download skipped in development mode');
+ return { success: false, message: 'Update downloads are disabled in development mode' };
+ }
+
+ console.log('πŸ“₯ Manual update download requested...');
+ await autoUpdater.downloadUpdate();
+
+ return { success: true, message: 'Update download started' };
+ } catch (error) {
+ console.error('❌ Update download error:', error);
+ throw error;
+ }
+ });
+
+ // Install update
+ ipcMain.handle('install-update', async () => {
+ try {
+ if (process.env.NODE_ENV === 'development') {
+ console.log('⚠️ Update installation skipped in development mode');
+ return { success: false, message: 'Update installation is disabled in development mode' };
+ }
+
+ console.log('πŸ”„ Installing update and restarting...');
+ autoUpdater.quitAndInstall();
+
+ return { success: true, message: 'Update installation started' };
+ } catch (error) {
+ console.error('❌ Update installation error:', error);
+ throw error;
+ }
+ });
+
+ // Get app version
+ ipcMain.handle('get-app-version', async () => {
+ try {
+ const { app } = require('electron');
+ const version = app.getVersion();
+ console.log('πŸ“± App version requested:', version);
+ return { version };
+ } catch (error) {
+ console.error('❌ Error getting app version:', error);
+ throw error;
+ }
+ });
+
+ // Get update status
+ ipcMain.handle('get-update-status', async () => {
+ try {
+ return {
+ updateAvailable: this.updateAvailable,
+ updateDownloaded: this.updateDownloaded,
+ isDevelopment: process.env.NODE_ENV === 'development'
+ };
+ } catch (error) {
+ console.error('❌ Error getting update status:', error);
+ throw error;
+ }
+ });
+ }
+
+ // Method to check for updates on startup
+ checkForUpdatesOnStartup() {
+ if (process.env.NODE_ENV !== 'development') {
+ // Wait a bit for the app to fully initialize
+ setTimeout(() => {
+ console.log('πŸ”„ Checking for updates on startup...');
+ autoUpdater.checkForUpdatesAndNotify();
+ }, 5000);
+ }
+ }
+}
+
+module.exports = UpdateManager;