[#13] Added bounds, step and increment keys to the number widget.#29
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 12 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 (19)
✨ 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 #29 +/- ##
==========================================
+ Coverage 98.92% 99.23% +0.31%
==========================================
Files 59 60 +1
Lines 1493 1578 +85
==========================================
+ Hits 1477 1566 +89
+ Misses 16 12 -4 ☔ View full report in Codecov by Harness. |
Closes #13
Summary
Adds optional
min,maxandstepbounds to number fields, enabling Up/Down arrow-key stepping and inline range validation in the interactive widget, with matching enforcement in the headless engine, the schema validator and the generated JSON schema.A new
NumberBoundsvalue object centralizes the range arithmetic, the human-readable range phrase, and a sharedviolation()check so every enforcement surface - widget, engine and validator - agrees on the same rule, including for float values.Fields that declare no bounds keep their existing plain-integer behaviour: the arrow keys stay inert and no range validation runs.
Changes
DrevOps\Tui\Config\NumberBounds, a readonly value object holding optionalmin/max/stepwithcontains(),describe(),violation(),clamp()andstep()methods.FieldBuilder::min(),::max()and::step()methods, plus abuildBounds()step that assembles aNumberBoundsonly when at least one of the three is declared.FieldBuilder::buildBounds()throwsConfigExceptionat config time whenminexceedsmax, or whenstepis not positive.boundsproperty toConfig\Field, threaded throughWidgetFactoryintoNumberWidget.NumberWidgetnow handlesUp/Downkeys via a newadjust()method that steps the value by the bounds' step (default1), clamped to the range; it renders its own key-hint line (↑/↓ adjust · enter accept · esc cancel) only when bounds are declared, viarendersHint().NumberWidget::accept()rejects an out-of-range value inline with a message built fromNumberBounds::describe().TextWidget::caretLine()soNumberWidget::view()can reuse the caret-rendering logic while adding its own hint and error rows.Engine::validateValue()and the newSchemaValidator::checkBounds()both callNumberBounds::violation(), so headless--prompts/environment input and JSON-schema-driven validation reject out-of-range values with the same message.SchemaGeneratoremitsmin,maxandstepkeys per field, and the newAgentHelp::rangeNote()appends a compact range annotation (e.g.(between 1 and 10, step 2)) to the agent-facing field help.NumberBounds::violation()narrows its input toint|floatbefore checking, so a non-numeric value passes through untouched while a float is enforced identically to an int - closing a bypass where an out-of-range float could previously slip past bounds enforcement.README.mdwith a usage example.Before / After