Skip to content

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

refactor: tighten comments and fix incorrect flag 0x02 claim

Haz2273f044b420
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index d8b19abee..9670969d3 100644
--- a/src/helpers/hotkeyManager.js
+++ b/src/helpers/hotkeyManager.js
@@ -909,9 +909,7 @@ class HotkeyManager {
if (success) {
this.currentHotkey = fallback;
debugLogger.log(`[HotkeyManager] ${backend} fallback hotkey "${fallback}" registered successfully`);
- // Only persist to .env (for loadSavedHotkeyOrDefault fallback path).
- // Do NOT update localStorage — it holds the user's preferred hotkey so the
- // app retries it on next startup once the conflict is resolved.
+ // Persist to .env only, not localStorage (preserves user's preferred key for retry on next launch).
await this._persistHotkeyToEnvFile(fallback);
this.notifyActiveHotkey(fallback);
this.notifyHotkeyFallback(hotkey, fallback);
diff --git a/src/helpers/kdeShortcut.js b/src/helpers/kdeShortcut.js
index 97412ab7c..2b4f09cf3 100644
--- a/src/helpers/kdeShortcut.js
+++ b/src/helpers/kdeShortcut.js
@@ -233,9 +233,8 @@ class KDEShortcutManager {
const actionId = [COMPONENT_NAME, slotName, "OpenWhispr", `OpenWhispr ${slotName}`];
try {
- // Pre-registration conflict check: query if another component already owns this key.
- // We use a low-level D-Bus call because dbus-next proxy can't marshal the 'ai'
- // signature correctly (it receives a number instead of an array).
+ // Pre-registration conflict check via low-level D-Bus call
+ // (dbus-next proxy can't marshal the 'ai' signature correctly).
try {
const dbusModule = getDBus();
const msg = new dbusModule.Message({
@@ -266,17 +265,14 @@ class KDEShortcutManager {
debugLogger.log("[KDEShortcut] Could not check for conflicts, proceeding:", checkErr.message);
}
- // Clear any stale registration first, then register with flag 0x02.
- // Flag 0x02 (SetPresent) is required for globalShortcutPressed signal delivery.
- // Flag 0 breaks signal delivery (shortcut registers but never fires).
- // Stale values are handled by the explicit unRegister before doRegister.
+ // Clear stale registration, then register with flag 0x02 (SetPresent).
+ // Flag 0x02 overwrites any saved binding; flag 0 preserves stale values.
try { await this.kglobalaccel.unRegister(actionId); } catch {}
await this.kglobalaccel.doRegister(actionId);
const result = await this.kglobalaccel.setShortcut(actionId, [qtKey], 0x02);
- // Post-registration conflict check: setShortcut returns the actual key
- // sequence assigned. If it differs from what we requested (e.g. returns [0]
- // or empty), the key is owned by another component.
+ // Post-registration conflict check: if setShortcut assigned a different key,
+ // another component owns it.
const assignedKey = Array.isArray(result) && result.length > 0 ? result[0] : null;
if (assignedKey !== null && assignedKey !== qtKey) {
debugLogger.log("[KDEShortcut] Shortcut conflict — setShortcut assigned different key", {
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index 46c3c9298..e68df80d3 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -729,10 +729,8 @@ export async function initializeSettings(): Promise<void> {
);
}
- // Show the active hotkey in UI (may differ from preferred if fallback is active).
- // Updates zustand only, NOT localStorage, so the preference is preserved.
- // The active key may not be set yet during early startup (hotkey registers after
- // 1s delay), but will be available when Control Panel opens from the tray later.
+ // Show the active hotkey in UI (zustand only, not localStorage).
+ // May return constructor default during early startup; corrected by dictation-key-active event later.
try {
const activeKey = await window.electronAPI?.getActiveDictationKey?.();
if (activeKey) {
@@ -740,7 +738,6 @@ export async function initializeSettings(): Promise<void> {
}
} catch {}
-
// Sync agent key from main process
try {
const envKey = await window.electronAPI.getAgentKey?.();
@@ -873,8 +870,7 @@ export async function initializeSettings(): Promise<void> {
}
});
- // Active hotkey updates from backend fallback — update UI display only, not localStorage.
- // localStorage keeps the user's preferred hotkey so the app retries it on next startup.
+ // Active hotkey updates from backend — zustand only, not localStorage.
window.electronAPI?.onDictationKeyActive?.((key: string) => {
useSettingsStore.setState({ dictationKey: key });
});