Block chain-flow Continue when required fields are empty#76
Open
prakashUXtech wants to merge 2 commits into
Open
Block chain-flow Continue when required fields are empty#76prakashUXtech wants to merge 2 commits into
prakashUXtech wants to merge 2 commits into
Conversation
ChainExecutor.advance() now validates the current step's required form_fields against the entered formData before advancing. Empty or whitespace-only required values block the advance (returns null), record a per-field message under validationErrors, and leave history + context untouched. A valid advance clears the errors and proceeds as before. Steps without form_fields are never validated, so legacy raw-ui flow steps are unaffected. FlowRunner no longer fires the terminal action on a validation-blocked flow.submit (advance returns null in both cases; it now checks hasValidationErrors to tell them apart) and renders an inline, accessible summary of the missing fields inside the step card.
7ea995e to
50d1986
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.
What was broken
In agent-authored multi-step chat flows (chain-flow v2), clicking Continue with empty required fields advanced to the next step anyway. The runtime never checked required fields, so an empty Order ID or Refund amount sailed straight through and the flow moved on.
The fix
ChainExecutor.advance()now validates the current step's required form fields against the enteredformDatabefore it advances:advance()returnsnull, leaves history and accumulated context untouched, and records a per-field message under a newvalidationErrorsmap (with ahasValidationErrorsgetter).form_fieldsare never validated, so legacy raw-ui flow steps keep working unchanged. Validation is opt-in via the field set.Required-ness already flows end to end: the pocketpaw builder's
_form_fieldstampsrequiredonto each entry inform_fields, and that survives into the rendered step spec. No threading was needed. Note thatrequiredlives only inform_fields, not in the step's rawuitree, which is why the executor reads it offform_fields.FlowRunner.sveltegets two changes:flow.submitno longer fires the terminal action.advance()returnsnullboth at a real terminal step and on a validation block, so the runner now checkshasValidationErrorsto tell them apart. Before this, submitting a terminal step with an empty required field marked the whole flow complete.role="alert"so assistive tech announces it. The user sees what is missing instead of a Continue click that quietly does nothing.Tests
The repro lives in a separate commit so it is easy to see it go from red to green:
chain-executor.test.tsadds 6 cases covering the executor contract: empty required fields block, whitespace counts as empty, only missing fields are flagged, a full set advances and clears errors, context is recorded only on a successful advance, and a step with noform_fieldsis left alone.FlowRunner.test.ts, andRipple.flow.test.tswere updated alongside (the terminal moved from anemitevent to achatloop to match the production builder).All 40 tests across the three flow files pass. The full suite is 912/913 (the one failure is a pre-existing widget-manifest description-length check, unrelated to this change).
bun run checkshows no new type errors in either changed file.Scope
Internal runtime fix to the chain-flow executor and its host component. No public API surface changed.