Skip to content

feat: one tools to interact with F0Form#3683

Merged
sauldom102 merged 18 commits intomainfrom
one-tools-to-interact-with-f0-forms
Mar 23, 2026
Merged

feat: one tools to interact with F0Form#3683
sauldom102 merged 18 commits intomainfrom
one-tools-to-interact-with-f0-forms

Conversation

@sauldom102
Copy link
Copy Markdown
Collaborator

@sauldom102 sauldom102 commented Mar 16, 2026

AI tools to interact with F0 Forms

Enables the One AI assistant to discover, fill, submit, and present F0 forms on the current page — bridging the gap between conversational AI and structured data entry.

Screen.Recording.2026-03-19.at.17.21.42.mov

What changed

AI Form Registry — New central registry (F0AiFormRegistry) that tracks all mounted F0 forms. Each form auto-registers its ref, schema, sections, current values, errors, and dirty state. The registry also supports virtual form definitions — forms the AI can present even when they're not yet rendered.

Four new CopilotKit tools:

  • formFill — Sets field values on a form by name, with full Zod validation and per-field error reporting
  • formSubmit — Submits a form programmatically, returning success/error status
  • formGetState — Reads current values, errors, dirty state, and schema for any registered form
  • presentForm — Opens a form (via F0AiFormPresenter) from a virtual definition, optionally passing params to async defaultValues

Form context in co-agent shared state — Form descriptions are pushed into CopilotKit's co-agent state via useCoAgent + setState, giving the backend agent structured access to what forms are active and their current state.

Async defaultValues with defaultValuesParamsSchemauseF0FormDefinition now supports async default values ((signal) => Promise<T>) with skeleton loading placeholders. When defaultValuesParamsSchema is provided, the callback receives typed params instead (({ employeeId }) => Promise<T>), enabling the AI to present a form pre-filled with entity-specific data.

customFieldName on all field types — Any field (not just fieldType: "custom") can now declare a customFieldName. The form-level renderCustomField callback dispatches on it, allowing consuming apps to inject custom data sources or rendering into standard fields (e.g. a select that gets its options from an external source).

useF0Form hook — New hook for external programmatic control: submit(), reset(), isDirty(), isSubmitting, hasErrors, plus a formRef to wire into <F0Form>.

Why it matters

Until now, the AI assistant couldn't interact with forms — the most common data-entry surface in Factorial. This unlocks workflows like "fill out a time-off request for next Monday" or "update this employee's role to Staff Engineer and save", going from multi-click manual processes to single-turn conversational actions.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat react Changes affect packages/react

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants