fix(settings): clear orphaned per-prompt shortcuts on legacy retirement#711
Draft
shivanshsen7 wants to merge 1 commit into
Draft
fix(settings): clear orphaned per-prompt shortcuts on legacy retirement#711shivanshsen7 wants to merge 1 commit into
shivanshsen7 wants to merge 1 commit into
Conversation
Retiring the legacy secondary-prompt-mode hotkey cleared PromptModeHotkeyShortcut/PromptModeSelectedPromptID but never touched DictationPromptConfigurations, a separate store still read unconditionally by dictationPromptShortcutAssignments(). Any residual .shortcut there (commonly a bare Command keypress left under __default__) kept firing as an always-on global hotkey with no dependency on PromptModeShortcutEnabled. Clear stale shortcut bindings once, at the same retirement boundary that already governs the legacy key, while preserving any real provider/model overrides. Fixes altic-dev#675
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
Retiring the legacy secondary-prompt-mode hotkey (
retireLegacySecondaryPromptShortcutIfNeeded()) clearsPromptModeHotkeyShortcut/PromptModeSelectedPromptID, but never touchesDictationPromptConfigurations— a separate, still-active data store used by the current "Custom shortcut per AI Prompt profile" feature.dictationPromptShortcutAssignments()turns every stored.shortcutinDictationPromptConfigurationsinto a live global hotkey unconditionally, with no dependency onPromptModeShortcutEnabledor either retirement flag. Any residual.shortcutleft over from before the legacy hotkey was retired — most commonly a bare Command keypress under the__default__entry — keeps firing forever, even though nothing in Settings shows or lets you clear it.This matches the two independent reports on #675: both show the exact same orphaned
keyCode: 55(Command) under__default__, despite having different Primary Dictation shortcuts configured (Right Option / Right Control). That consistency across unrelated users is why I'm confident this is leftover legacy state rather than an intentional per-profile shortcut.This PR clears any stale
.shortcutbindings once, at the same retirement boundary that already governsPromptModeHotkeyShortcut, while preserving any realproviderID/modelNameoverrides a user may have set on a prompt configuration.Type of Change
Related Issue or Discussion
Fixes #675
Testing
swiftlint --strict --config .swiftlint.yml Sources(SourceKit crashes on this machine — only Command Line Tools installed, no full Xcode; see note below)swiftformat --config .swiftformat Sources— diffed--lintoutput against unmodifiedmainfor both touched files; this change introduces zero new formatting findings (45 pre-existing findings unrelated to this change, unchanged before/after)Note on local verification: this machine only has Command Line Tools, not full Xcode, so
xcodebuild testisn't available andswiftlintcrashes on a missingsourcekitdInProcframework. I verified both changed files parse cleanly withxcrun swiftc -parse, and confirmed withswiftformat --lintthat this diff adds no new style issues. I also manually reproduced the exact preference-file shape from #675 on my own affected install (DictationPromptConfigurations.__default__.shortcut = {keyCode: 55, modifierKeyCodes: [55]},PromptModeShortcutEnabled = false) and applied the equivalent of this fix viadefaults deleteas a live workaround, which stopped Command from triggering dictation without disturbing the configured Primary Dictation shortcut. The new regression test reproduces that same data shape and assertsdictationPromptShortcutAssignments()— the sourceGlobalHotkeyManagerreads for these hotkeys — ends up empty after cleanup. CI (build.yml,macos-latestwith full Xcode) should be able to run the full suite including this test.Screenshots / Video
Notes
clearOrphanedDictationPromptShortcuts()clears.shortcuton every entry inDictationPromptConfigurations, not just__default__, since the legacy single-shortcut system could plausibly have left residue under__privateAI__or aprofile:*key too. The tradeoff: if anyone genuinely used the current "Custom shortcut" editor (Advanced AI Settings → prompt editor → "Custom shortcut") to bind a shortcut before updating past this migration, that binding would also be cleared. Given both #675 reports show the identicalkeyCode: 55artifact regardless of their actual configured Primary Dictation shortcut, I believe this is safe, but happy to narrow the scope (e.g. only__default__, or only shortcuts matching the known legacy default) if you'd prefer — you have visibility I don't into how many users use per-profile custom shortcuts today.