Skip to content

Sync mail into a flat per-account message list #9

Description

@Hohnik

Parent

Spec: MailChat MVP — email-as-chat

What to build

As a user, once I've connected an account, MailChat periodically polls it in the background and I can see the messages it fetched, per account, without manually refreshing. This ticket proves the ingestion pipeline (fetch → parse → persist → display) end-to-end; conversation grouping is not yet applied — messages are shown as a flat, ungrouped list per account.

Acceptance criteria

  • A parser converts raw RFC822/MIME message bytes into a structured representation: headers (From/To/Cc/Subject/Message-ID/In-Reply-To/References/Date) and a safely-renderable body (HTML converted/sanitized for display, no remote content execution).
  • A normalizer persists that parsed representation as a Message row tied to the account it was fetched from.
  • A background worker runs one polling task per connected account, fetching recent messages via the existing IMAP client and routing each through parser → normalizer; one account's failure/slowness does not block others from syncing.
  • A minimal htmx view lists synced messages per account (flat, ungrouped), and updates via polling as new mail arrives without a manual page reload.
  • Tests: sync-pipeline tests mocking only the IMAP connection boundary (same pattern as the existing imap_client tests), feeding real captured raw-message fixtures through the real parser → normalizer against a real temporary/in-memory SQLite database, asserting persisted Message rows are correct; an htmx route test asserting the flat message list renders correctly for a seeded account.

Blocked by

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions