Repository navigation
Conversation
AgentMail replies were delivered as text/plain only, so Markdown-authored agent replies reached recipients as literal **bold**, '- item' lists and pipe tables. The reply API already accepts an html body: render the same Markdown and send both parts. Adds src/channel/src/markdown-html.ts, a dependency-free renderer covering headings, emphasis, inline/fenced code, links and bare URLs, lists, pipe tables, blockquotes, rules and paragraphs; all content is HTML-escaped before formatting and links are restricted to http(s). The wrapper uses a presentation table with text-align:left and no max-width + auto margins, because Gmail honours those and centres the entire body. text is still sent in every case, so text-only clients and archives are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Send outbound replies with an HTML body (multipart/alternative)
What this changes
AgentMail replies are delivered as
text/plainonly. The provider's reply API already accepts anhtmlbody — this PR uses it, passing a rendered version of the same Markdown the agent produced:A new dependency-free renderer (
src/channel/src/markdown-html.ts) covers what agent repliesactually contain: headings, bold/italic/strikethrough, inline code, fenced code, links (explicit and
bare URLs), bullet/numbered lists, pipe tables, blockquotes, horizontal rules and paragraphs.
Why
Agent replies are Markdown. In any HTML-capable client that means recipients currently see literal
**bold**,- itemand| table |syntax — an email that looks broken rather than formatted.Supplying both parts is the standard fix: HTML clients render the formatted version, text-only
clients and archives keep the readable plain-text alternative.
Safety / compatibility
textis still sent in every case, so this is additive — text-only clients, mail archives andproviders that strip HTML are unaffected.
htmlis only built when there is text).marked, no DOM).http(s)URLs. Raw input like<script>is escaped, not passed through.Rendering notes
role="presentation"table shell withtext-align:leftand nomax-width+margin:0 autowrapper: Gmail honours those two properties and centres the entiremessage body, which reads wrong for a business email. An optional
maxWidthoption anchors acolumn to the left edge instead.
<style>block), since several clients drop head CSS.Testing
src/channel/src/markdown-html.test.tscovers headings/emphasis/lists, escaping, autolinkpunctuation, explicit links, inline code, pipe tables, fenced code, paragraph line breaks, the
left-aligned shell, and the optional max width.
npm test(vitest) — new suite only; no existing tests touched.Gmail renders the HTML and the plain-text alternative is intact.
Follow-ups (not in this PR)
linkColor/maxWidththrough channel config.htmlFormatconfig enum defaulting to
"text"; happy to add that if it is the preferred shape.