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
feat(hotkeys): record hotkey presses and releases in the debug log (#2886)
Aditya kumar singhcf4aa8a11477
diff --git a/CLAUDE.md b/CLAUDE.mdindex 0217427f6..6a9cf2719 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -89,6 +89,7 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.- Integrates with GnomeShortcutManager for GNOME Wayland support- Integrates with HyprlandShortcutManager for Hyprland Wayland support- Integrates with KDEShortcutManager for KDE Wayland support+ - Each press and release of a bound hotkey writes a debug-level `Hotkey event` line (`logHotkeyEvent`: source, action, key, owning slots, activation mode; key names only). Unbound keys and hotkey capture are skipped, since the macOS listener reports every right modifier and side mouse button. Every `globalShortcut` registration goes through `registerGlobalShortcut`, which logs a held key once and leaves keys the Windows/Linux listener watches to that listener; GNOME, KDE and Hyprland report through their `onHotkeyEvent` hook, and `handleMacPushModifierUp` logs the release of a macOS compound hold- **gnomeShortcut.js**: GNOME Wayland global shortcut integration- Uses D-Bus service to receive hotkey toggle commands- Registers shortcuts via gsettings (visible in GNOME Settings → Keyboard → Shortcuts)diff --git a/main.js b/main.jsindex 8d6ab4ec1..a17f4d9a3 100644--- a/main.js+++ b/main.js@@ -1646,6 +1646,7 @@ async function startApp() {let rightModActiveKey = null;globeKeyManager.on("right-modifier-down", async (modifier) => {+ hotkeyManager.logHotkeyEvent("macos-native", "down", modifier);// Check voice agent slot for right-modifierif (hotkeyManager.slotHasHotkey("voiceAgent", modifier)) {windowManager.sendToggleVoiceAgent();@@ -1682,6 +1683,7 @@ async function startApp() {});globeKeyManager.on("right-modifier-up", async (modifier) => {+ hotkeyManager.logHotkeyEvent("macos-native", "up", modifier);if (hotkeyManager.slotHasHotkey("dictation", modifier)) {if (!isLiveWindow(windowManager.mainWindow)) return;@@ -1734,6 +1736,7 @@ async function startApp() {globeKeyManager.on("mouse-button-down", async (button) => {if (hotkeyManager.isInListeningMode && hotkeyManager.isInListeningMode()) return;if (!isMouseButtonHotkey(button)) return;+ hotkeyManager.logHotkeyEvent("macos-native", "down", button);if (hotkeyManager.slotHasHotkey("voiceAgent", button)) {windowManager.sendToggleVoiceAgent();@@ -1773,6 +1776,7 @@ async function startApp() {globeKeyManager.on("mouse-button-up", async (button) => {if (hotkeyManager.isInListeningMode && hotkeyManager.isInListeningMode()) return;if (!isMouseButtonHotkey(button)) return;+ hotkeyManager.logHotkeyEvent("macos-native", "up", button);if (!hotkeyManager.slotHasHotkey("dictation", button)) return;if (!isLiveWindow(windowManager.mainWindow)) return;@@ -1877,6 +1881,7 @@ async function startApp() {// Dictation supports push-to-talk and needs the overlay window; meeting// drives other windows (matching their globalShortcut callbacks and macOS).const dispatchNativeKeyDown = (key) => {+ hotkeyManager.logHotkeyEvent("native-listener", "down", key);if (hotkeyManager.slotHasHotkey("dictation", key)) {if (!isLiveWindow(windowManager.mainWindow)) return;if (windowManager.getActivationMode() === "push") {@@ -1897,6 +1902,7 @@ async function startApp() {// Only dictation drives push-to-talk, so only its key-up matters.const dispatchNativeKeyUp = (key) => {+ hotkeyManager.logHotkeyEvent("native-listener", "up", key);if (!hotkeyManager.slotHasHotkey("dictation", key)) return;if (windowManager.winPushState?.active) {windowManager.handleWindowsPushKeyUp(key);diff --git a/src/helpers/gnomeShortcut.js b/src/helpers/gnomeShortcut.jsindex 711883ab5..dab8c22b8 100644--- a/src/helpers/gnomeShortcut.js+++ b/src/helpers/gnomeShortcut.js@@ -183,6 +183,8 @@ class GnomeShortcutManager {this.globalShortcutsPortal = new GnomeGlobalShortcutsPortal();// Track which slots have been registered in gsettingsthis.registeredSlots = new Set();+ // Set by HotkeyManager to debug-log each press: (slotName, action).+ this.onHotkeyEvent = null;}static isGnome() {@@ -261,21 +263,25 @@ class GnomeShortcutManager {this.bus.exportInterface({Toggle: () => {+ this.onHotkeyEvent?.("dictation", "press");if (this.dictationCallback) {this.dictationCallback();}},ToggleMeeting: () => {+ this.onHotkeyEvent?.("meeting", "press");if (this.meetingCallback) {this.meetingCallback();}},ToggleVoiceAgent: () => {+ this.onHotkeyEvent?.("voiceAgent", "press");if (this.voiceAgentCallback) {this.voiceAgentCallback();}},ToggleTranslation: () => {+ this.onHotkeyEvent?.("translation", "press");if (this.translationCallback) {this.translationCallback();}@@ -330,7 +336,10 @@ class GnomeShortcutManager {await this.unregisterKeybinding("dictation");const registered = await this.globalShortcutsPortal.registerKeybinding(keysym ? preferredTrigger.replace(EXTENDED_FUNCTION_KEY, keysym) : preferredTrigger,- callback+ (hotkeyArg, phase) => {+ this.onHotkeyEvent?.("dictation", phase);+ return callback(hotkeyArg, phase);+ });if (!registered) {await this.registerKeybinding(tapShortcut, "dictation", resolved);diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.jsindex 62ce31c83..053799bfe 100644--- a/src/helpers/hotkeyManager.js+++ b/src/helpers/hotkeyManager.js@@ -6,6 +6,7 @@ const HyprlandShortcutManager = require("./hyprlandShortcut");const KDEShortcutManager = require("./kdeShortcut");const { i18nMain } = require("./i18nMain");const { parseHotkeyList } = require("./hotkeyList");+const { createHotkeyRepeatGate } = require("./hotkeyRepeatGate");// Delay to ensure localStorage is accessible after window loadconst HOTKEY_REGISTRATION_DELAY_MS = 1000;@@ -453,6 +454,48 @@ class HotkeyManager extends EventEmitter {return (this.slots.get(slotName)?.hotkeys ?? []).includes(key);}+ // Debug-log line for a press or release of a bound hotkey: where it came from,+ // the slots that own it and their activation mode. Key names only, never+ // dictated text. Unbound keys are skipped because the macOS listener reports+ // every right modifier and side mouse button, and so is hotkey capture, where+ // the keys are the new hotkey being typed.+ logHotkeyEvent(source, action, key) {+ if (this.isListeningMode) return;+ const slots = [];+ for (const [slotName, slot] of this.slots) {+ if ((slot.hotkeys ?? []).includes(key)) slots.push(slotName);+ }+ if (slots.length === 0) return;+ // Only dictation can hold; every other slot toggles.+ const activationMode =+ slots.includes("dictation") && this.activationMode === "push" ? "push" : "tap";+ debugLogger.debug("Hotkey event", { source, action, key, slots, activationMode }, "hotkey");+ }++ // Desktop shortcut backends (GNOME, KDE, Hyprland) report a slot, not a key;+ // they bind only the slot's primary hotkey.+ logSlotHotkeyEvent(source, action, slotName) {+ this.logHotkeyEvent(source, action, this.slots.get(slotName)?.hotkeys?.[0]);+ }++ // Every globalShortcut registration goes through here so its presses reach the+ // debug log. The callback gets the hotkey that fired, so shared callbacks act+ // on the right one.+ registerGlobalShortcut(accelerator, hotkey, callback) {+ const isPress = createHotkeyRepeatGate();+ return globalShortcut.register(accelerator, () => {+ // A held key re-fires on every autorepeat, so log the hold once. A key the+ // Windows/Linux listener watches is logged there with its down and up.+ const nativeListenerLogs =+ process.platform !== "darwin" &&+ this.getNativeListenerKeys(this.activationMode).includes(hotkey);+ if (isPress() && !nativeListenerLogs) {+ this.logHotkeyEvent("global-shortcut", "press", hotkey);+ }+ return callback(hotkey);+ });+ }+// Name of the slot that owns `key`, or null. First match wins.findSlotByHotkey(key) {if (!key) return null;@@ -745,8 +788,7 @@ class HotkeyManager extends EventEmitter {globalShortcut.unregister(accelerator);}- // Pass the triggering hotkey so shared callbacks act on the one that fired.- const success = globalShortcut.register(accelerator, () => callback(hotkey));+ const success = this.registerGlobalShortcut(accelerator, hotkey, callback);debugLogger.log(`[HotkeyManager] Registration result for "${hotkey}": ${success}`);if (success) {return { success: true, hotkey, accelerator };@@ -935,7 +977,7 @@ class HotkeyManager extends EventEmitter {const prevAccel = previousAccelerators?.[i];if (!prevAccel) return;try {- const restored = globalShortcut.register(prevAccel, () => callback(previousHotkey));+ const restored = this.registerGlobalShortcut(prevAccel, previousHotkey, callback);if (restored) {debugLogger.log(`[HotkeyManager] Restored previous hotkey "${previousHotkey}" after failed registration`@@ -958,6 +1000,8 @@ class HotkeyManager extends EventEmitter {try {this.gnomeManager = new GnomeShortcutManager();+ this.gnomeManager.onHotkeyEvent = (slotName, action) =>+ this.logSlotHotkeyEvent("gnome", action, slotName);const dbusOk = await this.gnomeManager.initDBusService(callback);if (dbusOk) {@@ -994,6 +1038,8 @@ class HotkeyManager extends EventEmitter {try {this.kdeManager = new KDEShortcutManager();+ this.kdeManager.onHotkeyEvent = (slotName, action) =>+ this.logSlotHotkeyEvent("kde", action, slotName);const ok = await this.kdeManager.init();if (ok) {await this.kdeManager.removeRetiredAgentKeybinding();@@ -1038,6 +1084,8 @@ class HotkeyManager extends EventEmitter {try {this.hyprlandManager = new HyprlandShortcutManager();+ this.hyprlandManager.onHotkeyEvent = (slotName, action) =>+ this.logSlotHotkeyEvent("hyprland", action, slotName);const dbusOk = await this.hyprlandManager.initDBusService(callback);debugLogger.log("[HotkeyManager] Hyprland D-Bus init result:", dbusOk);diff --git a/src/helpers/hyprlandShortcut.js b/src/helpers/hyprlandShortcut.jsindex dc4edf960..9593c47e5 100644--- a/src/helpers/hyprlandShortcut.js+++ b/src/helpers/hyprlandShortcut.js@@ -204,6 +204,8 @@ class HyprlandShortcutManager {this.persistencePending = false;this.config = null;this.dbusNameRequestTimeoutMs = dbusNameRequestTimeoutMs;+ // Set by HotkeyManager to debug-log each press: (slotName, action).+ this.onHotkeyEvent = null;}/**@@ -283,15 +285,18 @@ class HyprlandShortcutManager {const toggleMethods = {};for (const [slot, method] of Object.entries(SLOT_TOGGLE_METHOD)) {toggleMethods[method] = () => {+ this.onHotkeyEvent?.(slot, "press");const cb = this.callbacks[slot];if (typeof cb === "function") cb();};}toggleMethods.PttDown = () => {+ this.onHotkeyEvent?.("dictation", "down");const cb = this.callbacks.dictation;if (typeof cb === "function") cb(undefined, "down");};toggleMethods.PttUp = () => {+ this.onHotkeyEvent?.("dictation", "up");const cb = this.callbacks.dictation;if (typeof cb === "function") cb(undefined, "up");};diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex c70c6ef7d..76a965f80 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -4585,7 +4585,7 @@ class IPCHandlers {`[IPC] Re-registering globalShortcut "${accelerator}" after capture mode`);const callback = this.windowManager.createHotkeyCallback();- const registered = globalShortcut.register(accelerator, () => callback(hk));+ const registered = hotkeyManager.registerGlobalShortcut(accelerator, hk, callback);if (!registered) {debugLogger.warn(`[IPC] Failed to re-register globalShortcut "${accelerator}" after capture mode`diff --git a/src/helpers/kdeShortcut.js b/src/helpers/kdeShortcut.jsindex 0c5084458..7dc08c2f8 100644--- a/src/helpers/kdeShortcut.js+++ b/src/helpers/kdeShortcut.js@@ -117,6 +117,8 @@ class KDEShortcutManager {this.componentProxy = null;this.callbacks = new Map();this.registeredSlots = new Set();+ // Set by HotkeyManager to debug-log each press and release: (slotName, action).+ this.onHotkeyEvent = null;}static isKDE() {@@ -196,13 +198,13 @@ class KDEShortcutManager {});iface.on("globalShortcutPressed", (componentUnique, shortcutUnique, timestamp) => {- debugLogger.log("[KDEShortcut] Shortcut pressed", { componentUnique, shortcutUnique });// KGlobalAccel signal sends the actionUnique value as shortcutUnique.// Direct callback lookup by slotName should match. Fallback maps// actionFriendly names for compatibility.- const callback =- this.callbacks.get(shortcutUnique) || this._findCallbackByFriendlyName(shortcutUnique);+ const slotName = this._resolveSlotName(shortcutUnique);+ const callback = slotName ? this.callbacks.get(slotName) : null;if (callback) {+ this.onHotkeyEvent?.(slotName, "down");callback(undefined, "down");} else {debugLogger.log("[KDEShortcut] No callback found for", {@@ -212,10 +214,8 @@ class KDEShortcutManager {}});iface.on("globalShortcutReleased", (componentUnique, shortcutUnique) => {- debugLogger.log("[KDEShortcut] Shortcut released", { componentUnique, shortcutUnique });- const slotName = this.callbacks.has(shortcutUnique)- ? shortcutUnique- : this._findSlotByFriendlyName(shortcutUnique);+ const slotName = this._resolveSlotName(shortcutUnique);+ if (slotName) this.onHotkeyEvent?.(slotName, "up");if (slotName !== "dictation") return;this.callbacks.get(slotName)?.(undefined, "up");});@@ -229,9 +229,10 @@ class KDEShortcutManager {}}- _findCallbackByFriendlyName(name) {- const slotName = this._findSlotByFriendlyName(name);- return slotName ? this.callbacks.get(slotName) : null;+ _resolveSlotName(shortcutUnique) {+ return this.callbacks.has(shortcutUnique)+ ? shortcutUnique+ : this._findSlotByFriendlyName(shortcutUnique);}_findSlotByFriendlyName(name) {diff --git a/src/helpers/linuxKeyManager.js b/src/helpers/linuxKeyManager.jsindex e803d410e..96a85fed0 100644--- a/src/helpers/linuxKeyManager.js+++ b/src/helpers/linuxKeyManager.js@@ -155,13 +155,11 @@ class LinuxKeyManager extends EventEmitter {}if (line === "KEY_DOWN") {- debugLogger.debug("[LinuxKeyManager] KEY_DOWN detected", { key });this.emit("key-down", key);return;}if (line === "KEY_UP") {- debugLogger.debug("[LinuxKeyManager] KEY_UP detected", { key });this.emit("key-up", key);return;}diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex a6a1ab4da..020d2f55c 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -855,6 +855,7 @@ class WindowManager {this.macCompoundPushState = {active: true,+ hotkey,downTime,isRecording: false,requiredModifiers,@@ -882,6 +883,9 @@ class WindowManager {return;}+ // The press came through globalShortcut, which can't see the release.+ this.hotkeyManager.logHotkeyEvent("macos-native", "up", this.macCompoundPushState.hotkey);+if (this.macCompoundPushState.safetyTimeoutId) {clearTimeout(this.macCompoundPushState.safetyTimeoutId);}diff --git a/src/helpers/windowsKeyManager.js b/src/helpers/windowsKeyManager.jsindex c4c8a77dc..b8145f8fe 100644--- a/src/helpers/windowsKeyManager.js+++ b/src/helpers/windowsKeyManager.js@@ -136,13 +136,11 @@ class WindowsKeyManager extends EventEmitter {}if (line === "KEY_DOWN") {- debugLogger.debug("[WindowsKeyManager] KEY_DOWN detected", { key });this.emit("key-down", key);return;}if (line === "KEY_UP") {- debugLogger.debug("[WindowsKeyManager] KEY_UP detected", { key });this.emit("key-up", key);return;}diff --git a/test/helpers/gnomeShortcutKeymap.test.js b/test/helpers/gnomeShortcutKeymap.test.jsindex 6d3a752dd..5af74906c 100644--- a/test/helpers/gnomeShortcutKeymap.test.js+++ b/test/helpers/gnomeShortcutKeymap.test.js@@ -228,6 +228,26 @@ test("Hold hands the portal the keysym", async () => {assert.deepEqual(triggers, ["CTRL+XF86Launch7"]);});+test("Hold reports each portal down and up for the debug log before acting on it", async () => {+ const { manager } = loadManager();+ let portalCallback;+ manager.globalShortcutsPortal = {+ registerKeybinding: async (_trigger, callback) => {+ portalCallback = callback;+ return true;+ },+ unregisterKeybinding: async () => {},+ };+ const order = [];+ manager.onHotkeyEvent = (slotName, action) => order.push(`log:${slotName}:${action}`);++ await manager.registerPushToTalk("Control+F16", (_hotkey, phase) => order.push(phase));+ portalCallback(undefined, "down");+ portalCallback(undefined, "up");++ assert.deepEqual(order, ["log:dictation:down", "down", "log:dictation:up", "up"]);+});+test("Hold falling back to Tap binds the keysym and reads the keymap once", async () => {const { manager, calls } = loadManager();manager.globalShortcutsPortal = {diff --git a/test/helpers/hotkeyEventLog.test.js b/test/helpers/hotkeyEventLog.test.jsnew file mode 100644index 000000000..f681a54de--- /dev/null+++ b/test/helpers/hotkeyEventLog.test.js@@ -0,0 +1,167 @@+const test = require("node:test");+const assert = require("node:assert/strict");++const registered = new Map();+require.cache[require.resolve("electron")] = {+ exports: {+ globalShortcut: {+ register(accelerator, callback) {+ if (registered.has(accelerator)) return false;+ registered.set(accelerator, callback);+ return true;+ },+ unregister(accelerator) {+ registered.delete(accelerator);+ },+ isRegistered: (accelerator) => registered.has(accelerator),+ unregisterAll: () => registered.clear(),+ },+ BrowserWindow: class {},+ },+};++const debugLogger = require("../../src/helpers/debugLogger");+const HotkeyManager = require("../../src/helpers/hotkeyManager.js");++function captureDebug(t) {+ const events = [];+ const original = debugLogger.debug;+ debugLogger.debug = (message, meta, scope) => events.push({ message, meta, scope });+ t.after(() => {+ debugLogger.debug = original;+ registered.clear();+ });+ return events;+}++function withPlatform(t, platform) {+ const original = Object.getOwnPropertyDescriptor(process, "platform");+ Object.defineProperty(process, "platform", { value: platform });+ t.after(() => Object.defineProperty(process, "platform", original));+}++async function managerWith(slotName, hotkey, callback = () => {}) {+ const manager = new HotkeyManager();+ await manager.registerSlot(slotName, hotkey, callback, { atomic: true });+ return manager;+}++test("logHotkeyEvent names the source, action, key, owning slots and activation mode", async (t) => {+ const events = captureDebug(t);+ const manager = await managerWith("dictation", "RightOption");+ manager.activationMode = "push";+ events.length = 0;++ manager.logHotkeyEvent("macos-native", "up", "RightOption");++ assert.deepEqual(events, [+ {+ message: "Hotkey event",+ meta: {+ source: "macos-native",+ action: "up",+ key: "RightOption",+ slots: ["dictation"],+ activationMode: "push",+ },+ scope: "hotkey",+ },+ ]);+});++test("a slot other than dictation always reads as tap", async (t) => {+ const events = captureDebug(t);+ const manager = await managerWith("voiceAgent", "RightCommand");+ manager.activationMode = "push";+ events.length = 0;++ manager.logHotkeyEvent("macos-native", "down", "RightCommand");++ assert.equal(events[0].meta.activationMode, "tap");+});++test("a key no slot owns is not logged", (t) => {+ const events = captureDebug(t);+ new HotkeyManager().logHotkeyEvent("macos-native", "down", "RightShift");+ assert.deepEqual(events, []);+});++test("nothing is logged while a new hotkey is being captured", async (t) => {+ const events = captureDebug(t);+ const manager = await managerWith("dictation", "RightOption");+ manager.setListeningMode(true);+ events.length = 0;++ manager.logHotkeyEvent("macos-native", "down", "RightOption");++ assert.deepEqual(events, []);+});++test("a desktop shortcut backend's slot event is logged under the slot's primary hotkey", async (t) => {+ const events = captureDebug(t);+ const manager = await managerWith("meeting", "F7");+ events.length = 0;++ manager.logSlotHotkeyEvent("gnome", "press", "meeting");++ assert.equal(events[0].meta.source, "gnome");+ assert.equal(events[0].meta.key, "F7");+ assert.deepEqual(events[0].meta.slots, ["meeting"]);+});++test("a globalShortcut press is logged before the callback runs", async (t) => {+ const events = captureDebug(t);+ const order = [];+ await managerWith("meeting", "F7", () => order.push("callback"));+ events.length = 0;+ const capture = debugLogger.debug;+ debugLogger.debug = (...args) => {+ order.push("log");+ capture(...args);+ };++ registered.get("F7")();++ assert.deepEqual(order, ["log", "callback"]);+ assert.equal(events[0].meta.source, "global-shortcut");+ assert.equal(events[0].meta.action, "press");+ assert.deepEqual(events[0].meta.slots, ["meeting"]);+});++test("a held globalShortcut is logged once, however often it repeats", async (t) => {+ const events = captureDebug(t);+ let calls = 0;+ await managerWith("meeting", "F7", () => calls++);+ events.length = 0;++ registered.get("F7")();+ registered.get("F7")();+ registered.get("F7")();++ assert.equal(calls, 3);+ assert.equal(events.length, 1);+});++test("a hold key the Windows listener watches is logged by the listener, not globalShortcut", async (t) => {+ withPlatform(t, "win32");+ const events = captureDebug(t);+ const manager = await managerWith("dictation", "F8");+ manager.activationMode = "push";+ events.length = 0;++ registered.get("F8")();++ assert.deepEqual(events, []);+});++test("a hotkey restored after a failed change still logs its presses", (t) => {+ const events = captureDebug(t);+ const manager = new HotkeyManager();+ manager.slots.get("dictation").hotkeys = ["F9"];++ manager._restorePreviousHotkeys(["F9"], ["F9"], () => {});+ registered.get("F9")();++ assert.equal(events.at(-1).meta.key, "F9");+ assert.equal(events.at(-1).meta.source, "global-shortcut");+});diff --git a/test/helpers/hotkeyStartup.test.js b/test/helpers/hotkeyStartup.test.jsindex bf52c008b..13aecebb3 100644--- a/test/helpers/hotkeyStartup.test.js+++ b/test/helpers/hotkeyStartup.test.js@@ -48,6 +48,7 @@ function fixture(backend, savedHotkey = "Scrolllock", registrationResult = true)"./kdeShortcut": { isKDE: () => backend === "KDE" },"./i18nMain": { i18nMain: { t: (key) => key } },"./hotkeyList": require("../../src/helpers/hotkeyList"),+ "./hotkeyRepeatGate": require("../../src/helpers/hotkeyRepeatGate"),};const context = {module: { exports: {} },diff --git a/test/helpers/hyprlandShortcut.test.js b/test/helpers/hyprlandShortcut.test.jsindex 56e4544fe..a681d3208 100644--- a/test/helpers/hyprlandShortcut.test.js+++ b/test/helpers/hyprlandShortcut.test.js@@ -113,6 +113,42 @@ test("exports every Hyprland D-Bus toggle", async () => {});});+test("every Hyprland D-Bus trigger reports its slot and action for the debug log", async () => {+ let exported;+ const dbusModule = {+ sessionBus() {+ return {+ connection: { on() {}, end() {} },+ requestName(_name, _flags, callback) {+ callback(null, 1);+ },+ exportInterface(methods) {+ exported = methods;+ },+ };+ },+ };+ const HyprlandShortcutManager = loadManager(() => "ok\n");+ await withDbusMock(dbusModule, async () => {+ const events = [];+ const manager = new HyprlandShortcutManager();+ manager.onHotkeyEvent = (slotName, action) => events.push([slotName, action]);+ assert.equal(await manager.initDBusService(() => {}), true);++ exported.Toggle();+ exported.ToggleMeeting();+ exported.PttDown();+ exported.PttUp();++ assert.deepEqual(events, [+ ["dictation", "press"],+ ["meeting", "press"],+ ["dictation", "down"],+ ["dictation", "up"],+ ]);+ });+});+test("fails D-Bus initialization when the connection errors before RequestName replies", async () => {let onError;const dbusModule = {diff --git a/test/helpers/pushToTalkForceStop.test.js b/test/helpers/pushToTalkForceStop.test.jsindex 9b1437e9d..f88b00685 100644--- a/test/helpers/pushToTalkForceStop.test.js+++ b/test/helpers/pushToTalkForceStop.test.js@@ -65,7 +65,11 @@ Module._load = originalLoad;function makeManager() {const sent = [];const manager = new WindowManager();- manager.hotkeyManager = { isInListeningMode: () => false };+ const hotkeyEvents = [];+ manager.hotkeyManager = {+ isInListeningMode: () => false,+ logHotkeyEvent: (...args) => hotkeyEvents.push(args),+ };// Before mainWindow is attached, so its own teardown sends stay out of `sent`.manager.setOnboardingActive(false);manager.mainWindow = {@@ -80,6 +84,7 @@ function makeManager() {manager,sent,hides,+ hotkeyEvents,channels: () => sent.map((entry) => entry.channel),};}@@ -143,6 +148,22 @@ test("the macOS compound ceiling reports a forced stop on the same channel", (t)assert.deepEqual(harness.sent.at(-2).payload, { reason: "timeout" });});+// globalShortcut reports the press but never the release, so the modifier release+// that ends the hold is what tells the debug log the key came up.+test("releasing a macOS compound hold logs the hotkey's release", (t) => {+ t.mock.timers.enable({ apis: ["setTimeout"] });+ t.after(() => t.mock.timers.reset());++ const harness = makeManager();+ harness.manager.startMacCompoundPushToTalk("Control+Option");+ t.mock.timers.tick(150);+ harness.manager.handleMacPushModifierUp("shift");+ harness.manager.handleMacPushModifierUp("control");++ assert.deepEqual(harness.hotkeyEvents, [["macos-native", "up", "Control+Option"]]);+ assert.equal(harness.channels().at(-1), "stop-dictation");+});+// The transcript arrives seconds after the stop and is surfaced by a toast inside// this window, so hiding it here would render the recovery pill invisibly.test("a forced stop leaves the window up for the transcript still being processed", (t) => {