fix(hotkey): apply primary dictation shortcut change to live event tap#474
Open
devzahirul wants to merge 1 commit into
Open
fix(hotkey): apply primary dictation shortcut change to live event tap#474devzahirul wants to merge 1 commit into
devzahirul wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Changing the Primary Dictation shortcut saved the new shortcut to
SettingsStorebut did not push it to the runningGlobalHotkeyManager, so the previously registered shortcut kept triggering dictation until the app was restarted.GlobalHotkeyManagermatches primary dictation against its in-memoryprimaryShortcutscache, refreshed only viaupdatePrimaryShortcuts(_:). The secondary/command/edit shortcut types call that update directly inapplyRecordedShortcut(_:to:), but the primary path (applyPrimaryDictationShortcut(_:edit:)) only mutated@Stateand relied on the.onChange(of:)side effect — driven from theNSEventshortcut-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 inapplyPrimaryDictationShortcut(_: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
Related Issues
Testing
swiftlint --strict --config .swiftlint.yml Sources(0 violations)xcodebuild -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS' build CODE_SIGNING_ALLOWED=NO→ BUILD SUCCEEDEDManual 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
applyPrimaryDictationShortcut(_:edit:); no public API or settings-schema changes.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.