Re-settled form logic in the interactive TUI after each accepted edit.#80
Conversation
Editing now recomputes derive rules, re-evaluates 'when' conditions and re-applies fix-ups through the engine, so fields show and hide live, derived values follow their sources, and an edited derive target pins as 'override' - matching what headless collection does. Condition-hidden fields no longer render as empty rows and contribute no answer, while keeping their settled values so a later activation surfaces them with their defaults. Surfaced the cancel button through the facade: 'Tui::interact()' now throws 'CancelException' (an 'InterruptException' subclass) instead of returning a cancelled session's answers exactly like a submitted form. Removed the unused field 'weight' (nothing ordered by it), made 'Scan' discovery return NULL for a missing directory like its sibling rules, dropped the incorrect 'multipleOf' from the agent schema (the step is a keyboard increment, not a value constraint), and fixed stale documentation references.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesThe PR adds engine-backed state resolution and interactive re-settling, including conditional visibility, derived-value overrides, fix-ups, active-field rendering, cursor clamping, and cancellation exceptions. It also removes field processing weight from public models and snapshots, clarifies discovery and schema behavior, and updates documentation and tests. Interactive engine flow
Field and answer contract cleanup
Discovery and schema contract corrections
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Tui
participant PanelController
participant Engine
User->>Tui: Edit field
Tui->>PanelController: Process accepted edit
PanelController->>Engine: settle(values, pinned)
Engine-->>PanelController: Settled values and active map
PanelController-->>User: Render active fields
User->>Tui: Cancel session
Tui-->>User: Raise CancelException
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 #80 +/- ##
==========================================
+ Coverage 98.18% 98.20% +0.01%
==========================================
Files 100 100
Lines 3306 3342 +36
==========================================
+ Hits 3246 3282 +36
Misses 60 60 ☔ View full report in Codecov by Harness. |
|
🚀 Deployed on https://6a5f7267228f863ad005e12e--tui-docs.netlify.app |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@docs/architecture/README.md`:
- Line 56: Clarify the interactive answer contract in the concluding “same
Answers object” wording: settled values for hidden fields remain retained
internally, but hidden fields are omitted from the returned active answers.
Apply this documentation change in docs/architecture/README.md at lines 56-56
and docs/content/architecture.mdx at lines 60-60, preserving the existing
headless parity description for visible fields.
In `@src/Engine/Engine.php`:
- Around line 109-137: Extract the shared derive-rule-building loop from
settle() into a helper such as deriveRulesOnly(array $fields), collecting only
fields whose derive property is non-null. Update settle() and deriveRules() to
use this helper, leaving deriveRules()’s pinned-value computation unchanged.
🪄 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: 0fad257e-2705-4e6f-88aa-0aeb5a9fa4f6
⛔ Files ignored due to path filters (4)
docs/architecture/architecture-dark.svgis excluded by!**/*.svgdocs/architecture/architecture.svgis excluded by!**/*.svgdocs/architecture/dataflow-tui-dark.svgis excluded by!**/*.svgdocs/architecture/dataflow-tui.svgis excluded by!**/*.svg
📒 Files selected for processing (30)
AGENTS.mddocs/architecture/README.mddocs/architecture/architecture.pumldocs/architecture/dataflow-tui.pumldocs/content/architecture.mdxdocs/content/configuration.mdxdocs/content/installation.mdxdocs/content/self-describing-answers.mdxdocs/content/widgets/pause.mdxplayground/01-quickstart.phpsrc/Answers/Answer.phpsrc/Answers/Answers.phpsrc/Builder/FieldBuilder.phpsrc/CancelException.phpsrc/Discovery/Scan.phpsrc/Engine/Engine.phpsrc/InterruptException.phpsrc/Model/Field.phpsrc/Render/PanelController.phpsrc/Schema/AgentHelp.phpsrc/Translation/Translator.phpsrc/Tui.phptests/phpunit/Unit/Answers/AnswersTest.phptests/phpunit/Unit/Builder/FormTest.phptests/phpunit/Unit/Discovery/DiscoverSpecsTest.phptests/phpunit/Unit/Engine/EngineConditionalTest.phptests/phpunit/Unit/Render/PanelControllerTest.phptests/phpunit/Unit/Schema/AgentHelpTest.phptests/phpunit/Unit/Testing/TuiTesterTest.phptests/phpunit/Unit/TuiTest.php
💤 Files with no reviewable changes (2)
- src/Builder/FieldBuilder.php
- src/Model/Field.php
…d the interactive answers contract.
This comment has been minimized.
This comment has been minimized.
|
@coderabbitai review |
✅ Action performedReview finished.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. You're currently rate limited under our Fair Usage Limits Policy. Your recent PR review activity is in the 95th percentile or higher among CodeRabbit users, so adaptive limits apply. Your next review will be available in 44 minutes. |
|
https://github.com/coderabbitai full review |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@docs/architecture/README.md`:
- Line 56: The architecture walkthroughs must describe the same current
Tui/ThemeManager theme configuration contract. Update
docs/architecture/README.md lines 56-56 and docs/content/architecture.mdx lines
60-60 so both use the current theme names and assign terminal capability
detection to the correct component, replacing the conflicting “dark”/“light” and
ThemeManager detection wording in the MDX page.
🪄 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: e03296b7-27ca-4d53-954d-73f91bec048e
⛔ Files ignored due to path filters (4)
docs/architecture/architecture-dark.svgis excluded by!**/*.svgdocs/architecture/architecture.svgis excluded by!**/*.svgdocs/architecture/dataflow-tui-dark.svgis excluded by!**/*.svgdocs/architecture/dataflow-tui.svgis excluded by!**/*.svg
📒 Files selected for processing (30)
AGENTS.mddocs/architecture/README.mddocs/architecture/architecture.pumldocs/architecture/dataflow-tui.pumldocs/content/architecture.mdxdocs/content/configuration.mdxdocs/content/installation.mdxdocs/content/self-describing-answers.mdxdocs/content/widgets/pause.mdxplayground/01-quickstart.phpsrc/Answers/Answer.phpsrc/Answers/Answers.phpsrc/Builder/FieldBuilder.phpsrc/CancelException.phpsrc/Discovery/Scan.phpsrc/Engine/Engine.phpsrc/InterruptException.phpsrc/Model/Field.phpsrc/Render/PanelController.phpsrc/Schema/AgentHelp.phpsrc/Translation/Translator.phpsrc/Tui.phptests/phpunit/Unit/Answers/AnswersTest.phptests/phpunit/Unit/Builder/FormTest.phptests/phpunit/Unit/Discovery/DiscoverSpecsTest.phptests/phpunit/Unit/Engine/EngineConditionalTest.phptests/phpunit/Unit/Render/PanelControllerTest.phptests/phpunit/Unit/Schema/AgentHelpTest.phptests/phpunit/Unit/Testing/TuiTesterTest.phptests/phpunit/Unit/TuiTest.php
💤 Files with no reviewable changes (2)
- src/Builder/FieldBuilder.php
- src/Model/Field.php
|
Summary
The interactive panel controller now re-settles the form's logic through the
Engineafter every accepted edit, so an editing session in the TUI behaves exactly like a headless collection: derive rules recompute,whenconditions show and hide fields live, and fix-ups re-apply. Condition-hidden fields no longer render as phantom empty rows or contribute answers, and editing a derive-ruled field pins it withProvenance::Overridethe same way a headless input does.Tui::interact()now throwsCancelException(a subclass ofInterruptException) when the session ends via the Cancel button, so a cancelled session can no longer be mistaken for a submitted one. Alongside this, the unusedField::$weightAPI was removed,Scandiscovery now returnsNULLfor a missing directory instead of an empty list, the agent JSON schema no longer emits an incorrectmultipleOffor a number field's step, and the architecture diagrams and docs were regenerated to match.Changes
Engine
Engine::settle(), which re-runs derive rules (skipping pinned targets),whenconditions and fix-ups over an edited value set to a fixpoint, returning the active map and settled values.Engine::resolveState(), the full-map twin ofcollect(): the same resolution and settling, but keeping every field - including inactive ones, which retain their settled value and provenance so a later activation change can surface them without re-resolving.Interactive controller
PanelControllernow owns anEngineinstance and an$activemap, settled once at construction (via a newresettle()method) and again after every accepted edit and after a modal dialog closes.answers()filters out fields whose condition currently fails, matching what headless collection returns, while the controller keeps their settled values internally so a later activation surfaces them intact.viewPanel()builds a per-frame filtered copy of the panel tree containing only currently-active fields (recursively), used by both the hub and modal frame renderers so hidden fields never render as empty rows.moveCursor(),activate()) and item counting now go throughitemCountFor()/visibleFields()instead of the raw panel field list, so the cursor clamps correctly when a condition hides the field it was on.Provenance::Overrideinstead ofProvenance::Edited, mirroring how a headless input to that field is recorded.Tui::controller()seeds the controller fromEngine::resolveState()instead ofcollect(), so an inactive field's default is available the moment its condition later turns true.Cancel signal
src/CancelException.php, aCancelException extends InterruptExceptionthrown when the session ends via the Cancel button rather than a submit.Tui::interact()now checks$controller->isCancelled()after the run loop ends and throwsCancelExceptioninstead of returning the session's answers.Discovery
Scan::discover()returnsNULLfor a missing directory instead of[], aligning it with its sibling discovery rules whereNULLmeans "nothing to discover" and[]means a genuine empty result from an existing, scannable directory.Schema
AgentHelpno longer emitsmultipleOffor aNumberBoundsfield'sstep, since the step is a keyboard increment for the interactive editor, not a value constraint the collection enforces.Field weight removal
weight()builder method and the$weightproperty fromFieldBuilderandField, and its propagation into theAnswer/Answerssnapshot - nothing in the codebase ordered by it.Docs and diagrams
docs/architecture/architecture.puml/.svgto add thePanelController -> Enginedependency, anddocs/architecture/dataflow-tui.puml/.svgto add the settle step after an accepted edit.docs/architecture/README.md,docs/content/architecture.mdx,docs/content/configuration.mdx,docs/content/installation.mdx,docs/content/self-describing-answers.mdx,docs/content/widgets/pause.mdx,AGENTS.mdandplayground/01-quickstart.phpto drop staleweight()references, document the Cancel/CancelExceptionbehaviour, and fix a stale playground autoloader path.Before / After
Summary by CodeRabbit
New Features
Changes
stepno longer constrains generated JSON schema viamultipleOf.Documentation
Tests