Skip to content

feat(platform): sync and triage every connected mailbox - #2916

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/sync-every-connected-mailbox
Aug 5, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/sync-every-connected-mailbox

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Stacked on #2915 (which is stacked on #2914) — review those first.

Mail sync only ever read the connector's default credential. An org with two IMAP mailboxes — say Recruitment and General Support — had one of them silently unread until someone promoted it, and promoting it stopped the other. Same for a second Gmail account.

conversation.sync_mailbox now walks every active credential on the connector, each from its own watermark. Inbox triage gets the same reach through a new conversation.list_mailbox_messages.

The watermark has to come from bodies, not envelopes

This is the part worth the closest read. The obvious source for "how far did this pass get" is the newest sentAt in the listed envelopes. That only works for IMAP:

connector list_messages returns
gmail { id, threadId } — no timestamp at all
outlook receivedDateTime (ISO string)
imap-smtp sentAt (epoch ms)

An envelope-derived watermark leaves Gmail and Outlook unset forever: every scheduled pass re-lists the newest limit messages, re-fetches all their bodies, and anything that arrived beyond that window between passes is never picked up. So the tip is read from the fetched, normalized bodies — the one shape all three providers converge on. That also means the watermark can never step past a message the fetch leg dropped.

Gmail's date falls back to internalDate, which is epoch ms as a string — new Date(...) returns Invalid Date on it, so the parse handles the numeric form too.

One bad mailbox no longer starves the rest

A credential that fails (expired password, unreachable host) is caught, logged, reported in inbound.reason, and the fan-out continues. Previously the throw aborted the pass, so every mailbox after the broken one in the iteration order never synced — permanently, since the default sorts first. A pass where every credential fails still throws, so a genuinely broken connector stays loud.

Watermarks are persisted per credential inside the loop, so mailboxes that already succeeded keep their progress even when a later one fails.

Triage packs lose their provider dialect

The three */triage-inbox packs each carried their own query dialect (q: in:inbox / top + orderby / limit + mailbox). That dialect now lives in conversation.list_mailbox_messages, so the three documents differ only by the connectorSlug they pass. The parity test is tightened to match: it substitutes that one value and compares everything else, so a drifted limit expression or a pack pointed at the wrong connector both fail. IMAP UIDs are unique only per mailbox, so ids are scoped by credential name and each digest entry names the mailbox it came from.

Docs

platform/admin/connectors, platform/automations/builtin, and develop/connectors in en / de / fr — the default-credential rule now has a named exception, and the per-mailbox position and skip-on-failure behaviour are described where an admin will look for them.

Tests

Fan-out from independent watermarks, first-pass tail for a never-synced mailbox, Gmail's timestamp-free envelopes still advancing, internalDate string parsing, separate Inbox/Sent watermarks, failure isolation, all-failed throw, and the triage fan-out. Every new assertion was checked against a deliberately broken implementation before being kept. Green: 74,378 server tests, 194 docs, 1,165 i18n/UI.

Base automatically changed from feat/mail-sync-credential-watermark to main August 5, 2026 09:06
Mail sync only ever read the connector's default credential. An org
with two IMAP mailboxes — Recruitment and General Support — had one of
them silently unread until someone promoted it, and promoting it
stopped the other.

Walk every active credential instead, each from its own watermark, and
advance that watermark from the newest body the pass actually fetched.
Reading it from the listed envelopes would only work for IMAP: Gmail
lists `{id, threadId}` and Graph lists `receivedDateTime`, so neither
carries the `sentAt` the envelope path looked for, and both would have
sat at no watermark forever — refetching the same newest page every
run and losing anything that fell out of it. Bodies also mean the
watermark never steps past a message the fetch leg dropped.

A mailbox that fails is skipped for that pass and reported in the
result, not thrown: one expired password used to abort the run and
starve every mailbox behind it in the fan-out. A pass where all of
them fail still throws, so a broken connector stays loud.

Inbox triage gets the same reach through a new
`conversation.list_mailbox_messages`, which also ends the provider
dialect the three triage packs each carried: they now differ only by
the `connectorSlug` they pass, and their digests name the mailbox each
message came from.
@Israeltheminer
Israeltheminer force-pushed the feat/sync-every-connected-mailbox branch from ab2a5b1 to 1e93b48 Compare August 5, 2026 09:25
@Israeltheminer
Israeltheminer merged commit 3b059c0 into main Aug 5, 2026
43 of 45 checks passed
@Israeltheminer
Israeltheminer deleted the feat/sync-every-connected-mailbox branch August 5, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant