Today header sync is capped at the 50 most recent messages per folder
(MailSyncer.FETCH_LIMIT = 50); the existing FetchPolicy governs body/attachment prefetch,
not history depth. Per decision, the default becomes fetching the entire mailbox history.
Scope
Replace the fixed 50-header cap with a full-history sync: page backwards through each
folder (batched IMAP fetch) until the whole folder is cached.
Run the backfill in the background (WorkManager) — resumable and cancellable — without
blocking foreground sync / pull-to-refresh; track per-folder progress (e.g. lowest UID
fetched).
Keep respecting FetchPolicy for body/attachment prefetch (headers first; bodies per
policy).
Batch + back off to avoid hammering the server or exhausting memory on large mailboxes;
surface progress in the UI.
Applies to new and existing accounts; retention (#13) is the escape valve.
Acceptance criteria
A new account backfills its full history over time, not just 50 messages.
Backfill survives process death / network loss and resumes; foreground UX stays responsive.
Relevant files
data/sync/MailSyncer.kt (FETCH_LIMIT, paging), mail/ImapClient.kt (fetchRecent -> paged),
sync workers/scheduler, a DAO for backfill progress
Dependencies
Pairs with #13 (retention bounds what's kept). Larger cache affects #21 (backup size)
and #22 (encrypted cache).
## Context
Today header sync is capped at the 50 most recent messages per folder
(`MailSyncer.FETCH_LIMIT = 50`); the existing `FetchPolicy` governs body/attachment prefetch,
not history depth. Per decision, the default becomes fetching the **entire** mailbox history.
## Scope
- [ ] Replace the fixed 50-header cap with a full-history sync: page backwards through each
folder (batched IMAP fetch) until the whole folder is cached.
- [ ] Run the backfill in the background (WorkManager) — resumable and cancellable — without
blocking foreground sync / pull-to-refresh; track per-folder progress (e.g. lowest UID
fetched).
- [ ] Keep respecting `FetchPolicy` for body/attachment prefetch (headers first; bodies per
policy).
- [ ] Batch + back off to avoid hammering the server or exhausting memory on large mailboxes;
surface progress in the UI.
- [ ] Applies to new and existing accounts; retention (#13) is the escape valve.
## Acceptance criteria
- A new account backfills its full history over time, not just 50 messages.
- Backfill survives process death / network loss and resumes; foreground UX stays responsive.
## Relevant files
- `data/sync/MailSyncer.kt` (FETCH_LIMIT, paging), `mail/ImapClient.kt` (`fetchRecent` -> paged),
sync workers/scheduler, a DAO for backfill progress
## Dependencies
Pairs with **#13** (retention bounds what's kept). Larger cache affects **#21** (backup size)
and **#22** (encrypted cache).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Context
Today header sync is capped at the 50 most recent messages per folder
(
MailSyncer.FETCH_LIMIT = 50); the existingFetchPolicygoverns body/attachment prefetch,not history depth. Per decision, the default becomes fetching the entire mailbox history.
Scope
folder (batched IMAP fetch) until the whole folder is cached.
blocking foreground sync / pull-to-refresh; track per-folder progress (e.g. lowest UID
fetched).
FetchPolicyfor body/attachment prefetch (headers first; bodies perpolicy).
surface progress in the UI.
Acceptance criteria
Relevant files
data/sync/MailSyncer.kt(FETCH_LIMIT, paging),mail/ImapClient.kt(fetchRecent-> paged),sync workers/scheduler, a DAO for backfill progress
Dependencies
Pairs with #13 (retention bounds what's kept). Larger cache affects #21 (backup size)
and #22 (encrypted cache).