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
fix(persistence): add file-based hotkey storage for reliable startup (#181)
iBasicTutorialsf0b0fea512fe
diff --git a/preload.js b/preload.jsindex b9ab37d2a..a0d845437 100644--- a/preload.js+++ b/preload.js@@ -7,7 +7,7 @@ const { contextBridge, ipcRenderer } = require("electron");const registerListener = (channel, handlerFactory) => {return (callback) => {if (typeof callback !== "function") {- return () => {};+ return () => { };}const listener =@@ -168,7 +168,7 @@ contextBridge.exposeInMainWorld("electronAPI", {// External link openeropenExternal: (url) => ipcRenderer.invoke("open-external", url),-+// Model management functionsmodelGetAll: () => ipcRenderer.invoke("model-get-all"),modelCheck: (modelId) => ipcRenderer.invoke("model-check", modelId),@@ -178,7 +178,7 @@ contextBridge.exposeInMainWorld("electronAPI", {modelCheckRuntime: () => ipcRenderer.invoke("model-check-runtime"),modelCancelDownload: (modelId) => ipcRenderer.invoke("model-cancel-download", modelId),onModelDownloadProgress: registerListener("model-download-progress"),-+// Anthropic APIgetAnthropicKey: () => ipcRenderer.invoke("get-anthropic-key"),saveAnthropicKey: (key) => ipcRenderer.invoke("save-anthropic-key", key),@@ -197,19 +197,23 @@ contextBridge.exposeInMainWorld("electronAPI", {getCustomReasoningKey: () => ipcRenderer.invoke("get-custom-reasoning-key"),saveCustomReasoningKey: (key) => ipcRenderer.invoke("save-custom-reasoning-key", key),+ // Dictation key persistence (file-based for reliable startup)+ getDictationKey: () => ipcRenderer.invoke("get-dictation-key"),+ saveDictationKey: (key) => ipcRenderer.invoke("save-dictation-key", key),+saveAllKeysToEnv: () => ipcRenderer.invoke("save-all-keys-to-env"),syncStartupPreferences: (prefs) => ipcRenderer.invoke("sync-startup-preferences", prefs),// Local reasoning- processLocalReasoning: (text, modelId, agentName, config) =>+ processLocalReasoning: (text, modelId, agentName, config) =>ipcRenderer.invoke("process-local-reasoning", text, modelId, agentName, config),- checkLocalReasoningAvailable: () =>+ checkLocalReasoningAvailable: () =>ipcRenderer.invoke("check-local-reasoning-available"),-+// Anthropic reasoningprocessAnthropicReasoning: (text, modelId, agentName, config) =>ipcRenderer.invoke("process-anthropic-reasoning", text, modelId, agentName, config),-+// llama.cppllamaCppCheck: () => ipcRenderer.invoke("llama-cpp-check"),llamaCppInstall: () => ipcRenderer.invoke("llama-cpp-install"),diff --git a/src/helpers/environment.js b/src/helpers/environment.jsindex 569271644..be65d3872 100644--- a/src/helpers/environment.js+++ b/src/helpers/environment.js@@ -91,6 +91,18 @@ class EnvironmentManager {return this._saveKey("CUSTOM_REASONING_API_KEY", key);}+ // Hotkey persistence for reliable startup+ getDictationKey() {+ return this._getKey("DICTATION_KEY");+ }++ saveDictationKey(key) {+ const result = this._saveKey("DICTATION_KEY", key);+ // Persist to .env file immediately for reliable startup+ this.saveAllKeysToEnvFile();+ return result;+ }+createProductionEnvFile(apiKey) {const envPath = path.join(app.getPath("userData"), ".env");@@ -147,6 +159,9 @@ OPENAI_API_KEY=${apiKey}if (process.env.LOCAL_REASONING_MODEL) {envContent += `LOCAL_REASONING_MODEL=${process.env.LOCAL_REASONING_MODEL}\n`;}+ if (process.env.DICTATION_KEY) {+ envContent += `DICTATION_KEY=${process.env.DICTATION_KEY}\n`;+ }fs.writeFileSync(envPath, envContent, "utf8");diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.jsindex 712077e58..33c00cf2d 100644--- a/src/helpers/hotkeyManager.js+++ b/src/helpers/hotkeyManager.js@@ -247,9 +247,22 @@ class HotkeyManager {async loadSavedHotkeyOrDefault(mainWindow, callback) {try {- const savedHotkey = await mainWindow.webContents.executeJavaScript(`- localStorage.getItem("dictationKey") || ""- `);+ // First check file-based storage (environment variable) - more reliable+ let savedHotkey = process.env.DICTATION_KEY || "";++ // Fall back to localStorage if env var is empty+ if (!savedHotkey) {+ savedHotkey = await mainWindow.webContents.executeJavaScript(`+ localStorage.getItem("dictationKey") || ""+ `);++ // If we found a hotkey in localStorage but not in env, migrate it+ if (savedHotkey && savedHotkey.trim() !== "") {+ process.env.DICTATION_KEY = savedHotkey;+ debugLogger.log(`[HotkeyManager] Migrated hotkey "${savedHotkey}" from localStorage to env`);+ }+ }+if (savedHotkey && savedHotkey.trim() !== "") {const result = this.setupShortcuts(savedHotkey, callback);if (result.success) {@@ -303,6 +316,21 @@ class HotkeyManager {// Escape the hotkey string to prevent injection issuesconst escapedHotkey = hotkey.replace(/\\/g, "\\\\").replace(/"/g, '\\"');+ // Save to environment variable for file-based persistence (more reliable)+ process.env.DICTATION_KEY = hotkey;++ // Persist to .env file for reliable startup+ try {+ // Lazy require to avoid circular dependencies+ const EnvironmentManager = require("./environment");+ const envManager = new EnvironmentManager();+ envManager.saveAllKeysToEnvFile();+ debugLogger.log(`[HotkeyManager] Saved hotkey "${hotkey}" to .env file`);+ } catch (err) {+ debugLogger.warn("[HotkeyManager] Failed to persist hotkey to .env file:", err.message);+ }++ // Also save to localStorage for backwards compatibilityif (this.mainWindow && !this.mainWindow.isDestroyed()) {try {await this.mainWindow.webContents.executeJavaScript(@@ -315,7 +343,7 @@ class HotkeyManager {return false;}} else {- debugLogger.warn("[HotkeyManager] Main window not available for saving hotkey");+ debugLogger.warn("[HotkeyManager] Main window not available for saving hotkey to localStorage");return false;}}diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex f7ce0f515..8f5045a99 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -689,6 +689,15 @@ class IPCHandlers {return this.environmentManager.saveCustomReasoningKey(key);});+ // Dictation key handlers for reliable persistence across restarts+ ipcMain.handle("get-dictation-key", async () => {+ return this.environmentManager.getDictationKey();+ });++ ipcMain.handle("save-dictation-key", async (event, key) => {+ return this.environmentManager.saveDictationKey(key);+ });+ipcMain.handle("save-anthropic-key", async (event, key) => {return this.environmentManager.saveAnthropicKey(key);});@@ -789,8 +798,8 @@ class IPCHandlers {}throw new Error(errorData.error?.message ||- errorData.error ||- `Anthropic API error: ${response.status}`+ errorData.error ||+ `Anthropic API error: ${response.status}`);}diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.tsindex 71ca15b38..efe8cb09b 100644--- a/src/hooks/useSettings.ts+++ b/src/hooks/useSettings.ts@@ -372,6 +372,7 @@ export function useSettings() {});// Wrap setDictationKey to notify main process (for Windows Push-to-Talk)+ // and persist to file-based storage for reliable startupconst setDictationKey = useCallback((key: string) => {setDictationKeyLocal(key);@@ -379,6 +380,10 @@ export function useSettings() {if (typeof window !== "undefined" && window.electronAPI?.notifyHotkeyChanged) {window.electronAPI.notifyHotkeyChanged(key);}+ // Also save to file-based storage for reliable persistence across restarts+ if (typeof window !== "undefined" && window.electronAPI?.saveDictationKey) {+ window.electronAPI.saveDictationKey(key);+ }},[setDictationKeyLocal]);diff --git a/src/types/electron.ts b/src/types/electron.tsindex 0288e8d13..085f244f3 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -356,6 +356,16 @@ declare global {getGroqKey: () => Promise<string | null>;saveGroqKey: (key: string) => Promise<void>;+ // Custom endpoint API keys+ getCustomTranscriptionKey?: () => Promise<string | null>;+ saveCustomTranscriptionKey?: (key: string) => Promise<void>;+ getCustomReasoningKey?: () => Promise<string | null>;+ saveCustomReasoningKey?: (key: string) => Promise<void>;++ // Dictation key persistence (file-based for reliable startup)+ getDictationKey?: () => Promise<string | null>;+ saveDictationKey?: (key: string) => Promise<void>;+// Debug logginggetLogLevel?: () => Promise<string>;log?: (entry: {