Skip to content

Introduce provider-neutral Mailbox Connection seam - #81

Merged
rajzik merged 2 commits into
mainfrom
codex/issue-50-introduce-mailbox-connection-seam
Jul 20, 2026
Merged

rajzik merged 2 commits into
mainfrom
codex/issue-50-introduce-mailbox-connection-seam

Conversation

@rajzik

@rajzik rajzik commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • introduce provider-neutral Mailbox Connection identities, mail-domain values, and explicit capabilities
  • route Gmail connection lifecycle, metadata sync, reading, push registration/wakeup sync, sending, and provider actions through the Gmail adapter
  • scope message and thread identity to a mailbox connection while preserving current Gmail behavior
  • document the boundary and add focused adapter, identity, view-model, session, and push-sync coverage

Validation

  • mise exec -- zsh scripts/check-apple-lint.zsh
  • mise exec -- xcodebuild test -quiet -project apps/unwired-mail/unwired-mail.xcodeproj -scheme unwired-mail -destination 'platform=iOS Simulator,name=iPhone 17'
  • mise exec -- pnpm lint
  • mise exec -- pnpm format
  • mise exec -- pnpm turbo run check-types
  • mise exec -- pnpm test
  • mise exec -- pnpm fallow
  • git diff --check

Closes #50


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features

    • Introduced a provider-neutral “Mailbox Connection” boundary with stable mailbox, thread, and message identities.
    • Updated Gmail integration to use capability-aware inbox operations (sync, read, search, categorize, push updates, send/reply/forward, and provider mail actions).
    • Adjusted inbox and connection UI to show only actions supported by the selected mailbox connection.
  • Bug Fixes

    • Improved inbox refresh and notification handling to use mailbox-scoped sync and cursor eligibility.
  • Documentation

    • Added documentation for the Mailbox Connection boundary and capabilities.
  • Tests

    • Added and updated test coverage for mailbox adapter routing and mailbox-scoped identities.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f45fcef-f56d-4007-bd16-fc1a5f467674

📥 Commits

Reviewing files that changed from the base of the PR and between 1f396db and b6d439b.

📒 Files selected for processing (3)
  • apps/unwired-mail/unwired-mail/Services/Mailbox/MailboxConnection.swift
  • apps/unwired-mail/unwired-mail/Services/ProductAccount/ProductAccountSession.swift
  • apps/unwired-mail/unwired-mailTests/GmailMessageMetadataServiceTests.swift
💤 Files with no reviewable changes (1)
  • apps/unwired-mail/unwired-mail/Services/ProductAccount/ProductAccountSession.swift

📝 Walkthrough

Walkthrough

The change introduces a provider-neutral MailboxConnection boundary, implements Gmail through that adapter, migrates account and inbox flows to mailbox identities and capabilities, updates session cleanup, and adds adapter, identity, and regression coverage.

Changes

Mailbox Connection seam

Layer / File(s) Summary
Mailbox contracts and Gmail adapter
apps/unwired-mail/unwired-mail/Services/Mailbox/..., README.md, docs/adr/..., .changeset/..., apps/unwired-mail/unwired-mail.xcodeproj/project.pbxproj
Adds mailbox identities, capabilities, protocols, threading/search models, Gmail mappings, and the GmailMailboxConnectionAdapter; registers and documents the boundary.
Mailbox-aware account and inbox flow
apps/unwired-mail/unwired-mail/Features/Account/AccountView.swift, apps/unwired-mail/unwired-mail/Services/Gmail/...
Routes connection, synchronization, search, reading, push, categorization, actions, and sending through mailbox types and capability checks, with connection-scoped stale-result guards.
Mailbox-based session cleanup
apps/unwired-mail/unwired-mail/Services/ProductAccount/ProductAccountSession.swift
Changes bootstrap, sign-in, sign-out, and account-switch cleanup to use MailboxConnectionClearing, defaulting to the Gmail mailbox adapter.
Adapter and migration validation
apps/unwired-mail/unwired-mailTests/...
Verifies adapter routing, provider-neutral capabilities, mailbox-scoped identities, inbox/search/categorization behavior, push handling, and session cleanup.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • unwired-dev/product#31: Shares the Gmail provider mail-action pipeline later routed through mailbox capabilities.
  • unwired-dev/product#38: Shares the Gmail push wakeup and synchronization flow refactored to mailbox types.
  • unwired-dev/product#49: Shares the Gmail provider connection flow integrated with the new adapter boundary.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing a provider-neutral Mailbox Connection seam.
