Skip to content

Comments

feat(CoCreationForm): add entity-select question type#3399

Draft
Rogermax wants to merge 1 commit intomainfrom
fct-cocreation-employee-question
Draft

feat(CoCreationForm): add entity-select question type#3399
Rogermax wants to merge 1 commit intomainfrom
fct-cocreation-employee-question

Conversation

@Rogermax
Copy link
Contributor

Summary

  • Adds new entity-select (single) and entity-select-multi question types to CoCreationForm
  • Edit mode: shows a dashed-border placeholder ("Respondents will see a person selector here")
  • Answer mode: renders a full EntitySelect component with search, avatars, and selection
  • Entities are provided by the consuming application via props (not stored in the form schema)
  • Includes Storybook stories for edit mode, answer mode single, and answer mode multi

Design decisions

The entity selector is fundamentally different from other question types because:

  1. The "options" (employees) come from an external API, not from the form schema
  2. The AI co-creation agent doesn't need to know the employee list — it just declares "put an employee selector here"
  3. The consuming app (Factorial) is responsible for passing entities and optionally onLoadEntities when rendering

This means in the schema/JSON the AI manipulates, an entity-select question is simply:

{ "type": "entity-select", "label": "Project manager", "id": "q1" }

No options array needed. The frontend wires in the employee data at render time.

Changes

New files

  • EntitySelectQuestion/index.tsx — component with edit placeholder + EntitySelect in answer mode
  • EntitySelectQuestion/types.ts — props including entities, groups, onLoadEntities
  • EntitySelectQuestion/index.stories.tsx — 3 stories with mock employees

Modified files

  • types.ts — added entity-select and entity-select-multi to types
  • Question/index.tsx — added switch cases
  • constants.ts — added to "Add question" menu with Person icon
  • lib.ts — added defaults
  • i18n-provider-defaults.ts — added translations

Test plan

  • Check Storybook stories under CoCreationForm/EntitySelectQuestion
  • Verify edit mode shows placeholder
  • Verify answer mode renders EntitySelect with mock employees
  • Verify entity-select types appear in the "Add question" menu
  • TypeScript compiles cleanly (pnpm tsc)

🤖 Generated with Claude Code

Add new "entity-select" and "entity-select-multi" question types to
CoCreationForm using EntitySelect component. In edit mode, shows a
placeholder preview. In answer mode, renders a full entity selector
with search, avatars, and single/multi selection. Entities are provided
by the consuming application via props.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added feat react Changes affect packages/react labels Feb 10, 2026
@github-actions
Copy link
Contributor

✅ No New Circular Dependencies

No new circular dependencies detected. Current count: 0

@github-actions
Copy link
Contributor

📦 Alpha Package Version Published

Use pnpm i github:factorialco/f0#npm/alpha-pr-3399 to install the package

Use pnpm i github:factorialco/f0#2c1c3027c29c7252c952581d56e4093772d87a59 to install this specific commit

@github-actions
Copy link
Contributor

🔍 Visual review for your branch is published 🔍

Here are the links to:

@github-actions
Copy link
Contributor

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 37.26% 6603 / 17718
🔵 Statements 36.67% 6744 / 18389
🔵 Functions 27.85% 1400 / 5026
🔵 Branches 26.43% 3678 / 13915
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/lib/providers/i18n/i18n-provider-defaults.ts 100% 100% 100% 100%
packages/react/src/sds/CoCreationForm/constants.ts 0% 100% 0% 0% 16-72
packages/react/src/sds/CoCreationForm/lib.ts 0% 0% 0% 0% 5-132
packages/react/src/sds/CoCreationForm/types.ts 100% 100% 100% 100%
packages/react/src/sds/CoCreationForm/EntitySelectQuestion/index.tsx 0% 0% 0% 0% 17-131
packages/react/src/sds/CoCreationForm/EntitySelectQuestion/types.ts 100% 100% 100% 100%
packages/react/src/sds/CoCreationForm/Question/index.tsx 0% 0% 0% 0% 23-43
Generated in workflow #10781 for commit 509eae5 by the Vitest Coverage Report Action

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.

1 participant