Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / email / AGENTS.md
| 1 | # AGENTS.md — email/ (':email') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `email/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install email (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :email / dir: email/ |
| 8 | - Package roots present: ui, data, platform, network, intents, widget |
| 9 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt |
| 10 | - Deps: :library:room, :library:widgets, :library:network |
| 11 | - Metadata: metadata_data/email.md (present) |
| 12 | - Rust: no / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** A modern open-source email client with a unified inbox across multiple accounts. Requires internet. |
| 16 | **Key features:** |
| 17 | - Unified inbox over any IMAP/SMTP provider, with presets + OAuth for Gmail/Outlook/Yahoo/iCloud/Fastmail |
| 18 | - Push mail over IMAP IDLE plus hourly poll for the rest; outbox retry, drafts, and snooze via WorkManager |
| 19 | - Composer with inline images (HTML editor + CID spans) and an EML file viewer |
| 20 | - Home-screen widget, rich notifications with actions, and assistant read/search intents |
| 21 | **Architecture / data-flow:** `ui/` Compose screens → `platform/EmailViewModel` (+ `EmailManager`, send/draft action helpers) → `data/` Room stores (`*Dao`/`*Store` pairs + `EmailRepository`) fed by workers (`EmailSyncWorker`, `ImapIdleService`, `OutboxSendWorker`, `SnoozeWorker`) → `network/` raw IMAP/SMTP clients. `MainActivity.onCreateBeforeContent`: `NetworkClient.init(SYSTEM)` first, then widget previews, intent handling, hourly-sync schedule, outbox flush, IDLE start, and two one-time backfills. |
| 22 | **Entry points + reading order:** `Route` (`MessageList` / `MessageThread` / `Composer` / `Outbox` / `Drafts` / `AddAccount` / `Settings` / `EmlViewer`) → `MainActivity.kt` → `Navigation.kt` → `ui/MainContent.kt` → `platform/EmailViewModel.kt` → `data/EmailRepository.kt`. |
| 23 | **Gotchas:** |
| 24 | - `NetworkClient.init(this, TrustBundle.SYSTEM)` must stay first in `onCreateBeforeContent` — mail servers need system CAs, not the first-party bundle |
| 25 | - `DateMillisBackfill`/`PeekContentBackfill` are one-time migrations gated on `runIfNeeded`; skipping them breaks sort order and snippet previews |
| 26 | - IDLE push is foreground-gated via `AppLifecycleTracker` — background delivery goes through the hourly worker + notifications, not the socket |
| 27 | - `network/imap/TrustAll.kt` exists for debug only; never widen its use |
| 28 | |
| 29 | ## Key files |
| 30 | ### Root — entry + navigation |
| 31 | - com/vayunmathur/email/MainActivity.kt |
| 32 | - com/vayunmathur/email/Navigation.kt |
| 33 | - com/vayunmathur/email/Route.kt |
| 34 | ### data/ — Room stores + sync workers |
| 35 | - com/vayunmathur/email/data/EmailModels.kt |
| 36 | - com/vayunmathur/email/data/EmailDatabase.kt |
| 37 | - com/vayunmathur/email/data/EmailAccountDao.kt |
| 38 | - com/vayunmathur/email/data/EmailAccountStore.kt |
| 39 | - com/vayunmathur/email/data/EmailMessageDao.kt |
| 40 | - com/vayunmathur/email/data/EmailMessageStore.kt |
| 41 | - com/vayunmathur/email/data/EmailOutboxDao.kt |
| 42 | - com/vayunmathur/email/data/EmailOutboxStore.kt |
| 43 | - com/vayunmathur/email/data/EmailQueryDao.kt |
| 44 | - com/vayunmathur/email/data/EmailQueryStore.kt |
| 45 | - com/vayunmathur/email/data/EmailRepository.kt |
| 46 | - com/vayunmathur/email/data/EmailSettings.kt |
| 47 | - com/vayunmathur/email/data/EmailSyncState.kt |
| 48 | - com/vayunmathur/email/data/EmailSyncWorker.kt |
| 49 | - com/vayunmathur/email/data/ImapIdleService.kt |
| 50 | - com/vayunmathur/email/data/ImapIdleRetryWorker.kt |
| 51 | - com/vayunmathur/email/data/OutboxSendWorker.kt |
| 52 | - com/vayunmathur/email/data/SnoozeWorker.kt |
| 53 | - com/vayunmathur/email/data/OutlookOAuth.kt |
| 54 | - com/vayunmathur/email/data/ProviderPresets.kt |
| 55 | - com/vayunmathur/email/data/CredentialCrypto.kt |
| 56 | - com/vayunmathur/email/data/DateMillisBackfill.kt |
| 57 | - com/vayunmathur/email/data/PeekContentBackfill.kt |
| 58 | ### network/ — raw IMAP + SMTP clients |
| 59 | - com/vayunmathur/email/network/imap/ImapClient.kt |
| 60 | - com/vayunmathur/email/network/imap/RawImapConnection.kt |
| 61 | - com/vayunmathur/email/network/imap/ImapWireIo.kt |
| 62 | - com/vayunmathur/email/network/imap/ImapParser.kt |
| 63 | - com/vayunmathur/email/network/imap/ImapFetchPipeline.kt |
| 64 | - com/vayunmathur/email/network/imap/MimeParser.kt |
| 65 | - com/vayunmathur/email/network/imap/MimeParserParts.kt |
| 66 | - com/vayunmathur/email/network/imap/ImapAuthException.kt |
| 67 | - com/vayunmathur/email/network/imap/TrustAll.kt — debug only |
| 68 | - com/vayunmathur/email/network/smtp/SmtpClient.kt |
| 69 | - com/vayunmathur/email/network/smtp/RawSmtpConnection.kt |
| 70 | - com/vayunmathur/email/network/smtp/MimeBuilder.kt |
| 71 | ### platform/ — ViewModel, actions, notifications, lifecycle |
| 72 | - com/vayunmathur/email/platform/EmailViewModel.kt |
| 73 | - com/vayunmathur/email/platform/EmailManager.kt |
| 74 | - com/vayunmathur/email/platform/EmailUiContract.kt |
| 75 | - com/vayunmathur/email/platform/EmailClientFlag.kt |
| 76 | - com/vayunmathur/email/platform/EmailSendActions.kt |
| 77 | - com/vayunmathur/email/platform/EmailDraftActions.kt |
| 78 | - com/vayunmathur/email/platform/AiSummaryHelper.kt |
| 79 | - com/vayunmathur/email/platform/EmailNotifications.kt |
| 80 | - com/vayunmathur/email/platform/EmailNotificationActionReceiver.kt |
| 81 | - com/vayunmathur/email/platform/AppLifecycleTracker.kt |
| 82 | - com/vayunmathur/email/platform/BootReceiver.kt |
| 83 | - com/vayunmathur/email/platform/EmlUtils.kt |
| 84 | - com/vayunmathur/email/platform/IntentState.kt |
| 85 | ### ui/ — list, thread, composer, account flows |
| 86 | - com/vayunmathur/email/ui/MainContent.kt |
| 87 | - com/vayunmathur/email/ui/MessageListScreen.kt |
| 88 | - com/vayunmathur/email/ui/MessageThreadScreen.kt |
| 89 | - com/vayunmathur/email/ui/FolderList.kt |
| 90 | - com/vayunmathur/email/ui/DetailItem.kt |
| 91 | - com/vayunmathur/email/ui/ComposerScreen.kt |
| 92 | - com/vayunmathur/email/ui/ComposerHeader.kt |
| 93 | - com/vayunmathur/email/ui/ComposerAttachments.kt |
| 94 | - com/vayunmathur/email/ui/ComposerHelpers.kt |
| 95 | - com/vayunmathur/email/ui/AttachmentItem.kt |
| 96 | - com/vayunmathur/email/ui/composer/EmailHtmlEditor.kt |
| 97 | - com/vayunmathur/email/ui/composer/EmailHtmlEditorController.kt |
| 98 | - com/vayunmathur/email/ui/composer/EmailHtmlSerializer.kt |
| 99 | - com/vayunmathur/email/ui/composer/EmailHtmlTagHandler.kt |
| 100 | - com/vayunmathur/email/ui/composer/EmailHtmlInline.kt |
| 101 | - com/vayunmathur/email/ui/composer/InlineImage.kt |
| 102 | - com/vayunmathur/email/ui/composer/CidImageSpan.kt |
| 103 | - com/vayunmathur/email/ui/DraftsScreen.kt |
| 104 | - com/vayunmathur/email/ui/OutboxScreen.kt |
| 105 | - com/vayunmathur/email/ui/EmlViewerScreen.kt |
| 106 | - com/vayunmathur/email/ui/AddAccountScreen.kt |
| 107 | - com/vayunmathur/email/ui/AddAccountSection.kt |
| 108 | - com/vayunmathur/email/ui/AddAccountInstructionsCard.kt |
| 109 | - com/vayunmathur/email/ui/OAuthActivity.kt |
| 110 | - com/vayunmathur/email/ui/SettingsScreen.kt |
| 111 | - com/vayunmathur/email/ui/EmailUiHelpers.kt |
| 112 | ### intents/ — assistant IPC |
| 113 | - com/vayunmathur/email/intents/GetRecentIntent.kt |
| 114 | - com/vayunmathur/email/intents/SearchIntent.kt |
| 115 | - com/vayunmathur/email/intents/EmailDataMapper.kt |
| 116 | ### widget/ — unified-inbox home widget |
| 117 | - com/vayunmathur/email/widget/EmailWidget.kt |
| 118 | - com/vayunmathur/email/widget/EmailWidgetReceiver.kt |
| 119 | |
| 120 | ## Verify (this module only) |
| 121 | ``` |
| 122 | ./gradlew :email:compileDevKotlin |
| 123 | ./gradlew :email:lint |
| 124 | ./gradlew :email:checkMetadata |
| 125 | ``` |