Skip to content

feat(sync): count Gmail's "send as" addresses as the owner's - #208

Open
leemour wants to merge 2 commits into
mainfrom
feat/gmail-sendas-mail-signals
Open

leemour wants to merge 2 commits into
mainfrom
feat/gmail-sendas-mail-signals

Conversation

@leemour

@leemour leemour commented Nov 26, 2026

Copy link
Copy Markdown
Member

Task

cli-core #3321, part a: for a Gmail account, read Gmail's "send as" addresses and count them as the owner's, beside the aliases from config.

Why

mail-cli 0.37.0 (#202) added aliases and the Sent folder by role. A Gmail alias that has never sent mail through Gmail still did not belong to the owner unless the owner listed it by hand.

What

  • sync reads users.settings.sendAs.list (docs) for a profile signed in with Google (auth: oauth).
    • It keeps every address that is not the primary one and has verificationStatus: accepted.
    • These go to cli-core as MailAccount.addresses, together with aliases.
  • No new scope. The docs list https://mail.google.com/ among the scopes that allow the call, and the sign-in already asks for it. gmail.googleapis.com joins the allowed hosts (DESKTOP.hosts, contracts/wirecat.json).
  • A failed read keeps the last list. Causes include the Gmail API being off in the Google project, a network error, or a refused token. The list is stored under the sync-state key mail_send_as, so a single failed answer does not turn the owner's alias mail back to incoming. sync reports the cause as send_as.unread, and send_as.aliases gives the count.
  • App-password profiles read no list. They cannot call the Gmail API, so aliases stays the way to name those addresses.
  • The sent copy's sync after messages send also passes the saved send-as list. cli-core #3384 treats a given list as complete, so leaving the list out would drop those aliases.
  • Docs: docs/configuration.md and docs/oauth-google.md (your own Google app needs the Gmail API turned on).

Works on the released cli-core 1.0.0, because these changes only add addresses. Removing an alias (#3321 part b) and the new mail signals are in WireCatLabs/cli-core#3384. mail-cli gets them with the next cli-core release and bump. After that bump, the line in docs/configuration.md that says "config unset aliases does not take it back" must change.

Testing

  • src/oauth.test.ts: a Gmail OAuth sync counts the one accepted alias (not the primary, not the pending one) and sends the token in a header. When Gmail answers 403, the next sync keeps the alias and reports send_as.unread. No token appears in the output.
  • src/aliases.test.ts: an app-password sync has no send_as.
  • pnpm typecheck, pnpm lint, the full suite with one worker (31 files, 382 tests), pnpm generate, test:matrix:check, docs:check, standards:check.
  • One test in oauth.test.ts, "keeps every profile's record when sign-ins finish at the same time", failed once under load and passed in three reruns and in the full run. It looks like an existing flake.

🤖 Generated with Claude Code

leemour and others added 2 commits November 26, 2026 17:35
A Gmail profile signed in with Google now reads users.settings.sendAs.list at each sync and
passes every address Gmail accepted (verificationStatus accepted, not the primary) to cli-core
as the owner's, beside the configured aliases. The https://mail.google.com/ scope the sign-in
already requests allows the call, so no scope is added. gmail.googleapis.com joins the hosts.

A failed read (the Gmail API off in the Google project, a network error) keeps the list read
last, under the sync-state key mail_send_as, so the owner's alias mail does not turn incoming
because Gmail did not answer once. sync reports it as send_as.unread. App-password profiles read
no list. Part of cli-core #3321.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sync after a send passes the whole list of the owner's addresses, so it must carry the
send-as aliases the last sync read: cli-core treats a given list as complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant