[#14] Added configurable key bindings with a vim preset.#30
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 32 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (41)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
+ Coverage 98.92% 99.32% +0.39%
==========================================
Files 59 67 +8
Lines 1493 1769 +276
==========================================
+ Hits 1477 1757 +280
+ Misses 16 12 -4 ☔ View full report in Codecov by Harness. |
Closes #14
Summary
Makes the TUI's key bindings configurable instead of hardcoded, adding a semantic keymap subsystem under
src/Input/that mirrors the existing theme subsystem: anActionenum of intents (MoveUp,Accept,Toggle,NewLine,ExternalEdit,Reveal,Quit, and more), aScopevalue object (base / navigation / per-FieldType),Binding,ScopedKeyMap, a validatingKeyMap,DefaultKeyMapandVimKeyMappresets, and aKeyMapManagerregistry/factory.Form::keys($preset, $overrides)resolves and validates the map at build time intoConfig->keymap, whichPanelControllerandWidgetFactoryinject into the panel dispatcher and every widget; each now asksmatches($key, Action)instead of testing a rawKeyName, including the textarea's Ctrl-E external-editor handoff, the password reveal toggle and confirm submit, and the toggle switch. On-screen key hints are derived from the live bindings so they can never drift from what a key actually does, and a bad binding - a conflict, an un-typeable printable character, an unknown preset - throws at form-build time rather than mid-session. Ships avimpreset and aplayground/8-key-bindings/example; the defaults reproduce the previous, hardcoded keys exactly.Changes
src/Input/keymap subsystem:Action(a pure enum of the semantic intents widgets understand: movement,Accept/Cancel, panelActivate/Back/Quit/scrolling, text editing includingNewLine/ExternalEdit, listToggle/SelectAll/SelectNone, confirmYes/No, passwordReveal),Scope(base / navigation / per-FieldType, and which scopes consume typed characters),Binding(a scope plus an action plus its keys), andScopedKeyMap(matches(),keysFor(),primary()for one scope).KeyMap, which layers a flat binding list (a preset's defaults, then any overrides, later wins) into per-scope maps and validates eagerly: a key bound to two different actions in one scope, or a printable character bound where it would be un-typeable, throwsInvalidArgumentExceptionat resolution time.DefaultKeyMap(reproduces the previous hardcoded bindings exactly) andVimKeyMap(addsh/j/k/lin the navigation and select scopes only, leaving every text and filter scope on arrows), plusKeyMapManageras the name-to-class registry and factory (create($preset, $overrides)), which rejects an unknown preset name outright.Form::keys($preset, $overrides)to resolve throughKeyMapManager::create()into the newConfig->keymapproperty atForm::build()time, so a bad binding fails at form-build time rather than mid-session.KeyMapintoPanelController(keeps the navigation scope for its own dispatch) and intoWidgetFactory, which calls the newWidgetInterface::setKeys()on every widget it builds, handing it the bindings for its field type.matches():AbstractWidgetgainedsetKeys(), akeyScope()hook (defaulting to the base scope) and a lazykeys()accessor that falls back to the default preset when a widget is built directly;handle()/handleCancel()across all widgets now call$this->keys()->matches($key, Action::...)in place of$key->is(KeyName::...), including the textarea's Ctrl-E external-editor handoff, the password reveal toggle and confirm submit, and the toggle switch.ThemeInterface/DefaultThemegainedkeyHint(Key)andkeysHint(ScopedKeyMap, label, Action...), andrenderStatusLine(),renderEditor()and the multiselect/password/textarea hint lines now build their footer text from the actual bound keys instead of a literal string.playground/8-key-bindings/run.php, running one form under--keys=default,--keys=vimor--keys=custom(a per-scope override sample), so the effect of each is visible side by side.->keys()usage, per-widget-type overrides, presets and validation rules) and regenerateddocs/architecture/architecture.puml/.svganddataflow-tui.puml/.svgto showKeyMap/KeyMapManageralongside the existing theme components.tests/phpunit/Unit/Input/KeyMapTest.phpand extendedFormTest,KeyStreamTest,ThemeRenderTest,WidgetFactoryTest,SelectWidgetTestandPauseWidgetTestto cover the new resolution, injection and derived-hint behavior.Before / After