Skip to content

Comments

email avatars#528

Merged
nizzyabi merged 3 commits intostagingfrom
feat/email-provider-avatars
Mar 28, 2025
Merged

email avatars#528
nizzyabi merged 3 commits intostagingfrom
feat/email-provider-avatars

Conversation

@ahmetskilinc
Copy link
Contributor

@ahmetskilinc ahmetskilinc commented Mar 28, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced email display with a refreshed sender avatar that now shows as a circular image with simplified fallback.
    • Reorganized email thread presentation to clearly showcase sender details and subject lines for improved readability.
  • Style

    • Updated visual styling for a more consistent and polished user interface across the mail components.

@vercel
Copy link

vercel bot commented Mar 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2025 0:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

The changes update the avatar display within the email module. In the MailDisplay component, the previous initials-based avatar is replaced with a circular image provided by the new getEmailLogo function. The fallback now shows only the first character of the sender’s name. In MailList, the layout and styling are refined for clarity and consistency. Additionally, a new utility function is added in the utils file and stylistic adjustments (switching from double to single quotes) have been made.

Changes

File(s) Change Summary
apps/…/mail-display.tsx & mail-list.tsx Enhanced avatar rendering: replaced sender initials with a circular image from getEmailLogo; updated fallback display and reorganized layout and selection styling in email threads.
apps/…/utils.ts Applied stylistic changes (double to single quotes) and added the getEmailLogo(email: string) function to generate logo URLs based on the sender's email.

Possibly related PRs

  • Feature/thread badge tooltips #410: Updates in MailList regarding avatar rendering improvements align with these changes.
  • reply ai #526: The addition of the getEmailLogo function in utils.ts relates to the modifications in MailList where the Avatar components are utilized.

Suggested reviewers

  • nizzyabi
  • MrgSub

Poem

Hop, hop—code leaps in the night,
A circular charm now shining bright.
Avatars updated with a stylish new glow,
Fallbacks that whisper a single letter’s show.
From mail threads to logos, our code hops along—
A rabbit's delight in each commit song! 🐰💻

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a48ee8 and ee87164.

📒 Files selected for processing (1)
  • apps/mail/components/mail/mail-list.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/mail/components/mail/mail-list.tsx

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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: 1

🧹 Nitpick comments (4)
apps/mail/components/mail/mail-display.tsx (2)

21-21: Import statement contains duplication

The cn function is now imported twice - once in this statement and once in a previous import that's not shown in the diff.

-import { cn, getEmailLogo } from '@/lib/utils';
+import { getEmailLogo } from '@/lib/utils';

153-160: Avatar integration looks good, but needs fallback handling

The implementation correctly integrates the new avatar functionality using the getEmailLogo function. However, it lacks error handling for cases where the image fails to load.

Consider adding an onError handler to the AvatarImage component:

<AvatarImage
  src={getEmailLogo(emailData?.sender?.email)}
  className="rounded-full"
+ onError={(e) => {
+   e.currentTarget.style.display = 'none';
+ }}
/>

Also, check that emailData?.sender?.name exists before accessing [0]:

<AvatarFallback className="rounded-full">
- {emailData?.sender?.name[0]}
+ {emailData?.sender?.name?.[0] || '?'}
</AvatarFallback>
apps/mail/components/mail/mail-list.tsx (2)

158-159: Same issue with Avatar fallback handling

Similar to mail-display.tsx, this implementation needs error handling for cases where the image fails to load and safer access to the name property.

<AvatarImage src={getEmailLogo(message.sender.email)} className="rounded-full" />
-<AvatarFallback className="rounded-full">{message.sender.name[0]}</AvatarFallback>
+<AvatarImage 
+  src={getEmailLogo(message.sender.email)} 
+  className="rounded-full" 
+  onError={(e) => {
+    e.currentTarget.style.display = 'none';
+  }}
+/>
+<AvatarFallback className="rounded-full">
+  {message.sender?.name?.[0] || '?'}
+</AvatarFallback>

127-127: Remove empty comment line

Line 127 contains an empty comment that should be removed.

-        {/**/}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 76cf73a and 12e11d7.

📒 Files selected for processing (3)
  • apps/mail/components/mail/mail-display.tsx (2 hunks)
  • apps/mail/components/mail/mail-list.tsx (9 hunks)
  • apps/mail/lib/utils.ts (5 hunks)
🔇 Additional comments (2)
apps/mail/components/mail/mail-list.tsx (2)

156-162: Avatar implementation in Thread component looks good

The implementation of the Avatar component in the Thread component matches the style and approach used in the mail-display.tsx file, which is good for consistency.


171-176: Improved unread indicator implementation

The new implementation for showing unread status is cleaner and more visually effective than before. The small blue dot is a good visual indicator.

