Skip to content

[WIP] [Keyboard Manager] Add exact match and orphaned-key notice to the new editor#49100

Draft
moooyo wants to merge 3 commits into
mainfrom
yuleng/worktree/kbm-editor-parity
Draft

[WIP] [Keyboard Manager] Add exact match and orphaned-key notice to the new editor#49100
moooyo wants to merge 3 commits into
mainfrom
yuleng/worktree/kbm-editor-parity

Conversation

@moooyo

@moooyo moooyo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Closes two functional-regression gaps in the new WinUI 3 Keyboard Manager editor (KeyboardManagerEditorUI, the default editor when useNewEditor is on) relative to the classic C++ XAML-Islands editor:

  • Exact Match for shortcuts — the per-origin-shortcut "exact match" flag (already supported and serialized by the engine, but never wired into the new editor).
  • Orphaned-key notice — a heads-up when a single-key remap leaves the original key with no way to be typed, mirroring the classic Remap Keys editor (reworked as a non-blocking notice to fit the new per-mapping flow).

⚠️ WIP / Draft — opened for early review. Not yet discussed with core contributors; no automated tests added (the new editor has no unit-test project yet). Validated via build + manual round-trip + code review.

PR Checklist

  • Closes: #xxx
  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: N/A — no new binaries; only existing Keyboard Manager projects changed

Detailed Description of the Pull Request / Additional comments

1. Exact Match

Shortcut::exactMatch already exists in the engine and is (de)serialized by MappingConfiguration for every shortcut remap type, but the new editor never exposed or persisted it. This PR threads it end-to-end:

  • Native wrapper (KeyboardManagerEditorLibraryWrapper): new exactMatch on the ShortcutMapping struct and the AddShortcutRemap export; GetShortcutRemap / GetShortcutRemapByType populate it from the origin shortcut.
  • Interop / service (KeyboardManagerInterop, ShortcutKeyMapping, KeyboardMappingService): marshal the flag both ways (int across the P/Invoke boundary, bool in managed code).
  • UI (UnifiedMappingControl, MainPage): an ExactMatchCheckBox (enabled only for multi-key shortcuts), wired through all action types (key/shortcut, text, URL, program, disable) on save, load and edit — matching the classic editor, which gates exact-match on the origin shortcut regardless of target type.

2. Orphaned-key notice

Wires up the previously-unused ValidationHelper.IsKeyOrphaned to inform the user when a single-key remap leaves the original key unreachable. Because the new editor saves one mapping at a time (unlike the classic batch editor), this is surfaced as a non-blocking, dismissible InfoBar shown after saving — saving still completes in a single click — rather than a modal confirmation.

Commits

  • b7556c8 Add exact match and orphaned-key warning to the new WinUI3 editor
  • 3197ae1 Fix issues found in review (exactMatch dropped on multi-key text re-enable; checkbox enable-state not synced on dropdown edits; IsKeyOrphaned now only counts key-output remaps as restoring a key)
  • ab99b6f Make the orphaned-key warning a non-blocking notice

Validation Steps Performed

  • Build: KeyboardManagerEditorLibraryWrapper (native) and KeyboardManagerEditorUI (C#) both build clean at x64 Debug (exit code 0).
  • Persistence: verified in code that the engine serializes/loads exactMatch for shortcut→key/shortcut/program/URI/text, so the flag round-trips to both the engine default.json and the editor's editorSettings.json.
  • Review: independent code-review and rubber-duck passes; the issues they surfaced are fixed in 3197ae1 (see commits).
  • Manual: exercised save/load/edit of exact-match shortcuts and the orphaned-key notice.

Still TODO before ready-for-review: agree the change with core contributors, and add automated coverage once/if a test project exists for the new editor.

Yu Leng (from Dev Box) and others added 3 commits July 2, 2026 16:05
Close two functional-regression gaps in the new Keyboard Manager editor
(KeyboardManagerEditorUI) relative to the classic C++ editor:

- Exact Match: thread the origin-shortcut exactMatch flag through the
  native wrapper (AddShortcutRemap + ShortcutMapping struct), interop,
  and UI. Wired for all action types (key/shortcut, text, URL, program,
  disable) on multi-key shortcuts, with save/load/edit round-trip. The
  engine (MappingConfiguration) already serialized exactMatch.

- Orphaned-key warning: wire up the previously-unused
  ValidationHelper.IsKeyOrphaned to warn (via a key-scoped, two-step
  InfoBar confirmation) when a single-key remap leaves the original key
  unassigned, mirroring the classic Remap Keys editor. The check runs
  before deleting the existing mapping so cancelling is non-destructive.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- EnableShortcut: re-enabling a multi-key text mapping went through the
  string AddShortcutMapping overload without exactMatch, silently
  clearing exact-match in the engine while editorSettings.json kept it.
  Now forwards exactMatch.

- UnifiedMappingControl: the exact-match (and app-specific) checkbox
  enable state was only refreshed on keyboard-hook capture, not on
  dropdown key edits / auto-grow. Refresh it from _triggerKeys
  CollectionChanged so changing the trigger via the dropdown keeps the
  state in sync.

- ValidationHelper.IsKeyOrphaned: only count RemapShortcut (key-output)
  mappings as restoring a key; program/URL/text targets do not make a
  physical key reachable again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The orphaned-key warning previously blocked saving and required a second
Save click to confirm, which is unintuitive in the new per-mapping flow.
Change it to save in a single click and show a dismissible informational
banner on the main page afterwards (only for single-key remaps that leave
the original key with no assignment), so the operation is no longer
interrupted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added Area-Localization issues regarding to Localization the application Product-Keyboard Manager labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Localization issues regarding to Localization the application Product-Keyboard Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant