Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

Reset stale modifier hotkey state

altic-dev02813185d2bb
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 04812dd8..b6ff8c17 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -521,6 +521,9 @@ struct ContentView: View {
.onChange(of: self.selectedProviderID) { _, newValue in
SettingsStore.shared.selectedProviderID = newValue
}
+ .onChange(of: self.activeShortcutRecordingTarget) { _, _ in
+ self.hotkeyManager?.resetModifierOnlyShortcutTracking()
+ }
.onChange(of: self.isPromptModeShortcutEnabled) { newValue in
SettingsStore.shared.promptModeShortcutEnabled = newValue
self.hotkeyManager?.updatePromptModeShortcutEnabled(newValue)
diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swift
index f6063b9a..9bc554b1 100644
--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift
+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift
@@ -358,6 +358,7 @@ final class GlobalHotkeyManager: NSObject {
}
if self.isShortcutCaptureActiveProvider?() ?? false {
+ self.resetModifierOnlyShortcutTracking()
return Unmanaged.passUnretained(event)
}
@@ -684,6 +685,7 @@ final class GlobalHotkeyManager: NSObject {
let reason = (type == .tapDisabledByTimeout) ? "timeout" : "user input"
DebugLogger.shared.warning("Event tap disabled by \(reason) — attempting immediate re-enable", source: "GlobalHotkeyManager")
+ self.resetModifierOnlyShortcutTracking()
if let tap = self.eventTap {
CGEvent.tapEnable(tap: tap, enable: true)
@@ -697,6 +699,20 @@ final class GlobalHotkeyManager: NSObject {
return Unmanaged.passUnretained(event)
}
+ func resetModifierOnlyShortcutTracking() {
+ self.pressedModifierKeyCodes = []
+ self.modifierOnlyKeyDown = false
+ self.otherKeyPressedDuringModifier = false
+ self.modifierPressStartTime = nil
+ self.pendingHoldModeStart?.cancel()
+ self.pendingHoldModeStart = nil
+ self.pendingHoldModeType = nil
+ self.isKeyPressed = false
+ self.isPromptModeKeyPressed = false
+ self.isCommandModeKeyPressed = false
+ self.isRewriteKeyPressed = false
+ }
+
private func handlePromptModeKeyDown(keyCode: UInt16, modifiers: NSEvent.ModifierFlags) -> Bool {
guard self.promptModeShortcutEnabled, self.matchesPromptModeShortcut(keyCode: keyCode, modifiers: modifiers) else { return false }
if self.pressAndHoldMode {
@@ -1096,6 +1112,7 @@ final class GlobalHotkeyManager: NSObject {
self.initializationTask?.cancel()
self.healthCheckTask?.cancel()
+ self.resetModifierOnlyShortcutTracking()
self.isInitialized = false
self.initializeWithDelay()
}