Skip to content

feat(gmail): auto-select reply From from the addressed send-as alias - #948

Merged
steipete merged 5 commits into
openclaw:mainfrom
ronny-rentner:feat/gmail-reply-from-autoselect
Aug 2, 2026
Merged

feat(gmail): auto-select reply From from the addressed send-as alias#948
steipete merged 5 commits into
openclaw:mainfrom
ronny-rentner:feat/gmail-reply-from-autoselect

Conversation

@ronny-rentner

Copy link
Copy Markdown
Contributor

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:

  1. explicit --from (unchanged — always wins)
  2. the send-as alias the original was addressed to (To before Cc, first verified match)
  3. the account default (unchanged fallback)

Only verified send-as aliases are eligible, and the alias is resolved through the existing resolveComposeFrom path, 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-all and 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.com then gets a reply from primary@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

  • Unit test for the picker (pickSendAsFromRecipients): To-wins, Cc-used, To-beats-Cc, first-match, case-insensitive match, no-match → empty, unverified alias skipped.
  • End-to-end reply test: addressed-to-alias → alias used as From; no matching alias → account default; explicit --from → override honored.
  • go test ./internal/cmd/, make lint — 0 issues.

@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: 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".

Comment thread internal/cmd/gmail_reply_commands.go Outdated
Comment on lines +139 to +141
if alias := pickSendAsFromRecipients(info.ToAddrs, info.CcAddrs, sendAs); alias != "" {
if picked, pickErr := resolveComposeFrom(ctx, svc, account, alias, sendAs, sendAsErr); pickErr == nil {
from = picked

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 5:58 AM ET / 09:58 UTC.

ClawSweeper review

What this changes

This PR adds --auto-from-addressed-alias to Gmail reply, reply-all, and reply-based draft commands, selecting an addressed verified send-as alias only when explicitly requested.

Merge readiness

Blocked until real behavior proof is added - 3 items remain

Current main does not contain this opt-in Gmail reply feature, while a collaborator explicitly verified the revised default-preserving design and recommended landing it. The patch has no supported correctness finding, but it still needs inspectable after-fix real-behavior proof before merge.

Priority: P2
Reviewed head: 118ca7029c0195a8bdc4780d9f5c2e9ccd591002

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The compatibility-safe patch and focused coverage look mergeable, but absent inspectable real-behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: A collaborator describes successful focused, built-CLI, and full-CI validation, but the PR body and available comments provide no inspectable redacted live output, logs, recording, or linked artifact showing after-fix Gmail behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: A collaborator describes successful focused, built-CLI, and full-CI validation, but the PR body and available comments provide no inspectable redacted live output, logs, recording, or linked artifact showing after-fix Gmail behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current main lacks the opt-in feature: The checked-out main reply options and compose helpers have no --auto-from-addressed-alias flag or recipient-based send-as selection, so this PR remains necessary rather than already implemented.
Explicit opt-in preserves compatibility: The proposed reply path changes identity only when the new flag is true and --from is empty; it chooses an alias before signature resolution and otherwise retains the account-default path.
Focused regression coverage accompanies the implementation: The branch adds picker cases for verified aliases and reply/draft tests covering default-off behavior, opted-in alias selection, fallback, explicit --from precedence, and signature selection.
Findings None None.
Security None None.

How this fits together

Gmail 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]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: A collaborator describes successful focused, built-CLI, and full-CI validation, but the PR body and available comments provide no inspectable redacted live output, logs, recording, or linked artifact showing after-fix Gmail behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The feature is an opt-in CLI contract across four commands; its visible behavior should be demonstrated against a real Gmail account before merge, with private addresses and tokens redacted.
  • Complete next step (P2) - No repair is needed: the patch is correct, and the remaining merge gate is contributor or maintainer-supplied real-behavior proof rather than a file-level defect.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Command surface 4 command docs updated The identity-selection flag is documented consistently for reply, reply-all, draft create, and draft update.
Patch scope 12 files; 404 added, 117 removed The patch combines the command implementation, targeted regression coverage, and generated command-reference updates.

Merge-risk options

Maintainer options:

  1. Attach real Gmail identity proof (recommended)
    Add a redacted terminal transcript, logs, or recording from a real account showing default fallback, opt-in alias selection, and explicit --from precedence before landing.
  2. Accept maintainer-verified evidence
    A maintainer may accept the recorded built-CLI validation as sufficient if repository policy allows it, acknowledging that no inspectable artifact is currently attached.

Technical review

Best 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 --from override.

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 --from win, and selects the alias before signature lookup; that is safer than the original unconditional default change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: A new reply identity-selection flag affects which verified alias users send from and must preserve existing default and explicit-override behavior.

Label justifications:

  • P2: This is a bounded Gmail workflow enhancement with an explicit compatibility-preserving design and no demonstrated urgent regression.
  • merge-risk: 🚨 compatibility: A new reply identity-selection flag affects which verified alias users send from and must preserve existing default and explicit-override behavior.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: A collaborator describes successful focused, built-CLI, and full-CI validation, but the PR body and available comments provide no inspectable redacted live output, logs, recording, or linked artifact showing after-fix Gmail behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main lacks the opt-in feature: The checked-out main reply options and compose helpers have no --auto-from-addressed-alias flag or recipient-based send-as selection, so this PR remains necessary rather than already implemented. (internal/cmd/gmail_reply_commands.go:21, c7d66df6a99a)
  • Explicit opt-in preserves compatibility: The proposed reply path changes identity only when the new flag is true and --from is empty; it chooses an alias before signature resolution and otherwise retains the account-default path. (internal/cmd/gmail_reply_commands.go:127, 118ca7029c01)
  • Focused regression coverage accompanies the implementation: The branch adds picker cases for verified aliases and reply/draft tests covering default-off behavior, opted-in alias selection, fallback, explicit --from precedence, and signature selection. (internal/cmd/gmail_reply_commands_test.go:237, 118ca7029c01)
  • Maintainer-approved revised behavior: A collaborator states that commit 55cc2efd changed the originally automatic behavior to the explicit flag, preserved explicit --from precedence, checked signature ordering, and recommends landing after focused and full-CI validation. (internal/cmd/gmail_reply_commands.go:127, 55cc2efdee7a)
  • Current release provenance: The current main checkout is at c7d66df6; the latest release supplied in review context is v0.34.1 at 4747fb05, and the checked-out changelog has no entry for this unmerged feature. (CHANGELOG.md:1, 4747fb05a429)
  • Ownership history limitation: Recent local Gmail-path history identifies adjacent current-main contributors, but targeted blame required a missing partial-clone object and could not fetch because host resolution failed; ownership confidence is therefore limited to available history and PR evidence. (internal/cmd/gmail_reply_commands.go:95, 4985e2681e31)

Likely related people:

  • steipete: Peter Steinberger authored the collaborator commit that turned the identity change into an opt-in and supplied the latest explicit validation and landing recommendation. (role: recent area contributor and PR reviewer; confidence: high; commits: 55cc2efdee7a, 118ca7029c01; files: internal/cmd/gmail_reply_commands.go, internal/cmd/gmail_drafts.go)
  • chrischall: Recent main history shows work on reply-draft correctness in the same Gmail drafts path, making this a sensible secondary routing contact. (role: recent adjacent contributor; confidence: medium; commits: 4985e2681e31; files: internal/cmd/gmail_drafts.go)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted real Gmail proof for the default, opt-in alias, and explicit --from paths; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-01T11:54:03.264Z sha f129464 :: needs real behavior proof before merge. :: [P1] Preserve the established default reply identity
  • reviewed 2026-08-01T13:12:18.447Z sha f129464 :: needs real behavior proof before merge. :: [P1] Preserve the established default reply identity
  • reviewed 2026-08-01T14:52:45.278Z sha f129464 :: needs real behavior proof before merge. :: [P1] Preserve the established default reply identity
  • reviewed 2026-08-01T15:45:31.008Z sha f129464 :: needs real behavior proof before merge. :: [P1] Preserve the established default reply identity
  • reviewed 2026-08-02T02:41:39.058Z sha f129464 :: needs real behavior proof before merge. :: [P1] Preserve the established default reply identity
  • reviewed 2026-08-02T06:09:50.058Z sha 55cc2ef :: needs real behavior proof before merge. :: [P3] Document the supported --from precedence
  • reviewed 2026-08-02T06:28:47.856Z sha 55cc2ef :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T08:45:39.688Z sha 55cc2ef :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 30, 2026
@ronny-rentner
ronny-rentner force-pushed the feat/gmail-reply-from-autoselect branch from b84aea1 to e4d3bdc Compare August 1, 2026 05:20
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Maintainer verification complete. I pushed 55cc2efd to preserve the existing default while keeping the contributor's useful alias-selection implementation as an explicit opt-in.

The feature is now available as --auto-from-addressed-alias on gmail reply, gmail reply-all, gmail drafts create, and gmail drafts update. Omitting the flag keeps the account-default From behavior; an explicit --from still wins. The alias is selected before signature resolution, so the chosen identity and signature remain consistent.

Proof:

  • Focused reply and draft regression tests pass, including default-off, opt-in alias selection, explicit override, fallback, and signature selection.
  • A source-blind built-CLI contract passed for all four commands: default dry runs report auto_from_addressed_alias: false, opt-in dry runs report true, explicit --from remains visible, help exposes the flag, and missing-body validation still exits 2.
  • Full make ci passes, including all Go tests, lint/deadcode/format checks, generated command docs, docs-site validation, agent-skill checks, and script tests.
  • Autoreview is clean with no accepted/actionable findings.

Recommendation: LAND.

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

The current head now preserves the existing default and exposes alias selection through the explicit --auto-from-addressed-alias flag; please review the updated behavior and maintainer proof above.

@clawsweeper

clawsweeper Bot commented Aug 2, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Aug 2, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 2, 2026
@steipete
steipete merged commit 88eb361 into openclaw:main Aug 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants