Skip to content

feat(gmail): add first-class reply commands#803

Merged
steipete merged 11 commits into
mainfrom
codex/gmail-reply-commands
Jun 14, 2026
Merged

feat(gmail): add first-class reply commands#803
steipete merged 11 commits into
mainfrom
codex/gmail-reply-commands

Conversation

@steipete

Copy link
Copy Markdown
Collaborator

Summary

  • add first-class gmail reply and gmail reply-all commands
  • inherit Re: subjects and quote the original message by default
  • preserve display names and derive Reply-To/From plus reply-all To/Cc recipients
  • make --to, --cc, and --bcc additive placement/move operations, with repeatable --remove
  • preserve quoted CID resources as multipart/related instead of sending broken inline images
  • keep edited-subject replies out of the original Gmail thread while retaining RFC reply headers
  • preserve inline images when forwarding and stop forwards from claiming reply threading
  • document the workflow in the command reference, Gmail workflow guide, specification, changelog, and gog agent skill

Why

The Gmail API accepts complete RFC MIME messages through messages.send; it does not provide reply or reply-all methods. The previous lower-level send flags exposed MIME, subject, quote, recipient, display-name, and inline-resource details to callers. That made normal email behavior fragile for both humans and agents.

These commands move that behavior into a stable CLI primitive with Gmail-like defaults.

Official contracts used:

Compatibility

  • gmail send --reply-to-message-id remains available as the lower-level composition path and now inherits the original subject when --subject is omitted.
  • Explicit recipient values on gmail send retain replacement semantics; first-class reply commands provide additive/move semantics.
  • Forwards no longer set the original threadId or RFC reply headers because their changed Fwd: subject cannot satisfy Gmail's explicit thread-matching contract.

Validation

  • make ci
  • structured autoreview: clean after fixing a nameless forwarded-attachment regression
  • unit coverage for recipient derivation, display names containing commas, moves/removals, inherited and edited subjects, no-send guards, CID extraction/fetching, MIME nesting, broken CID failure, forwarding, and nameless attachments
  • live Gmail smoke: sent a seed message, replied with gmail reply, and verified the stored raw message had the same thread, inherited Re: subject, correct To, matching In-Reply-To and References, reply body, and quoted original
  • live reply-all smoke: moved the inherited recipient from To to Bcc, verified no duplicate remained, confirmed --no-quote, and confirmed Gmail retained the original thread
  • disposable live-test messages moved to Trash after verification

@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

Please review the first-class Gmail reply/reply-all semantics, recipient placement and removal behavior, Gmail thread matching, RFC reply headers, multipart/related CID preservation, forward compatibility changes, and regression coverage. Local make ci, structured autoreview, and live Gmail raw-message verification are green.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 14, 2026, 1:59 AM ET / 05:59 UTC.

Summary
The PR adds first-class gmail reply and gmail reply-all commands with recipient derivation, quoting, CID preservation, forward-threading changes, docs, skill guidance, and regression tests.

Reproducibility: not applicable. this is a feature PR rather than a current-main bug report. The changed behavior is source-reviewable and the PR body reports live Gmail raw-message verification for reply and reply-all.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 32 files, +1784/-155. The PR changes Gmail command behavior, MIME generation, generated docs, workflow docs, skill guidance, and tests.
  • Current checks: 5 passing, 4 pending. Final merge readiness still depends on pending test and Windows CI checks finishing successfully.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Wait for pending test and Windows CI checks to complete green before merge.

Risk before merge

  • [P1] Final required CI was not fully green at the time of this review; test and Windows checks were still pending.
  • [P1] The PR intentionally changes gmail forward so forwards no longer claim the original Gmail thread, which existing users may notice after upgrade.
  • [P1] Reply/reply-all recipient derivation and placement now sit in a first-class Gmail send path, so maintainer review should treat this as message-delivery sensitive even though the prior routing findings appear fixed.

Maintainer options:

  1. Land after final checks (recommended)
    If the pending CI finishes green and maintainers accept the documented forward-threading behavior, the PR can proceed without a narrow automated repair.
  2. Ask for opt-in compatibility behavior
    Maintainers could require a compatibility flag if preserving existing gmail forward threading is more important than aligning forwards with Gmail's subject-matching thread contract.
  3. Pause for extra live routing proof
    If recipient routing remains concerning, pause until an additional redacted live reply-all proof covers the specific edge case maintainers care about.

