Refactor: move hotkey display-string formatting onto HotKeyCombination#8
Merged
Merged
Conversation
PreferencesWindow's shortcut row built its '⇧⌘1'-style label inline, including a
33-entry macOS keycode->label map embedded in the view. Move it onto the model
type as HotKeyCombination.displayString / .keyName(_:), where modifierFlags
already lives. The view keeps only its UI states ('None', 'Press shortcut…').
Behavior-preserving. Adds HotKeyCombinationDisplayTests (6 cases), including a
regression guard for the non-sequential digit keycodes (kVK_ANSI_5=23, _6=22).
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
#8) Move PreferencesWindow's inline shortcut-label formatting (modifier symbols + 33-entry macOS keycode->label map) onto HotKeyCombination.displayString / .keyName(_:), beside the existing modifierFlags. View keeps only its UI states. Behavior-preserving. Adds HotKeyCombinationDisplayTests (6 cases) incl. a guard for the non-sequential digit keycodes. CI green.
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
#8) Move PreferencesWindow's inline shortcut-label formatting (modifier symbols + 33-entry macOS keycode->label map) onto HotKeyCombination.displayString / .keyName(_:), beside the existing modifierFlags. View keeps only its UI states. Behavior-preserving. Adds HotKeyCombinationDisplayTests (6 cases) incl. a guard for the non-sequential digit keycodes. CI green.
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.
Summary
First
PreferencesWindowslice. The shortcut row built its⇧⌘1-style label inline in the view'sdisplayText, including a 33-entry macOS keycode→label map (keyName) embedded in the SwiftUI struct.This moves the formatting onto the model type, where
modifierFlagsalready lives:The view keeps only its genuine UI states:
Scope / safety
Key<code>fallback.kVK_ANSI_5 = 23,_6 = 22) is preserved and now has a regression test — this is the exact mapping that was previously swapped and mis-fired the recorder.event.modifierFlagsuses in the live key-capture code are untouched (unrelatedNSEventaccessor).Tests
HotKeyCombinationDisplayTests(6 cases): command+shift digit, full ⌃⌥⇧⌘ ordering, non-sequential digit keycodes, unknown-keycode fallback, empty string for keyCode 0, and special-key labels (Space/Return/Esc).🤖 Generated with Claude Code
Generated by Claude Code