Uh oh!
There was an error while loading. Please reload this page.
fix(gmail): send emails as multipart/alternative so they render full-width - #4611
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds helpers to safely convert between plain text and HTML ( Updates attachment handling to use Reviewed by Cursor Bugbot for commit 01ca2dd. Configure here. |
Uh oh!
There was an error while loading. Please reload this page.
…ding compound entities
waleedlatif1
commented
May 15, 2026
waleedlatif1
commented
May 15, 2026
@cursor review |
Greptile SummaryThis PR fixes the narrow hard-wrapped rendering issue in Gmail by switching both the send and draft tools from bare
Confidence Score: 5/5Safe to merge — the change is backwards-compatible (same tool params, same response shape), the MIME structure follows RFC 2046, and the new encoding path is well-covered by tests that decode real wire output. The MIME restructuring is straightforward and localized to two builder functions. Both the attachment and non-attachment paths produce valid RFC 2046 MIME. Base64 encoding correctly handles arbitrary UTF-8. The duplicate MIME-Version header that existed in the old else branch of buildMimeMessage is silently cleaned up as a side effect. No pre-existing callers are broken since the public API surface is unchanged. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[buildSimpleEmailMessage / buildMimeMessage] --> B{Has attachments?}
B -- No --> C[multipart/alternative]
B -- Yes --> D[multipart/mixed]
D --> E[multipart/alternative nested part]
D --> F[attachment parts base64 encoded]
C --> G[text/plain base64 + UTF-8]
C --> H[text/html base64 + UTF-8]
E --> G
E --> H
I[contentType = text or undefined] --> J[plainTextToHtml blank lines to p newlines to br]
I --> K[plain = body as-is]
L[contentType = html] --> M[htmlToPlainText strip tags decode entities]
L --> N[html = body as-is]
J --> H
K --> G
M --> G
N --> H
Reviews (2): Last reviewed commit: "fix(gmail): encode body parts as base64 ..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 15, 2026
waleedlatif1
commented
May 15, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 02b88f9. Configure here.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 01ca2dd. Configure here.
Summary
text/plain, which Gmail renders in a narrow hard-wrapped column — LLM-generated bodies looked cropped width-wise compared to hand-composed emails.multipart/alternative(text/plain first, text/html last, per RFC 2046) so HTML clients render flowed paragraphs while plain-text-only clients keep the original body as the fallback. Attachments now nest asmultipart/mixed → multipart/alternative + parts, the canonical Gmail API structure.Type of Change
Testing
Added 11 unit tests for the new helpers and both build functions (15/15 pass). Decoded real wire output to confirm MIME structure.
bun run check:api-validation:strictpasses.Checklist