From 05f7164c95ea31a825b7565fa3eb873531973181 Mon Sep 17 00:00:00 2001 From: zahirulAIIUB Date: Mon, 29 Jun 2026 17:30:46 +0600 Subject: [PATCH] fix(hotkey): apply primary dictation shortcut change to live event tap Changing the Primary Dictation shortcut updated SettingsStore but not the running GlobalHotkeyManager, so the previously registered shortcut kept triggering dictation until the app was restarted. Secondary/command/edit shortcuts all refresh the manager directly in applyRecordedShortcut(_:to:). The primary path only mutated @State and relied on the .onChange(of:) side effect - driven from the NSEvent shortcut-capture callback - to both persist and refresh the manager's cached primaryShortcuts array. When that refresh did not run, the event tap kept matching the old shortcut. Persist and call updatePrimaryShortcuts(_:) directly in applyPrimaryDictationShortcut(_:edit:), mirroring the other shortcut types, so replacements take effect without a restart. Fixes #470 --- Sources/Fluid/ContentView.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift index 1a5d3ec3..4d171d53 100644 --- a/Sources/Fluid/ContentView.swift +++ b/Sources/Fluid/ContentView.swift @@ -1091,7 +1091,17 @@ struct ContentView: View { shortcuts.append(shortcut) } } - self.primaryDictationShortcuts = shortcuts + + // Persist and push the normalized list to the running event tap right here, mirroring the + // other shortcut types in applyRecordedShortcut(_:to:). GlobalHotkeyManager matches primary + // dictation against its cached `primaryShortcuts` array, so the previous shortcut keeps + // firing until this update runs. Doing it directly (instead of relying solely on the + // .onChange(of:) side effect, which is driven from the NSEvent capture callback) makes the + // replacement take effect without an app restart. (#470) + SettingsStore.shared.primaryDictationShortcuts = shortcuts + let storedShortcuts = SettingsStore.shared.primaryDictationShortcuts + self.primaryDictationShortcuts = storedShortcuts + self.hotkeyManager?.updatePrimaryShortcuts(storedShortcuts) } private func setShortcutTargetEnabled(_ enabled: Bool, for target: ShortcutRecordingTarget) {