Add live-connection Sieve script management for JMAP accounts via
RFC 9661: list, create, edit, delete, and activate scripts.
Accessible via "Email filters" in the account popup menu.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add use_super_parameters, use_key_in_widget_constructors, and
avoid_positional_boolean_parameters to enforce modern Dart idioms and
prevent widget state-loss bugs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use xdg-open directly on Linux for opening attachments (fixes 'file type not supported' error)
- Add mime package for comprehensive MIME type detection in compose screen
- Show file size and MIME type for attachments in compose screen
- Add open/preview button for attachments in compose screen
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- New test/integration/email_repository_jmap_test.dart covers full sync,
incremental sync, server-side deletion reconciliation, getEmailBody
with cache, sendEmail, and flushPendingChanges (flag, delete, move).
- Fix: Email/set destroy must be an array per RFC 8620 §5.3; was passing
a bare string which Stalwart silently rejected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds downloadBlob() to JmapClient (RFC 8620 §6 downloadUrl template)
and routes downloadAttachment() to it for JMAP accounts. IMAP path
is unchanged.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds per-account incremental search (3+ chars, 300 ms debounce) that
queries local DB and shows results grouped: Folders → Addresses → Messages.
Address results link to a dedicated filtered-by-address email list screen.
Routes: /accounts/:id/search and /accounts/:id/emails/by-address/:addr.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- FolderDrawer widget: shows account name/email in header, sorted
folder list with unread badges; tapping a folder navigates via
context.go (replaces route rather than stacking)
- MailboxListScreen and EmailListScreen both get the drawer (burger
icon auto-appears) and the account display name in the AppBar
- Folder sort logic moved to folder_drawer.dart (shared)
- accountByIdProvider added to di.dart for reactive account lookup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tapping an account tile now opens the folder list rather than jumping
straight to INBOX. The redundant "All mailboxes" popup entry is removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
isLogEnabled now depends solely on the verbose zone flag, not kDebugMode.
Logs only flow to the sync log when account.verbose is true; stdout stays
silent in all builds.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Settings page was a duplicate of the accounts list with less
functionality. AccountListScreen now has a "Sync log" entry in each
account's popup menu and no longer has a settings icon in the app bar.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When account.verbose is true, raw IMAP/JMAP protocol traffic is captured
via a Zone, redacted of credentials (LOGIN password, AUTHENTICATE tokens),
and stored in the sync log entry for display in the sync log screen.
- DB schema v13: adds verbose column to accounts, protocolLog to sync_logs
- IMAP: Zone print-capture feeds ImapClient isLogEnabled output
- JMAP: JmapClient.call() writes request/response bodies to zone buffer
- Sync log screen: shows a monospace "Protocol log" block when present
- Edit account screen: adds verbose toggle with warning subtitle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sets isLogEnabled=kDebugMode on ImapClient so raw IMAP traffic appears
in the debug console without touching release builds.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each sync cycle now records per-mailbox fetched/skipped/bytes in a new
sync_log_mailboxes table and displays a collapsible "Per mailbox" section
in the sync log screen.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Multiple account sync loops share one DB. Without WAL, a write
transaction from one account blocks reads from another, causing
SQLITE_BUSY (code 5) errors even on SELECTs. WAL mode lets readers
and writers proceed concurrently. busy_timeout = 5 s makes SQLite
retry instead of immediately surfacing SQLITE_LOCKED on the rare
writer-writer conflict that WAL doesn't eliminate.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add _CapturingSyncLogRepository and two tests (IMAP + JMAP) that assert
a failed sync cycle produces an error entry in the sync log. Also
replace .ignore() in the catch blocks with a proper try-catch so the
sync log write is genuinely attempted and any secondary failure is
logged to stdout rather than silently dropped.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously the catch block awaited _syncLog.log(), so a second DB error
(e.g. lock contention) would escape the catch, skip the log() call and
the backoff delay, and surface as an unhandled exception. Using .ignore()
means a log write failure is silently dropped but the error is always
printed to stdout and the backoff always runs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without a transaction, N individual inserts each re-acquire the SQLite
write lock, creating a window where a concurrent sync-log write hits
SQLITE_LOCKED. The whole batch then throws, no checkpoint is saved, and
the inbox ends up with only the emails that inserted before the failure.
Wrapping in one transaction makes the batch atomic and holds the lock
for a single commit instead of N.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track how many emails were already up-to-date (skipped) and the
approximate bytes transferred per sync cycle. SyncEmailsResult
accumulates fetched/skipped/bytes across mailboxes; DB schema v11
adds emailsSkipped and bytesTransferred columns to sync_logs.
SyncLogScreen shows "X new · Y up-to-date · took Zs" in the tile
subtitle with full detail rows in the expansion panel.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- syncEmails/syncMailboxes/flushPendingChanges now return int counts
- SyncLogs DB schema v10: adds protocol, mailboxesSynced, pendingFlushed
- SyncLogEntry carries all new fields; AccountSyncManager collects and logs them
- SyncLogScreen uses ExpansionTile with per-row detail rows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All protocol-level fakes moved to integration tests. Only logout() and
serverInfo override remain, used by connection_test_service_test.dart.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All tests that needed real IMAP/SMTP now live in integration tests.
The max-attempts test uses an inline failing lambda, not the fake client.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add lcov to nix flake (required for flutter --merge-coverage)
- stalwart-dev/test.sh: collect and merge coverage when unit baseline exists
- run_unit_tests.sh: remove inline coverage check (now in dedicated task)
- Taskfile: add coverage task; check runs test → integration → coverage
sequentially so the gate sees combined unit + integration data
- check-fast (pre-commit) omits coverage gate since integration tests
don't run there; full gate runs only in task check
- Drop two untestable fake-only tests (UID-validity reset, malformed envelope)
- Coverage threshold restored to 80% (84% with merged data)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace full-sync fetchMessages(1:*) with UID SEARCH ALL + UID FETCH
so every message gets a reliable UID on all servers
- Guard CONDSTORE select on server capability to avoid BAD from
servers that do not advertise CONDSTORE/QRESYNC
- Add SyncLogEntry model + observeSyncLogs stream to SyncLogRepository
- Add SyncLogScreen with per-entry duration/error display
- Wire history icon in SettingsScreen → /accounts/:id/sync-log route
- Fix FakeImapClient to expose initialized serverInfo via field override
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause: flutter test ran all 3 integration test files in parallel
against the same Stalwart instance. Concurrent SMTP/IMAP from
email_repository_imap_test and concurrent_sync_test caused SMTP rate
limiting (4th send hung for ~27s) and flushPendingChanges race failures.
Fixes:
- stalwart-dev/test.sh: add --concurrency=1 so test files run serially
- concurrent_sync_test: reduce timeout 2 min → 30 s (tests now pass in ~2s)
- imap_client_factory + test helpers: set defaultResponseTimeout=20s on
ImapClient so individual IMAP commands never block indefinitely
- jmap_client: reduce HTTP call timeout 30 s → 10 s (local server; keeps
stacked-timeout total well below any reasonable per-test limit)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- IMAP CONDSTORE (RFC 7162): skip sync when HIGHESTMODSEQ is unchanged;
refresh only changed flags via CHANGEDSINCE on incremental sync
- JMAP blob expiry: re-fetch email bodies older than 7 days (schema v8→v9
adds nullable cachedAt column to email_bodies)
- Offline compose queue: expose stuck pending_changes rows via
observeFailedMutations / retryMutation / discardMutation; surface them
in a FailedMutationBanner on the mailbox list screen
- Unit tests for all three features (236 passing)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move JMAP send, push, and conflict-resolution items from Next steps
into Implemented features. Replace the next-steps section with
optional future work (CONDSTORE, blob expiry, UI for stuck mutations).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sends 4 emails (2 per direction) between alice (IMAP) and bob (JMAP),
then concurrently syncs both accounts and verifies the in-memory Drift
DB cache has no duplicates and contains all expected rows.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Check notUpdated/notDestroyed per-item errors in Email/set; throw
JmapSetItemException for permanent failures (notFound, forbidden) so
they are discarded immediately rather than retried
- Add _maxChangeAttempts=5 constant; _recordChangeError() evicts the
pending-change row when attempts reach the limit, preventing unbounded
queue growth from transient errors
- Both IMAP and JMAP flush paths now use _recordChangeError() consistently
- Document server-wins conflict-resolution policy in DB-SYNC.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add watchJmapPush(accountId, password) to EmailRepository; IMAP and
JMAP-without-push return Stream.empty() so callers fall through to polling
- EmailRepositoryImpl opens an SSE (text/event-stream) connection to the
server's eventSourceUrl; yields void on each StateChange event; properly
cancellable via StreamController.onCancel
- _JmapAccountSync._wait() subscribes to watchJmapPush and races it against
the 30 s poll timer and the stop signal — whichever fires first unblocks
the next sync cycle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- sendEmail dispatches on account type: IMAP keeps SMTP+APPEND path,
JMAP chains Email/set create + EmailSubmission/set in one API call
- Sent mailbox looked up by role='sent' from local DB so sent mail lands
in the right folder
- JmapClient gains uploadUrl/eventSourceUrl/capabilities from session,
supportsSubmission getter, withSubmission flag on call(), and uploadBlob()
for attachment upload before send
- Mailboxes table gains nullable role column (schema v8); _upsertJmapMailboxes
persists role from JMAP Mailbox/get response
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Include bodyValues/textBody/htmlBody/attachments in every Email/get call
during syncEmails; _upsertJmapEmails writes to email_bodies so first open
is instant even for freshly synced messages
- Extract _parseJmapBody helper shared by sync path and on-demand fetch
- Add JmapStateMismatchException; _applyPendingChangeJmap passes ifInState
and returns newState; on stateMismatch the local checkpoint is cleared so
the next cycle does a full re-sync before retrying the mutation
- Update DB-SYNC.md to reflect what has been implemented
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>