Skip to content

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

Fix auto-update bugs and add update notification overlay

Gabriel Stein50346296d1bb
diff --git a/main.js b/main.js
index 442029b34..2b9e6c614 100644
--- a/main.js
+++ b/main.js
@@ -279,6 +279,7 @@ function initializeCoreManagers() {
);
windowManager.meetingDetectionEngine = meetingDetectionEngine;
updateManager = new UpdateManager();
+ updateManager.setWindowManager(windowManager);
windowsKeyManager = new WindowsKeyManager();
textEditMonitor = new TextEditMonitor();
windowManager.textEditMonitor = textEditMonitor;
diff --git a/preload.js b/preload.js
index 5575aec20..ff277146f 100644
--- a/preload.js
+++ b/preload.js
@@ -659,4 +659,13 @@ contextBridge.exposeInMainWorld("electronAPI", {
"navigate-to-meeting-note",
(callback) => (_event, data) => callback(data)
),
+
+ onUpdateNotificationData: registerListener(
+ "update-notification-data",
+ (callback) => (_event, data) => callback(data)
+ ),
+ getUpdateNotificationData: () => ipcRenderer.invoke("get-update-notification-data"),
+ updateNotificationReady: () => ipcRenderer.invoke("update-notification-ready"),
+ updateNotificationRespond: (action) =>
+ ipcRenderer.invoke("update-notification-respond", action),
});
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index 7825b70c5..f4562626c 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -65,6 +65,8 @@ export default function ControlPanel() {
() => localStorage.getItem("gpuBannerDismissedUnified") === "true"
);
const cloudMigrationProcessed = useRef(false);
+ const updateReadyToastShown = useRef(false);
+ const updateErrorToastShown = useRef<Error | null>(null);
const { hotkey } = useHotkey();
const { toast } = useToast();
const {
@@ -114,22 +116,31 @@ export default function ControlPanel() {
useEffect(() => {
if (updateStatus.updateDownloaded && !isDownloading) {
- toast({
- title: t("controlPanel.update.readyTitle"),
- description: t("controlPanel.update.readyDescription"),
- variant: "success",
- });
+ if (!updateReadyToastShown.current) {
+ updateReadyToastShown.current = true;
+ toast({
+ title: t("controlPanel.update.readyTitle"),
+ description: t("controlPanel.update.readyDescription"),
+ variant: "success",
+ });
+ }
+ } else {
+ updateReadyToastShown.current = false;
}
}, [updateStatus.updateDownloaded, isDownloading, toast, t]);
useEffect(() => {
- if (updateError) {
+ if (updateError && updateError !== updateErrorToastShown.current) {
+ updateErrorToastShown.current = updateError;
toast({
title: t("controlPanel.update.problemTitle"),
description: t("controlPanel.update.problemDescription"),
variant: "destructive",
});
}
+ if (!updateError) {
+ updateErrorToastShown.current = null;
+ }
}, [updateError, toast, t]);
useEffect(() => {
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 1074b4465..fbb400489 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -3382,7 +3382,15 @@ EOF`,
<Button
onClick={async () => {
try {
- await checkForUpdates();
+ const result = await checkForUpdates();
+ if (result && !result.updateAvailable) {
+ toast({
+ title: t("settingsPage.general.updates.dialogs.noUpdates.title"),
+ description: t(
+ "settingsPage.general.updates.dialogs.noUpdates.description"
+ ),
+ });
+ }
} catch {}
}}
disabled={checkingForUpdates || updateStatus.isDevelopment}
diff --git a/src/components/UpdateNotificationOverlay.tsx b/src/components/UpdateNotificationOverlay.tsx
new file mode 100644
index 000000000..49c2221b2
--- /dev/null
+++ b/src/components/UpdateNotificationOverlay.tsx
@@ -0,0 +1,102 @@
+import { useState, useEffect, useCallback } from "react";
+import { useTranslation } from "react-i18next";
+import { X } from "lucide-react";
+
+interface UpdateNotificationData {
+ version: string;
+ releaseDate?: string;
+}
+
+export default function UpdateNotificationOverlay() {
+ const { t } = useTranslation();
+ const [data, setData] = useState<UpdateNotificationData | null>(null);
+ const [isVisible, setIsVisible] = useState(false);
+
+ useEffect(() => {
+ let shown = false;
+
+ const show = (d: UpdateNotificationData) => {
+ if (shown) return;
+ shown = true;
+ setData(d);
+ setTimeout(() => {
+ setIsVisible(true);
+ window.electronAPI?.updateNotificationReady?.();
+ }, 50);
+ };
+
+ const cleanup = window.electronAPI?.onUpdateNotificationData?.((incoming: UpdateNotificationData) =>
+ show(incoming)
+ );
+
+ window.electronAPI?.getUpdateNotificationData?.().then((pulled: UpdateNotificationData | null) => {
+ if (pulled) show(pulled);
+ });
+
+ return () => cleanup?.();
+ }, []);
+
+ const respond = useCallback(
+ async (action: string) => {
+ if (!data) return;
+ setIsVisible(false);
+ await new Promise((r) => setTimeout(r, 200));
+ window.electronAPI?.updateNotificationRespond?.(action);
+ },
+ [data]
+ );
+
+ return (
+ <div className="w-full h-full bg-transparent p-2">
+ <div
+ className={[
+ "bg-card/95 dark:bg-surface-2/95 backdrop-blur-xl",
+ "border border-border/40 dark:border-border-subtle/40",
+ "rounded-xl shadow-lg p-2.5",
+ "transition-all duration-300 ease-out",
+ isVisible
+ ? "translate-x-0 opacity-100 scale-100"
+ : "translate-x-[120%] opacity-0 scale-95",
+ ].join(" ")}
+ >
+ <div className="flex items-center gap-2.5">
+ <div className="shrink-0 bg-primary/10 rounded-md p-1">
+ <svg viewBox="0 0 20 20" className="w-4.5 h-4.5 text-primary" fill="none">
+ <path
+ d="M10 2a1 1 0 011 1v6.586l2.707-2.707a1 1 0 111.414 1.414l-4.414 4.414a1 1 0 01-1.414 0L4.879 8.293a1 1 0 011.414-1.414L9 9.586V3a1 1 0 011-1z"
+ fill="currentColor"
+ />
+ <path
+ d="M4 13a1 1 0 011 1v1a1 1 0 001 1h8a1 1 0 001-1v-1a1 1 0 112 0v1a3 3 0 01-3 3H6a3 3 0 01-3-3v-1a1 1 0 011-1z"
+ fill="currentColor"
+ />
+ </svg>
+ </div>
+
+ <div className="flex-1 min-w-0">
+ <p className="text-[12px] font-semibold text-foreground leading-tight truncate">
+ {t("updateNotification.title")}
+ </p>
+ <p className="text-[11px] text-muted-foreground leading-tight mt-0.5">
+ {t("updateNotification.body", { version: data?.version ?? "" })}
+ </p>
+ </div>
+
+ <button
+ onClick={() => respond("update")}
+ className="shrink-0 bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80 text-[11px] font-medium px-2.5 py-1 rounded-md transition-colors"
+ >
+ {t("updateNotification.cta")}
+ </button>
+
+ <button
+ onClick={() => respond("dismiss")}
+ className="shrink-0 text-muted-foreground/60 hover:text-foreground transition-colors p-0.5"
+ >
+ <X className="w-3.5 h-3.5" />
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index d7adf6364..330af02de 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -4021,6 +4021,26 @@ class IPCHandlers {
this.windowManager?.showNotificationWindow();
});
+ ipcMain.handle("get-update-notification-data", async () => {
+ return this.windowManager?._pendingUpdateNotificationData ?? null;
+ });
+
+ ipcMain.handle("update-notification-ready", async () => {
+ this.windowManager?.showUpdateNotificationWindow();
+ });
+
+ ipcMain.handle("update-notification-respond", async (_event, action) => {
+ this.windowManager?.dismissUpdateNotification();
+ if (action === "update") {
+ try {
+ await this.updateManager?.downloadUpdate();
+ } catch (error) {
+ console.error("Failed to start update download from notification:", error);
+ }
+ }
+ return { success: true };
+ });
+
ipcMain.handle("get-desktop-sources", async (_event, types) => {
try {
const { desktopCapturer } = require("electron");
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index f46294248..8d3f64946 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -23,6 +23,8 @@ class WindowManager {
this.agentWindow = null;
this.notificationWindow = null;
this._notificationTimeout = null;
+ this.updateNotificationWindow = null;
+ this._updateNotificationDismissed = false;
this.tray = null;
this.hotkeyManager = new HotkeyManager();
this.dragManager = new DragManager();
@@ -1052,6 +1054,79 @@ class WindowManager {
this.notificationWindow = null;
}
+ async showUpdateNotification(info) {
+ if (this._updateNotificationDismissed) return;
+ if (this.updateNotificationWindow && !this.updateNotificationWindow.isDestroyed()) {
+ this.updateNotificationWindow.close();
+ this.updateNotificationWindow = null;
+ }
+
+ const display = screen.getPrimaryDisplay();
+ const position = WindowPositionUtil.getNotificationPosition(display);
+
+ this.updateNotificationWindow = new BrowserWindow({
+ ...NOTIFICATION_WINDOW_CONFIG,
+ ...position,
+ });
+
+ WindowPositionUtil.setupAlwaysOnTop(this.updateNotificationWindow);
+
+ if (process.env.NODE_ENV === "development") {
+ await DevServerManager.waitForDevServer();
+ await this.updateNotificationWindow.loadURL(
+ `${DevServerManager.DEV_SERVER_URL}?update-notification=true`
+ );
+ } else {
+ const fileInfo = DevServerManager.getAppFilePath(false);
+ await this.updateNotificationWindow.loadFile(fileInfo.path, {
+ query: { ...fileInfo.query, "update-notification": "true" },
+ });
+ }
+
+ this._pendingUpdateNotificationData = {
+ version: info?.version,
+ releaseDate: info?.releaseDate,
+ };
+
+ this._updateNotificationReadyFallback = setTimeout(() => {
+ this._updateNotificationReadyFallback = null;
+ if (this.updateNotificationWindow && !this.updateNotificationWindow.isDestroyed()) {
+ this.updateNotificationWindow.webContents.send(
+ "update-notification-data",
+ this._pendingUpdateNotificationData
+ );
+ this.updateNotificationWindow.showInactive();
+ }
+ }, 3000);
+
+ this.updateNotificationWindow.on("closed", () => {
+ this.updateNotificationWindow = null;
+ });
+ }
+
+ showUpdateNotificationWindow() {
+ if (this._updateNotificationReadyFallback) {
+ clearTimeout(this._updateNotificationReadyFallback);
+ this._updateNotificationReadyFallback = null;
+ }
+ if (this.updateNotificationWindow && !this.updateNotificationWindow.isDestroyed()) {
+ this.updateNotificationWindow.showInactive();
+ }
+ }
+
+ dismissUpdateNotification() {
+ this._pendingUpdateNotificationData = null;
+ this._updateNotificationDismissed = true;
+ if (this._updateNotificationReadyFallback) {
+ clearTimeout(this._updateNotificationReadyFallback);
+ this._updateNotificationReadyFallback = null;
+ }
+ if (this.updateNotificationWindow && !this.updateNotificationWindow.isDestroyed()) {
+ this.updateNotificationWindow.close();
+ }
+ this.updateNotificationWindow = null;
+ }
+
sendToControlPanel(channel, data) {
const win = this.controlPanelWindow;
if (!win || win.isDestroyed()) return;
diff --git a/src/hooks/useUpdater.ts b/src/hooks/useUpdater.ts
index 4139a3864..be3ca94b8 100644
--- a/src/hooks/useUpdater.ts
+++ b/src/hooks/useUpdater.ts
@@ -1,11 +1,5 @@
import { useState, useEffect, useCallback, useRef } from "react";
-/**
- * Centralized hook for managing app updates.
- * Prevents EventEmitter memory leaks by ensuring update listeners
- * are only registered once globally using a singleton pattern.
- */
-
interface UpdateStatus {
updateAvailable: boolean;
updateDownloaded: boolean;
@@ -19,12 +13,6 @@ interface UpdateInfo {
files?: any[];
}
-interface UpdateProgress {
- percent: number;
- transferred: number;
- total: number;
-}
-
interface UpdateState {
status: UpdateStatus;
info: UpdateInfo | null;
@@ -35,7 +23,6 @@ interface UpdateState {
error: Error | null;
}
-// Global state shared across all hook instances
let globalState: UpdateState = {
status: {
updateAvailable: false,
@@ -50,31 +37,19 @@ let globalState: UpdateState = {
error: null,
};
-// Listeners registry for global state updates
const stateListeners = new Set<(state: UpdateState) => void>();
-
-// Flag to track if event listeners have been registered
let listenersRegistered = false;
const cleanupFunctions: Array<() => void> = [];
-/**
- * Notify all hook instances of state changes
- */
function notifyListeners() {
stateListeners.forEach((listener) => listener({ ...globalState }));
}
-/**
- * Update global state and notify all listeners
- */
function updateGlobalState(updates: Partial<UpdateState>) {
globalState = { ...globalState, ...updates };
notifyListeners();
}
-/**
- * Register IPC event listeners (only once globally)
- */
function registerEventListeners() {
if (listenersRegistered || !window.electronAPI) {
return;
@@ -82,7 +57,6 @@ function registerEventListeners() {
listenersRegistered = true;
- // Update available
if (window.electronAPI.onUpdateAvailable) {
const dispose = window.electronAPI.onUpdateAvailable((_event, info) => {
updateGlobalState({
@@ -93,23 +67,23 @@ function registerEventListeners() {
if (dispose) cleanupFunctions.push(dispose);
}
- // Update not available
if (window.electronAPI.onUpdateNotAvailable) {
const dispose = window.electronAPI.onUpdateNotAvailable(() => {
+ // Preserve downloaded state — don't nuke a pending install
+ const keepDownloaded = globalState.status.updateDownloaded;
updateGlobalState({
status: {
...globalState.status,
updateAvailable: false,
- updateDownloaded: false,
+ updateDownloaded: keepDownloaded,
},
- info: null,
+ info: keepDownloaded ? globalState.info : null,
isChecking: false,
});
});
if (dispose) cleanupFunctions.push(dispose);
}
- // Update downloaded
if (window.electronAPI.onUpdateDownloaded) {
const dispose = window.electronAPI.onUpdateDownloaded((_event, info) => {
updateGlobalState({
@@ -123,7 +97,6 @@ function registerEventListeners() {
if (dispose) cleanupFunctions.push(dispose);
}
- // Download progress
if (window.electronAPI.onUpdateDownloadProgress) {
const dispose = window.electronAPI.onUpdateDownloadProgress((_event, progressObj) => {
updateGlobalState({
@@ -134,7 +107,6 @@ function registerEventListeners() {
if (dispose) cleanupFunctions.push(dispose);
}
- // Update error
if (window.electronAPI.onUpdateError) {
const dispose = window.electronAPI.onUpdateError((_event, error) => {
updateGlobalState({
@@ -148,9 +120,6 @@ function registerEventListeners() {
}
}
-/**
- * Cleanup function (called when last hook instance unmounts)
- */
function cleanup() {
if (stateListeners.size === 0 && listenersRegistered) {
cleanupFunctions.forEach((fn) => fn());
@@ -159,28 +128,14 @@ function cleanup() {
}
}
-/**
- * Custom hook for app update management
- *
- * Features:
- * - Singleton pattern prevents duplicate event listeners
- * - Shared state across all component instances
- * - Automatic cleanup when no components are using it
- *
- * @returns Update state and control functions
- */
export function useUpdater() {
const [state, setState] = useState<UpdateState>(globalState);
const isInstallingRef = useRef(false);
useEffect(() => {
- // Register this component as a state listener
stateListeners.add(setState);
-
- // Register global event listeners (only once)
registerEventListeners();
- // Initialize update status from main process
const initializeUpdateStatus = async () => {
try {
if (window.electronAPI?.getUpdateStatus) {
@@ -201,16 +156,12 @@ export function useUpdater() {
initializeUpdateStatus();
- // Cleanup on unmount
return () => {
stateListeners.delete(setState);
cleanup();
};
}, []);
- /**
- * Check for updates manually
- */
const checkForUpdates = useCallback(async () => {
updateGlobalState({ isChecking: true, error: null });
try {
@@ -226,9 +177,6 @@ export function useUpdater() {
}
}, []);
- /**
- * Download the available update
- */
const downloadUpdate = useCallback(async () => {
if (state.status.updateDownloaded) {
return { success: true, message: "Update already downloaded" };
@@ -247,9 +195,6 @@ export function useUpdater() {
}
}, [state.status.updateDownloaded]);
- /**
- * Install the downloaded update and restart the app
- */
const installUpdate = useCallback(async () => {
if (!state.status.updateDownloaded) {
throw new Error("No update available to install");
@@ -261,11 +206,15 @@ export function useUpdater() {
try {
await window.electronAPI.installUpdate();
- // Set a timeout to reset state if app doesn't quit
setTimeout(() => {
if (isInstallingRef.current) {
isInstallingRef.current = false;
- updateGlobalState({ isInstalling: false });
+ updateGlobalState({
+ isInstalling: false,
+ error: new Error(
+ "Install timed out. Please restart the app manually to apply the update."
+ ),
+ });
}
}, 10000);
} catch (error) {
@@ -278,9 +227,6 @@ export function useUpdater() {
}
}, [state.status.updateDownloaded]);
- /**
- * Get the current app version
- */
const getAppVersion = useCallback(async () => {
try {
const result = await window.electronAPI.getAppVersion();
@@ -292,7 +238,6 @@ export function useUpdater() {
}, []);
return {
- // State
status: state.status,
info: state.info,
downloadProgress: state.downloadProgress,
@@ -300,8 +245,6 @@ export function useUpdater() {
isDownloading: state.isDownloading,
isInstalling: state.isInstalling,
error: state.error,
-
- // Actions
checkForUpdates,
downloadUpdate,
installUpdate,
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index f737682f2..21e1c0b0e 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1943,5 +1943,10 @@
"open": "Öffnen",
"dismiss": "Schließen"
}
+ },
+ "updateNotification": {
+ "title": "Update verfügbar",
+ "body": "Version {{version}} ist bereit",
+ "cta": "Jetzt aktualisieren"
}
}
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index e18649dd2..045812132 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1982,5 +1982,10 @@
"open": "Open",
"dismiss": "Dismiss"
}
+ },
+ "updateNotification": {
+ "title": "Update Available",
+ "body": "Version {{version}} is ready",
+ "cta": "Update Now"
}
}
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 272560202..d4e12292a 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1943,5 +1943,10 @@
"open": "Abrir",
"dismiss": "Cerrar"
}
+ },
+ "updateNotification": {
+ "title": "Actualización disponible",
+ "body": "La versión {{version}} está lista",
+ "cta": "Actualizar ahora"
}
}
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 9ddd4e6fb..b12b069ff 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1943,5 +1943,10 @@
"open": "Ouvrir",
"dismiss": "Fermer"
}
+ },
+ "updateNotification": {
+ "title": "Mise à jour disponible",
+ "body": "La version {{version}} est prête",
+ "cta": "Mettre à jour"
}
}
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 107aaa675..23e85d43e 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1943,5 +1943,10 @@
"open": "Apri",
"dismiss": "Chiudi"
}
+ },
+ "updateNotification": {
+ "title": "Aggiornamento disponibile",
+ "body": "La versione {{version}} è pronta",
+ "cta": "Aggiorna ora"
}
}
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index c75fa6c78..b3c93479f 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1943,5 +1943,10 @@
"open": "開く",
"dismiss": "閉じる"
}
+ },
+ "updateNotification": {
+ "title": "アップデートあり",
+ "body": "バージョン {{version}} が利用可能です",
+ "cta": "今すぐ更新"
}
}
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 2fdece6cf..b720afd74 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1943,5 +1943,10 @@
"open": "Abrir",
"dismiss": "Fechar"
}
+ },
+ "updateNotification": {
+ "title": "Atualização disponível",
+ "body": "A versão {{version}} está pronta",
+ "cta": "Atualizar agora"
}
}
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index fc14875ec..235810aa0 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1943,5 +1943,10 @@
"open": "Открыть",
"dismiss": "Закрыть"
}
+ },
+ "updateNotification": {
+ "title": "Доступно обновление",
+ "body": "Версия {{version}} готова",
+ "cta": "Обновить"
}
}
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index f11cef94b..3495ff9d5 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1943,5 +1943,10 @@
"open": "打开",
"dismiss": "关闭"
}
+ },
+ "updateNotification": {
+ "title": "有可用更新",
+ "body": "版本 {{version}} 已就绪",
+ "cta": "立即更新"
}
}
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 8353a2505..f08e09c7d 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1943,5 +1943,10 @@
"open": "開啟",
"dismiss": "關閉"
}
+ },
+ "updateNotification": {
+ "title": "有可用更新",
+ "body": "版本 {{version}} 已就緒",
+ "cta": "立即更新"
}
}
diff --git a/src/main.jsx b/src/main.jsx
index 777fa35d1..3e4365a98 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -20,6 +20,7 @@ const ControlPanel = React.lazy(controlPanelImport);
const OnboardingFlow = React.lazy(onboardingFlowImport);
const AgentOverlay = React.lazy(agentOverlayImport);
import MeetingNotificationOverlay from "./components/MeetingNotificationOverlay.tsx";
+import UpdateNotificationOverlay from "./components/UpdateNotificationOverlay.tsx";
let root = null;
@@ -273,12 +274,16 @@ if (!isOAuthBrowserRedirect()) {
function AppRouter() {
useTheme();
- const isMeetingNotification = window.location.search.includes("meeting-notification=true");
+ const params = window.location.search;
- if (isMeetingNotification) {
+ if (params.includes("meeting-notification=true")) {
return <MeetingNotificationOverlay />;
}
+ if (params.includes("update-notification=true")) {
+ return <UpdateNotificationOverlay />;
+ }
+
return <MainApp />;
}
diff --git a/src/updater.js b/src/updater.js
index 3f787e65e..409c9a161 100644
--- a/src/updater.js
+++ b/src/updater.js
@@ -11,6 +11,8 @@ class UpdateManager {
this.isDownloading = false;
this.eventListeners = [];
this.updateCheckInterval = null;
+ this.windowManager = null;
+ this._suppressNotification = false;
this.setupAutoUpdater();
}
@@ -20,14 +22,15 @@ class UpdateManager {
this.controlPanelWindow = controlPanelWindow;
}
+ setWindowManager(windowManager) {
+ this.windowManager = windowManager;
+ }
+
setupAutoUpdater() {
- // Only configure auto-updater in production
if (process.env.NODE_ENV === "development") {
- // Auto-updater disabled in development mode
return;
}
- // Configure auto-updater for GitHub releases
autoUpdater.setFeedURL({
provider: "github",
owner: "OpenWhispr",
@@ -65,18 +68,10 @@ class UpdateManager {
autoUpdater.channel = nativeArch === "arm64" ? "latest-arm64" : "latest-x64";
}
- // Disable auto-download - let user control when to download
autoUpdater.autoDownload = false;
-
- // Enable auto-install on quit - if user ignores update and quits normally,
- // the update will install automatically (best UX)
- // User can also manually trigger install with "Install & Restart" button
autoUpdater.autoInstallOnAppQuit = true;
-
- // Enable logging in production for debugging (logs are user-accessible)
autoUpdater.logger = console;
- // Set up event handlers
this.setupEventHandlers();
}
@@ -96,16 +91,25 @@ class UpdateManager {
};
}
this.notifyRenderers("update-available", info);
+ if (this.windowManager && info && !this._suppressNotification) {
+ this.windowManager.showUpdateNotification(info).catch((err) => {
+ console.error("Failed to show update notification:", err);
+ });
+ }
+ this._suppressNotification = false;
},
"update-not-available": (info) => {
this.updateAvailable = false;
- this.updateDownloaded = false;
- this.isDownloading = false;
- this.lastUpdateInfo = null;
+ this._suppressNotification = false;
+ if (!this.updateDownloaded) {
+ this.isDownloading = false;
+ this.lastUpdateInfo = null;
+ }
this.notifyRenderers("update-not-available", info);
},
error: (err) => {
console.error("❌ Auto-updater error:", err);
+ this._suppressNotification = false;
this.isDownloading = false;
this.notifyRenderers("update-error", err);
},
@@ -131,7 +135,6 @@ class UpdateManager {
},
};
- // Register and track event listeners for cleanup
Object.entries(handlers).forEach(([event, handler]) => {
autoUpdater.on(event, handler);
this.eventListeners.push({ event, handler });
@@ -161,14 +164,11 @@ class UpdateManager {
}
console.log("🔍 Checking for updates...");
+ this._suppressNotification = true;
const result = await autoUpdater.checkForUpdates();
if (result?.isUpdateAvailable && result?.updateInfo) {
console.log("📋 Update available:", result.updateInfo.version);
- console.log(
- "📦 Download size:",
- result.updateInfo.files?.map((f) => `${(f.size / 1024 / 1024).toFixed(2)}MB`).join(", ")
- );
return {
updateAvailable: true,
version: result.updateInfo.version,
@@ -253,8 +253,8 @@ class UpdateManager {
const { app, BrowserWindow } = require("electron");
- // Remove listeners that prevent windows from closing
- // so quitAndInstall can shut down cleanly
+ // Set windowManager.isQuitting before removing close listeners
+ app.emit("before-quit");
app.removeAllListeners("window-all-closed");
BrowserWindow.getAllWindows().forEach((win) => {
win.removeAllListeners("close");