Linked Issues check ✅ Passed The seam, identities, explicit capabilities, tests, and docs align with the linked issue's acceptance criteria.
Out of Scope Changes check ✅ Passed The changes stay focused on the mailbox seam, adapter, tests, and docs with no unrelated functionality evident.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-50-introduce-mailbox-connection-seam

Comment @coderabbitai help to get the list of available commands.

@rajzik

rajzik commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 1f396dbd80

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rajzik
rajzik marked this pull request as ready for review July 20, 2026 14:20
@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/unwired-mail/unwired-mail/Services/Mailbox/MailboxConnection.swift`:
- Around line 250-259: Update the date formatting logic in dateText(for:) to
reuse a single static DateFormatter configured with the existing calendar,
format, locale, and time zone instead of constructing one per call. Keep
dateText(for:)’s output and timestamp conversion unchanged.

In
`@apps/unwired-mail/unwired-mail/Services/ProductAccount/ProductAccountSession.swift`:
- Line 21: Remove the unused gmailMessageBodyReader property from
ProductAccountSession, along with its initializer parameter and assignment.
Update all call sites to stop passing this dependency while preserving
mailboxConnectionService.clearLocalConnection(...) for body-cache cleanup.

In `@apps/unwired-mail/unwired-mailTests/GmailMessageMetadataServiceTests.swift`:
- Around line 1890-1906: Update RecordingGmailMessageSearchService and
DelayedGmailMessageSearchService so searchProvider records the supplied
MailboxConnection instead of discarding it. Add a synced/search connection
property following the RecordingPushGmailMetadataSyncService pattern, and
preserve the existing query and message behavior so tests can assert routing
explicitly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9cae6888-a500-479d-bb6d-217f0ff75ab4

📥 Commits

Reviewing files that changed from the base of the PR and between deebe5d and 1f396db.

📒 Files selected for processing (14)
  • .changeset/provider-neutral-mailbox-connection.md
  • README.md
  • apps/unwired-mail/unwired-mail.xcodeproj/project.pbxproj
  • apps/unwired-mail/unwired-mail/Features/Account/AccountView.swift
  • apps/unwired-mail/unwired-mail/Services/Gmail/GmailMessageMetadataService.swift
  • apps/unwired-mail/unwired-mail/Services/Gmail/GmailPushRelayService.swift
  • apps/unwired-mail/unwired-mail/Services/Mailbox/MailboxConnection.swift
  • apps/unwired-mail/unwired-mail/Services/ProductAccount/ProductAccountSession.swift
  • apps/unwired-mail/unwired-mailTests/GmailMessageMetadataServiceTests.swift
  • apps/unwired-mail/unwired-mailTests/GmailProviderConnectionServiceTests.swift
  • apps/unwired-mail/unwired-mailTests/GmailPushRelayServiceTests.swift
  • apps/unwired-mail/unwired-mailTests/MailboxConnectionAdapterTests.swift
  • apps/unwired-mail/unwired-mailTests/ProductAccountSessionTests.swift
  • docs/adr/0011-provider-native-mail-adapters.md

Comment thread apps/unwired-mail/unwired-mail/Services/Mailbox/MailboxConnection.swift Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce provider-neutral Mailbox Connection seam

1 participant