Skip to content

Expose screening results to custom form components - #574

Merged
prestoncabe merged 7 commits into
mainfrom
555-screening-results-service
Oct 22, 2026
Merged

prestoncabe merged 7 commits into
mainfrom
555-screening-results-service

Conversation

@prestoncabe

@prestoncabe prestoncabe commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Custom form-js fields can now read screening results through a per-form service and reactive Preact hook in published screeners, preview, and the editor canvas. This provides the shared results interface for the upcoming Next steps and Print summary components.

Closes #555. Third PR for #552, following #573. The Next steps component follows in #556.

The service exposes the latest results, pending state, and evaluation failures. It retains previous results while the latest answers are pending, including debounce and failed requests; the parent screening flows continue rejecting stale responses. Fields receive frozen copies, and updates neither import schemas nor submit answers. Service instances are isolated between forms, and fields render an empty snapshot when the module is unavailable.

Editor samples use configured benefit IDs and names, with clearly named examples filling any missing eligible, ineligible, or undecided outcomes. Benefit list loads update the editor's cached benefits without an extra tab-switch fetch or loss of unsaved form changes. Samples stay outside answers and saved schemas.

The hook uses the viewer's shared FormContext and useSyncExternalStore, since form-js 1.15's exported useService uses an editor-only context. Integration tests exercise actual custom Preact fields in both live renderers and the editor canvas.

Validation:

  • All 30 focused tests passed across five files, covering service behavior, real form renderers, editor wiring, and screening completion flows.
  • Production frontend build passed.
  • git diff --check passed.
  • All five CI checks passed: full frontend, builder API, library API, end-to-end, and documentation.

prestoncabe and others added 7 commits October 22, 2026 16:25
Clicking Form Editor forced a full screener refetch to pick up benefit
changes, which hid the tabs behind a spinner on every visit and only
refreshed that one tab. Benefit list loads now update the editor's
cached screener directly, so every tab sees current benefits without a
network round trip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The published and preview renderers each looked up the service and
created the same effect. A shared connectScreeningResults helper keeps
future changes to what reaches custom fields in one place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a failed evaluation the snapshot stayed pending with nothing to
distinguish it from a request in flight, so fields showing an updating
state would wait indefinitely. The snapshot now carries a failed flag
from the published screener and preview, cleared when an evaluation
succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
useScreeningResults looked up its service strictly, so any form built
without screeningResultsModule failed to render with "No provider for
screeningResults". The hook now falls back to an empty snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Samples took their outcome from each configured benefit's position, so
a screener with one or two benefits never showed an ineligible or
undecided sample in the editing canvas. Clearly named examples now
fill in any outcome the configured benefits don't cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The snapshot froze only its top level, so a field that sorted or
annotated results in place changed the parent's signal value without
notifying it, letting the results panel and question hiding drift from
the API response. Live results are now deep-copied and deep-frozen once
per evaluation, and editor samples are frozen too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@prestoncabe
prestoncabe marked this pull request as ready for review October 22, 2026 21:41
@prestoncabe
prestoncabe merged commit b6bcf34 into main Oct 22, 2026
5 checks passed
@prestoncabe
prestoncabe deleted the 555-screening-results-service branch October 22, 2026 21:44
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.

Expose screening results to form-js custom components

1 participant