fix: store email proposal bodies as documents so plain-text bodies keep their line breaks
Closed
FE
3d ago+57+57+01234567890123456789-27-27-01234567890123456789
Problem
When an agent or app proposes draft_email / send_email with a plain-text string body (e.g. Twenty for Twenty's meeting follow-ups), the approval card shows the whole email as one paragraph. If the person edits it first, it is also sent as one paragraph.
The email tool schema accepts a string body: "HTML markup is sent as-is, anything else as plain text". The server keeps that promise when it sends (convertEmailBodyToEmailDocument). The card didn't: it passed the raw string to the inline email editor, whose parseLegacyHtmlDocument read every string as HTML, and HTML ignores newlines.
Fix: one interpretation of a string body, at the edge
buildEmailProposal(server), the single entry point for every email proposal from agents and apps, converts the body with the sameconvertEmailBodyToEmailDocumentthe send path uses. A stored proposal always carries an email document. A body that can't be converted is rejected back to the proposer.AiChatToolCallApprovalEmailCardonly ever receives a document. It drops its string branch, the stored original body and the "send the original if unchanged" comparison. It serializes the document for the editor and parses it back on approve.INLINE_EMAIL_BODY_EDITOR_PROFILEdropsparseLegacyDocument(parseLegacyHtmlDocumentis deleted). Nothing reaches it as a non-canonical string any more: the composer already passed documents. It registersHtmlDocumentNode, so an HTML string proposal shows as the raw HTML block that will actually be sent instead of a lossy reparse. That node isn't in the block catalog, so the composer's insert menu is unchanged.
Breaking, accepted: proposals created before this change that still hold a string body open with an empty editor. Discard them and propose again.
Tests
build-inbox-message-tool-call-part.util.spec.ts: an app proposing a plain-text body gets a document with hard breaks.- Front
ai,activities/emailsandadvanced-text-editorsuites pass (1,373 tests); serverai/tool/tool-providerspecs pass, except suites that needtwenty-emails/twenty-client-sdkbuilt. Typecheck,oxlintandoxfmtare clean on the changed files.