Commit Graph

412 Commits

Author SHA1 Message Date
Ahmet Kilinc
906a02cd97 update deps and remove unused deps (#2006)
# Package Dependency Updates

## Description

This PR updates several package dependencies across the project:

- Updated `@elevenlabs/react` from 0.1.5 to 0.5.1 in mail app
- Added `@elevenlabs/elevenlabs-js` 2.12.2 to server app
- Removed unused dependencies: `deepmerge`, `dexie`, `emblor`, and `react-markdown`
- Added `sanitize-html` 2.16.0 to mail app
- Removed `elevenlabs` 1.59.0 from server (replaced with newer `@elevenlabs/elevenlabs-js`)
- Updated PNPM package manager from 10.12.1 to 10.15.0
- Updated Node types from 22.15.29 to 24.3.0
- Updated various dev dependencies including prettier, dotenv-cli, and tsx
- Updated Zod from 3.25.42 to 4.1.1
- Updated wrangler catalog version from 4.28.1 to 4.32.0

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Security**
  * Safer message rendering via HTML sanitization.
* **Improvements**
  * Updated voice/AI integration for increased reliability and compatibility.
  * General stability and performance enhancements across the app.
* **Chores**
  * Upgraded core libraries, developer tooling, and package manager to latest versions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-25 20:52:59 +02:00
amrit
71c57d14af feat: add email verification based on spf/dkim/dmarc/logo verification (#1622)
Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
2025-08-25 19:18:11 +01:00
adam
cd252bd980 Datadog Implementation (#1990) 2025-08-25 19:11:49 +01:00
amrit
6e93fad242 ui: add cross in the undo email toast, decrease time from 30s to 15s (#1979)
<!-- This is an auto-generated description by cubic. -->

## Summary by cubic
Added a close (cross) button to the undo email toast and reduced the undo window from 30 seconds to 15 seconds. 

- **UI Improvements**
 - The undo toast now shows a close button for quick dismissal.
 - The undo option is available for 15 seconds instead of 30.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Improved Undo experience: separate flows for scheduled vs. immediate sends with clearer toasts. Undoing a scheduled send cancels scheduling; undoing an immediate send restores the draft (including attachments) and reopens the composer. Toasts now last 15 seconds and include a close button.
  * Default delay before processing a send/schedule reduced from 30 seconds to 15 seconds.

* **Bug Fixes**
  * Prevented negative time remaining, ensuring Undo is reliably available and consistent with the 5-second gating.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-11 10:33:05 -07:00
Ahmet Kilinc
6a632086e3 feat: optimistic delete draft (#1981)
# Add ability to delete drafts

This PR adds the ability to delete drafts directly from the mail list interface. It implements:

1. A delete button that appears when hovering over draft items
2. Backend support for draft deletion in both Google and Microsoft mail providers
3. Optimistic UI updates to immediately remove deleted drafts from the view

The implementation follows the existing optimistic action pattern used for other mail operations, ensuring a consistent user experience.

## Type of Change

-  New feature (non-breaking change which adds functionality)

## Areas Affected

- [x] Email Integration (Gmail, Outlook, etc.)
- [x] User Interface/Experience
- [x] API Endpoints

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- New Features
  - Delete drafts directly from the mail list via a new trash icon on each draft.
  - Immediate, optimistic removal of deleted drafts from the list for faster feedback.
  - Contextual tooltips on draft actions for clearer guidance.

- Bug Fixes
  - Corrected a visual offset issue in the action bar for consistent positioning.
  - Improved range selection behavior for multi-select actions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-11 17:57:48 +01:00
amrit
2e2474d2da feat: add autosuggestions while sending email (#1495)
Co-authored-by: Adam <13007539+MrgSub@users.noreply.github.com>
2025-08-10 10:27:18 -07:00
Adam
79ebdd721d Disable OpenTelemetry instrumentation and reduce state cache invalidations (#1975)
# 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
Disabled OpenTelemetry instrumentation and reduced unnecessary state cache invalidations to improve server performance.

- **Refactors**
  - Commented out OpenTelemetry setup and usage in the server entrypoint.
  - Limited calls to invalidate and send state cache in thread and workflow logic.

<!-- End of auto-generated description by cubic. -->
2025-08-10 10:24:46 -07:00
devin-ai-integration[bot]
b24a96f33c feat: integrate OpenTelemetry tracing with @microlabs/otel-cf-workers (#1971)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Adam <github@ajxb.net>
Co-authored-by: Aj Wazzan <x_1337@outlook.com>
2025-08-09 16:42:15 -07:00
devin-ai-integration[bot]
aac07d916f Optimize sendDoState function with Durable Object caching (#1968)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Adam <github@ajxb.net>
2025-08-09 15:13:43 -07:00
Adam
91c4349634 Improve auth error handling and connection reset functionality (#1963)
# 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
Improved authentication error handling and connection reset logic to provide clearer feedback and ensure user sessions are properly revoked when issues occur.

- **Bug Fixes**
  - Added redirects and token revocation for failed user info fetches.
  - Improved handling when no connections are found for a user.
  - Triggered mailbox resync if inbox is empty after filtering.

- **Dependencies**
  - Updated better-auth and related packages to the latest versions.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved error handling during authentication by revoking tokens, resetting connections, and redirecting users to the home page when user info retrieval fails or email is missing.
  * Enhanced session management by explicitly revoking and signing out sessions when no user connections are found.

* **New Features**
  * Automatically triggers a forced inbox refresh if no threads are found in the inbox, ensuring the latest messages are displayed.

* **Chores**
  * Updated the "better-auth" dependency to version ^1.3.4.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-09 12:30:13 -07:00
Adam
e17c3c7be6 Disable meet functionality and remove unused code (#1967)
# 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
Disabled the meet feature across the app and removed unused code related to meet functionality.

- **Refactors**
 - Commented out meet-related UI and logic in the sidebar.
 - Added an environment flag to control meet availability.
 - Updated backend routes to check the flag and return 501 if meet is disabled.
 - Deleted unused meet code and cleaned up server files.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Added environment variable to enable or disable the meeting creation feature.
  * Introduced thread-level resynchronization and improved thread fetching performance.

* **Bug Fixes**
  * Meeting creation is now disabled in the sidebar and backend when the feature flag is off, preventing unintended access.

* **Refactor**
  * Improved concurrency for shard data operations and optimized thread retrieval logic.
  * Removed legacy workflow functions for a cleaner codebase.

* **Chores**
  * Removed scheduled cron triggers from the local server environment configuration.

* **Other**
  * Enhanced synchronization after sending emails and creating drafts to ensure up-to-date thread information.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-09 12:17:44 -07:00
Adam
fb29c6b737 Add rate limiting to meet creation endpoint (#1950)
# Restrict Video Meeting Creation to Pro Users

## Description

This PR restricts the video meeting creation functionality to Pro users only. It also adds rate limiting to the meeting creation endpoint to prevent abuse. The UI has been updated to hide the video meeting button for non-Pro users.

## Type of Change

- [x]  New feature (non-breaking change which adds functionality)
- [x] 🔒 Security enhancement
- [x]  Performance improvement

## Areas Affected

- [x] User Interface/Experience
- [x] Authentication/Authorization
- [x] API Endpoints

## Testing Done

- [x] Manual testing performed

## Security Considerations

- [x] Authentication checks are in place
- [x] Rate limiting is implemented

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings

## Additional Notes

The PR includes:
1. Refactoring the Pro user detection logic into a reusable utility function
2. Adding rate limiting to the meeting creation endpoint (10 requests per minute)
3. Conditionally rendering the video meeting button in the sidebar based on Pro status
4. Proper error handling for unauthorized meeting creation attempts
2025-08-08 10:33:08 -07:00
Adam
3ca38991fe Optimize thread counting and add license headers to workflow files (#1949)
# 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
Improved thread counting performance by batching label queries and added Apache license headers to workflow files.

- **Refactors**
  - Replaced individual thread count queries with a single batched query for all labels.
  - Added license headers to workflow-related source files.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Improved thread counting performance by enabling batch counting of threads across multiple folders or labels.
* **Refactor**
  * Streamlined folder synchronization logic and removed unused or commented-out code for better maintainability.
* **Documentation**
  * Added Apache 2.0 license headers to several files to clarify usage and licensing terms.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-07 17:37:29 -07:00
Adam
18314cd088 Enable spam email processing and improve label management workflow (#1948)
# Improved Email Labeling System with DEV_PROXY Support

## Description

This PR enhances the email labeling workflow with a more sophisticated approach to label management. It replaces the previous labeling system with a new implementation that better handles existing labels and user-defined topics.

Key improvements:
- Added DEV_PROXY environment variable to support local development
- Implemented a more robust label suggestion system that prioritizes existing account labels
- Added ability to create missing labels when appropriate
- Modified thread workflow to reload inbox after syncing
- Enabled processing of messages marked as spam (commented out spam filtering)
- Added a test:cron script for local testing of scheduled handlers

## Type of Change

- [x]  New feature (non-breaking change which adds functionality)
- [x] 🐛 Bug fix (non-breaking change which fixes an issue)
- [x]  Performance improvement

## Areas Affected

- [x] Email Integration (Gmail, IMAP, etc.)
- [x] Development Workflow

## Testing Done

- [x] Manual testing performed

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] I have updated the documentation

## Additional Notes

The new labeling system now follows a three-step process:
1. Retrieves existing user account labels
2. Gets user-defined topics for potential new labels
3. Intelligently suggests and applies labels, prioritizing existing ones

The DEV_PROXY environment variable allows for easier local development by redirecting notification requests through a local proxy when configured.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Improved label suggestion and synchronization, now incorporating user topics and existing labels for more accurate email organization.
  * Added spam detection to prevent intent analysis on spam-tagged messages.
  * Enhanced workflow steps for label management, including new steps for user topic retrieval and label suggestion generation.

* **Bug Fixes**
  * Messages labeled as spam are now properly excluded from certain processing steps.

* **Chores**
  * Updated environment variable defaults to enable workflows in local and staging environments.
  * Added a new script for testing scheduled tasks via a local endpoint.
  * Disabled the "seed-style" CLI command.

* **Other Improvements**
  * Inbox folder now reloads automatically after thread updates.
  * Improved logging for thread processing and label synchronization.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-07 14:23:01 -07:00
Ahmet Kilinc
fae9457e88 fix: auto draft compose (#1946)
# Update Email Assistant to use HTML formatting

## Description

This PR updates the Email Assistant system prompt to generate emails with proper HTML formatting instead of plain text.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Improved formatting of automatically generated drafts by displaying line breaks as HTML `<br>` tags.

* **Style**
  * Removed unnecessary trailing spaces from certain prompt texts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-07 17:02:23 +01:00
amrit
69e0676b51 chore: refine system prompt and small update to eval (#1940)
<!-- This is an auto-generated description by cubic. -->

## Summary by cubic
Refined the system prompt for the email assistant to clarify tool usage, safety protocols, and response guidelines. Updated eval test case builders for more realistic coverage and improved test data generation.

- **Prompt Improvements**
  - Expanded instructions on when and how to use tools, safety checks, and bulk actions.
  - Added detailed workflow examples, safety protocols, and clearer self-check steps.
  - Updated common use cases and removed manual instruction responses.

- **Eval Updates**
  - Replaced and improved test case builders for Gmail search and email composition.
  - Made test prompts and expected outputs more realistic and varied.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Enhanced AI assistant guidance with more detailed instructions for tool usage, safety protocols, and workflow examples.
  * Added comprehensive safety protocols for bulk and destructive email operations, including confirmation steps and undo guidance.
  * Expanded support for contextual assistance and smart organization workflows.

* **Refactor**
  * Improved and modularized test case generation for AI email search and composition, with stricter validation and clearer prompts.

* **Style**
  * Updated prompt language to prioritize relevance in email retrieval instead of a fixed number of recent emails.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-06 21:00:58 -07:00
Adam
5b7edd2717 Implement database sharding for improved email storage scalability (#1943)
# Implement Database Sharding for Email Storage

This PR implements database sharding to improve scalability and performance for email storage. The system now distributes email data across multiple shards instead of storing all data in a single database instance.

## 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

## Description

This PR introduces a sharding mechanism for email storage to handle large volumes of data more efficiently:

1. Created a new `ShardRegistry` Durable Object to track and manage shards for each connection
2. Implemented logic to distribute threads across multiple shards based on size limits (9GB per shard)
3. Modified thread operations to work across shards, including:
   - Thread retrieval with shard fallback
   - Aggregation of results from multiple shards
   - Sequential processing for paginated results
4. Moved notification handling from a separate component to the AI sidebar
5. Added shard count display in the user interface
6. Refactored server utilities to support the new sharding architecture
7. Updated API endpoints to work with the sharded database structure

The implementation ensures that as email volume grows, the system can scale horizontally by adding new shards rather than being limited by a single database's capacity.

## Testing Done

- [x] Manual testing performed
- [x] Cross-browser testing (if UI changes)

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] All tests pass locally

## Additional Notes

This change significantly improves the system's ability to handle large email volumes by distributing data across multiple database shards. The UI now displays the number of shards in use, providing transparency about the underlying storage architecture.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Introduced sharding support for improved scalability and performance.
  * Added display of shard count in the user interface.
  * Enhanced sidebar to handle real-time updates for mail, labels, and state.

* **Bug Fixes**
  * Improved cache invalidation and data refresh for more accurate mail and label updates.

* **Refactor**
  * Centralized thread and label operations for better maintainability.
  * Simplified and streamlined backend logic for thread and label management.

* **Chores**
  * Updated configuration to support new sharding infrastructure.
  * Removed unused notification provider component and related logic.

* **Documentation**
  * UI now reflects the number of database shards in relevant menus.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-06 20:03:55 -07:00
devin-ai-integration[bot]
b9a5db50ae Implement per-page workflow system for sync-threads to overcome API limits (#1941)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Adam <github@ajxb.net>
Co-authored-by: Aj Wazzan <x_1337@outlook.com>
2025-08-06 12:44:19 -07:00
devin-ai-integration[bot]
17639d4af0 Move syncThreads logic to Cloudflare Workflow (#1939)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Adam <github@ajxb.net>
Co-authored-by: Aj Wazzan <x_1337@outlook.com>
2025-08-05 22:24:31 -07:00
Adam
2facf596e2 Add ThreadSyncWorker for improved thread synchronization (#1937)
# 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 ThreadSyncWorker Durable Object to handle thread synchronization, improving reliability and separation of concerns in thread syncing.

- **New Features**
  - Introduced ThreadSyncWorker for dedicated thread sync operations.
  - Updated server logic to use ThreadSyncWorker for fetching and storing thread data.
  - Registered ThreadSyncWorker in environment and configuration files.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Introduced a new background worker to improve email thread synchronization reliability and performance.
  * Enhanced logging for thread synchronization, including duration and progress details.

* **Bug Fixes**
  * Increased retry attempts for Gmail rate-limiting errors to improve sync robustness.

* **Chores**
  * Updated environment and configuration settings to support the new background worker.
  * Removed keyboard shortcut functionality for category labels in the mail interface.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-05 17:18:26 -07:00
Adam
a3068ee3ed Add retry mechanism for thread listing failures in syncThreads (#1931)
# 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 retry mechanism to syncThreads so that if thread listing fails, it waits 1 minute and retries the same page instead of skipping it.

- **Bug Fixes**
  - Prevents data loss by ensuring failed thread listing pages are retried, not skipped.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved error handling and retry logic to prevent immediate failures when listing threads, enabling automatic retries after a short delay.
  * Enhanced logging to provide clearer information about retry attempts and page processing status.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-05 13:12:07 -07:00
Adam
ee246dba07 Add do state broadcasting in syncThread function (#1930)
# 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 do state broadcasting to the syncThread function so that state changes are shared after each sync.

- **New Features**
  - Calls sendDoState and logs the result after syncing a thread.
  - Handles errors during broadcasting without interrupting the sync process.

<!-- End of auto-generated description by cubic. -->
2025-08-05 12:42:12 -07:00
Adam
cba0bb6bd6 Delete thread labels and labels tables when resetting sync state (#1929)
# 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
When resetting the sync state, the system now deletes the thread_labels and labels tables in addition to threads. This ensures all related label data is cleared during a sync reset.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Improved data consistency by ensuring that additional related tables are cleared during a forced resynchronization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-05 12:30:23 -07:00
Adam
cfdcb03502 Update AI chat example queries and improve tool descriptions (#1928)
# 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
Updated example queries in the chat interface and clarified tool descriptions to make them easier to understand and use.

- **Improvements**
  - Replaced and refined example queries for better relevance.
  - Expanded tool descriptions to give clearer guidance on their purpose and usage.
  - Added a rule to prevent returning IDs directly in responses.

<!-- End of auto-generated description by cubic. -->
2025-08-05 11:33:56 -07:00
Adam
d2621c044b Use label names instead of IDs for thread label management (#1927)
# 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
Switched thread label management to use label names instead of label IDs throughout the backend.

- **Refactors**
  - Updated database schema and related code to remove label ID fields and use label names for adding, removing, and displaying thread labels.
  - Adjusted prompt instructions and tool descriptions to reference label names.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Introduced a new web search tool that provides concise answers to user queries using Perplexity AI.

* **Bug Fixes**
  * Improved reliability when modifying thread labels, ensuring accurate label retrieval even if a thread is not initially found.

* **Refactor**
  * Updated label handling to use label names instead of IDs throughout the app.
  * Removed unused label-related data from thread records for improved data consistency.

* **Style**
  * Enhanced descriptions for label modification parameters to clarify expected input.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-05 11:11:59 -07:00
Adam
0f7e2ed340 Remove created_at and updated_at fields from threads table (#1926)
# 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 the created_at and updated_at fields from the threads table and updated related code and migrations.

<!-- End of auto-generated description by cubic. -->
2025-08-05 10:28:42 -07:00
Adam
851170814e Update email queue IDs and remove unused import (#1925)
# 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
Updated email queue IDs in wrangler.jsonc to match new configuration and removed an unused import from the mail component.

<!-- End of auto-generated description by cubic. -->
2025-08-05 10:19:19 -07:00
Adam
aa759143c1 Remove sync status indicator and fix JSON trailing commas (#1924)
# 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 the sync status indicator from the mail layout and fixed trailing commas in wrangler.jsonc files to ensure valid JSONC formatting.

- **Bug Fixes**
  - Cleaned up JSONC files by removing trailing commas that could cause parsing errors.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Removed the syncing status indicator from the mail interface.

* **Chores**
  * Updated configuration files with improved formatting and added new rules for handling certain file types in different environments.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-05 09:57:49 -07:00
Adam
fec8e1be22 Scheduling (#1914)
Co-authored-by: amrit <iamamrit27@gmail.com>
2025-08-04 22:36:21 -07:00
Adam
3d0dd59920 Refactor ZeroDriver to use SQLite database for thread and label management (#1917)
# Migrate ZeroDriver to use SQLite database with Drizzle ORM

## Description

This PR refactors the ZeroDriver to use a SQLite database with Drizzle ORM for managing threads and labels, replacing the previous storage approach. The implementation includes:

- Added a new database schema with tables for threads, labels, and thread-label relationships
- Created comprehensive database operations for thread and label management
- Updated all agent methods to use the new database layer
- Modified TRPC routes and tools to work with the updated database structure
- Added thread count information to the DoState to display folder counts in the UI

This change improves query capabilities, enables more complex filtering operations, and provides a more reliable storage solution for email data.

## 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] My changes generate no new warnings
- [x] I have updated the documentation

## Additional Notes

The PR includes database migration files to ensure smooth transitions for existing users. The new database structure allows for more efficient querying of threads by labels and supports complex filtering operations that were previously difficult to implement.

---

_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 a new SQLite-backed database layer for managing email threads and labels, enabling advanced filtering, pagination, and label management.
  * Added a "Force re-sync" option and a syncing status indicator with detailed info to the user menu.
  * Enhanced syncing status UI for improved clarity and visual feedback.

* **Improvements**
  * Optimized email syncing and label modification logic for greater reliability and performance.
  * Standardized agent usage across mail, label, and draft operations for consistency.
  * Refined UI elements for syncing feedback and debug actions.

* **Bug Fixes**
  * Improved handling of thread and label counts and syncing state in the user interface.

* **Chores**
  * Migrated internal data access to use Drizzle ORM and modular database functions.
  * Added configuration and migration files to support the new database backend.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-04 22:30:01 -07:00
Adam
cc8d3f7069 Add email syncing status indicators and optimize folder synchronization (#1915)
# Email Syncing Status Indicators

## Description

Added real-time email syncing status indicators to the mail UI that show when emails are being synchronized, which folders are currently syncing, and the current storage size. This provides users with better visibility into background processes.

## Type of Change

- [x]  New feature (non-breaking change which adds functionality)
- [x]  Performance improvement

## Areas Affected

- [x] Email Integration (Gmail, IMAP, etc.)
- [x] User Interface/Experience

## 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

This PR implements a state management system for email synchronization status using Jotai atoms. The server now broadcasts syncing status through Party, and the UI displays this information in a non-intrusive way at the top of the mail interface.

Key changes:
- Created a new `useDoState` hook to manage syncing state
- Added status indicators in the mail layout component
- Modified the server to track and broadcast syncing status
- Improved folder synchronization logic to be more efficient
- Removed unnecessary delays in the synchronization process

---

_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 a real-time syncing status indicator in the mail interface, displaying current sync progress, folders being synced, and storage usage.
  * Introduced live syncing state updates communicated between server and client for improved sync transparency.

* **Improvements**
  * Enhanced background synchronization logic to provide clearer feedback on syncing activity.
  * Real-time updates now reflect the latest syncing state without delays.
  * Removed artificial delays in syncing processes for faster synchronization.
  * Triggered folder syncing asynchronously when fetching threads from the database.

* **Bug Fixes**
  * Removed unused and obsolete code related to database table management and sync rate-limiting.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-04 12:36:17 -07:00
Adam
01e2adf492 Redesign mail categories to use label-based filtering instead of search queries (#1902)
# Redesigned Mail Categories with Label-Based Filtering

## Description

Reimplemented the mail categories feature to use label-based filtering instead of search queries. This change makes it easier for users to customize and manage their inbox views by selecting specific labels rather than writing complex search queries.

The PR enables the categories settings page in the navigation and completely redesigns the UI to focus on label selection. Users can now add, delete, reorder, and set default categories with a more intuitive interface.

## Type of Change

-  New feature (non-breaking change which adds functionality)
- 🎨 UI/UX improvement

## Areas Affected

- [x] User Interface/Experience
- [x] Data Storage/Management

## Testing Done

- [x] Manual testing performed

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] My code follows the project's style guidelines

## Additional Notes

The PR also includes improvements to the thread querying logic in the backend to better support label-based filtering. The categories feature is now called "Views" in the UI to better reflect its purpose.

---

_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**
  * Categories settings page is now accessible from navigation.
  * Categories (now called "Views") can be managed with multi-select label filters, drag-and-drop reordering, add/delete actions, and unsaved changes tracking.
  * Save and reset options are available for category changes.

* **Improvements**
  * Category selection supports multi-label filtering with a dropdown menu.
  * UI styling updated for better dark mode support and usability.
  * Localization updated to rename "Categories" to "Views".
  * Navigation and mail list no longer use category query parameters, simplifying URL handling.

* **Bug Fixes**
  * Removed unused and AI-related code for category search queries.

* **Chores**
  * Added a pre-commit script to enforce linting before commits.
  * Refactored internal logic for category and thread management for better maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-04 10:34:29 -07:00
Adam
c3582d3120 Remove hardcoded Cloudflare credentials from configuration files (#1898)
# 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 hardcoded Cloudflare account ID and API token from configuration files to improve security.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Chores**
  * Updated environment variable values for Cloudflare account ID and API token to empty strings in configuration files.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-03 14:23:30 -07:00
Adam
99bc631a4f Remove unused variables and comment out getFolderLabelId function (#1897)
# 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 unused variables from ai-chat.tsx and commented out the unused getFolderLabelId function in mail.ts to clean up the codebase.

<!-- End of auto-generated description by cubic. -->
2025-08-03 13:51:39 -07:00
Adam
649eb45d60 Add thread context to AI chat and enhance security with locked prompts (#1896)
# 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 thread, folder, and filter context to chat prompts and enforced strict security rules to prevent unsafe responses.

- **Security**
  - Wrapped all chat prompts with locked instructions to block code, markup, and unsafe content.
- **Context Awareness**
  - Passed current thread, folder, and filter info to chat prompts for more relevant responses.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Chat prompts now include enhanced security instructions and contextual information such as thread, folder, and filter details for improved safety and relevance.
  * All chat messages, including system messages, are now displayed in the chat interface.

* **Improvements**
  * Contextual information is now passed throughout the chat pipeline, enabling more accurate and context-aware responses.
  * Updated default chat prompts for improved consistency.
  * Message submission now clears the editor content and ensures the chat view scrolls to the latest message.

* **Bug Fixes**
  * Ensured editor content is cleared and chat scrolls to the bottom after sending a message.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-03 13:48:14 -07:00
Adam
5723c627ee Remove thread ID tracking and filter suggestion files (#1895)
# 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 thread ID tracking from the agent and deleted unused filter suggestion files to simplify code and reduce complexity.

- **Refactors**
  - Removed all code related to thread ID updates and tracking in both client and server.
  - Deleted filter suggestion utilities and types from mail and server libs.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Enhanced inbox search tool to allow specifying the folder and number of results when searching email threads.

* **Bug Fixes**
  * Improved handling of email thread listing to ensure correct retrieval based on search queries and folder selection.

* **Refactor**
  * Removed deprecated email filter suggestion logic and related utilities from both client and server.
  * Cleaned up unused message types and socket communication related to thread ID updates.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-03 13:41:08 -07:00
Adam
108dc8db5f Make AutoRAG optional and improve thread summary fallback (#1888)
# 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
Made AutoRAG optional so it only runs when configured, and improved thread summary fallback to always return basic info if a summary is missing.

- **Bug Fixes**
  - Thread summary now returns subject, sender, and date even if no summary is found.
  - AutoRAG is only used when enabled, with a proper fallback to raw search results.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Introduced a new inbox search tool supporting natural language queries with configurable result limits.
  * Enabled conditional use of advanced search features based on environment settings.

* **Improvements**
  * Clarified tool parameter descriptions.
  * Enhanced tool registration to accept dynamic header values.

* **Refactor**
  * Improved internal handling of request headers and tool configuration.

* **Chores**
  * Removed default fallback server URL in tool registration scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-01 15:21:47 -07:00
Adam
a34028c1bc Streamline email assistant prompt and add server-side tool execution (#1887)
# 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. -->
2025-08-01 14:14:50 -07:00
Adam
fd6a222c78 Allow SSE connections with system__caller_id (#1886)
# 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
Allowed SSE connections when the X-Caller header is set to system__caller_id, enabling system-level clients to connect without standard authentication.

<!-- End of auto-generated description by cubic. -->
2025-08-01 13:47:24 -07:00
Adam
0343c292ba Allow SSE connections without X-Caller header (#1885)
# 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
SSE connections to the /vsse endpoint can now be established without requiring the X-Caller header. If X-Caller is missing, the connection is still allowed as long as the Authorization header is valid.

<!-- End of auto-generated description by cubic. -->
2025-08-01 13:40:21 -07:00
Adam
032006c0f0 Add voice SSE endpoint and thread summary tool to MCP agent (#1884)
# 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 new voice SSE endpoint for authenticated callers and a thread summary tool to the MCP agent for summarizing email threads.

- **New Features**
  - Added /vsse SSE endpoint with authentication for voice integrations.
  - Added getThreadSummary tool to MCP agent to return concise summaries of email threads.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Added a new endpoint at `/vsse` with enhanced multi-step authorization and user verification.
  * Introduced a tool to generate AI-powered summaries of email threads, providing concise overviews along with key thread details.

* **Improvements**
  * Updated thread listings to display sender information in the format: name <email>.
  * Improved thread retrieval logic for more accurate results.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-01 13:07:31 -07:00
Adam
9a22f39721 Pass thread context to AI chat via system messages instead of prompt (#1883)
# 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
Thread context is now sent to the chat as a system message instead of being included in the prompt. This makes thread handling more flexible and decouples context from prompt generation.

- **Refactors**
  - Removed thread ID from the prompt and updated backend logic to use system messages for thread context.
  - Adjusted chat component to append thread context as a system message before user input.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Introduced a tool to generate and display summaries for specific email threads, including key details like subject, sender, and received date.

* **Improvements**
  * Enhanced AI chat functionality by updating message handling and filtering system messages from the chat display.
  * Updated AI chat prompts and tools for improved interaction and flexibility.
  * Simplified and streamlined internal chat handling for better reliability and maintainability.

* **Bug Fixes**
  * Corrected minor display and formatting issues in chat components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-01 12:34:10 -07:00
Adam
bcf2d17b44 Integrate Dormroom for durable object management and queryable storage (#1873)
## 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 -->
2025-08-01 09:43:42 -07:00
devin-ai-integration[bot]
b709dfcba4 Centralize env imports from cloudflare:workers (#1792)
# Centralize env imports from cloudflare:workers

## Summary

This PR centralizes all `env` imports from `cloudflare:workers` in the `apps/server` directory by creating a single centralized file (`src/env.ts`) that exports both the runtime `env` and its type. All 19 files that previously imported `env` directly from `cloudflare:workers` have been updated to use the centralized import.

**Key Changes:**
- Created `apps/server/src/env.ts` to export `env` and `Env` type centrally
- Updated 19 files across the server codebase to import from centralized location
- Preserved type safety by exporting `Env` type for use in type definitions
- Maintained all existing functionality while improving maintainability

This change makes env-related maintenance easier and ensures consistency across the codebase. All `env` bindings are now imported from a single source of truth.

## Review & Testing Checklist for Human

- [ ] **Verify import paths are correct** - Spot check 3-4 files with different relative paths (e.g., `src/main.ts` uses `./env`, `src/lib/utils.ts` uses `../env`, `src/trpc/routes/ai/compose.ts` uses `../../../env`) to ensure no typos in path calculations
- [ ] **Test core env-dependent functionality** - Beyond server startup, verify that authentication, AI services, and email processing work correctly since these heavily depend on env bindings
- [ ] **Confirm build works properly** - Run the full build process to catch any import resolution issues that might not surface during dev server startup
- [ ] **Verify type safety** - Check that TypeScript compilation passes and that the `Env` type export works correctly in `ctx.ts` and other type definitions

**Recommended Test Plan:**
1. Start the dev server and confirm it runs without errors
2. Test a few core user flows that depend on env variables (login, AI features, email sync)
3. Run any available test suites to catch regressions
4. Build the project for production to verify no import issues

---

### Diagram

```mermaid
%%{ init : { "theme" : "default" }}%%
graph TD
    env["apps/server/src/env.ts<br/>(NEW CENTRALIZED FILE)"]:::major-edit
    
    main["apps/server/src/main.ts"]:::major-edit
    ctx["apps/server/src/ctx.ts"]:::major-edit
    services["apps/server/src/lib/services.ts"]:::minor-edit
    utils["apps/server/src/lib/utils.ts"]:::minor-edit
    auth["apps/server/src/lib/auth.ts"]:::minor-edit
    google["apps/server/src/lib/driver/google.ts"]:::minor-edit
    compose["apps/server/src/trpc/routes/ai/compose.ts"]:::minor-edit
    
    cloudflare["'cloudflare:workers'<br/>(External Module)"]:::context
    
    env --> main
    env --> ctx
    env --> services
    env --> utils
    env --> auth
    env --> google
    env --> compose
    
    cloudflare --> env
    cloudflare --> main
    
    main -.->|"Also imports WorkerEntrypoint,<br/>DurableObject, RpcTarget"| cloudflare
    
    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

- The centralized `env.ts` file exports both the runtime `env` and its TypeScript type for maximum flexibility
- Some files like `main.ts` and `routes/chat.ts` still import other items from `cloudflare:workers` (WorkerEntrypoint, DurableObject, RpcTarget) - only the `env` import was moved
- Server startup testing was successful, confirming basic functionality works
- This change improves maintainability by providing a single point of control for env imports

**Session Info:** Requested by Adam (@MrgSub)  
**Link to Devin run:** https://app.devin.ai/sessions/d31157d47fdb432c961bf8fae7248dd1
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Centralized all env imports from cloudflare:workers into a single src/env.ts file in apps/server, updating 19 files to use this shared import for better maintainability and type safety.

- **Refactors**
  - Created src/env.ts to export env and its type.
  - Updated all server files to import env from the new centralized file.

<!-- End of auto-generated description by cubic. -->
2025-08-01 09:26:07 -07:00
Adam
78987ea588 Add email composition and sending tools to MCP agent (#1874)
# 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 new tools to the MCP agent for composing and sending emails directly through the agent interface.

- **New Features**
  - Added a tool to generate email drafts based on prompts and thread context.
  - Added a tool to send emails, including support for drafts, CC, and BCC.

<!-- End of auto-generated description by cubic. -->
2025-07-30 17:47:27 -07:00
Adam
803a6caedb Implement workflow chain execution to share results between workflows (#1872)
# 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 workflow chain execution so results can be shared between workflows, enabling workflows to pass data to each other during execution.

- **New Features**
  - Introduced `executeWorkflowChain` to run multiple workflows in sequence and share results.
  - Updated workflow runner to use the new chain execution method.

<!-- End of auto-generated description by cubic. -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved accuracy in counting successfully synced threads during workflow execution.
  * Workflows now proceed regardless of certain environment variable settings.

* **New Features**
  * Added support for executing multiple workflows in sequence with consolidated result and error reporting.

* **Refactor**
  * Simplified and streamlined workflow execution logic for better maintainability.

* **Style**
  * Enhanced code formatting for improved readability.

* **Documentation**
  * Updated method signatures to clarify optional parameters.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-30 15:29:31 -07:00
amrit
9707613cf4 feat: add email template management functionality (#1573) 2025-07-31 01:10:16 +05:30
devin-ai-integration[bot]
f664c537b2 feat: sync threadId to ZeroAgent via WebSocket for multi-tab support (#1870)
# feat: sync threadId to ZeroAgent via WebSocket for multi-tab support

## Summary

This PR implements real-time threadId synchronization between the frontend and ZeroAgent backend to provide better context to the AI assistant. When users navigate between email threads in the frontend (via `useQueryState('threadId')`), the system now automatically sends WebSocket updates to the ZeroAgent so the AI knows which thread the user is currently viewing.

**Key changes:**
- Added `ThreadIdUpdate` WebSocket message type for bidirectional communication
- Created `ThreadIdSyncProvider` component that monitors threadId changes and sends updates
- Modified `ZeroAgent` to store threadId per connection for multi-tab support  
- Updated AI system prompt generation to include current threadId context
- Maintains connection isolation so multiple tabs can have different active threads

## Review & Testing Checklist for Human
- [ ] **Verify frontend loads properly and threadId sync works** - There was a CSS import error during development that prevented browser testing. Confirm the app loads and threadId changes trigger WebSocket messages in DevTools.
- [ ] **Test multi-tab support** - Open multiple browser tabs, navigate to different threads in each tab, and verify the AI chat in each tab has context for the correct thread.
- [ ] **Confirm AI system prompt includes threadId** - Start a chat conversation and verify the AI assistant has proper context about the current thread the user is viewing.
- [ ] **Check for regressions** - Verify existing email navigation, AI chat functionality, and WebSocket notifications still work as expected.
- [ ] **Test edge cases** - Try rapid thread navigation, WebSocket reconnections, and tab closing/opening to ensure the system handles these scenarios gracefully.

---

### Diagram

```mermaid
%%{ init : { "theme" : "default" }}%%
graph TD
    Frontend["apps/mail/components/party.tsx<br/>NotificationProvider"]:::major-edit
    ThreadSync["ThreadIdSyncProvider<br/>(new component)"]:::major-edit
    QueryState["useQueryState('threadId')<br/>(existing hook)"]:::context
    
    Backend["apps/server/src/routes/agent/index.ts<br/>ZeroAgent class"]:::major-edit
    Types["apps/server/src/routes/agent/types.ts<br/>Message Types"]:::minor-edit
    Prompt["apps/server/src/lib/prompts.ts<br/>AiChatPrompt"]:::context
    
    QueryState --> ThreadSync
    ThreadSync --> Frontend
    Frontend -->|"WebSocket ThreadIdUpdate"| Backend
    Backend --> Prompt
    Types -.->|"defines message structure"| Frontend
    Types -.->|"defines message structure"| Backend
    
    
    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

- **Session Info**: Requested by @MrgSub, implemented in Devin session: https://app.devin.ai/sessions/f2c92b4c778d4314a4c9947ca2022667
- **Environment Issue**: Frontend had CSS import errors during development preventing full browser testing. The implementation follows existing WebSocket patterns but needs verification in a working environment.
- **Architecture**: Uses existing connection management system where each browser tab gets a unique connectionId, enabling independent threadId tracking per tab.
- **Backward Compatibility**: Changes are additive and shouldn't break existing functionality, but the system prompt generation flow has been modified to use stored threadId instead of request-time threadId.
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Enabled real-time syncing of the current threadId to ZeroAgent over WebSocket, allowing each browser tab to maintain its own thread context for multi-tab support.

- **New Features**
  - Added a ThreadIdSyncProvider component to detect thread changes and send updates to ZeroAgent.
  - ZeroAgent now tracks threadId per connection, so each tab can have independent context.
  - System prompt generation now uses the correct threadId for each connection.

<!-- End of auto-generated description by cubic. -->
2025-07-30 10:18:18 -07:00
Adam
15bbf89c3b Add Effect-free workflow implementation for direct Cloudflare Workers execution (#1869)
## Description

Added support for draft detection in email threads to improve the auto-draft generation workflow. This PR adds an `isLatestDraft` flag to thread responses, allowing the system to check if a draft already exists in a thread without making additional API calls. The workflow engine has been optimized to skip draft generation for threads that already have drafts, automated emails, or messages older than 7 days.

Additionally, implemented non-Effect.ts versions of the workflow functions to provide an alternative implementation path that doesn't rely on the Effect library, which will help with testing and debugging.

## Type of Change

- [x]  New feature (non-breaking change which adds functionality)
- [x]  Performance improvement

## Areas Affected

- [x] Email Integration (Gmail, IMAP, etc.)
- [x] Data Storage/Management

## Testing Done

- [x] Manual testing performed

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] I have commented my code, particularly in complex areas

## Additional Notes

The draft detection improvements reduce unnecessary API calls to check for existing drafts, which should improve performance and reduce the likelihood of hitting API rate limits. The workflow engine now also properly skips automated emails and old threads, focusing resources on generating drafts only for relevant conversations.

---

_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
2025-07-29 16:38:17 -07:00
Adam
762895a76f Pass results to workflow step condition function (#1867)
# 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
Updated the workflow engine to pass the results object to each step's condition function, allowing conditions to use previous step results.

<!-- End of auto-generated description by cubic. -->
2025-07-29 14:13:25 -07:00