Skip to content

Comments

Allow sending from email aliases added through gmail#743

Merged
ahmetskilinc merged 1 commit intoMail-0:stagingfrom
atharvadeosthale:atharva/send-using-alias
Apr 22, 2025
Merged

Allow sending from email aliases added through gmail#743
ahmetskilinc merged 1 commit intoMail-0:stagingfrom
atharvadeosthale:atharva/send-using-alias

Conversation

@atharvadeosthale
Copy link
Contributor

@atharvadeosthale atharvadeosthale commented Apr 22, 2025

Description

Added a From field in email composer and reply composer. The aliases will be fetched through Gmail API and this will allow the user to send through an alias configured by them in Gmail settings.


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)

Checklist

  • I have read the CONTRIBUTING 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

This is primarily useful for people who avoid Google Workspace (like me) and use Cloudflare to route emails to personal Gmail account and configure the Gmail account to send from the domain.

Screenshots/Recordings

image
image


By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features
    • Added support for selecting the "From" email address when composing or replying to emails, including a dropdown menu to choose from available email aliases.
    • Introduced fetching and display of email aliases associated with the active email account.
  • Bug Fixes
    • Improved handling and fallback for email alias retrieval failures.
  • Localization
    • Added and updated English language strings to support the new "From" field and improved label formatting.

@vercel
Copy link

vercel bot commented Apr 22, 2025

@atharvadeosthale is attempting to deploy a commit to the Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 22, 2025

Walkthrough

This update introduces comprehensive support for selecting the sender email address ("From" field) when composing or replying to emails. It adds backend and frontend logic for retrieving email aliases, updates the email sending flow to allow specifying a custom sender address, and enhances the user interface with dropdown menus for alias selection. The changes include new server-side modules, driver interface extensions, React hooks, and UI components, as well as corresponding updates to localization and type definitions. Error handling and fallback mechanisms are implemented to ensure robust alias retrieval and usage.

Changes

File(s) Change Summary
apps/mail/actions/email-aliases.ts Introduced a new module to fetch email aliases for the active connection, defining the EmailAlias type and the getEmailAliases async function with error handling and fallback logic.
apps/mail/actions/send.ts Updated the sendEmail function to accept an optional fromEmail parameter and pass it to the driver, enabling explicit sender address specification.
apps/mail/app/api/driver/google.ts Modified outgoing message parsing to use a provided fromEmail if available; added a new getEmailAliases method to retrieve Gmail "send as" aliases; updated recipient filtering logic to use the actual sender.
apps/mail/app/api/driver/types.ts Added the getEmailAliases method to the MailManager interface, returning a promise with alias objects.
apps/mail/components/create/create-email.tsx
apps/mail/components/mail/reply-composer.tsx
Enhanced compose and reply UIs with a "From" dropdown for alias selection, managed with new state and the useEmailAliases hook; updated send logic to use the selected alias; added new UI elements and minor layout adjustments.
apps/mail/hooks/use-email-aliases.ts Added a new React hook useEmailAliases to fetch and manage email alias data from the backend using SWR.
apps/mail/locales/en.json Added a new localization string for the "From" label and adjusted formatting for the "Bcc" label.
apps/mail/types/index.ts Extended the IOutgoingMessage interface with an optional fromEmail property to support custom sender addresses.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ComposeUI as Compose/Reply UI
    participant useEmailAliases
    participant Backend as /api/driver/email-aliases
    participant getEmailAliases
    participant Driver
    participant Provider

    User->>ComposeUI: Open compose or reply
    ComposeUI->>useEmailAliases: Fetch aliases
    useEmailAliases->>Backend: GET /api/driver/email-aliases
    Backend->>getEmailAliases: Call getEmailAliases()
    getEmailAliases->>Driver: driver.getEmailAliases()
    Driver->>Provider: Fetch aliases from provider (e.g., Gmail)
    Provider-->>Driver: Return alias data
    Driver-->>getEmailAliases: Return aliases
    getEmailAliases-->>Backend: Return aliases
    Backend-->>useEmailAliases: Return aliases
    useEmailAliases-->>ComposeUI: Provide aliases

    User->>ComposeUI: Select "From" alias and send email
    ComposeUI->>sendEmail: Call sendEmail({ ..., fromEmail })
    sendEmail->>Driver: driver.create({ ..., fromEmail })
    Driver->>Provider: Send email with specified fromEmail
    Provider-->>Driver: Confirmation
    Driver-->>sendEmail: Return result
