#25
Add folders, labels, and drag-to-organize mail
Summary
- add provider-backed folders for hosted mail and labels for Gmail, including create, rename, delete, navigation, counts, and mobile access
- persist folder icon and color appearance with a bounded Hugeicons picker, OKLCH-aware rendering, and the new
mail_collection_appearancesmigration - add master, modifier-key, and shift-range mail selection with contextual bulk actions
- add Motion-powered drag stacks, responsive folder drop feedback, curved drop completion, and staged list reflow
- support moving selected mail into custom folders, Inbox, Archive, Spam, Trash, or Unread with source-aware provider mutations
Validation
pnpm test— 108 passedpnpm exec tsc --noEmit— passed- ESLint across every changed TypeScript/TSX/MJS file — passed
pnpm build— passed with Next.js 16.3.3git diff --check origin/main...HEAD— passed- browser-tested folder creation and appearance controls, selection states, drag/drop feedback, custom-folder and Archive moves, Inbox moves, Unread drops, and staged exit/reflow behavior
Activity
7mikeyreviewed3mo ago
Addressed the provider contract note in 24d49ca.
- Folder deselection now moves mail from the custom folder back to Inbox in both the demo and Stalwart providers.
- Add/remove operations share explicit source and destination transfer semantics.
- Added regression coverage for both transfer directions.
Validation on the pushed commit: 109 tests, TypeScript, production build, changed-file ESLint, and diff checks all pass.
ac766cd into main3mo ago
Review summary
Reviewed the folder/label + drag-to-organize changes: API routes (
app/api/mail/collections/**,app/api/mail/threads/[id]/route.ts), themail_collection_appearancesmigration and schema, provider mutation logic (lib/gmail/provider.ts,lib/stalwart/provider.ts,lib/demo/provider.ts) plus their client layers, and the selection/drag logic (lib/mail/thread-selection.ts,lib/mail/thread-drag.ts, bulk-action handling incomponents/mail/thread-list.tsx).Auth/ownership: every mutating route (
collectionsPOST/PATCH/DELETE,threads/[id]PATCH) checksgetSessionUser()and resolves the target account throughresolveMailAccount, which scopes lookups byuser.idviafindStoredMailAccount(user.id, accountId)— no cross-account/IDOR path found for collection or thread mutations.Input validation:
normalizeCollectionIcon/normalizeCollectionColoruse a closed allowlist and a strict hex regex before anything is persisted or rendered, so the new appearance fields aren't an injection/XSS vector.normalizeCollectionNamebounds length. Gmail/Stalwart client calls consistentlyencodeURIComponentpath segments and JSON-encode bodies.Migration:
0005_cool_trauma.sqladdsmail_collection_appearanceswithON DELETE CASCADEonuser_idand a unique index over(user_id, account_id, collection_id)matching theonConflictDoUpdatetarget insaveMailCollectionAppearance— consistent and safe for concurrent upserts.Provider contract note (non-blocking):
MailProvider.setThreadCollectionis typed to supportselected: falsefor any collection kind, butStalwartProvider/DemoProviderunconditionallyreturn falsewhenselectedisfalse(only Gmail's implementation actually removes a label). Today no UI path calls it withselected: falsefor a"folder"kind collection (thread-toolbar.tsxandlist-toolbar.tsxboth hardcodeselected: truefor folders), so this isn't currently reachable, but it's a latent trap if a future "remove from folder" affordance is added — worth a comment or a narrower type (selectedonly meaningful for"label").No blocking correctness or security issues found in this pass. Validation in the PR description (tests, tsc, eslint, build, manual browser testing) is consistent with what I saw in the diff.