feat(gmail): add --html flag for HTML email composition#417
feat(gmail): add --html flag for HTML email composition#417malob wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
Add --html flag to +send, +reply, +reply-all, and +forward, enabling HTML email composition. When set, --body is treated as HTML content and the Content-Type switches from text/plain to text/html. For replies and forwards, the quoted/forwarded block matches Gmail web UI fidelity: gmail_quote_container class, gmail_sendername structure, mailto links in attribution and metadata, <div dir="ltr"> wrapper on quoted content, and RFC 2822 dates reformatted to Gmail's human-friendly style. When the original message has no HTML body, plain text is HTML-escaped with <br> line breaks as a fallback (with a stderr diagnostic).
🦋 Changeset detectedLatest commit: 03965b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the Gmail CLI commands by introducing an Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is an excellent pull request that adds a significant new feature for composing HTML emails. The changes are well-structured, with shared logic correctly refactored into the mod.rs module for reuse across the send, reply, and forward commands. The implementation pays close attention to fidelity with the Gmail web UI, including details like CSS classes, date formatting, and mailto links. Security considerations, such as HTML escaping of headers, are also handled correctly. The addition of comprehensive tests for the new HTML functionality and helper utilities is commendable. I have reviewed the code for critical and high-severity issues and found none. The implementation is robust and of high quality.
Description
Adds an
--htmlflag to all four Gmail composition commands (+send,+reply,+reply-all,+forward). When set,--bodyis treated as HTML content andContent-Typeswitches fromtext/plaintotext/html.For
+send, this is straightforward — the flag just changes the content type.For
+reply,+reply-all, and+forward, the flag also changes how thequoted/forwarded block is constructed. Instead of plain-text quoting, the HTML
output matches Gmail web UI fidelity:
gmail_quote/gmail_quote_containerCSS classes on the outer divgmail_sendernamestructure on the forwarded From line (<strong>+<span>)mailto:links on email addresses in reply attribution and forward metadata<div dir="ltr">wrapper on quoted reply content<br>separator between user body and quoted/forwarded block (not\r\n\r\n)When the original message has an HTML body (
multipart/alternative), it is useddirectly in the quoted/forwarded block. When there is no HTML part, the plain text
body is HTML-escaped with
<br>line breaks as a fallback (with a stderr diagnosticso the user knows the output is a conversion, not the original formatting).
How the fidelity targets were determined
The HTML structure was reverse-engineered from real Gmail web UI messages — I examined
the raw RFC 2822 bodies of replies and forwards sent from the Gmail web interface and
matched the class names, element nesting, and attribute patterns. A few details were
intentionally skipped as not worth replicating:
<div class="msg{id}">wrapper on forwarded bodies — Gmail JS internal, no rendering effectcid:image references will appear broken in quoted/forwarded HTML (documentedin SKILL.md tips as a known limitation; externally hosted images are unaffected)
Shared helpers extracted to
mod.rsThe HTML formatting required several shared helpers in
mod.rs(allpub(super)): HTMLescaping, MIME tree walking for
text/htmlextraction, mailto link formatting, RFC 5322address parsing, and date reformatting via
chrono(already a direct dependency).split_mailbox_listwas promoted fromreply.rsto shared scope, which also fixed alatent bug where naive
split(',')would break on quoted commas in display names like"Doe, John" <john@example.com>.Live testing
Tested on live emails using
+reply --htmland+forward --htmlagainst real threads.Both rendered correctly in the Gmail web UI — quoted blocks appeared with proper formatting,
attribution lines had clickable mailto links, and the overall structure matched native
Gmail replies/forwards.
Checklist:
AGENTS.mdguidelines (no generatedgoogle-*crates).cargo fmt --allto format the code perfectly.cargo clippy -- -D warningsand resolved all warnings.pnpx changeset) to document my changes.