Comment on lines +354 to +356
export const getEmailLogo = (email: string) => {
return process.env.NEXT_PUBLIC_IMAGE_API_URL + email;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

New utility function for email avatars needs improvement

The new getEmailLogo function that concatenates email directly to the API URL has several issues:

  1. No URL encoding for the email address, which could cause issues with special characters
  2. No validation that the environment variable ends with a separator character
  3. No fallback if the environment variable is undefined

I recommend improving the implementation like this:

-export const getEmailLogo = (email: string) => {
-  return process.env.NEXT_PUBLIC_IMAGE_API_URL + email;
-};
+export const getEmailLogo = (email: string = '') => {
+  if (!email) return '';
+  
+  const baseUrl = process.env.NEXT_PUBLIC_IMAGE_API_URL || '';
+  if (!baseUrl) return '';
+  
+  // Ensure we have a separator between base URL and email
+  const separator = baseUrl.endsWith('/') ? '' : '/';
+  return `${baseUrl}${separator}${encodeURIComponent(email)}`;
+};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getEmailLogo = (email: string) => {
return process.env.NEXT_PUBLIC_IMAGE_API_URL + email;
};
export const getEmailLogo = (email: string = '') => {
if (!email) return '';
const baseUrl = process.env.NEXT_PUBLIC_IMAGE_API_URL || '';
if (!baseUrl) return '';
// Ensure we have a separator between base URL and email
const separator = baseUrl.endsWith('/') ? '' : '/';
return `${baseUrl}${separator}${encodeURIComponent(email)}`;
};

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

🧹 Nitpick comments (1)
apps/mail/components/mail/mail-list.tsx (1)

583-584: Hardcoded "Starred" label text.

The label text for starred items has been hardcoded instead of potentially using a translation key.

Consider using the translation system for the "Starred" text to maintain consistency with other labels:

-              labelContent = 'Starred';
+              labelContent = t('common.mailCategories.starred');
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12e11d7 and 6a48ee8.

📒 Files selected for processing (1)
  • apps/mail/components/mail/mail-list.tsx (9 hunks)
🔇 Additional comments (13)
apps/mail/components/mail/mail-list.tsx (13)

3-11: Updated import statement formatting.

The import statements have been reformatted to use single quotes instead of double quotes, improving consistency with the project's style guide. Each import is now on its own line with proper indentation, enhancing readability.


17-18: Added Avatar components and rearranged imports.

The Avatar components have been added to display email sender avatars, aligning with the new UI requirements. The imports have been properly organized.


21-21: Added getEmailLogo utility import.

The getEmailLogo function has been imported from utils to support the new avatar display feature, which generates logo images based on email addresses.


38-55: Improved component props formatting.

The component props have been restructured with better indentation and organization, making the code more readable and maintainable.


136-140: Refined email selection and read status styling logic.

The conditional class application has been improved to better handle the opacity and highlighting of selected or read emails.


148-154: Repositioned MailQuickActions component.

The quick actions component has been moved to a more appropriate position in the component hierarchy, maintaining its functionality while better supporting the new layout.


156-160: Added avatar display for email senders.

The new avatar component implementation displays the sender's image using the getEmailLogo function with a fallback to the first character of the sender's name. This improves visual recognition of emails.


161-177: Enhanced email thread header layout.

The layout for displaying sender information has been improved with better spacing and organization. The unread indicator now appears as a circular dot next to the sender's name, providing a cleaner visual indicator.


178-201: Improved layout for email metadata and indicators.

Labels, reply counts, and received date are now properly aligned and styled, with appropriate tooltips for additional context. The transition effects have been refined for better user experience.


202-212: Enhanced subject line display.

The subject line is now displayed with proper truncation and styling based on selection state, improving readability while maintaining a clean interface.


266-273: Refactored navigation handler for improved readability.

The handleNavigateToThread function has been reformatted with consistent indentation and better parameter usage, improving code readability and maintainability.


281-286: Updated useMailNavigation hook implementation.

The hook now properly handles the resetNavigation functionality and has better parameter formatting.


473-481: Simplified empty state check logic.

The empty state detection and rendering logic has been simplified, making the code more readable and easier to maintain.

@nizzyabi nizzyabi merged commit 8467178 into staging Mar 28, 2025
5 checks passed
nizzyabi added a commit that referenced this pull request Apr 1, 2025
* adjustable height

* h1 h2 h3 working in reply composer

* select dropdown for categories

* feat(navbar): update item label based on auth status

* feature/persist user settings (#513)

* feat: persist setting (codycodes95)

* feat: update settings to jsonb

* feat: run migration

* feat: save changes to db

* fix: naming

* feat: validate settings schema

* feat: add i18n

* fix: set i18n variables

* fix: coderabbit comment

* feat: improve function readability

* feat: use hook

* fix:update settings

---------

Co-authored-by: Cody Partington <codythatsme@gmail.com>

* remove unique status from email in schema

* early access check added to schema

* updated readme

* add contributors

* remove text-decoration

* text-decoration

* remove auto focus on search

* ahuh

* gg

* i18n

* check email for early access (#519)

* check email for early access

* one check

* saving...

* disable buttons

* disable

* fix

* saving...

* saving...

* minor

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Hindi)

* reply and searchbar display

* reply ai (#526)

* reply ai

* ai functionality

* line height

* adam fixes

---------

Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com>
Co-authored-by: Nizzy <nizabizaher@gmail.com>

* Autocompletions for reply and create

* email avatars (#528)

* added email avatars

* fix small issue

* small ui fix

* color fix

* reply ui

* New translations en.json (Japanese)

* New translations en.json (Korean)

* no drop down

* ui fix

* wip performance

* saving...

* saving...

* saving...

* saving...

* - updated phrases
- added delay of 2 matching characters

* Improved ai with custom prompt (#534)

* ai

* improved ai

* improved-ai-with-custom-prompt

* empty commit

* removed new lines

* empty commit

* search

* forwarding

* search filter removed. all in ai now

* saving...

* fix double submit on command enter create email

* saving...

* saving...

* turn search ai into a server action

* fuix

* show most recent email in thread

* saving...

* saving...

* forward and reply in one compose button

* saving...

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* fix to height reply composer

* posthog

* remove github login for now

* refresh

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* revert

* a

* fix load more

* fix load more

* remove use memo from thread to not load when opening an email

* fix switching accounts

---------

Co-authored-by: Nizzy <nizabizaher@gmail.com>
Co-authored-by: pietrodev07 <pietro.dev.07@gmail.com>
Co-authored-by: Sergio JVA <60497216+sergio-jva@users.noreply.github.com>
Co-authored-by: Cody Partington <codythatsme@gmail.com>
Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com>
Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>
Co-authored-by: [bot] <zero@ibra.rip>
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
nizzyabi added a commit that referenced this pull request Apr 1, 2025
* adjustable height

* h1 h2 h3 working in reply composer

* select dropdown for categories

* feat(navbar): update item label based on auth status

* feature/persist user settings (#513)

* feat: persist setting (codycodes95)

* feat: update settings to jsonb

* feat: run migration

* feat: save changes to db

* fix: naming

* feat: validate settings schema

* feat: add i18n

* fix: set i18n variables

* fix: coderabbit comment

* feat: improve function readability

* feat: use hook

* fix:update settings

---------

Co-authored-by: Cody Partington <codythatsme@gmail.com>

* remove unique status from email in schema

* early access check added to schema

* updated readme

* add contributors

* remove text-decoration

* text-decoration

* remove auto focus on search

* ahuh

* gg

* i18n

* check email for early access (#519)

* check email for early access

* one check

* saving...

* disable buttons

* disable

* fix

* saving...

* saving...

* minor

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Hindi)

* reply and searchbar display

* reply ai (#526)

* reply ai

* ai functionality

* line height

* adam fixes

---------

Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com>
Co-authored-by: Nizzy <nizabizaher@gmail.com>

* Autocompletions for reply and create

* email avatars (#528)

* added email avatars

* fix small issue

* small ui fix

* color fix

* reply ui

* New translations en.json (Japanese)

* New translations en.json (Korean)

* no drop down

* ui fix

* wip performance

* saving...

* saving...

* saving...

* saving...

* - updated phrases
- added delay of 2 matching characters

* Improved ai with custom prompt (#534)

* ai

* improved ai

* improved-ai-with-custom-prompt

* empty commit

* removed new lines

* empty commit

* search

* forwarding

* search filter removed. all in ai now

* saving...

* fix double submit on command enter create email

* saving...

* saving...

* turn search ai into a server action

* fuix

* show most recent email in thread

* saving...

* saving...

* forward and reply in one compose button

* saving...

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* fix to height reply composer

* posthog

* remove github login for now

* refresh

* New translations en.json (French)

* New translations en.json (Spanish)

* New translations en.json (Arabic)

* New translations en.json (Catalan)

* New translations en.json (Czech)

* New translations en.json (German)

* New translations en.json (Japanese)

* New translations en.json (Korean)

* New translations en.json (Polish)

* New translations en.json (Portuguese)

* New translations en.json (Russian)

* New translations en.json (Turkish)

* New translations en.json (Latvian)

* New translations en.json (Hindi)

* revert

* a

* fix load more

* fix load more

* remove use memo from thread to not load when opening an email

* fix switching accounts

* navbar changed to login

---------

Co-authored-by: Nizzy <nizabizaher@gmail.com>
Co-authored-by: pietrodev07 <pietro.dev.07@gmail.com>
Co-authored-by: Sergio JVA <60497216+sergio-jva@users.noreply.github.com>
Co-authored-by: Cody Partington <codythatsme@gmail.com>
Co-authored-by: Adam <x_1337@outlook.com>
Co-authored-by: Ahmet Kilinc <akx9@icloud.com>
Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com>
Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>
Co-authored-by: [bot] <zero@ibra.rip>
This was referenced Apr 5, 2025
@ahmetskilinc ahmetskilinc deleted the feat/email-provider-avatars branch April 26, 2025 14:38
This was referenced Jul 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.

2 participants