Share one recipients editor across the email composer, approval cards and calendar
Based on main. Also carries the change from twentyhq/twenty#30415 (closed in favour of this stack): email proposal bodies are stored as documents, so plain-text bodies keep their line breaks, and the approval card only reads documents. twentyhq/twenty#30456 later replaces that server conversion with explicit body formats.
Problem
There were two To/Cc/Bcc editors. The composer used EmailRecipientsFieldInput (contact suggestions, drag between fields, chip keyboard navigation). The AI approval card and review deck used AiChatEmailRecipientsRow, a plain input with chips. On top of that, the drag-and-drop setup (sensors, plugins, handlers, drop context, dragged indices, excluded suggestion keys) was copied in the composer, the calendar composer and the field story.
Change
EmailRecipientsProviderowns the recipients of a group of fields (recipientsByFieldIdandonChange) plus all the drag-and-drop wiring. It exposes them throughEmailRecipientsContext, built with the existingcreateRequiredContext.EmailRecipientsFieldInputnow takes onlyfieldId,label,onSubmit,contextRecordandinputRef. It reads its recipients, drag state and excluded suggestion keys from the context, so a caller can no longer pass them inconsistently.EmailRecipientsFieldsis the To/Cc/Bcc group:{ recipientsByFieldId, onChange, onSubmit?, contextRecord?, readonly? }.- It owns the Cc/Bcc toggle: Cc and Bcc show when expanded, while a drag is in progress, or when either already has recipients.
- It has a read-only mode (
EmailRecipientsReadonlyFields) for sent or skipped emails in the review deck.
- Callers:
- The composer uses
EmailRecipientsFields.showCcBccis removed fromuseEmailComposerState. - The AI approval card and review deck use
EmailRecipientsFields.isCcBccExpandedis removed from the draft type.AiChatEmailRecipientsRowis deleted. Approval cards gain contact suggestions, drag between fields and chip keyboard navigation. - The calendar composer wraps its Guests field in
EmailRecipientsProvider.
- The composer uses
EmailRecipientsByFieldIdmoves frommoveEmailRecipientsBetweenFields.tstotypes/, andDraggedEmailRecipientsgets its own type.
Screenshots
From Storybook, before (twentyhq/twenty#30415) and after. The layout is unchanged on purpose; what changes is that the approval card now runs the composer's editor.
AI approval deck, typing in To. Before: a plain text box. After: the shared editor's autocomplete. It reads "No results" only because the story mocks no people.
| Before | After |
|---|---|
![]() | ![]() |
AI approval deck, Cc/Bcc expanded. Before: "Add recipient" placeholders on the old row. After: the same fields as the composer.
| Before | After |
|---|---|
![]() | ![]() |
Read-only review (sent or locked). Before: a "Cc/Bcc" toggle stayed on a card that can't be edited. After: EmailRecipientsReadonlyFields lists the recipients only.
| Before | After |
|---|---|
![]() | ![]() |
Unchanged on screen, now built on the same component: the email composer (Cc/Bcc expanded) and the calendar composer's Guests field.
| Email composer | Calendar guests |
|---|---|
![]() | ![]() |
Not in scope
- Campaigns: they target a message list, not addresses, so they keep their list picker.
- Workflow email steps: recipients are variable-capable text fields there. Moving them onto chips needs variable support in the chip input, which is a separate change.
Tests
- New
EmailRecipientsFields.test.tsx: Cc/Bcc revealed on demand and focused; shown when they already have recipients; removing a chip updates its field; read-only lists recipients without inputs or remove buttons. AiChatToolCallApprovalEmailCard.test.tsxnow mocks contact suggestions, renders inside aToastProviderand polyfillsPointerEvent, like other drag-and-drop tests.build-inbox-message-tool-call-part.util.spec.ts(from #30415): an app proposing a plain-text body gets a document with hard breaks.- The
ai,activities,side-paneland email-thread widget suites pass (1,845 tests). Typecheck,oxlintandoxfmtare clean on the changed files.
Generated by Claude Code







