Gmail: multi-account support - #259
Open
hilash wants to merge 2 commits into
Open
Conversation
- gmail_credentials keyed by lowercased email (migration 005 migrates the 'default' row in place); gmail_index gains an account column. - imap-client functions take an optional account; omitted = the first-connected account, so existing consumers work unchanged. - Routes accept ?account= / body.account; disconnect without a param removes everything (old behavior) and the Gmail skill is only uninstalled when no accounts remain. - /api/gmail/status returns accounts[] with per-account needsReconnect and lastIndexed, keeping the old top-level shape for the primary account. - GmailSection lists accounts with per-account disconnect/reconnect and an 'Add another account' flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Gmail integration now supports connecting multiple accounts simultaneously. Stacked on #258 (base branch); retargets to
mainautomatically when that merges.Storage
gmail_credentialsrows are keyed by lowercased email instead of the single'default'row. Migration005_gmail_multi_account.sqlrewrites the existing row in place.gmail_indexgains anaccountcolumn (''= pre-migration rows).Back-compat by construction
Every imap-client function (
searchEmails,readThread,listLabels,createLabel,applyLabel,getUnread) takes an optionalaccount(email). Omitted = the first-connected account (ORDER BY rowid), so single-account installs and existing consumers — Mailroom, the Gmail skill, anything calling the routes without an account — keep working with zero changes.API
GET /api/gmail/search|thread/:id|labelsaccept?account=;POST /api/gmail/label|labels|indexacceptbody.account.POST /api/gmail/connectkeys the row by email — each connect adds or refreshes one account without touching others.DELETE /api/gmail/disconnect?account=xremoves one account; no param removes all (pre-multi-account behavior). The Gmail skill is only uninstalled when no accounts remain.GET /api/gmail/statusreturnsaccounts: [{email, needsReconnect, lastIndexed}]while keeping the old top-level shape (describing the primary account) for existing consumers.UI
GmailSection shows per-account rows — green when healthy, amber "Reconnect needed" with a pre-filling Re-enter link when the stored password can't be decrypted — each with its own disconnect button, plus an "Add another account" flow.
Verification
npx tsc --noEmitclean;npm run lint0 errors; crypto tests 3/3needsReconnect; search with an unknown account returnsGmail account X not connected; scoped disconnect of an unknown account no-ops without touching real accounts🤖 Generated with Claude Code