Fix #58: mapValidated on MultipleChoice prompts and move error display to bottom#59
Open
kevin-lee wants to merge 1 commit intoneandertech:mainfrom
Open
Fix #58: mapValidated on MultipleChoice prompts and move error display to bottom#59kevin-lee wants to merge 1 commit intoneandertech:mainfrom
mapValidated on MultipleChoice prompts and move error display to bottom#59kevin-lee wants to merge 1 commit intoneandertech:mainfrom
Conversation
…ve error display to bottom Two bugs existed in `PromptFramework.mapValidated` when used with `MultipleChoice` prompts: 1. After a validation rejection showed an error message, subsequent non-ENTER actions (TAB toggle, arrow keys) did not clear the error. The inner framework's status was permanently stuck at `Running(Left(err))` because non-ENTER handlers use `identity` for status, causing stale error rendering and visual artifacts (duplicate/shifted items on terminal). 2. After a first rejection, selecting then deselecting and pressing ENTER again produced no visible feedback because the rendering was already identical to the displayed error state. Fix in `PromptFramework.mapValidated` (two coordinated changes): - `renderState`: translate the outer wrapper's `Running(Left(err))` status directly into an inner `self.Status.Running(Left(err))` for rendering, instead of always reading `self.currentStatus()` which could be stale. - `handleEvent`: backward-propagate `self.Status.Init` instead of `self.Status.Running(Left(err))`, guarded by `innerWasFinished` to only apply when the inner was actually `Finished` (not when it was `Running` with its own validation error, e.g. `InteractiveTextInput`). Fix in `InteractiveMultipleChoice.renderState`: - Move the error message rendering from between instructions and options to after the options list. When no error is present, a blank line is rendered in its place. This keeps the line count constant across error/non-error states, preventing terminal scroll-induced cursor offset issues that caused duplicate rendering when the prompt was near the terminal bottom. Also adds a `validated-multi` interactive example for manual testing.
5ce1547 to
022c09e
Compare
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.
Fix #58:
mapValidatedonMultipleChoiceprompts and move error display to bottomBug:
cue4s-multiple-choice-bug.mp4
Why was the error moved to the bottom?
After the first fix, the list rendering was fine, but it had another issue. Please watch this video.
cue4s-multiple-choice-bug-fixed-but-another-bug.mp4
The error message at the bottom (SOLUTION IN THIS PR)
This is a demo of the fix that this PR offers.
cue4s-multiple-choice-bug-fixed-all.mp4
Two bugs existed in
PromptFramework.mapValidatedwhen used withMultipleChoiceprompts:After a validation rejection showed an error message, subsequent non-ENTER
actions (TAB toggle, arrow keys) did not clear the error. The inner
framework's status was permanently stuck at
Running(Left(err))becausenon-ENTER handlers use
identityfor status, causing stale error renderingand visual artifacts (duplicate/shifted items on terminal).
After a first rejection, selecting then deselecting and pressing ENTER again
produced no visible feedback because the rendering was already identical to
the displayed error state.
Fix in
PromptFramework.mapValidated(two coordinated changes):renderState: translate the outer wrapper'sRunning(Left(err))statusdirectly into an inner
self.Status.Running(Left(err))for rendering,instead of always reading
self.currentStatus()which could be stale.handleEvent: backward-propagateself.Status.Initinstead ofself.Status.Running(Left(err)), guarded byinnerWasFinishedto onlyapply when the inner was actually
Finished(not when it wasRunningwith its own validation error, e.g.
InteractiveTextInput).Fix in
InteractiveMultipleChoice.renderState:after the options list. When no error is present, a blank line is rendered
in its place. This keeps the line count constant across error/non-error
states, preventing terminal scroll-induced cursor offset issues that caused
duplicate rendering when the prompt was near the terminal bottom.
Also adds a
validated-multiinteractive example for manual testing.