# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Simplified the email assistant system prompt for clarity and added server-side tool execution for voice and web integrations.
- **Refactors**
- Rewrote the assistant prompt to be shorter, more direct, and easier for models to follow.
- Removed unused and verbose prompt sections.
- **New Features**
- Added a server-side tool execution endpoint and utility for handling tool calls from the client.
- Introduced a script to register all tools with ElevenLabs for voice agent integration.
<!-- End of auto-generated description by cubic. -->
## Description
This PR integrates Dormroom for managing durable objects and enabling queryable storage for email agents. It improves how we handle agent instances and database operations, making our system more robust and maintainable.
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- ⚡ Performance improvement
## Areas Affected
- [x] Email Integration (Gmail, IMAP, etc.)
- [x] Data Storage/Management
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Checklist
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
## Key Changes
1. Added Dormroom dependency for better durable object management
2. Implemented `@Migratable` and `@Queryable` decorators for ZeroDriver class
3. Created new `getZeroClient` function to replace direct agent instantiation
4. Fixed redirect header handling to prevent header persistence after redirects
5. Improved folder sync logic to skip unnecessary operations for aggregate instances
6. Standardized environment variable access through instance properties
7. Added structured database migrations for thread storage
8. Enhanced type safety with proper environment type definitions
These changes improve our agent architecture and make database operations more reliable while maintaining backward compatibility.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Introduced new methods for database size reporting and conditional folder synchronization.
* Added structured environment typing for improved configuration management.
* **Refactor**
* Standardized environment variable access throughout the server and agent components.
* Migrated database schema management to a migration system.
* Updated client acquisition logic to utilize execution context.
* **Bug Fixes**
* Improved redirect handling in the mail provider to clean up response headers after navigation.
* Adjusted redirect logic to only trigger under specific authorization conditions.
* **Chores**
* Added the "dormroom" dependency to the server application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Added Sentry error monitoring to the Cloudflare worker environment to capture and report runtime errors.
- **Dependencies**
- Installed the @sentry/cloudflare package and updated configuration for Sentry integration.
<!-- End of auto-generated description by cubic. -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Added a utility for bulk deleting Cloudflare KV keys and updated workflow processing to use it for more efficient cleanup.
- **Dependencies**
- Added the Cloudflare SDK as a new dependency.
<!-- End of auto-generated description by cubic. -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Added the Effect language service for improved TypeScript support and set up pretty logging for better error and debug output.
- **Dependencies**
- Added @effect/language-service as a dev dependency and configured it in tsconfig.
- **Refactors**
- Updated logging to use Effect's pretty logger for clearer logs.
<!-- End of auto-generated description by cubic. -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Added automatic user topics generation from email subjects and improved label management to keep labels in sync with user interests.
- **New Features**
- Generates 1–6 user topics based on email subjects and creates labels for them if needed.
- Stores and caches generated topics for faster access.
- Exposes user topics via agent API and broadcasts updates to the frontend.
- **Refactors**
- Centralized Google service account parsing.
- Improved thread and label change handling in pipelines for better reliability.
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Introduced user topic generation from email subjects to highlight user interests.
* Enabled retrieval, display, and automatic creation of labels for user topics with cache management.
* Added real-time notifications for user topic updates.
* Added manual mail folder reload capability.
* **Enhancements**
* Improved label synchronization with detailed tracking of label changes per thread.
* Updated email thread labeling instructions for clarity and flexibility.
* Unified service account handling across workflows.
* **Bug Fixes**
* Fixed cache invalidation for user topics to ensure up-to-date information.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Removed all Prometheus metrics and Grafana integration from the server codebase.
- **Dependencies**
- Removed prom-client and related packages from dependencies and lockfile.
<!-- End of auto-generated description by cubic. -->
## Description
Added 'style' tag to the list of allowed HTML tags in the email sanitization configuration. This change enables the preservation of inline CSS styles when processing email HTML content, which is important for maintaining the original formatting and appearance of emails.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Enhanced email content display by allowing inline styles in emails.
* Improved security by sanitizing CSS within email styles to allow only safe properties and block harmful rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# feat: add Grafana monitoring for ZeroAgent, ZeroDriver, and tRPC performance
## Summary
Implements centralized Grafana monitoring for the Zero server to track performance metrics across tRPC API calls, ZeroDriver operations, and email handling. The implementation uses Prometheus-format metrics that can be scraped by Grafana Cloud for observability and performance analysis.
**Key Components:**
- **Centralized metrics utility** (`src/lib/metrics.ts`) with Prometheus counters and histograms
- **tRPC middleware** for automatic API call timing and success/error tracking
- **ZeroDriver instrumentation** for email operations (markAsRead, create)
- **Metrics endpoint** (`/metrics`) for Prometheus scraping
- **Environment-based configuration** for Grafana Cloud integration
**Metrics Tracked:**
- `trpc_request_duration_seconds` - API call timing by procedure and status
- `trpc_requests_total` - API call counts by procedure and status
- `zero_driver_operation_duration_seconds` - Email operation timing
- `email_operations_total` - Email operation counts by provider and status
- `zero_agent_operation_duration_seconds` - Agent operation timing (framework ready)
## Review & Testing Checklist for Human
- [ ] **Test actual metric collection** - Perform real email operations (read, compose, sync) and verify metrics are collected at `/metrics` endpoint
- [ ] **Performance verification** - Monitor response times during normal usage to ensure no degradation from monitoring overhead
- [ ] **Environment configuration** - Set up `GRAFANA_ENDPOINT`, `GRAFANA_USERNAME`, `GRAFANA_PASSWORD` in staging/production environments
- [ ] **Staging deployment test** - Deploy to staging and verify Cloudflare Workers compatibility (removed `collectDefaultMetrics()` due to Node.js API incompatibility)
- [ ] **Complete instrumentation** - Consider adding monitoring to remaining ZeroAgent operations and additional ZeroDriver methods as needed
---
### Diagram
```mermaid
%%{ init : { "theme" : "default" }}%%
graph TD
subgraph "Core Server"
A["src/main.ts<br/>+metrics endpoint"]:::major-edit
B["src/trpc/trpc.ts<br/>+middleware"]:::major-edit
end
subgraph "Monitoring Infrastructure"
C["src/lib/metrics.ts<br/>NEW centralized utility"]:::major-edit
D["src/overrides.d.ts<br/>+TypeScript types"]:::minor-edit
end
subgraph "Email Operations"
E["src/routes/agent/index.ts<br/>+ZeroDriver monitoring"]:::major-edit
end
subgraph "Configuration"
F["wrangler.jsonc<br/>+environment vars"]:::minor-edit
G["package.json<br/>+prom-client"]:::minor-edit
end
A --> C
B --> C
E --> C
C --> F
D --> F
subgraph Legend
L1[Major Edit]:::major-edit
L2[Minor Edit]:::minor-edit
L3[Context/No Edit]:::context
end
classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
```
### Notes
- **Cloudflare Workers Compatibility**: Removed `collectDefaultMetrics()` due to `process.cpuUsage` incompatibility - this is expected and handled
- **Async Design**: Metrics collection is non-blocking to minimize performance impact
- **Partial Implementation**: Currently instruments key ZeroDriver operations; additional operations can be added incrementally
- **Environment Variables**: All Grafana configuration is externalized for security and flexibility
**Link to Devin run**: https://app.devin.ai/sessions/f88e66bd577843aba5f0d452d4dfe0e8
**Requested by**: @MrgSub

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Added Grafana monitoring for ZeroAgent, ZeroDriver, and tRPC performance by exposing Prometheus-format metrics and instrumenting key operations.
- **New Features**
- Centralized metrics utility for tracking API and email operation performance.
- tRPC middleware and ZeroDriver methods now record timing and status metrics.
- `/metrics` endpoint added for Prometheus scraping.
- Environment variables support Grafana Cloud integration.
<!-- End of auto-generated description by cubic. -->
# Improved Attachment Handling and UI Refinements
## Description
This PR improves email attachment handling by implementing on-demand attachment fetching and enhancing error handling. It also includes several UI refinements to the email composer and navigation components.
Key changes:
- Added a dedicated hook and API endpoint for fetching message attachments
- Improved error handling with user-facing toast notifications for attachment operations
- Updated the email composer to hide subject input when replying to messages
- Enhanced styling for compose button, categories dropdown, and search bar
- Fixed attachment loading issues by fetching data on demand instead of storing large attachment data
## Type of Change
- [x] 🐛 Bug fix (non-breaking change which fixes an issue)
- [x] ✨ New feature (non-breaking change which adds functionality)
- [x] 🎨 UI/UX improvement
- [x] ⚡ Performance improvement
## Areas Affected
- [x] Email Integration (Gmail, IMAP, etc.)
- [x] User Interface/Experience
- [x] Data Storage/Management
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Security Considerations
- [x] No sensitive data is exposed
- [x] Input validation is implemented
## Checklist
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
## Additional Notes
The attachment handling improvements should resolve issues where large attachments were causing performance problems or failing to load properly. The UI refinements provide a more consistent experience across the application.
## Description
Refactored the AI chat component and email assistant to improve performance, reliability, and user experience. This PR introduces a new `inboxRag` tool for natural language email search, replaces the previous `listThreads` implementation, and enhances the prompt design for more efficient inbox management.
---
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- ⚡ Performance improvement
## Areas Affected
- [x] Email Integration (Gmail, IMAP, etc.)
- [x] User Interface/Experience
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Checklist
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
## Additional Notes
Key improvements:
- Added `ThreadPreview` component to replace the previous thread rendering approach
- Refactored `ToolResponse` to use specialized subcomponents for different tool types
- Updated AI prompts with better instructions for multi-step and parallel operations
- Switched backend models to Claude 3.5 for improved reasoning capabilities
- Fixed key prop issues in attachment rendering to prevent React warnings
- Increased agent max steps from 5 to 10 for more complex operations
- Added better markdown styling support for lists and other elements
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Introduced advanced AI-powered inbox search and organization with new tools and richer assistant guidance.
* Added support for Anthropic AI models for chat and search tasks.
* Enabled new streaming tool for natural language inbox search.
* **Improvements**
* Enhanced AI assistant prompt with detailed instructions, expanded use cases, and improved communication style.
* Modularized and streamlined AI chat component for clearer tool response rendering and better markdown styling.
* Increased chat step limit in the AI sidebar for longer conversations.
* Improved uniqueness of attachment keys to prevent display issues.
* **Bug Fixes**
* Corrected parameter naming for thread and draft listing to ensure accurate pagination.
* **Chores**
* Updated dependencies and environment variables for improved configuration and model support.
* Cleaned up unused code and imports for better maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# Refactor Email Processing Pipeline to Use Effect Library
This PR refactors the email processing workflow from using Cloudflare Workers' Workflow API to using the Effect library for better error handling and functional programming patterns. The main changes include:
1. Replaced workflow-based implementation with Effect-based implementation
2. Added queue-based processing for thread notifications
3. Improved CORS handling with more robust origin validation
4. Fixed Google service account validation to properly handle empty JSON
5. Changed UI label from "Labels" to "Categories" in the mail component
6. Added selective query persistence in the query provider
7. Improved error handling throughout the notification pipeline
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- ⚡ Performance improvement
## Areas Affected
- [x] Email Integration (Gmail, IMAP, etc.)
- [x] User Interface/Experience
- [x] Data Storage/Management
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Security Considerations
- [x] No sensitive data is exposed
- [x] Authentication checks are in place
- [x] Input validation is implemented
## Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in complex areas
- [x] My changes generate no new warnings
## Additional Notes
The Effect library provides better error handling and composability compared to the previous workflow implementation. This change should improve reliability and maintainability of the email processing pipeline.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Enhanced email processing with new effect-based workflows for email data handling, summarization, and vectorization.
* Improved thread and message history retrieval capabilities with retry logic.
* **Bug Fixes**
* Fixed label text in the mail UI from "Labels" to "Categories".
* Improved error handling and validation for environment variables.
* **Refactor**
* Major restructuring of workflow logic to use effect-based functions for better reliability and maintainability.
* Simplified query cache invalidation and persistence logic.
* Updated server workflow imports and exports to use new pipeline functions.
* Streamlined server route logic for thread synchronization and authorization.
* Replaced local prompt name helper with centralized implementation.
* **Chores**
* Updated server dependencies.
* Cleaned up configuration files by removing unused workflow bindings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](https://github.com/Mail-0/Zero/blob/staging/.github/CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
# Add image support to email composer
This PR adds support for inline images in the email composer. Users can now drag and drop or paste images directly into the email body, which will be properly embedded in the outgoing emails.
## Key changes:
- Added TipTap extensions for image handling and file handling
- Modified the sanitize HTML function to process base64 images and convert them to CID references
- Updated Google and Microsoft mail managers to handle inline images in emails
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Added support for inserting and handling images (including drag-and-drop and paste) in the email composer.
* Inline images are now properly embedded and displayed in sent emails and drafts.
* **Bug Fixes**
* Improved sanitization to allow safe image embedding while restricting allowed tags and attributes.
* **Chores**
* Updated and added dependencies to support image handling and improved email processing.
* Removed the toast notification test route and related UI.
* **Refactor**
* Streamlined attachment processing and schema handling for better reliability and maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# Implement Gmail Push Notifications with Workflows
This PR implements a comprehensive Gmail push notification system using Cloudflare Workflows. It creates a subscription factory pattern to handle different email providers, with Google implementation completed. The system processes Gmail history updates, vectorizes messages, generates thread summaries, and applies AI-generated labels.
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- ⚡ Performance improvement
## Areas Affected
- [x] Email Integration (Gmail, IMAP, etc.)
- [x] User Interface/Experience
- [x] Data Storage/Management
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in complex areas
- [x] My changes generate no new warnings
## Additional Notes
Key changes:
1. Created subscription factory pattern with Google implementation
2. Added Cloudflare Workflows for processing Gmail notifications
3. Implemented thread and message vectorization
4. Added AI-based thread labeling
5. Fixed string template in party.tsx component
6. Added cheerio for HTML parsing
7. Enabled interactive dev session in wrangler config
The system now processes Gmail notifications in real-time, extracts meaningful data, and provides AI-generated labels for better email organization.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Introduced advanced workflows for processing and labeling email threads using AI, including summarization, vectorization, and automatic label assignment.
- Added support for managing subscriptions and notifications for Google and Outlook email providers.
- Implemented user notification and token verification features for enhanced security and real-time updates.
- **Improvements**
- Streamlined subscription management with new queue-based and scheduled background processing for renewals and state tracking.
- Enhanced label management with detailed default categories for email threads.
- Improved connection and subscription state handling for greater reliability and clarity.
- **Bug Fixes**
- Adjusted connection handling to ensure correct context usage and state updates.
- **Chores**
- Updated environment configurations to support new workflows, queues, and storage namespaces.
- Added new dependencies and updated development scripts for improved development experience.
- **Documentation**
- Expanded type definitions and documentation for new features and provider support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Description
### ElevenLabs Agent Configuration
1. Add **Webhook** Tool Call `manage_email`
- Description:
```
The manage_email tool lets the assistant perform any necessary mailbox operations—like listing, reading, composing, sending, labeling, archiving, or deleting emails—by translating a single, natural-language instruction (e.g., “List my unread messages”) into the appropriate API call.
```
- Method: `POST`
- URL:
```ts
`https://${hostname}/api/ai/call/${connectionId}`
```
^ Update `hostname` and `connectionId` to the hardcoded versions.
- Response timeout (seconds): `120 secs` (max)
- Parameters:
- Data type: `String`
- Identifier: `query`
- Required: `true`
- Value Type: `LLM Prompt`
- Description:
```
Create a query that encompasses what the user wants to do with their email.
```
2. In Voice Tab:
- TTS output format: `μ-law 8000 Hz`
3. In Advanced Tab:
- User input audio format: `μ-law 8000 Hz`
4. In Agent Tab:
- LLM: `Claude Sonnet 4`
- Temperature: `Creative`
- System prompt:
```
You are an AI email assistant that uses clear and concise language in a conversational style. Treat manage_email calls as if you are performing the actions directly and reporting back to the user—never say “the system is asking” or mention the tool. Always let the user know you’re looking into their request before you run the action, since processing may take a few seconds. After you have the information, respond naturally—do not simply repeat raw JSON or refer to "the tool."
If a user’s request does not involve reading, searching, composing, sending, labeling, archiving, or deleting emails, reply politely that you can only handle mailbox tasks. Never hallucinate; if you’re uncertain of user intent or missing details, ask follow-up questions before taking any action.
Tool: manage_email
- Parameter:
{ \"query\": \"<string>\" }
- The query must be a single natural-language instruction that the webhook can interpret, for example:
\"List my unread messages\"
\"Compose a reply to Anna about the budget\"
\"Archive all emails from last week\"
\"Mark these messages as read\"
Behavior Guidelines
1. Acknowledge and notify before running the action
- e.g., “Sure, let me check that for you…” or “I’m looking into your inbox now…”
2. Confirm the request involves mailbox operations
- If yes, ensure you have all necessary details; if not, reply: “I’m sorry, I can only help with email-related tasks.”
3. Ask for missing information
- If you need details like which thread, recipient, or time period, ask before proceeding.
4. Execute exactly one action per email request
- Translate the user’s intent into a concise query string.
- Run that action once.
6. Respond as if you performed it yourself
- Once you have the results, use them as context. Summarize or expand in natural, conversational language, as if you retrieved and processed it yourself.
- Highlight urgent topics, dates, deadlines, or actions the user should not miss.
- Do not include raw IDs, metadata, or technical details unless they clarify the answer.
7. Avoid duplicate actions
- Only run another action if a follow-up genuinely requires it.
8. Always end by offering further help
- After each response, ask if the user needs anything else or any further assistance.
Common Scenarios
- Listing or searching
User: “Show me my latest emails.”
Assistant: “Sure, let me check your inbox… [runs action]”
Action:
{ \"query\": \"List my latest 10 emails in inbox\" }
Assistant: (once complete) “Here are your ten most recent messages. I notice one about the project deadline on June 5—you might want to review that soon. Anything else I can help with?”
- Reading a message or thread
User: “Read the email from Sarah about the design update.”
Assistant: “Okay, fetching that now… [runs action]”
Action:
{ \"query\": \"Get and display the email from Sarah about the design update\" }
Assistant: (once complete) “Sarah’s message says the design review is scheduled for tomorrow at 2 PM. She’s asking if you can finalize the mockups by end of day. Let me know if you need anything else.”
- Composing or replying
User: “Draft a reply to Tom about tomorrow’s meeting.”
Assistant: “Who should I send it to, and any specific points you want to include?”
(Once details are gathered)
Assistant: “Great, drafting that now… [runs action]”
Action:
{ \"query\": \"Compose a reply to Tom saying I will attend tomorrow’s meeting and confirm the agenda\" }
Assistant: (once complete) “Here’s the draft: ‘Hi Tom, I’ll be there for tomorrow’s meeting at 10 AM. Could you confirm the agenda so I can prepare? Thanks!’ Would you like any edits or need anything else?”
- Sending an email or draft
User: “Send the draft I just approved to the team.”
Assistant: “Sending that now… [runs action]”
Action:
{ \"query\": \"Send the approved draft to team@example.com with subject 'Team Update'\" }
Assistant: (once complete) “Your update was sent successfully to team@example.com. Anything else I can help with?”
- Modifying labels, archiving, or deleting
User: “Archive all emails from last month.”
Assistant: “Got it—archiving now… [runs action]”
Action:
{ \"query\": \"Archive all emails from last month\" }
Assistant: (once complete) “All emails from May have been archived. Need anything else?”
- Creating or deleting labels
User: “Create a label called Important with blue background and white text.”
Assistant: “I’ll set that up… [runs action]”
Action:
{ \"query\": \"Create label Important with background #0000FF and text #FFFFFF\" }
Assistant: (once complete) “Label ‘Important’ was created successfully. Would you like any more help?”
Response Style
- Always reply conversationally, using natural language and a friendly tone.
- Before each action, reassure the user that you’re retrieving their information.
- After you have the results, interpret them for the user—explain what they mean and what next steps to consider.
- If a request isn’t about mailbox operations, politely decline with: “I’m here to help with email tasks—could you clarify if you need mailbox actions?”
- Never provide speculative or hallucinated details; when in doubt, ask for clarification.
- Always be friendly, and at the end of your responses ask if the user needs anything else or any further assistance.
```
---
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Introduced a new POST /call endpoint that processes user queries with AI-powered Gmail tools, enabling actions such as searching emails, listing threads, retrieving details, managing labels, and more.
- **Bug Fixes**
- Removed all Twilio and WebSocket-based call handling, simplifying the interface and eliminating related errors.
- **Refactor**
- Streamlined the server by removing legacy call service logic and consolidating AI-driven Gmail operations under a single endpoint.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
### TL;DR
Added a new voice assistant feature to the mail app using ElevenLabs integration.
### What changed?
- Created a new voice assistant page at `/mail/voice` with a complete UI for voice interactions
- Added a navigation item for the Voice Assistant under a new "AI & Tools" section
- Updated the ElevenLabs package from `@11labs/react` to `@elevenlabs/react` (version 0.1.5)
- Added localization support for the voice assistant feature
- Implemented email context loading to provide the assistant with recent email information
### How to test?
1. Navigate to `/mail/voice` in the mail app
2. Ensure you're logged in and have granted microphone permissions
3. Click "Start Conversation" to begin interacting with the voice assistant
4. Test the mute/unmute functionality during conversation
5. Verify that recent emails are properly loaded and provided as context
### Why make this change?
This change enhances the mail application with voice interaction capabilities, allowing users to interact with their email through natural language. The voice assistant can access recent emails for context, providing a hands-free way to manage email communications. This feature improves accessibility and offers an alternative interface for users who prefer voice commands over traditional input methods.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Introduced a voice assistant feature, including a VoiceButton UI for starting and managing voice interactions within the mail app.
- Added a global keyboard shortcut ("v") to quickly open the voice assistant.
- Implemented a new alert component for improved user notifications.
- Added localization for the voice assistant in the navigation sidebar.
- **Enhancements**
- Updated the Sparkles icon with improved color and opacity styling.
- **Bug Fixes**
- Corrected localization string formatting for error messages.
- **Chores**
- Updated and reorganized dependencies to support new voice and AI features.
- Added new context providers for managing voice interactions throughout the app.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# Switch to Groq LLM and Improve AI Sidebar Focus
This PR switches the AI model from OpenAI's GPT-4o to Groq's Llama-4-Maverick for both the ZeroAgent and search query generation. It also improves the AI sidebar UX by automatically focusing the editor when the sidebar is opened.
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- ⚡ Performance improvement
## Areas Affected
- [x] User Interface/Experience
- [x] API Endpoints
## Testing Done
- [x] Manual testing performed
## Checklist
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
## Additional Notes
The PR includes:
1. Adding Groq SDK dependency
2. Switching from OpenAI to Groq LLM models
3. Adding auto-focus to the AI sidebar editor when opened
4. Cleaning up unused code in mail components
5. Simplifying the AI sidebar toggle logic
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- The editor in the AI chat sidebar now automatically gains focus when the sidebar is opened.
- **Refactor**
- Simplified the logic and state management for sidebar and bulk selection actions in the mail app.
- Streamlined sidebar open/close toggling for improved reliability.
- **Chores**
- Switched AI model provider from OpenAI GPT-4o to Groq’s Llama 4 Maverick model for chat and search features.
- Updated server dependencies to include the new Groq AI SDK.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
…essing
# READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.
## Description
Please provide a clear description of your changes.
---
## Type of Change
Please delete options that are not relevant.
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement
## Areas Affected
Please check all that apply:
- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure
## Testing Done
Describe the tests you've done:
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)
## Security Considerations
For changes involving data or authentication:
- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)
## Checklist
- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published
## Additional Notes
Add any other context about the pull request here.
## Screenshots/Recordings
Add screenshots or recordings here if applicable.
---
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Introduced AI voice call handling with Twilio and ElevenLabs integration, enabling real-time conversational AI over phone calls.
- Added a new /ai API route for voice and call management.
- Implemented a system prompt for an AI email assistant with robust tool invocation and safety protocols.
- Added a new database table for key management (JWKS).
- Added endpoints for obtaining signed URLs for ElevenLabs conversational AI.
- Added voice-related API routes and integrated voiceRouter into main API.
- **Improvements**
- Enhanced authentication by supporting bearer tokens and refining session user handling throughout the app.
- Updated Zod schema descriptions for improved API documentation.
- Streamlined context management for user sessions across server routes and procedures.
- **Chores**
- Updated dependencies and added new packages for Twilio, ElevenLabs, and JOSE.
- Added scripts for streamlined Docker database management and development startup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
# Add Intercom integration and enhance phishing detection in mail display
## Description
This PR adds Intercom integration for customer support and enhances the phishing detection capabilities in the mail display component. The changes include:
1. Integrating Intercom messenger for user support with secure JWT authentication
2. Enhancing the AI web search query to better identify suspicious domains and potential phishing attempts
3. Reorganizing the help and feedback UI elements in the navigation sidebar
## Type of Change
- ✨ New feature (non-breaking change which adds functionality)
- 🔒 Security enhancement
- 🎨 UI/UX improvement
## Areas Affected
- [x] User Interface/Experience
- [x] Authentication/Authorization
- [x] Security
## Testing Done
- [x] Manual testing performed
## Security Considerations
- [x] No sensitive data is exposed
- [x] Authentication checks are in place
- [x] JWT implementation for secure Intercom authentication
## Checklist
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
## Additional Notes
The phishing detection enhancement improves security by adding domain validation to the AI search query, helping users identify suspicious email domains more effectively. The Intercom integration provides a direct support channel for users within the application.
_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Added Intercom messenger integration, allowing users to access help via a new "Help" button in the sidebar.
- Introduced a "Feedback" navigation item in the sidebar for quick access to external feedback submission.
- **Enhancements**
- Improved person background search to include phishing detection and domain validity context.
- **Chores**
- Updated dependencies to support new features.
- Adjusted navigation configuration for sidebar items.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **Chores**
- Updated React and its TypeScript type definitions to the latest versions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Removed unused esbuild configuration for dropping console statements.
- Updated `vite.config.ts` to streamline configuration.
- Enhanced `wrangler.jsonc` with environment-specific variables for local, staging, and production.
- Refactored components to utilize `useActiveConnection` for managing active connections, ensuring consistent access across the application.
- Adjusted various components (e.g., `page.tsx`, `mail-display.tsx`, `nav-user.tsx`) to replace session-based connection handling with active connection management.
- Cleaned up imports and improved code readability across multiple files.
Upgraded "drizzle-kit" to 0.31.1 and adjusted "drizzle-orm" versioning for consistency. Additionally, updated Radix dependencies to their latest versions to ensure compatibility and improvements.