Skip to content

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

fix: prevent Windows hotkey listener state corruption on hotkey switch (#364)

Gabriel Stein24e4f9929308
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index f85b8437a..d7adf6364 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -1334,10 +1334,14 @@ class IPCHandlers {
const needsListener =
effectiveHotkey &&
!isGlobeLikeHotkey(effectiveHotkey) &&
- (activationMode === "push" || isModifierOnlyHotkey(effectiveHotkey));
+ (activationMode === "push" ||
+ isModifierOnlyHotkey(effectiveHotkey) ||
+ isRightSideModifier(effectiveHotkey));
if (needsListener) {
debugLogger.log(`[IPC] Restarting Windows key listener for hotkey: ${effectiveHotkey}`);
this.windowsKeyManager.start(effectiveHotkey);
+ } else {
+ this.windowsKeyManager.stop();
}
}
diff --git a/src/helpers/windowsKeyManager.js b/src/helpers/windowsKeyManager.js
index f0be1d6b8..4528cab3f 100644
--- a/src/helpers/windowsKeyManager.js
+++ b/src/helpers/windowsKeyManager.js
@@ -98,19 +98,24 @@ class WindowsKeyManager extends EventEmitter {
}
});
- this.process.on("error", (error) => {
+ const proc = this.process;
+
+ proc.on("error", (error) => {
+ if (this.process === proc) this.process = null;
this.reportError(error);
- this.process = null;
});
- this.process.on("exit", (code, signal) => {
- this.process = null;
- this.isReady = false;
+ proc.on("exit", (code, signal) => {
+ if (this.process === proc) {
+ this.process = null;
+ this.isReady = false;
+ }
if (code !== 0) {
- const error = new Error(
- `Windows key listener exited with code ${code ?? "null"} signal ${signal ?? "null"}`
+ this.reportError(
+ new Error(
+ `Windows key listener exited with code ${code ?? "null"} signal ${signal ?? "null"}`
+ )
);
- this.reportError(error);
}
});
}