feat(keyboard): sequence-grammar chord helpers for leader chords (RIG-2707) - #612
Merged
Merged
Conversation
|
Compass engineering docs preview: https://compass-ux-rig-2707-chord-gr.compass-eng-docs.pages.dev Deployed from |
This was referenced Aug 25, 2026
rigel-mintaka
force-pushed
the
compass-ux/rig-2707-chord-grammar-helpers
branch
from
August 25, 2026 17:51
09f111f to
6a8939e
Compare
This was referenced Aug 25, 2026
Merged
rigel-mintaka
marked this pull request as ready for review
August 25, 2026 18:28
…-2707) Adds three pure, table-independent helpers to `keymap.ts` for the leader/mnemonic-chord grammar frozen in `docs/designs/product/compass-leader-chords/design.md` (T1): - `chordSegments(chord)` — split a chord on its single space; a plain chord yields a one-element array, a sequence like `"G B"` yields `["G", "B"]`. Space is a collision-free separator because the literal Space key normalizes to the `"Space"` token in the dispatcher. - `leaderPrefixes(keymap, platform)` — the resolved first segment of every multi-segment row, derived from the table so the dispatcher never hard-codes a leader key. - `formatChordForDisplay(chord, platform)` — a single chord resolves through `resolveChord` (`"Mod+B"` → `"Cmd+B"`); a sequence joins resolved segments with `" then "` (`"G B"` → `"G then B"`). The single formatter behind every display surface. Extends the `KeymapEntry` doc block with the sequence grammar and its three authoring rules (exactly two segments; every segment modifier-less; the leader prefix never doubles as a complete chord). Pure additions: no production caller and no shipped-helper change (`shortcutFor`/`shortcutForAria` hardening and the `DEFAULT_KEYMAP` sequence rows are T2). `formatChordForDisplay` is the shared root — RIG-2484 T2/T3 and RIG-2530's CoachTip (RIG-2703) both consume it. Tests extend `keymap.test.ts` over a fixture keymap (the real table carries no sequence rows until T2): segment splitting, leader-prefix derivation, and single-vs-sequence display formatting on both platforms. Ledger-impact: none. DL-248..DL-252 for this record landed with the design PR (#544); this impl slice ratifies no new decision. Refs RIG-2707 Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
force-pushed
the
compass-ux/rig-2707-chord-grammar-helpers
branch
from
August 26, 2026 03:31
6a8939e to
24df261
Compare
mattwilkinsonn
approved these changes
Aug 26, 2026
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.
This PR is part of a stack containing 4 PRs:
mainAdds three pure, table-independent helpers to
keymap.tsfor the leader/mnemonic-chord grammar frozen indocs/designs/product/compass-leader-chords/design.md(T1):chordSegments(chord)— split a chord on its single space; a plain chord yields a one-element array, a sequence like"G B"yields["G", "B"]. Space is a collision-free separator because the literal Space key normalizes to the"Space"token in the dispatcher.leaderPrefixes(keymap, platform)— the resolved first segment of every multi-segment row, derived from the table so the dispatcher never hard-codes a leader key.formatChordForDisplay(chord, platform)— a single chord resolves throughresolveChord("Mod+B"→"Cmd+B"); a sequence joins resolved segments with" then "("G B"→"G then B"). The single formatter behind every display surface.Extends the
KeymapEntrydoc block with the sequence grammar and its three authoring rules (exactly two segments; every segment modifier-less; the leader prefix never doubles as a complete chord).Pure additions: no production caller and no shipped-helper change (
shortcutFor/shortcutForAriahardening and theDEFAULT_KEYMAPsequence rows are T2).formatChordForDisplayis the shared root — RIG-2484 T2/T3 and RIG-2530's CoachTip (RIG-2703) both consume it.Tests extend
keymap.test.tsover a fixture keymap (the real table carries no sequence rows until T2): segment splitting, leader-prefix derivation, and single-vs-sequence display formatting on both platforms.Ledger-impact: none. DL-248..DL-252 for this record landed with the design PR (#544); this impl slice ratifies no new decision.
Refs RIG-2707
Co-authored-by: Matt Wilkinson matt@rigel.build