fix(settings): clear orphaned per-prompt shortcuts on legacy retirement - #711
fix(settings): clear orphaned per-prompt shortcuts on legacy retirement#711shivanshsen7 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
|
Had a close look at this against current main after #815 landed. The diagnosis and the plist evidence in #675 are useful. I found two coupled blockers in the implementation: The cleanup cannot run on the installs it targets. Giving it a fresh key makes the current cleanup too broad. I would also pin down the writer before choosing that signature. The retirement commit does not write to One smaller workflow note: because this is still a draft, the main build/lint/test workflow has not run yet. The branch conflict is limited to Happy to help with the rebase and run the full lint/build/test gate once the migration signature is narrowed, if that would be useful. |
|
I just added as draft coz i felt that it will be burden as its full ai generated and i thought it could help as i loved the app. |
|
whatever you want. I also use this app all the time and so I've started contributing too. |
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.