feat(gmail): add recipient management flags and extract shared message builder#362
feat(gmail): add recipient management flags and extract shared message builder#362malob wants to merge 2 commits intogoogleworkspace:mainfrom
Conversation
Add --cc and --bcc to +send, --to and --bcc to +reply and +reply-all, and --bcc to +forward. This brings all four Gmail helpers to feature parity for basic recipient management. Key behaviors: - --to on reply/reply-all is additive (appends to auto-computed To) - --remove only affects auto-computed recipients, not explicit flags - Dedup with priority To > CC > BCC via new dedup_recipients() - Validation deferred until after all additions and dedup - Empty/whitespace --cc/--bcc/--to filtered to None at parse time - BCC header included in raw message (Gmail API strips before delivery) Also includes: - CAUTION boxes in all four SKILL.md files - SendConfig visibility narrowed to pub(super) - Consistent "email address(es)" wording across clap help and SKILL.md
…ssues Extract duplicated header-construction logic from send.rs, reply.rs, and forward.rs into a shared MessageBuilder in mod.rs. This centralizes CRLF header-injection sanitization and RFC 2047 subject encoding that were previously inconsistent across the three paths. Additional changes: - Fix silent auth failure in send.rs (Err(_) swallowed all auth errors) - Fix try_get_one error swallowing in parse_reply_args (explicit match on MatchesError::UnknownArgument, propagate unexpected errors) - Extract shared helpers: build_references, parse_optional_trimmed, encode_header_value, sanitize_header_value - Introduce ForwardEnvelope (analogous to ReplyEnvelope) - Introduce ThreadingHeaders to group in_reply_to/references
🦋 Changeset detectedLatest commit: 6e2b0c3 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 enhances the Gmail command-line interface by introducing comprehensive recipient management flags across 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 pull request introduces new recipient management flags (--cc, --bcc, --to) across the Gmail composition helpers, achieving feature parity. More importantly, it includes a major refactoring that extracts a shared MessageBuilder. This change significantly improves the codebase by centralizing header construction, which fixes critical security vulnerabilities related to header injection in the +reply and +forward commands. The refactoring also addresses other important issues, including a silent authentication failure in +send, incorrect handling of non-ASCII subjects, and parsing errors for optional arguments. The implementation is robust, with comprehensive test coverage for the new logic and bug fixes.
Description
Brings all four Gmail composition helpers to feature parity for recipient management:
+send: add--cc,--bcc+reply/+reply-all: add--to(additive),--bcc+forward: add--bcc--toon reply/reply-all appends to the auto-computed To field. If an email appears inmultiple fields,
dedup_recipientskeeps it in the highest-priority one (To > CC > BCC).Commit 1 — Feature
Adds the flags, dedup logic, argument parsing, tests, skill file updates, and changeset.
Commit 2 — Refactor and bugfixes
Adding the flags tripled the surface area of duplicated header-construction code across
send, reply, and forward — each independently doing the same
if let Some(cc)/push_str(&format!(...))pattern. The second commit extracts a sharedMessageBuilderinto
mod.rsthat centralizes:parse_optional_trimmed(also fixes
--fromon reply/forward, which was not previously trimmed)ThreadingHeadersgrouping —in_reply_toandreferencesare now a singleOption<ThreadingHeaders>onMessageBuilder, making it structurally impossible toset one without the other
Additional fixes:
+send—Err(_)swallowed all auth errors and fell back tounauthenticated mode; now returns
GwsError::Authimmediately (except during--dry-run)try_get_oneerror swallowing in reply —.ok().flatten()hid all errors; nowexplicitly matches
UnknownArgumentand propagates unexpected errorsThis commit is cleanly revertable if reviewers prefer the feature without the refactor.
Dry Run Output:
Not applicable — CC/BCC/From are encoded inside the RFC 2822 raw message, not as separate
JSON fields. The
users.messages.sendrequest body ({"raw": "..."}) is structurallyunchanged.
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.