Skip to content

Block chain-flow Continue when required fields are empty#76

Open
prakashUXtech wants to merge 2 commits into
mainfrom
fix/flow-required-validation
Open

Block chain-flow Continue when required fields are empty#76
prakashUXtech wants to merge 2 commits into
mainfrom
fix/flow-required-validation

Conversation

@prakashUXtech

Copy link
Copy Markdown
Contributor

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 entered formData before it advances:

  • A required field that is missing, blank, or whitespace-only blocks the advance. advance() returns null, leaves history and accumulated context untouched, and records a per-field message under a new validationErrors map (with a hasValidationErrors getter).
  • A valid advance clears the errors and proceeds exactly as before.
  • Steps with no form_fields are 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_field stamps required onto each entry in form_fields, and that survives into the rendered step spec. No threading was needed. Note that required lives only in form_fields, not in the step's raw ui tree, which is why the executor reads it off form_fields.

FlowRunner.svelte gets two changes:

  1. A blocked flow.submit no longer fires the terminal action. advance() returns null both at a real terminal step and on a validation block, so the runner now checks hasValidationErrors to tell them apart. Before this, submitting a terminal step with an empty required field marked the whole flow complete.
  2. When the executor reports validation errors, the runner renders an inline summary inside the step card listing each missing field, with 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.ts adds 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 no form_fields is left alone.
  • The shared onboarding-wizard fixture, FlowRunner.test.ts, and Ripple.flow.test.ts were updated alongside (the terminal moved from an emit event to a chat loop 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 check shows 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.

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.
@prakashUXtech prakashUXtech force-pushed the fix/flow-required-validation branch from 7ea995e to 50d1986 Compare June 18, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant