Auto complete of To/cc/bcc #375

Closed
opened 2026-06-03 20:22:30 +00:00 by guettli · 1 comment
guettli commented 2026-06-03 20:22:30 +00:00 (Migrated from codeberg.org)

Auto complete of To/cc/bcc should prioritize last To usage (sent folder) to received messages.

Example: I wrote to info@foo.de yesterday, and I got a spam message from info@spam.de some minutes ago.

When I type "i" in To field, I want to see info@foo.de first.

Auto complete of To/cc/bcc should prioritize last To usage (sent folder) to received messages. Example: I wrote to info@foo.de yesterday, and I got a spam message from info@spam.de some minutes ago. When I type "i" in To field, I want to see info@foo.de first.
guettlibot commented 2026-06-03 22:15:02 +00:00 (Migrated from codeberg.org)

The PR is open at https://codeberg.org/guettli/sharedinbox/pulls/380.

Here's a summary of what was done:

Problem: The To/Cc/Bcc autocomplete sorted suggestions purely by recency (receivedAt DESC). A spam email received today from info@spam.de would appear before info@foo.de that the user deliberately sent to yesterday.

Fix (lib/data/repositories/email_repository_impl.dart):

  • Before processing candidate rows, searchAddresses now queries the mailboxes table for any mailbox with role='sent' and collects their paths.
  • Candidate email rows are split into two groups: sent-folder rows first, then all others — each group still sorted by recency internally.
  • Within sent-folder rows, toAddresses/ccJson are checked before fromJson (since fromJson in a sent email is the user's own address, not a useful suggestion).

Test (test/unit/email_repository_impl_test.dart):

  • Added searchAddresses prioritises sent-folder addresses over newer received — inserts an older sent email to info@foo.de and a newer inbox email from info@spam.de, verifies info@foo.de is returned first.
  • All 492 existing tests continue to pass.
The PR is open at https://codeberg.org/guettli/sharedinbox/pulls/380. Here's a summary of what was done: **Problem:** The To/Cc/Bcc autocomplete sorted suggestions purely by recency (`receivedAt` DESC). A spam email received today from `info@spam.de` would appear before `info@foo.de` that the user deliberately sent to yesterday. **Fix** (`lib/data/repositories/email_repository_impl.dart`): - Before processing candidate rows, `searchAddresses` now queries the `mailboxes` table for any mailbox with `role='sent'` and collects their paths. - Candidate email rows are split into two groups: sent-folder rows first, then all others — each group still sorted by recency internally. - Within sent-folder rows, `toAddresses`/`ccJson` are checked before `fromJson` (since `fromJson` in a sent email is the user's own address, not a useful suggestion). **Test** (`test/unit/email_repository_impl_test.dart`): - Added `searchAddresses prioritises sent-folder addresses over newer received` — inserts an older sent email to `info@foo.de` and a newer inbox email from `info@spam.de`, verifies `info@foo.de` is returned first. - All 492 existing tests continue to pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: guettli/sharedinbox#375