Skip to content

fix(hotkey): apply primary dictation shortcut change to live event tap#474

Open
devzahirul wants to merge 1 commit into
altic-dev:mainfrom
devzahirul:fix/470-primary-dictation-shortcut-overwrite
Open

fix(hotkey): apply primary dictation shortcut change to live event tap#474
devzahirul wants to merge 1 commit into
altic-dev:mainfrom
devzahirul:fix/470-primary-dictation-shortcut-overwrite

Conversation

@devzahirul

Copy link
Copy Markdown

Description

Changing the Primary Dictation shortcut saved the new shortcut to SettingsStore but did not push it to the running GlobalHotkeyManager, so the previously registered shortcut kept triggering dictation until the app was restarted.

GlobalHotkeyManager matches primary dictation against its in-memory primaryShortcuts cache, refreshed only via updatePrimaryShortcuts(_:). The secondary/command/edit shortcut types call that update directly in applyRecordedShortcut(_:to:), but the primary path (applyPrimaryDictationShortcut(_:edit:)) 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. When that refresh did not run, the event tap kept matching the old shortcut.

The fix persists and calls updatePrimaryShortcuts(_:) directly in applyPrimaryDictationShortcut(_:edit:), mirroring the other shortcut types, so a replacement (or an added shortcut) takes effect immediately without a restart. It is idempotent with the existing .onChange(of:) handler.

Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🧹 Chore
  • 📝 Documentation update

Related Issues

Testing

  • Tested on Intel Mac
  • Tested on Apple Silicon Mac
  • Tested on macOS Tahoe 26
  • Ran linter locally: swiftlint --strict --config .swiftlint.yml Sources (0 violations)
  • Built unsigned: xcodebuild -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS' build CODE_SIGNING_ALLOWED=NOBUILD SUCCEEDED

Manual repro (from the issue): Settings → Global Shortcuts → Change the Primary Dictation shortcut (e.g. ⇧+\`` → Hyper+``). After the fix only the new shortcut triggers dictation, immediately, with no app restart.

Notes

  • One-line behavioral change in applyPrimaryDictationShortcut(_:edit:); no public API or settings-schema changes.
  • Also resolves the same staleness for the Add shortcut flow, which shares the same method.
  • A focused unit test was not added because the defect is in the SwiftUI propagation inside ContentView (not unit-testable without invasive hooks); GlobalHotkeyManager.updatePrimaryShortcuts(_:) already replaces the cached set correctly, so a manager-level test would pass both before and after and would not guard this regression.

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 altic-dev#470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐞 BUG] Changing Primary Dictation shortcut doesn't remove/overwrite previous shortcut

1 participant