Loading

Suggested reviewers

  • needleXO
  • ahmetskilinc

Poem

In a warren of emails, the rabbit hops,
Now choosing "From" before each send and stop.
Aliases fetched, a dropdown appears,
Compose or reply, the sender is clear!
With hooks and drivers, the logic aligns,
🐇✨—now mail can wear many signs!
Hooray for the warren, where choice always shines.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
apps/mail/components/create/create-email.tsx (1)

360-362: 🛠️ Refactor suggestion

Reset the selectedFromEmail state when clearing the form.

After successfully sending an email, the component resets all form fields except the selectedFromEmail state. This could cause unexpected behavior if the user composes another email.

  setBccEmails([]);
  setShowCc(false);
  setShowBcc(false);
+ setSelectedFromEmail(null);
  setSubjectInput('');
  setAttachments([]);
  setMessageContent('');
🧹 Nitpick comments (3)
apps/mail/hooks/use-email-aliases.ts (2)

8-20: Well-implemented hook for email alias fetching

The useEmailAliases hook is cleanly implemented using useSWRImmutable, which is appropriate for email aliases that don't change frequently. The implementation follows React best practices for data fetching hooks.

Consider enhancing error handling to provide more graceful fallbacks when alias fetching fails, ensuring users can still send emails even if alias retrieval encounters issues.

export function useEmailAliases() {
  const { data, error, isLoading, mutate } = useSWRImmutable<EmailAlias[]>(
    '/api/driver/email-aliases',
    fetcher,
  );

  return {
    aliases: data || [],
    isLoading,
    error,
+   isError: !!error,
    mutate,
  };
}

6-6: Consider adding error handling to the fetcher

The current fetcher doesn't handle HTTP error responses. Consider adding error handling to provide better diagnostic information when API calls fail.

-const fetcher = (url: string) => fetch(url).then((res) => res.json());
+const fetcher = async (url: string) => {
+  const res = await fetch(url);
+  if (!res.ok) {
+    throw new Error(`Failed to fetch email aliases: ${res.status} ${res.statusText}`);
+  }
+  return res.json();
+};
apps/mail/components/create/create-email.tsx (1)

596-633: Add error handling for email alias fetch failures.