Next step before merge

  • [P2] The remaining action is maintainer review of compatibility-sensitive Gmail behavior and pending final checks, not an automated code repair.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes Gmail compose/MIME code, docs, and skill text without new dependencies, workflow permissions, secrets handling, or artifact execution.

Review details

Best possible solution:

Land only after final checks are green and maintainers accept the compatibility-visible forward-threading and recipient-routing semantics.

Do we have a high-confidence way to reproduce the issue?

Not applicable; this is a feature PR rather than a current-main bug report. The changed behavior is source-reviewable and the PR body reports live Gmail raw-message verification for reply and reply-all.

Is this the best way to solve the issue?

Yes, subject to maintainer acceptance of the compatibility change: first-class reply commands are a narrower, more maintainable solution than making users rebuild reply MIME through lower-level gmail send flags.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0d4dae4b41af.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-change live Gmail smoke evidence for reply and reply-all, including raw-message checks for thread, subject, recipients, reply headers, quote behavior, and cleanup of disposable messages.

Label justifications:

  • P2: This is a normal-priority Gmail compose feature with important but bounded user impact.
  • merge-risk: 🚨 compatibility: The PR intentionally changes gmail forward so forwards no longer claim the original Gmail thread.
  • merge-risk: 🚨 message-delivery: The PR centralizes reply and reply-all recipient derivation, placement, moves, and removal on the Gmail send path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. First-class reply and reply-all commands turn fragile Gmail reply MIME composition into a stable CLI primitive for humans and agents.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body provides after-change live Gmail smoke evidence for reply and reply-all, including raw-message checks for thread, subject, recipients, reply headers, quote behavior, and cleanup of disposable messages.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-change live Gmail smoke evidence for reply and reply-all, including raw-message checks for thread, subject, recipients, reply headers, quote behavior, and cleanup of disposable messages.
Evidence reviewed

What I checked:

  • Repository policy applied: AGENTS.md was read fully; its PR review-mode guidance says to use gh pr view / gh pr diff and not switch branches or change code. (AGENTS.md:34, 0d4dae4b41af)
  • No maintainer notes present: The repository has .agents/skills/* files but no .agents/maintainer-notes/ files matching this PR surface. (0d4dae4b41af)
  • PR metadata and proof: gh pr view reports head a4551f88e30736f4290f274b4b89b907f8d89448, 32 changed files, mergeable true, and a PR body with live Gmail smoke validation for reply and reply-all raw-message behavior. (a4551f88e307)
  • Reply command implementation: The new reply command resolves the send-as identity, prepares reply context, derives recipients, clears the Gmail threadId on edited subjects, appends preserved inline resources, and sends through Gmail messages.send. (internal/cmd/gmail_reply_commands.go:49, a4551f88e307)
  • Recipient safety implementation: buildReplyRecipients excludes self addresses, preserves parsed mailbox names, applies explicit To/Cc/Bcc moves, processes repeatable removals, and fails if no recipients remain. (internal/cmd/gmail_recipients.go:16, a4551f88e307)
  • Inline CID preservation: The CID helper parses HTML and only preserves MIME parts referenced from CID URL attributes or CSS url(...), avoiding earlier literal-text false positives. (internal/cmd/gmail_inline.go:33, a4551f88e307)

Likely related people:

  • steipete: git log --follow, git blame, and git shortlog show Peter Steinberger as the current-main author for the Gmail send/reply/forward and MIME code paths touched by this PR; the PR metadata maps that contributor to the steipete handle. (role: recent Gmail write-path contributor; confidence: high; commits: 3a66566be7a4, 91532648b7ae, 8a58cf7d0b12; files: internal/cmd/gmail_send.go, internal/cmd/gmail_reply.go, internal/cmd/gmail_forward.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jun 14, 2026
@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Maintainer decision: accept the intentional gmail forward threading change.

A forward changes the subject to Fwd: .... Gmail documents that explicit thread insertion requires the supplied threadId, RFC-compliant References and In-Reply-To, and a matching subject. The old forward path supplied reply headers and the original thread ID despite the changed subject. That was not a reliable or valid threading contract.

Forwards should create a separate conversation while preserving forwarded content, inline CID resources, and ordinary attachments. No compatibility flag is needed. First-class reply and reply-all retain the original thread when their inherited subject matches.

Local make ci, branch autoreview, and live raw-message validation remain green at 6c743c66.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c743c66aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/gmail_reply_commands.go
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 14, 2026
@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The blocking HTML-only reply finding is fixed in a7196ce. The reply composer derives visible plain text from HTML replies and HTML-only originals while retaining image-only replies as HTML-only. Focused regression coverage, full make ci, and local autoreview are green.

@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

The HTML-only reply finding is fixed in a7196ce. Plain and HTML alternatives now preserve equivalent reply and quoted-original content, non-visible HTML is excluded from derived plain text, and image-only HTML replies remain HTML-only. Full make ci and local autoreview are green.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

gog --gmail-no-send gmail send --to you@example.com --subject test --text body

P3 Badge Use the existing Gmail body flag in docs

The Gmail send command exposes --body/--body-file, not --text (see GmailSendCmd.Body in internal/cmd/gmail_send.go), so this new guardrail example fails as soon as users copy it instead of demonstrating no-send behavior. Please change the example to use --body body.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/gmail_reply.go
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 14, 2026
steipete added 2 commits June 14, 2026 05:31
…mands

# Conflicts:
#	CHANGELOG.md
#	internal/cmd/gmail_drafts.go
#	internal/cmd/gmail_forward.go
#	internal/mailmime/mime.go
#	internal/slidesmarkdown/markdown.go
@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

Both findings from the previous review are fixed at 9fb7e235: hidden body elements are excluded from HTML-derived plain alternatives, and the send-guard example now uses the valid --body flag in docs/gmail-workflows.md:54.

The branch is refreshed against current main, mergeable, and clean under full make ci plus branch autoreview.

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The branch is refreshed against current main and the prior findings are fixed at 9fb7e235: hidden HTML preheader content is excluded from derived plain alternatives, and the Gmail workflow example uses --body.

Full make ci, focused Gmail/MIME tests, skill frontmatter parsing, and branch autoreview are green.

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Final head 2abe9fde includes the scoped CID fix, current main, and the deterministic generated command-count refresh. Branch autoreview and full make ci are clean.

@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

Final head 2abe9fde includes the scoped CID fix, current main, and the deterministic generated command-count refresh. Branch autoreview against origin/main found no actionable findings, and full make ci passed.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2abe9fde3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/gmail_recipients.go Outdated
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 14, 2026
@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

The URL-scheme finding is fixed at c04e9459: single-URL attributes require a leading cid: scheme, and srcset CID references are matched only at candidate boundaries. Full make ci and local autoreview are green.

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The URL-scheme finding is fixed at c04e9459: normal URLs containing cid: text are ignored, while real CID attributes, srcset candidates, and CSS references remain supported. Full make ci and local autoreview are green.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: c04e94595b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

The recipient-safety finding is fixed at 35c8c48d: fallback to original To recipients now requires the original From to match the active account or an alias. Full make ci and local autoreview are green.

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The recipient-safety finding is fixed at 35c8c48d: external senders with self-directed Reply-To no longer fall back to unrelated original recipients. Full make ci and local autoreview are green.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

…mands

# Conflicts:
#	internal/cmd/gmail_forward.go
#	internal/cmd/gmail_reply.go
@steipete

Copy link
Copy Markdown
Collaborator Author

@codex review

Final mergeable head a9928b31 includes all prior review fixes plus current main's inbound-content decoder extraction. The merge keeps upstream gmailcontent ownership while preserving this PR's inline-resource and forward-threading behavior. Branch autoreview against current origin/main found no actionable findings, and full make ci passed.

@steipete

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Final mergeable head a9928b31 includes all prior review fixes and current main. Branch autoreview against origin/main and full make ci are clean.

@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a9928b31b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added the proof: sufficient Contributor real behavior proof is sufficient. label Jun 14, 2026
@steipete steipete merged commit ba350d6 into main Jun 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant