Skip to content

Add global hotkey rebinding UI#28

Merged
StuartMeeks merged 2 commits into
mainfrom
feat/hotkey-rebinding
May 30, 2026
Merged

Add global hotkey rebinding UI#28
StuartMeeks merged 2 commits into
mainfrom
feat/hotkey-rebinding

Conversation

@StuartMeeks

Copy link
Copy Markdown
Owner

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 via InputKeyboardSource, maps the key to the Core vocabulary (A–Z, 0–9, F1–F12, Space/Tab/Enter), builds a HotkeyBinding, 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 via IHotkeyService.TryRegister, persists to AppConfig, updates the display. On failure (chord already in use — TryRegister unregisters the old binding first), it restores the previous binding and shows an inline error. Reset restores Ctrl+Alt+S.
  • Chord formatting + validation moved to HotkeyBinding (IsValid, ToDisplayString) in Core — unit-tested; the capture control is the only WinUI-side logic.

Tests

  • New SettingsViewModelTests (rebind success persists + updates display; rejects no-modifier; restores previous + errors on registration failure; reset → default) and HotkeyBindingTests (validity, display formatting). Full suite: 145 passing.
  • WinUI head compiles clean on the Windows build agent (0/0).

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

StuartMeeks and others added 2 commits May 30, 2026 09:14
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>
@StuartMeeks StuartMeeks merged commit 9455c37 into main May 30, 2026
4 checks passed
@StuartMeeks StuartMeeks deleted the feat/hotkey-rebinding branch May 30, 2026 10:04
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