The component doesn't handle potential errors when fetching email aliases. If the fetch fails, users won't know why no aliases appear.

  <DropdownMenuContent
    className="w-[var(--radix-dropdown-trigger-width)]"
    align="start"
  >
    {isLoadingAliases ? (
      <div className="px-2 py-1 text-center text-sm">Loading...</div>
+   ) : error ? (
+     <div className="px-2 py-1 text-center text-sm text-destructive">
+       Failed to load aliases
+     </div>
    ) : aliases && aliases.length > 0 ? (
      aliases.map((alias) => (
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c295d6 and fe69246.

📒 Files selected for processing (9)
  • apps/mail/actions/email-aliases.ts (1 hunks)
  • apps/mail/actions/send.ts (3 hunks)
  • apps/mail/app/api/driver/google.ts (5 hunks)
  • apps/mail/app/api/driver/types.ts (1 hunks)
  • apps/mail/components/create/create-email.tsx (8 hunks)
  • apps/mail/components/mail/reply-composer.tsx (11 hunks)
  • apps/mail/hooks/use-email-aliases.ts (1 hunks)
  • apps/mail/locales/en.json (2 hunks)
  • apps/mail/types/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/mail/hooks/use-email-aliases.ts (1)
apps/mail/actions/email-aliases.ts (1)
  • EmailAlias (7-11)
apps/mail/components/create/create-email.tsx (3)
apps/mail/hooks/use-email-aliases.ts (1)
  • useEmailAliases (8-20)
apps/mail/components/ui/dropdown-menu.tsx (4)
  • DropdownMenu (171-171)
  • DropdownMenuTrigger (172-172)
  • DropdownMenuContent (173-173)
  • DropdownMenuItem (174-174)
apps/mail/components/ui/button.tsx (1)
  • Button (55-55)
🔇 Additional comments (24)
apps/mail/app/api/driver/types.ts (1)

39-39: Clean interface extension for email alias support

The addition of the getEmailAliases method to the MailManager interface is well-designed with an appropriate return type that captures all essential alias information (email address, optional display name, and primary status flag). This interface extension properly supports the PR objective of enabling Gmail alias selection.

apps/mail/types/index.ts (1)

119-119: Well-designed type extension for sender alias support

The addition of the optional fromEmail property to the IOutgoingMessage interface is clean and maintains backward compatibility. This change properly enables specifying a custom sender email address when composing messages, which is essential for the Gmail alias feature.

apps/mail/actions/send.ts (1)

17-17: Clean implementation of fromEmail parameter

The fromEmail parameter is correctly added to the sendEmail function signature and properly passed to the driver. The implementation maintains backward compatibility by making the parameter optional, ensuring a smooth integration with the email alias selection feature.

Also applies to: 27-27, 56-56

apps/mail/locales/en.json (2)

90-90: LGTM! Added localization key for the new "From" field.

The new localization key for the "From" field has been appropriately placed in the searchBar section, making it available throughout the application.


140-140: LGTM! Fixed formatting for "bcc" key.

Small formatting correction for consistency with other keys in the localization file.

apps/mail/app/api/driver/google.ts (4)

232-243: LGTM! The outgoing message parser now supports custom sender email.

The implementation correctly handles the optional fromEmail parameter with appropriate fallback to the default email from the connection configuration. The debug logging helps with troubleshooting.


271-272: LGTM! Updated recipient debugging to use the dynamic sender email.

The debugging output now correctly references the dynamic senderEmail variable instead of the hardcoded fromEmail.


314-315: LGTM! Updated CC and BCC filtering to use the dynamic sender email.

The filtering logic now correctly excludes the sender's email from CC and BCC recipients using the dynamic senderEmail variable.

Also applies to: 335-336


488-525: LGTM! Well-implemented email aliases retrieval.

The implementation follows best practices:

  1. First retrieves the primary email from the profile
  2. Fetches all "sendAs" aliases configured in Gmail
  3. Combines them into a single array with appropriate metadata
  4. Includes comprehensive error handling

The method properly handles Gmail's API response structure and maintains type safety throughout.

apps/mail/actions/email-aliases.ts (2)

1-12: LGTM! Clean type definition and server-side action setup.

The file starts with the server action directive and imports the necessary dependencies. The EmailAlias type is well-defined with all the required fields.


13-36: LGTM! Well-implemented email aliases retrieval with proper error handling.

The server action follows best practices:

  1. Gets the active connection and validates tokens
  2. Creates the appropriate driver for the connection
  3. Delegates the alias retrieval to the driver
  4. Provides a graceful fallback in case of errors

The function will never throw errors to the client, ensuring robust behavior even when the API call fails.

apps/mail/components/mail/reply-composer.tsx (6)

17-18: LGTM! Added necessary imports for dropdown functionality.

The component properly imports the required UI components and hooks for the dropdown menu and email alias functionality.

Also applies to: 27-38


62-72: LGTM! Extracted DragOverlay for better code organization.

Moving the DragOverlay component to the top of the file improves code organization and readability.


184-185: LGTM! Added state for From email selection and API integration.

The component properly manages the selected "From" email with React state and integrates with the useEmailAliases hook to fetch available aliases.


348-348: LGTM! Updated sendEmail to include the selected From email.

The sendEmail call now includes the fromEmail parameter with appropriate fallback logic if no alias is selected.


777-812: LGTM! Well-implemented From email dropdown in the recipient editing view.

The dropdown implementation:

  1. Shows a loading state while fetching aliases
  2. Properly displays the list of aliases with name and email
  3. Indicates the primary email address
  4. Falls back to the user's default email if no aliases are available
  5. Uses the appropriate UI components for a clean, consistent look

The dropdown is well-positioned in the UI next to the other recipient fields.


874-909: LGTM! Added From email dropdown to compact view.

The dropdown is consistently implemented in the compact view, maintaining the same functionality and appearance as in the expanded view.

apps/mail/components/create/create-email.tsx (7)

8-8: LGTM! Import addition for dropdown UI.

The ChevronDown icon import is correctly added for use in the From email dropdown menu.


11-11: LGTM! Hook import for fetching email aliases.

The useEmailAliases hook import is correctly added to fetch Gmail aliases from the API.


91-91: LGTM! State for tracking selected email.

The selectedFromEmail state variable is appropriately initialized as null and will store the user's chosen sender address.


120-120: LGTM! Hook initialization for email aliases.

The hook is correctly implemented to fetch aliases and track loading state.


321-323: LGTM! Proper fallback logic for sender email.

The code correctly implements a fallback chain:

  1. Uses the user-selected email if available
  2. Falls back to the first alias if available
  3. Defaults to the user's primary email as last resort

335-335: LGTM! Email sending integration.

The fromEmail parameter is correctly passed to the sendEmail action.


596-633: LGTM! Well-implemented From email selector UI.

The From email selector is implemented with:

  • Clear labeling with translation support
  • Loading state handling
  • Proper display of email aliases with names and primary status indicators
  • Disabled state during loading or when sending
  • Appropriate dropdown positioning

The implementation follows the same pattern as other email fields in the form.

@ahmetskilinc ahmetskilinc changed the base branch from main to staging April 22, 2025 10:50
Copy link
Contributor

@ahmetskilinc ahmetskilinc left a comment

Choose a reason for hiding this comment

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

I didn't even know you could add aliases in gmail. Good work. Lgtm

@ahmetskilinc ahmetskilinc merged commit 9a75453 into Mail-0:staging Apr 22, 2025
1 of 2 checks passed
@atharvadeosthale atharvadeosthale mentioned this pull request Apr 22, 2025
MrgSub added a commit that referenced this pull request Apr 22, 2025
* draft fixes:
- added cc and bcc when saving drafts
- save drafts less aggresively

* some fixes for saving attachments to draft

* fix for empty draft loading

* fix draft list recipient name/address

* also show 'No Recipient' if empty

* remove comments

* switch to mimetext for draft saving to keep formatting consistent

* add message title to draft list

* feat: single api for oauth connections

* fix: add extra error handling

* chore: simplify and fix the dev env

* Ai generate security (#706)

* Create prompts with XML formatting

* Include XML formatted prompts in generate func

* remove unused regex and add helper functions/warnings

* error handling

* Update apps/mail/lib/prompts.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* lint issues

* Update prompts.ts

* #706 (comment)

Coderabbit fix 1

* erabbitai bot 3 days ago ⚠️ Potential issue  errorOccurred state is stale inside finally  React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag.  -  } finally { -      setIsLoading(false); -      if (!errorOccurred || isAskingQuestion) { -        setIsExpanded(true); -      } else { -        setIsExpanded(false); // Collapse on errors -      } -  } +  } finally { +      setIsLoading(false); +      // Use a local flag to track errors deterministically +      const hadError = isAskingQuestion ? false : !!errorFlagRef.current; +      setIsExpanded(!hadError); +  } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching.  Committable suggestion skipped: line range outside the PR's diff.

* #706 (comment)

* #706 (comment)

* #706 (comment)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Add a new Vietnamese translation file to support Vietnamese language users (#726)

* feat(i18n): add Vietnamese language support

Add Vietnamese ('vi') to the list of supported languages in the
i18n configuration and JSON file to expand language options.

* Add a new Vietnamese translation file to support Vietnamese language users.

* Clear Vietnamese translation strings

* Update es.json (#710)

Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>

* Update app manifest and add new icons for PWA (#739)

* feat: allow sending from email aliases added through gmail (#743)

* Refactor IP handling in early-access routes

* Add unauthorized error handling in sign out function

---------

Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: BlankParticle <blankparticle@gmail.com>
Co-authored-by: grim <75869731+ripgrim@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Chánh Đại <dai@chanhdai.com>
Co-authored-by: Dani B. <danibaldomirm@gmail.com>
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
Co-authored-by: Humber Nieto <56887259+humbernieto@users.noreply.github.com>
Co-authored-by: Atharva Deosthale <atharva.deosthale17@gmail.com>
@SwedishChef1
Copy link

@atharvadeosthale @ahmetskilinc - do we want to hide the From field if the user doesn't have any aliases set up etc?

Screenshot 2025-04-22 at 12 11 41 PM

@atharvadeosthale
Copy link
Contributor Author

@AxelJetpack nice idea. I gave it a thought when coding it out. My only problem is that the Gmail API is really slow. When the compose page is opened, it took me 2-3 seconds to fetch email aliases.

If we implement the from field only appearing if aliases is found, it will cause an ugly layout shift every time a user goes to the compose page and has an alias.

My recommendations (and would love some feedback, happy to work on them)

  • Cache the aliases after email fetch into Redis. This way only the initial fetch will have a layout shift. The problem with this though is that if the user adds an alias in Gmail, we have no way to know and invalidate the cache. Doing it manually on user side also is not a good idea imo.

  • The dropdown should be converted to plain text with the default logged in email while the email aliases are being fetched. If there are aliases, we can convert it to a dropdown. We can make it so that the text and dropdown use the same space so there is no layout shift.

Do you have any recommendations? Would love to explore ideas to make this better. Thanks.

MrgSub added a commit that referenced this pull request Apr 23, 2025
* draft fixes:
- added cc and bcc when saving drafts
- save drafts less aggresively

* some fixes for saving attachments to draft

* fix for empty draft loading

* fix draft list recipient name/address

* also show 'No Recipient' if empty

* remove comments

* switch to mimetext for draft saving to keep formatting consistent

* add message title to draft list

* feat: single api for oauth connections

* fix: add extra error handling

* chore: simplify and fix the dev env

* Ai generate security (#706)

* Create prompts with XML formatting

* Include XML formatted prompts in generate func

* remove unused regex and add helper functions/warnings

* error handling

* Update apps/mail/lib/prompts.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* lint issues

* Update prompts.ts

* #706 (comment)

Coderabbit fix 1

* erabbitai bot 3 days ago ⚠️ Potential issue  errorOccurred state is stale inside finally  React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag.  -  } finally { -      setIsLoading(false); -      if (!errorOccurred || isAskingQuestion) { -        setIsExpanded(true); -      } else { -        setIsExpanded(false); // Collapse on errors -      } -  } +  } finally { +      setIsLoading(false); +      // Use a local flag to track errors deterministically +      const hadError = isAskingQuestion ? false : !!errorFlagRef.current; +      setIsExpanded(!hadError); +  } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching.  Committable suggestion skipped: line range outside the PR's diff.

* #706 (comment)

* #706 (comment)

* #706 (comment)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Add a new Vietnamese translation file to support Vietnamese language users (#726)

* feat(i18n): add Vietnamese language support

Add Vietnamese ('vi') to the list of supported languages in the
i18n configuration and JSON file to expand language options.

* Add a new Vietnamese translation file to support Vietnamese language users.

* Clear Vietnamese translation strings

* Update es.json (#710)

Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>

* Update app manifest and add new icons for PWA (#739)

* feat: allow sending from email aliases added through gmail (#743)

* Refactor IP handling in early-access routes

* Add unauthorized error handling in sign out function

* Redirect from Home Page on Session (#701)

* Updated lockfile

* Updated home page session validation

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Refactor settings handling and golden ticket logic

* Feat: og:image Generation on /compose route (#730)

* Create route og image

* resolve coderabbit nitpicks

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Update session check to include user id before redirecting

* Fix unauthorized error handling in multiple actions

* Enable shortcuts settings in navigation

* Refactor error handling to return unauthorized gracefully

* Update Hero component with new imports and link adjustments

* Update redirect URL to use hostname from req object

* Fix redirect URL formatting and add log for missing user ID

* Fix error handling in API routes for unauthorized requests

* Refactor throwUnauthorizedGracefully function for readability

* Fix error handling in driver routes

* Handle unauthorized gracefully when getting connections

* Refactor mail actions for better error handling

* Refactor deleteActiveConnection function for readability

* fixed (#752)

* Refactor error handling in mail actions to return null or specific error messages instead of throwing unauthorized errors. This improves readability and maintains functionality across various actions.

* Update Google auth provider configuration

* Delete connection and update hero text

* Refactor error handling to use StandardizedError class

* Refactor error handling for Google API driver

---------

Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: BlankParticle <blankparticle@gmail.com>
Co-authored-by: grim <75869731+ripgrim@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Chánh Đại <dai@chanhdai.com>
Co-authored-by: Dani B. <danibaldomirm@gmail.com>
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
Co-authored-by: Humber Nieto <56887259+humbernieto@users.noreply.github.com>
Co-authored-by: Atharva Deosthale <atharva.deosthale17@gmail.com>
Co-authored-by: Nikita Drokin <86173808+nikitadrokin@users.noreply.github.com>
MrgSub added a commit that referenced this pull request Apr 25, 2025
* draft fixes:
- added cc and bcc when saving drafts
- save drafts less aggresively

* some fixes for saving attachments to draft

* fix for empty draft loading

* fix draft list recipient name/address

* also show 'No Recipient' if empty

* remove comments

* switch to mimetext for draft saving to keep formatting consistent

* add message title to draft list

* feat: single api for oauth connections

* fix: add extra error handling

* chore: simplify and fix the dev env

* Ai generate security (#706)

* Create prompts with XML formatting

* Include XML formatted prompts in generate func

* remove unused regex and add helper functions/warnings

* error handling

* Update apps/mail/lib/prompts.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* lint issues

* Update prompts.ts

* #706 (comment)

Coderabbit fix 1

* erabbitai bot 3 days ago ⚠️ Potential issue  errorOccurred state is stale inside finally  React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag.  -  } finally { -      setIsLoading(false); -      if (!errorOccurred || isAskingQuestion) { -        setIsExpanded(true); -      } else { -        setIsExpanded(false); // Collapse on errors -      } -  } +  } finally { +      setIsLoading(false); +      // Use a local flag to track errors deterministically +      const hadError = isAskingQuestion ? false : !!errorFlagRef.current; +      setIsExpanded(!hadError); +  } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching.  Committable suggestion skipped: line range outside the PR's diff.

* #706 (comment)

* #706 (comment)

* #706 (comment)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Add a new Vietnamese translation file to support Vietnamese language users (#726)

* feat(i18n): add Vietnamese language support

Add Vietnamese ('vi') to the list of supported languages in the
i18n configuration and JSON file to expand language options.

* Add a new Vietnamese translation file to support Vietnamese language users.

* Clear Vietnamese translation strings

* Update es.json (#710)

Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>

* Update app manifest and add new icons for PWA (#739)

* feat: allow sending from email aliases added through gmail (#743)

* Refactor IP handling in early-access routes

* Add unauthorized error handling in sign out function

* Redirect from Home Page on Session (#701)

* Updated lockfile

* Updated home page session validation

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Refactor settings handling and golden ticket logic

* Feat: og:image Generation on /compose route (#730)

* Create route og image

* resolve coderabbit nitpicks

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Update session check to include user id before redirecting

* Fix unauthorized error handling in multiple actions

* Enable shortcuts settings in navigation

* Refactor error handling to return unauthorized gracefully

* Update Hero component with new imports and link adjustments

* Update redirect URL to use hostname from req object

* Fix redirect URL formatting and add log for missing user ID

* Fix error handling in API routes for unauthorized requests

* Refactor throwUnauthorizedGracefully function for readability

* Fix error handling in driver routes

* Handle unauthorized gracefully when getting connections

* Refactor mail actions for better error handling

* Refactor deleteActiveConnection function for readability

* fixed (#752)

* Refactor error handling in mail actions to return null or specific error messages instead of throwing unauthorized errors. This improves readability and maintains functionality across various actions.

* Update Google auth provider configuration

* Delete connection and update hero text

* Refactor error handling to use StandardizedError class

* Refactor error handling for Google API driver

* Add labels to sidebar, labels settings and useLabels hook (#746)

* Adds labels from the provider:
- labels page in settings
- labels page translations
- added labels for google provider

* useLabels and labels in sidebar

* fix rate limit parts of labels route

* Added labels to mail-list

* - add rate limiting
- move useThreadsLabel

---------

Co-authored-by: Adam <x_1337@outlook.com>

* bin count of unread messages

* dixes drafts not saving persistently

* dont show from field is no aliases

* limited height of attachment dialog

* added delete page

* correct way to delete accounts

* - adds new revokeRefreshToken method to Google driver
- updates lib/auth.ts to use the new method
- updates actions/user.ts
- updates app/(routes)/settings/danger-zone/page.tsx

* Add posthog-js dependency and implement label filtering in NavMain component

- Added posthog-js version 1.236.6 to package.json and bun.lock.
- Introduced search functionality by implementing handleFilterByLabel in NavMain component.
- Updated NavItem to trigger label filtering on click.

* Enhance NavItem component to support onClick event handling

- Updated NavItem to include an onClick prop for the Link component, allowing for custom click behavior.
- Maintained existing functionality with prefetch and target attributes.

---------

Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: BlankParticle <blankparticle@gmail.com>
Co-authored-by: grim <75869731+ripgrim@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Chánh Đại <dai@chanhdai.com>
Co-authored-by: Dani B. <danibaldomirm@gmail.com>
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
Co-authored-by: Humber Nieto <56887259+humbernieto@users.noreply.github.com>
Co-authored-by: Atharva Deosthale <atharva.deosthale17@gmail.com>
Co-authored-by: Nikita Drokin <86173808+nikitadrokin@users.noreply.github.com>
Co-authored-by: Adarsh Tiwari <adarshtiwari797023@gmail.com>
MrgSub added a commit that referenced this pull request Apr 25, 2025
* draft fixes:
- added cc and bcc when saving drafts
- save drafts less aggresively

* some fixes for saving attachments to draft

* fix for empty draft loading

* fix draft list recipient name/address

* also show 'No Recipient' if empty

* remove comments

* switch to mimetext for draft saving to keep formatting consistent

* add message title to draft list

* feat: single api for oauth connections

* fix: add extra error handling

* chore: simplify and fix the dev env

* Ai generate security (#706)

* Create prompts with XML formatting

* Include XML formatted prompts in generate func

* remove unused regex and add helper functions/warnings

* error handling

* Update apps/mail/lib/prompts.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* lint issues

* Update prompts.ts

* #706 (comment)

Coderabbit fix 1

* erabbitai bot 3 days ago ⚠️ Potential issue  errorOccurred state is stale inside finally  React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag.  -  } finally { -      setIsLoading(false); -      if (!errorOccurred || isAskingQuestion) { -        setIsExpanded(true); -      } else { -        setIsExpanded(false); // Collapse on errors -      } -  } +  } finally { +      setIsLoading(false); +      // Use a local flag to track errors deterministically +      const hadError = isAskingQuestion ? false : !!errorFlagRef.current; +      setIsExpanded(!hadError); +  } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching.  Committable suggestion skipped: line range outside the PR's diff.

* #706 (comment)

* #706 (comment)

* #706 (comment)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Add a new Vietnamese translation file to support Vietnamese language users (#726)

* feat(i18n): add Vietnamese language support

Add Vietnamese ('vi') to the list of supported languages in the
i18n configuration and JSON file to expand language options.

* Add a new Vietnamese translation file to support Vietnamese language users.

* Clear Vietnamese translation strings

* Update es.json (#710)

Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>

* Update app manifest and add new icons for PWA (#739)

* feat: allow sending from email aliases added through gmail (#743)

* Refactor IP handling in early-access routes

* Add unauthorized error handling in sign out function

* Redirect from Home Page on Session (#701)

* Updated lockfile

* Updated home page session validation

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Refactor settings handling and golden ticket logic

* Feat: og:image Generation on /compose route (#730)

* Create route og image

* resolve coderabbit nitpicks

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Update session check to include user id before redirecting

* Fix unauthorized error handling in multiple actions

* Enable shortcuts settings in navigation

* Refactor error handling to return unauthorized gracefully

* Update Hero component with new imports and link adjustments

* Update redirect URL to use hostname from req object

* Fix redirect URL formatting and add log for missing user ID

* Fix error handling in API routes for unauthorized requests

* Refactor throwUnauthorizedGracefully function for readability

* Fix error handling in driver routes

* Handle unauthorized gracefully when getting connections

* Refactor mail actions for better error handling

* Refactor deleteActiveConnection function for readability

* fixed (#752)

* Refactor error handling in mail actions to return null or specific error messages instead of throwing unauthorized errors. This improves readability and maintains functionality across various actions.

* Update Google auth provider configuration

* Delete connection and update hero text

* Refactor error handling to use StandardizedError class

* Refactor error handling for Google API driver

* Add labels to sidebar, labels settings and useLabels hook (#746)

* Adds labels from the provider:
- labels page in settings
- labels page translations
- added labels for google provider

* useLabels and labels in sidebar

* fix rate limit parts of labels route

* Added labels to mail-list

* - add rate limiting
- move useThreadsLabel

---------

Co-authored-by: Adam <x_1337@outlook.com>

* bin count of unread messages

* dixes drafts not saving persistently

* dont show from field is no aliases

* limited height of attachment dialog

* added delete page

* correct way to delete accounts

* - adds new revokeRefreshToken method to Google driver
- updates lib/auth.ts to use the new method
- updates actions/user.ts
- updates app/(routes)/settings/danger-zone/page.tsx

* Add posthog-js dependency and implement label filtering in NavMain component

- Added posthog-js version 1.236.6 to package.json and bun.lock.
- Introduced search functionality by implementing handleFilterByLabel in NavMain component.
- Updated NavItem to trigger label filtering on click.

* Enhance NavItem component to support onClick event handling

- Updated NavItem to include an onClick prop for the Link component, allowing for custom click behavior.
- Maintained existing functionality with prefetch and target attributes.

* fix: add missing dompurify dep (#765)

* user can edit enail after selecting (#760)

* User can able to delete from bin  (#670)

* delete mails permanently from bin

* add English translations for delete mail actions

* update the call handleDelete

* fixed handle delete function

* handleDelete call

* enhance handledelete to reset bulk selection after deletion

* removed the scope

* delete mails permanently from bin

* add English translations for delete mail actions

* update the call handleDelete

* handleDelete call

* enhance handledelete to reset bulk selection after deletion

* removed the scope

---------

Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: Adam <x_1337@outlook.com>

* send draft instead of new message (#767)

* Add sendDraft method to Gmail driver and MailManager interface

* fix sendDraft method

* Add support for sending draft emails and clear draftId after sending

---------

Co-authored-by: Adam <x_1337@outlook.com>

* Add Chinese language support for mail app

* Update email addresses in send function

* Add import statement for deleteActiveConnection function

---------

Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: BlankParticle <blankparticle@gmail.com>
Co-authored-by: grim <75869731+ripgrim@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Chánh Đại <dai@chanhdai.com>
Co-authored-by: Dani B. <danibaldomirm@gmail.com>
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
Co-authored-by: Humber Nieto <56887259+humbernieto@users.noreply.github.com>
Co-authored-by: Atharva Deosthale <atharva.deosthale17@gmail.com>
Co-authored-by: Nikita Drokin <86173808+nikitadrokin@users.noreply.github.com>
Co-authored-by: Adarsh Tiwari <adarshtiwari797023@gmail.com>
Co-authored-by: Adarsh Tiwari <134617221+Adarsh9977@users.noreply.github.com>
This was referenced Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants