feat(gmail): auto-select reply From from the addressed send-as alias - #948
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b84aea1bd2
ℹ️ 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".
| if alias := pickSendAsFromRecipients(info.ToAddrs, info.CcAddrs, sendAs); alias != "" { | ||
| if picked, pickErr := resolveComposeFrom(ctx, svc, account, alias, sendAs, sendAsErr); pickErr == nil { | ||
| from = picked |
There was a problem hiding this comment.
Select the alias before resolving its signature
When a reply is addressed to an alias and the user passes --signature without an explicit --from, the signature has already been fetched using the account-default from.sendingEmail at lines 119–128 before this block changes from to the addressed alias. The resulting message therefore sends from the alias but includes the primary identity's signature, contrary to --signature's active-send-as semantics and potentially exposing the wrong identity; determine the automatic From identity before resolving and appending the signature.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 5:58 AM ET / 09:58 UTC. ClawSweeper reviewWhat this changesThis PR adds Merge readiness⛔ Blocked until real behavior proof is added - 3 items remain Current Priority: P2 Review scores
Verification
How this fits togetherGmail reply and reply-draft commands fetch the original message, choose a sending identity, optionally attach that identity’s signature, and build a MIME message for Gmail. This change adds an opt-in identity-selection step between reading original recipients and resolving the signature. flowchart LR
A[Reply or reply-draft command] --> B[Fetch original message]
B --> C[Read To and Cc recipients]
D[Verified send-as aliases] --> E[Opt-in alias picker]
C --> E
E --> F[Resolve From identity]
F --> G[Resolve matching signature]
G --> H[Build Gmail reply or draft]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the default-off flag after attaching a redacted real Gmail reply or draft proof that shows the selected alias, fallback, and explicit Do we have a high-confidence way to reproduce the issue? Not applicable as a defect report: this is a new opt-in command behavior, and its source paths plus focused tests are concrete. Is this the best way to solve the issue? Yes. The collaborator’s opt-in flag preserves the established default identity, lets explicit AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c7d66df6a99a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (22 earlier review cycles; latest 8 shown)
|
b84aea1 to
e4d3bdc
Compare
|
Maintainer verification complete. I pushed The feature is now available as Proof:
Recommendation: LAND. |
|
@clawsweeper re-review The current head now preserves the existing default and exposes alias selection through the explicit |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
# Conflicts: # internal/cmd/gmail_drafts.go
Summary
When replying without an explicit
--from, this selects the send-as alias the original message was addressed to as the reply's From identity, instead of always sending from the account default.Precedence:
--from(unchanged — always wins)Only verified send-as aliases are eligible, and the alias is resolved through the existing
resolveComposeFrompath, so it can never produce an invalid From. If the send-as lookup fails, the account default stays in place.Applies to both
gmail reply/gmail reply-alland reply drafts.Motivation
On an account with multiple verified send-as aliases, a reply currently always goes out as the account default — even when the original was addressed to a specific alias. Someone who writes to
alias@example.comthen gets a reply fromprimary@example.com. This keeps the reply on the identity the sender actually wrote to, which is what most people expect a "reply" to do.Note on default behavior
This changes default reply behavior (no new flag required to trigger it). I think matching the addressed alias is the least-surprising default, but if you'd rather gate it behind an opt-in flag or a config setting, I'm happy to adjust — flagging it here since it's a behavior change rather than a purely additive one.
Testing
pickSendAsFromRecipients): To-wins, Cc-used, To-beats-Cc, first-match, case-insensitive match, no-match → empty, unverified alias skipped.--from→ override honored.go test ./internal/cmd/,make lint— 0 issues.