#32

Add recipient autocomplete to email composers

MergedstylesshOwnermerged intofrom

Summary

  • add mailbox-scoped recipient suggestions for Gmail, hosted JMAP, and demo accounts
  • share an accessible autocomplete field across new-message and reply composers for To, Cc, and Bcc
  • preserve free-form address entry, deduplicate selections, isolate cached results per mailbox, and hide the selector when no matches remain

Validation

  • corepack pnpm test — 149 passed
  • corepack pnpm exec next typegen && corepack pnpm exec tsc --noEmit
  • focused ESLint for all changed TypeScript and TSX files
  • corepack pnpm build
  • browser QA for pointer and keyboard selection, free-form entry, To/Cc/Bcc, hard refresh, empty results, and a 320px viewport

Repository lint boundary

Full corepack pnpm lint still reports the two existing @typescript-eslint/no-require-imports violations in babel.config.js and postcss.config.js; changed-file ESLint is clean.

Activity

7
mikeyreviewed2mo ago
mikey2mo ago

Reviewed the diff (app/api/mail/recipients/route.ts, components/mail/address-field.tsx, provider changes, and the lib/mail/recipients.ts helpers) against the surrounding code.

Auth/IDOR check: GET /api/mail/recipients takes account from the query string, but getMailProvider → resolveMailAccount scopes lookups through findStoredMailAccount(user.id, accountId), so a caller can't fetch another user's account by ID. No confused-deputy issue found here.

Dedup/filter logic (lib/mail/recipients.ts) — self-exclusion, case-insensitive de-duplication, and the ranking in filterRecipientSuggestions all check out against the accompanying unit tests.

Two non-blocking findings below, both about the new Stalwart/JMAP listRecipientSuggestions path — left inline:

  1. lib/stalwart/client.ts — adding to/cc/bcc to the shared emailSummaryProperties also inflates every regular listThreads() call (the hot mail-listing path), even though only the new suggestions endpoint needs those fields and toThread() never reads them.
  2. lib/stalwart/provider.ts — listRecipientSuggestions() queries across all mailboxes with no Spam/Trash exclusion, unlike the Gmail provider directly above it which explicitly filters -in:spam -in:trash. Hosted/JMAP accounts will get spam senders suggested as recipients.

Nothing else stood out as a correctness or security blocker; the composer wiring (mailboxEmail/accountId threading into useRecipientSuggestions), the client-side per-mailbox cache, and the no-store cache header on the new route all look correct.

stylesshOwner2mo ago

Addressed both JMAP review findings in 8c8506d:

  • Restored the normal emailSummaryProperties payload and added a per-call properties override, so folder listing no longer fetches To/Cc/Bcc. The recipient endpoint requests only from, to, cc, and bcc.
  • The provider now resolves the account's Junk and Trash mailbox IDs and passes them through JMAP inMailboxOtherThan, preventing mail found only in those folders from contributing autocomplete suggestions.
  • Added regression coverage for the default summary payload, recipient-only property overrides, and Junk/Trash query exclusion.

Validation: 151 tests passed; focused ESLint passed; Next route type generation and TypeScript passed; production build passed; git diff --check passed.

stylessh merged commit 44d92c7 into main2mo ago

Branch stylessh/recipient-autocomplete has been merged.

Checking branch