Staging
Summary by CodeRabbit
-
New Features
- Added the ability to identify and display disconnected email connections, including a "Disconnected" badge and a "Reconnect" button in the connections settings UI.
- Automatic client redirection is now supported when certain server-side conditions are met.
-
Improvements
- Marking emails as read/unread or important now ensures mail counts and related data are refreshed automatically.
- Switching accounts refreshes additional user data for improved consistency.
- Enhanced error handling for expired connections, with automatic UI updates and redirection.
-
Bug Fixes
- Prevented AI email generation when both subject and message are empty, providing a clear error message.
-
Localization
- Added new English strings for "Reconnect" and "Disconnected" in email connection settings.
-
Chores
- Updated dependencies for improved stability.
- Database schema changes: connection tokens can now be null, and provider IDs are restricted to supported values.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| 0 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 13, 2025 3:37am |
[!CAUTION]
Review failed
The pull request is closed.
Walkthrough
This update introduces UI and backend changes to better handle disconnected mail connections. It identifies connections missing tokens, marks them as disconnected, and provides a "Reconnect" option in the UI. The backend exposes disconnected IDs, and the database schema is updated to allow nullable access tokens. Additional improvements include cache invalidation after mail mutations, localization updates, and handling server-driven client redirects.
Changes
| File(s) | Change Summary |
|---|---|
| apps/mail/app/(routes)/settings/connections/page.tsx, apps/mail/locales/en.json | Refactored connections UI to show "Disconnected" badge and "Reconnect" button for disconnected accounts; updated localization strings for new UI elements. |
| apps/server/src/trpc/routes/connections.ts, apps/server/src/trpc/trpc.ts | Backend now returns disconnectedIds for connections missing tokens; handles "invalid_grant" errors by clearing tokens and triggering client redirect via header. |
| packages/db/migrations/0026_smooth_norrin_radd.sql, packages/db/migrations/meta/0026_snapshot.json, packages/db/migrations/meta/_journal.json, packages/db/src/schema.ts | Database migration and schema changes: accessToken in connection table is now nullable; providerId type restricted; migration snapshot and journal updated. |
| apps/mail/components/context/thread-context.tsx, apps/mail/components/mail/mail-quick-actions.tsx, apps/mail/components/mail/mail.tsx, apps/mail/components/mail/thread-display.tsx, apps/mail/lib/hotkeys/mail-list-hotkeys.tsx | Added cache invalidation for mail count after marking threads as read/unread/important. |
| apps/mail/components/create/email-composer.tsx | Added validation to prevent AI email generation when both subject and message are empty; added paste event handler to attach files from clipboard; added "Remove All" attachments button. |
| apps/mail/components/ui/nav-user.tsx | Added cache invalidation for brain labels query after account switch; increased max width for displayed email in active account UI. |
| apps/mail/providers/query-provider.tsx, apps/server/src/main.ts | Added client-side redirect support via custom response header X-Zero-Redirect and exposed this header in CORS configuration. |
| apps/mail/package.json, packages/db/package.json, apps/server/package.json | Updated drizzle-kit and drizzle-orm package versions in relevant package.json files. |
| apps/server/src/lib/driver/google.ts | Minor whitespace and formatting adjustments, no logic changes. |
| apps/mail/components/party.tsx | Replaced custom debounce hook with remeda funnel utility for debouncing refetch calls, increasing debounce delay from 1s to 10s. |
| apps/server/src/lib/server-utils.ts | Moved token validation from getActiveConnection to connectionToDriver; simplified function signature; added explicit error throw for missing tokens. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant SettingsPage
participant Server
participant Database
participant AuthClient
User->>SettingsPage: Visit connections settings
SettingsPage->>Server: Fetch connections list
Server->>Database: Query connections (with tokens)
Database-->>Server: Return connections data
Server-->>SettingsPage: Return { connections, disconnectedIds }
SettingsPage->>User: Display connections
alt Connection is in disconnectedIds
SettingsPage->>User: Show "Disconnected" badge and "Reconnect" button
User->>SettingsPage: Click "Reconnect"
SettingsPage->>AuthClient: linkSocial(providerId, callbackUrl)
end
sequenceDiagram
participant Client
participant Server
participant Database
Client->>Server: Mail action (e.g., mark as read)
Server->>Database: Update mail status
Database-->>Server: Ack
Server-->>Client: Success response
Client->>Client: Invalidate mail count query cache
Client->>Server: Refetch mail count
Server->>Database: Query mail count
Database-->>Server: Return count
Server-->>Client: Return updated count
sequenceDiagram
participant Client
participant Server
Client->>Server: API request (with credentials)
Server-->>Client: Response with X-Zero-Redirect header (if needed)
alt X-Zero-Redirect header present
Client->>Client: window.location.href = header value
end
Possibly related PRs
- Mail-0/Zero#945: Modifies the connections settings page UI to display disconnected connections with a "Disconnected" badge and "Reconnect" button, directly relating to the same feature and component.
- Mail-0/Zero#954: Shares identical UI and logic changes for connection disconnect controls and reconnect functionality, indicating a direct relationship.
- Mail-0/Zero#942: Introduces initial debounce logic replaced and extended by this PR’s changes to debouncing with
remedafunnel utility.
Suggested reviewers
- needleXO
- ahmetskilinc
Poem
A bunny hopped through code today,
Connections lost, now show the way—
With badges red and buttons bright,
"Reconnect!" they urge, set things right.
Tokens nullable, caches clear,
The mailbox hums, the path is near.
🐇✨
[!TIP]
⚡️ Faster reviews with caching
- CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure
Review - Disable Cacheat either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off theData Retentionsetting under your Organization Settings.Enjoy the performance boost—your workflow just got faster.
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b6fd5fbe82e76dd60aa4b13bda01f6977988792e and 2b35b04962499246d788022a13ae6990f1a28a5d.
📒 Files selected for processing (8)
-
apps/mail/app/(routes)/settings/connections/page.tsx(3 hunks) -
apps/mail/components/create/email-composer.tsx(3 hunks) -
apps/mail/components/mail/mail-list.tsx(1 hunks) -
apps/mail/components/mail/mail.tsx(4 hunks) -
apps/mail/components/party.tsx(3 hunks) -
apps/mail/components/ui/nav-user.tsx(2 hunks) -
apps/mail/providers/query-provider.tsx(2 hunks) -
apps/server/src/lib/server-utils.ts(1 hunks)
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.