[#12] Added a contextual key-binding help footer and '?' overlay.#33
[#12] Added a contextual key-binding help footer and '?' overlay.#33AlexSkrypnyk wants to merge 4 commits into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 46 minutes 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 selected for processing (1)
📝 WalkthroughWalkthroughAdds structured widget key hints, contextual footer rendering, a ChangesContextual help system
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
=======================================
Coverage 99.51% 99.52%
=======================================
Files 70 72 +2
Lines 2082 2106 +24
=======================================
+ Hits 2072 2096 +24
Misses 10 10 ☔ View full report in Codecov by Harness. |
Each widget contributes its own hint fragments through a typed 'Hint' list, replacing the 'rendersHint()' split and the hand-rolled per-widget hint strings. A single footer renders from the active context - the panel hub or the focused widget - and 'NumberWidget' now steps through remappable 'Increment'/'Decrement' actions so its hints are binding-driven too. A '?' key opens a form-scoped help overlay, and '->footer(FALSE)' turns the footer off.
Each widget's hints() spreads the base accept/cancel fragments from 'AbstractWidget::hints()' rather than repeating them, so the shared tail lives in one place. The rendered footers are unchanged.
'FilePickerWidget' now contributes a 'hints()' list (single vs multiple mode) instead of the removed 'rendersHint()', and the custom-theme example overrides 'renderHints()' in place of the folded-in 'renderStatusLine()'.
a777d77 to
f51fe76
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Builder/Form.php (1)
332-349: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider named arguments for the growing
Configconstructor call.The positional call now spans 16 arguments, several of matching types (
$color/$unicodeboth?bool,$submitLabel/$cancelLabelbothstring), making transposition errors easy to introduce silently as more fields are appended (this PR adds the 16th). Named arguments would make each value self-documenting and immune to reordering mistakes.♻️ Proposed refactor using named arguments
$config = new Config( - $this->title, - $this->subject, - $panels, - $this->fixups, - $this->theme, - $this->banner, - $this->buttons, - $this->submitLabel, - $this->cancelLabel, - $this->clearOnExit, - $this->color, - $this->unicode, - $this->envPrefix, - $this->themeOptions, - KeyMapManager::create($this->keymap, $this->keymapOverrides), - $this->footer, + title: $this->title, + subject: $this->subject, + panels: $panels, + fixups: $this->fixups, + theme: $this->theme, + banner: $this->banner, + buttons: $this->buttons, + submitLabel: $this->submitLabel, + cancelLabel: $this->cancelLabel, + clearOnExit: $this->clearOnExit, + color: $this->color, + unicode: $this->unicode, + envPrefix: $this->envPrefix, + themeOptions: $this->themeOptions, + keymap: KeyMapManager::create($this->keymap, $this->keymapOverrides), + footer: $this->footer, );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Builder/Form.php` around lines 332 - 349, Replace the positional Config construction in the Form builder with named arguments matching each Config constructor parameter, including title, subject, panels, fixups, theme, banner, buttons, labels, flags, color, environment prefix, theme options, keymap manager, and footer. Preserve the existing values while making the mapping explicit and safe to reorder.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Render/PanelController.php`:
- Around line 489-499: Replace the `$seen` associative array keyed by
`$field->type->value` in `helpSections()` with a list of enum cases, checking
duplicates via strict `in_array($field->type, $seen, TRUE)` and appending unseen
types directly. Keep `->value` out of this internal deduplication path.
---
Outside diff comments:
In `@src/Builder/Form.php`:
- Around line 332-349: Replace the positional Config construction in the Form
builder with named arguments matching each Config constructor parameter,
including title, subject, panels, fixups, theme, banner, buttons, labels, flags,
color, environment prefix, theme options, keymap manager, and footer. Preserve
the existing values while making the mapping explicit and safe to reorder.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: acba9099-0223-4276-9afe-7113ae1dd01c
📒 Files selected for processing (42)
README.mdplayground/2-custom-theme/OceanTheme.phpsrc/Builder/Form.phpsrc/Config/Config.phpsrc/Input/Action.phpsrc/Input/DefaultKeyMap.phpsrc/Input/Hint.phpsrc/Render/HelpSection.phpsrc/Render/PanelController.phpsrc/Theme/DefaultTheme.phpsrc/Widget/AbstractWidget.phpsrc/Widget/ConfirmWidget.phpsrc/Widget/FilePickerWidget.phpsrc/Widget/MultiSelectWidget.phpsrc/Widget/NumberWidget.phpsrc/Widget/PasswordWidget.phpsrc/Widget/PauseWidget.phpsrc/Widget/SearchWidget.phpsrc/Widget/SelectWidget.phpsrc/Widget/SuggestWidget.phpsrc/Widget/TextareaWidget.phpsrc/Widget/ToggleWidget.phpsrc/Widget/WidgetInterface.phptests/phpunit/Unit/Builder/FormTest.phptests/phpunit/Unit/Input/KeyMapTest.phptests/phpunit/Unit/Render/PanelControllerTest.phptests/phpunit/Unit/Theme/ThemeOptionsTest.phptests/phpunit/Unit/Theme/ThemeRenderTest.phptests/phpunit/Unit/Widget/ConfirmWidgetTest.phptests/phpunit/Unit/Widget/FilePickerWidgetTest.phptests/phpunit/Unit/Widget/MultiSearchWidgetTest.phptests/phpunit/Unit/Widget/MultiSelectWidgetTest.phptests/phpunit/Unit/Widget/NumberWidgetTest.phptests/phpunit/Unit/Widget/PasswordWidgetTest.phptests/phpunit/Unit/Widget/PauseWidgetTest.phptests/phpunit/Unit/Widget/SearchWidgetTest.phptests/phpunit/Unit/Widget/SelectWidgetTest.phptests/phpunit/Unit/Widget/SuggestWidgetTest.phptests/phpunit/Unit/Widget/TextWidgetTest.phptests/phpunit/Unit/Widget/TextareaWidgetTest.phptests/phpunit/Unit/Widget/ToggleWidgetTest.phptests/phpunit/Unit/Widget/WidgetFactoryTest.php
|
Closes #12
Summary
The TUI's key hints were fixed and partial: the hub only ever showed move/select/back, some widgets rendered their own hint line while others left the editor chrome to show a generic accept/cancel, and there was no way to discover a widget's less-obvious bindings. This adds a contextual key-binding help footer that shows exactly the keys valid in the current context (the panel hub or the focused widget editor), driven by a new typed
Hintvalue object that every widget contributes via ahints()method. A?key opens a form-scoped help overlay listing the hub and every widget type the form uses. The footer is theme-driven (Unicode + ASCII, respects remapped keys) and can be turned off with->footer(FALSE).Changes
Hintvalue object (src/Input/Hint.php) pairing a label with theAction(s) whose live keys illustrate it, plus newAction::Help,Action::IncrementandAction::Decrementcases;DefaultKeyMapbinds?toHelpin the navigation scope and the up/down arrows toIncrement/Decrementin theNumberfield scope, overriding base movement there.WidgetInterface::rendersHint(): boolwithhints(): list<Hint>; every widget now contributes its own ordered hint list, spreading the shared accept/cancel tail fromAbstractWidget::hints(), instead of a subset self-rendering and a subset deferring to a generic accept/cancel.NumberWidgetsteps through the remappableIncrement/Decrementactions rather than hard-coded arrow keys, and gained its ownkeyScope()so the field-scoped bindings apply.DefaultTheme::renderStatusLine()was replaced byrenderHints()(renders any list ofHintfragments against a scope's live bindings, dropping fragments whose actions are unbound), plus a newrenderHelp()overlay renderer;renderEditor()now takes the widget's hint list instead of arendersHintboolean. Added theHelpSectionrender DTO (src/Render/HelpSection.php) pairing a titled context with its bindings and hints.PanelControllerrenders one contextual footer per frame (hub hints or the focused widget's hints), handles?as a new help-overlay state that any key dismisses, and builds the overlay's sections (navigation plus each field type the current form uses, deduplicated in first-seen order). The footer and overlay are both gated on the newConfig::footerflag.Form::footer(bool $show)and the correspondingConfig::footerproperty (defaultTRUE) so the footer can be turned off form-wide.FilePickerWidget(its single/multiple-mode hints now come fromhints()) and the custom-theme playground example (OceanThemeoverridesrenderHints()in place of the folded-inrenderStatusLine()).ConfirmWidget,FilePickerWidget,MultiSelectWidget,NumberWidget,PasswordWidget,SearchWidget,SelectWidget,SuggestWidget,TextWidget,TextareaWidget,ToggleWidget,MultiSearchWidget), the hub footer, the help overlay open/close/list behaviour, and thefooter(FALSE)toggle; documented the footer and overlay in the README navigation section.Before / After
Summary by CodeRabbit
New Features
?help overlay showing navigation and field-specific shortcuts.->footer(FALSE).Documentation