Skip to content

feat: replace ShortcutRecorder with MASShortcut#233

Merged
2ndalpha merged 3 commits intomasterfrom
replace-shortcutrecorder-with-masshortcut
Feb 28, 2026
Merged

feat: replace ShortcutRecorder with MASShortcut#233
2ndalpha merged 3 commits intomasterfrom
replace-shortcutrecorder-with-masshortcut

Conversation

@2ndalpha
Copy link
Owner

@2ndalpha 2ndalpha commented Feb 28, 2026

Summary

Replace ShortcutRecorder with MASShortcut, which provides both the recorder UI and global hotkey monitoring in a single library. Based on the approach from #220.

  • Simplify hotkey architecture from 3 layers to 2, reducing ShortcutRecorderView from 73 to 20 lines
  • Delete GlobalHotkeys.h/.m and Hotkey.h/.m (394 lines removed)
  • No user data migration needed — MASDictionaryTransformer reads/writes the same UserDefaults plist format

Test plan

  • Build succeeds (./build.sh)
  • App launches without crashes
  • Preferences → Hotkeys tab displays existing shortcuts correctly
  • Recording, clearing, and persisting shortcuts works
  • Global hotkeys work immediately at launch (without opening Preferences)

Replace the ShortcutRecorder SPM dependency and custom GlobalHotkeys/Hotkey
ObjC classes with MASShortcut, which provides both the recorder UI
(MASShortcutView) and global hotkey monitoring (MASShortcutBinder).

This simplifies the architecture from three layers to two:
- UI: NSViewRepresentable wrapping MASShortcutView with UserDefaults binding
- Runtime: MASShortcutBinder binds defaults keys to notification-posting actions

MASDictionaryTransformer ensures backward-compatible reading/writing of the
existing UserDefaults plist format, so no user data migration is needed.

Changes:
- Add MASShortcut SPM dependency (branch master), remove ShortcutRecorder
- Create GlobalShortcuts.swift for hotkey binding via MASShortcutBinder
- Rewrite ShortcutRecorderView.swift to wrap MASShortcutView (73 → 20 lines)
- Wire GlobalShortcuts.shared into ApplicationController launch
- Remove GlobalHotkeys NSCustomObject from MainMenu.xib
- Delete GlobalHotkeys.h/.m and Hotkey.h/.m
- Use bridged Preferences.h constants in HotkeysTab
Cover the MASShortcut integration with unit tests:

GlobalShortcutsTests:
- Singleton identity and non-nil
- MASShortcutBinder configured with MASDictionaryTransformerName
- Each hotkey binding registers with the shortcut monitor

ShortcutRecorderViewTests:
- Preferences.h constants match expected string values
- MASShortcutView configured with correct key, style, and transformer
- View reads shortcut from UserDefaults via dictionary transformer
- Clearing shortcut writes empty dictionary (MASShortcut behavior)
- Remove unused expectedNotificationName parameter from test helper and
  rename methods to reflect what they actually verify (registration)
- Fix stale doc comment referencing deleted GlobalHotkeys class
- Pin MASShortcut to specific revision instead of branch master
@2ndalpha 2ndalpha merged commit 12339cd into master Feb 28, 2026
18 checks passed
@2ndalpha 2ndalpha deleted the replace-shortcutrecorder-with-masshortcut branch February 28, 2026 14:42
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.

1 participant