Add global hotkey rebinding UI#28
Merged
Merged
Conversation
The global hotkey is now editable from Settings instead of display-only. A focusable HotkeyCaptureBox records a chord (modifier(s) + key), and SettingsViewModel.RebindHotkey re-registers via IHotkeyService and persists on success; on failure (chord already taken) it restores the previous binding and surfaces a notice. A Reset button restores Ctrl+Alt+S. Chord formatting + validation moved to HotkeyBinding (IsValid, ToDisplayString) in Core and unit-tested; the capture control is the only WinUI-side piece. SettingsViewModel now takes IHotkeyService. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Enter/Space now begins recording when the box has focus (pointer users tap), so keyboard-only users can rebind. A bare key while recording (e.g. Tab to move on) cancels recording and passes through, so focus isn't trapped. Found by codex review. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements the Hotkey rebinding UI carried-over item (task #7). The global hotkey was shown read-only in Settings; it's now editable.
How it works
HotkeyCaptureBox(WinUI) — a focusable box (not a Button, so Space/Enter don't activate it). Click it, press a chord; it reads modifier state viaInputKeyboardSource, maps the key to the Core vocabulary (A–Z, 0–9, F1–F12, Space/Tab/Enter), builds aHotkeyBinding, and invokes the rebind command. Esc cancels; modifier-only/unsupported keys are ignored so it keeps listening until a usable chord (≥1 modifier + key).SettingsViewModel.RebindHotkey— re-registers viaIHotkeyService.TryRegister, persists toAppConfig, updates the display. On failure (chord already in use —TryRegisterunregisters the old binding first), it restores the previous binding and shows an inline error. Reset restoresCtrl+Alt+S.HotkeyBinding(IsValid,ToDisplayString) in Core — unit-tested; the capture control is the only WinUI-side logic.Tests
SettingsViewModelTests(rebind success persists + updates display; rejects no-modifier; restores previous + errors on registration failure; reset → default) andHotkeyBindingTests(validity, display formatting). Full suite: 145 passing.Note for review
The capture control's key/modifier reading can't be runtime-verified from Linux — worth a quick manual check that pressing e.g. Ctrl+Shift+K records and registers, and that an in-use chord shows the revert notice.
🤖 Generated with Claude Code