#32
Add recipient autocomplete to email composers
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 passedcorepack 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
7mikeyreviewed2mo ago
Addressed both JMAP review findings in 8c8506d:
- Restored the normal
emailSummaryPropertiespayload and added a per-callpropertiesoverride, so folder listing no longer fetches To/Cc/Bcc. The recipient endpoint requests onlyfrom,to,cc, andbcc. - 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.
44d92c7 into main2mo ago
Reviewed the diff (
app/api/mail/recipients/route.ts,components/mail/address-field.tsx, provider changes, and thelib/mail/recipients.tshelpers) against the surrounding code.Auth/IDOR check:
GET /api/mail/recipientstakesaccountfrom the query string, butgetMailProvider→resolveMailAccountscopes lookups throughfindStoredMailAccount(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 infilterRecipientSuggestionsall check out against the accompanying unit tests.Two non-blocking findings below, both about the new Stalwart/JMAP
listRecipientSuggestionspath — left inline:lib/stalwart/client.ts— addingto/cc/bccto the sharedemailSummaryPropertiesalso inflates every regularlistThreads()call (the hot mail-listing path), even though only the new suggestions endpoint needs those fields andtoThread()never reads them.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/accountIdthreading intouseRecipientSuggestions), the client-side per-mailbox cache, and theno-storecache header on the new route all look correct.