Skip to content

Comments

Staging#771

Merged
MrgSub merged 73 commits intomainfrom
staging
Apr 25, 2025
Merged

Staging#771
MrgSub merged 73 commits intomainfrom
staging

Conversation

@MrgSub
Copy link
Collaborator

@MrgSub MrgSub commented Apr 25, 2025

Summary by CodeRabbit

  • New Features
    • Added support for sending existing email drafts.
    • Enabled inline editing of email addresses in compose fields.
    • Added the ability to permanently delete threads from the bin.
    • Introduced Chinese (Simplified) and Chinese (Traditional) language support.
  • Enhancements
    • Improved error handling and feedback for note operations.
    • Refined email sending logic to handle drafts and regular emails.
    • Updated context menu actions for threads in the bin.
  • Bug Fixes
    • Improved handling of note data in the notes hook.
  • Chores
    • Added "dompurify" as a dependency.
    • Removed Vietnamese localization file.
    • Updated locale configuration to include new languages.
  • Documentation
    • Added and updated localized strings for mail deletion actions.
  • Tests
    • Added a script to send test emails using the Resend API.

ahmetskilinc and others added 30 commits April 19, 2025 01:28
- added cc and bcc when saving drafts
- save drafts less aggresively
chore: simplify and fix the dev env
* 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>
…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
Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
* Updated lockfile

* Updated home page session validation

---------

Co-authored-by: Adam <x_1337@outlook.com>
* Create route og image

* resolve coderabbit nitpicks

---------

Co-authored-by: Adam <x_1337@outlook.com>
Adarsh9977 and others added 21 commits April 23, 2025 13:51
- updates lib/auth.ts to use the new method
- updates actions/user.ts
- updates app/(routes)/settings/danger-zone/page.tsx
…mponent

- 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.
- Updated NavItem to include an onClick prop for the Link component, allowing for custom click behavior.
- Maintained existing functionality with prefetch and target attributes.
* 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>
* 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>
@vercel
Copy link

vercel bot commented Apr 25, 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 Apr 25, 2025 8:58pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

Walkthrough

This update introduces multiple enhancements and refactorings across the mail application. Key changes include the addition of a thread deletion feature with context menu integration, support for sending drafts via the mail driver and UI, and improvements to the email input component enabling inline editing. The notes panel's async operations are now consistently wrapped in toast notifications. Two new Chinese language variants are added to localization, while the Vietnamese locale is removed. The EnableBrain function is refactored for explicit connection handling and invoked upon new connection creation. A new script for sending test emails is added, and a dependency on dompurify is introduced.

Changes

File(s) Change Summary
apps/mail/actions/brain.ts Refactored EnableBrain to require a connection argument, simplified error handling, and ensured boolean return.
apps/mail/actions/mail.ts Consolidated imports, improved starred tag check, and added new exported deleteThread function with error handling.
apps/mail/actions/send.ts Updated sendEmail to accept optional draftId and conditionally send draft or create new email.
apps/mail/app/api/driver/google.ts
apps/mail/app/api/driver/types.ts
Added sendDraft method to MailManager interface and Google mail driver implementation.
apps/mail/components/context/thread-context.tsx Integrated deleteThread into context menu for bin threads; added async handler with toast notifications.
apps/mail/components/create/create-email.tsx Added handleEditEmail for inline editing, refactored send logic to support drafts, and minor UI class tweak.
apps/mail/components/create/email-input.tsx Enhanced EmailInput to support inline editing of email chips via new prop and internal state.
apps/mail/components/mail/note-panel.ts Refactored all async note operations to use toast-wrapped async functions for consistent UX.
apps/mail/components/mail/thread-display.tsx Renamed notes panel state, moved NotesPanel rendering to main thread action area, removed dropdown integration.
apps/mail/hooks/use-notes.tsx Changed notes data extraction to return result directly, not from .data property.
apps/mail/i18n/config.ts
i18n.json
Added zh_TW and zh_CN language entries to supported locales.
apps/mail/lib/auth.ts Updated user info extraction, added Microsoft as trusted provider, and invoked EnableBrain after new connection creation.
apps/mail/locales/en.json Added new mail deletion-related localization strings.
apps/mail/locales/vi.json Removed Vietnamese locale file and all placeholder translations.
apps/mail/package.json Added dompurify dependency.
apps/mail/scripts.ts Added new script to send test emails using Resend API and Faker for random sender names.

Sequence Diagram(s)

Thread Deletion Flow

sequenceDiagram
    participant User
    participant ThreadContextMenu
    participant deleteThread (action)
    participant ActiveDriver
    participant Toast

    User->>ThreadContextMenu: Select "delete from bin"
    ThreadContextMenu->>deleteThread: Call with threadId
    deleteThread->>ActiveDriver: driver.delete(threadId)
    ActiveDriver-->>deleteThread: Success/Error
    deleteThread->>Toast: Show loading/success/error
    deleteThread-->>ThreadContextMenu: Return success
Loading

Sending Email or Draft

sequenceDiagram
    participant User
    participant CreateEmail
    participant sendEmail (action)
    participant MailDriver

    User->>CreateEmail: Click Send
    CreateEmail->>sendEmail: With emailData (+draftId if present)
    alt draftId provided
        sendEmail->>MailDriver: sendDraft(draftId, emailData)
    else
        sendEmail->>MailDriver: create(emailData)
    end
    MailDriver-->>sendEmail: Success/Error
    sendEmail-->>CreateEmail: Result
Loading

Inline Editing of Email Chips

sequenceDiagram
    participant User
    participant EmailInput
    participant CreateEmail

    User->>EmailInput: Click on email chip
    EmailInput->>EmailInput: Show input for editing
    User->>EmailInput: Edit and press Enter
    EmailInput->>CreateEmail: onEditEmail(type, index, newEmail)
    CreateEmail-->>EmailInput: Update state
Loading

Possibly related PRs

  • Staging #768: Also adds deleteThread and related context menu handling for thread deletion, directly overlapping with this PR.
  • chore(i18n): config #445: Refactors the LANGUAGES constant in the i18n config, related to this PR's addition of new Chinese language entries.
  • User can able to delete from bin  #670: Adds and integrates deleteThread and its context menu usage, closely mirroring the thread deletion feature in this PR.

Suggested reviewers

  • needleXO
  • ahmetskilinc

Poem

🐇
In the garden of code, new features bloom,
Deleting threads from the bin now meets its doom!
Emails can be edited, drafts sent with flair,
Notes toast with promise, improvements everywhere.
Two new languages join the song,
While Vietnamese hops along.
With every hop, the app grows bright—
Hooray for changes, crisp and right!
✉️🌱


📜 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 c8069d5 and 7707f7a.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • apps/mail/actions/brain.ts (1 hunks)
  • apps/mail/actions/mail.ts (3 hunks)
  • apps/mail/actions/send.ts (4 hunks)
  • apps/mail/app/api/driver/google.ts (1 hunks)
  • apps/mail/app/api/driver/types.ts (1 hunks)
  • apps/mail/components/context/thread-context.tsx (3 hunks)
  • apps/mail/components/create/create-email.tsx (8 hunks)
  • apps/mail/components/create/email-input.tsx (4 hunks)
  • apps/mail/components/mail/note-panel.tsx (7 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
  • apps/mail/hooks/use-notes.tsx (1 hunks)
  • apps/mail/i18n/config.ts (1 hunks)
  • apps/mail/lib/auth.ts (6 hunks)
  • apps/mail/locales/en.json (2 hunks)
  • apps/mail/locales/vi.json (0 hunks)
  • apps/mail/package.json (1 hunks)
  • apps/mail/scripts.ts (1 hunks)
  • i18n.json (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/mail/locales/vi.json
🧰 Additional context used
🧬 Code Graph Analysis (7)
apps/mail/actions/send.ts (1)
apps/mail/app/api/driver/google.ts (1)
  • driver (195-1061)
apps/mail/app/api/driver/types.ts (1)
apps/mail/types/index.ts (1)
  • IOutgoingMessage (110-120)
apps/mail/components/create/create-email.tsx (1)
apps/mail/actions/send.ts (1)
  • sendEmail (7-67)
apps/mail/components/context/thread-context.tsx (1)
apps/mail/actions/mail.ts (1)
  • deleteThread (117-128)
apps/mail/actions/brain.ts (1)
packages/db/src/schema.ts (1)
  • connection (77-94)
apps/mail/app/api/driver/google.ts (1)
apps/mail/types/index.ts (1)
  • IOutgoingMessage (110-120)
apps/mail/components/mail/thread-display.tsx (1)
apps/mail/components/mail/note-panel.tsx (1)
  • NotesPanel (245-859)
🔇 Additional comments (37)
apps/mail/package.json (1)

69-69: Good addition of DOMPurify for HTML sanitization.

Adding DOMPurify is a security best practice for handling and rendering HTML content, particularly important in a mail application where user-generated content is displayed.

apps/mail/app/api/driver/types.ts (1)

13-13: LGTM - Good interface addition for draft sending functionality.

The addition of the sendDraft method to the MailManager interface is well-structured and aligns with the new draft sending functionality described in the PR objectives.

apps/mail/hooks/use-notes.tsx (1)

25-27:

Details

❓ Verification inconclusive

Verify API response structure change.

The change assumes the API now returns notes directly rather than nested within a data property. Ensure this is consistent with the API implementation.


🏁 Script executed:

#!/bin/bash
# Check the API response structure in the notes endpoint implementation
rg -A 10 "notes\?threadId" --type ts

Length of output: 697


Double-check /api/driver/notes response shape

The hook at apps/mail/hooks/use-notes.tsx (lines 25–27) now assumes that calling

const result = await fetcher('/api/driver/notes?threadId=' + threadId);
return result || [];

yields a flat Note[], not wrapped in { data: Note[] }. Confirm that your server-side handler (e.g. pages/api/driver/notes.ts) returns the array at the root. Adjust either the API or this hook to align with the actual response structure.

apps/mail/components/mail/thread-display.tsx (3)

43-43: Added Note type import to support notes functionality.

This import supports the enhanced note features mentioned in the AI summary, providing proper type checking for note operations.


146-146: Renamed state variable for better semantic clarity.

Renaming from isNotesOpen to isNotesPanelOpen provides more descriptive naming that better reflects the state's purpose.


287-287: Improved UI by moving NotesPanel to a prominent position.

The NotesPanel component is now directly rendered in the thread action buttons area (conditioned on threadId existence) rather than being hidden in a dropdown menu. This makes the notes feature more accessible to users.

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

22-24: Added localization strings for mail deletion operations.

These new strings provide user feedback during mail deletion operations:

  • Loading state: "Deleting mail..."
  • Error state: "Failed to delete mail"
  • Success state: "Mail deleted"

These additions support the new thread deletion functionality mentioned in the AI summary.


255-255: Added localization string for permanent deletion command.

The new "Delete from Bin" string supports the UI for the new thread deletion functionality, allowing users to permanently delete emails from the bin folder.

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

17-17: Added optional draftId parameter to sendEmail function.

This change enables the function to handle sending existing drafts, supporting the draft sending feature mentioned in the AI summary.

Also applies to: 28-28


48-58: Extracted email data into a separate variable for reuse.

Good refactoring to create an emailData variable that can be used for both new emails and draft emails, improving code readability.


60-64: Added conditional logic to support sending drafts.

The function now conditionally either:

  1. Sends an existing draft using driver.sendDraft() when a draftId is provided
  2. Creates a new email using driver.create() when no draftId is provided

This implementation aligns with the enhanced email sending capabilities mentioned in the AI summary.

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

835-853: Added sendDraft method to support sending existing drafts.

This new method:

  1. Accepts a draft ID and outgoing message data
  2. Uses the same error handling pattern as other methods
  3. Properly calls the Gmail API's users.drafts.send method

The implementation follows the existing patterns in the codebase and properly integrates with the Gmail API. This method enables the draft sending feature mentioned in the AI summary.

apps/mail/actions/mail.ts (2)

94-94: Improved tag checking logic 👍

The change to use find() with startsWith() instead of includes() enhances the flexibility of the starred tag detection, allowing it to match any tag that begins with 'STARRED'.


117-128: Well-implemented thread deletion function

The new deleteThread function is well-structured with proper error handling, including checking for fatal errors and connection deletion when necessary. It follows the same pattern as other server actions in this file.

apps/mail/components/context/thread-context.tsx (2)

29-29: Updated import to include the new function

The import statement has been properly updated to include the new deleteThread function.


285-291: New context menu option for permanent deletion from bin

The "delete from bin" option is properly added to the bin folder context menu, following the same pattern as other menu items and using appropriate icons and translations.

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

4-8: Good refactoring to use explicit connection parameter

This change improves the function by making its dependencies explicit rather than fetching the connection internally, which is better for testing and reusability.

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

271-288: Good addition of email editing functionality

The new handleEditEmail function is well-implemented with proper validation, state updates, and error handling. It enhances the user experience by allowing inline editing of existing email addresses.


357-375: Well-structured support for sending drafts

The refactoring of handleSendEmail to consolidate email data and conditionally handle drafts is well-implemented. The code now cleanly supports both creating new emails and sending drafts using the same underlying action.


408-408: Good cleanup of draftId after sending

Clearing the draft ID after successful sending ensures the form is properly reset for the next email composition.


600-600: Consistent application of new edit functionality

The onEditEmail prop has been consistently added to all three email input components, correctly implementing the inline editing functionality across to, cc, and bcc fields.

Also applies to: 616-616, 633-633

apps/mail/lib/auth.ts (4)

18-18: Clean addition of EnableBrain import

The import of the EnableBrain function matches the changes implemented later in the file where the function is called with connection details.


48-48: Simplification of user info property access

The code now directly accesses userInfo.address, userInfo.name, and userInfo.photo properties instead of using nested property access. This simplifies the code and improves readability.

Also applies to: 54-55, 67-67


118-118: Added Microsoft to trusted providers

The trusted providers list has been expanded to include 'microsoft' alongside 'google', which enables account linking between these providers.


254-258: Proper connection creation and brain integration

The refactored code now:

  1. Generates a connection ID once before insertion
  2. Reuses this ID when creating the connection
  3. Immediately enables brain features after connection creation by passing the ID and provider details

This approach ensures consistency between the database entry and the brain subscription.

Also applies to: 275-277

apps/mail/components/mail/note-panel.tsx (7)

290-308: Improved note creation with toast notifications

The note creation process now properly wraps the entire async flow inside a toast promise, providing user feedback during loading, success, and error states. The code also ensures the note content is trimmed before sending.


325-342: Enhanced note editing with proper user feedback

Note editing now follows the same pattern of wrapping the async operations in toast promises, with appropriate loading, success, and error messages.


358-371: Consistent notification pattern for note deletion

The note deletion process has been refactored to follow the same toast notification pattern, maintaining consistency across all note operations.


381-394: Improved pin toggling with toast notifications

The pin toggling process now uses toast promises with conditional success messages based on whether the note is being pinned or unpinned.


397-409: Enhanced color change with user feedback

Color change operations now correctly use toast promises for better user experience.


439-448: Consistent handling of reordering operations

Both pinned and unpinned note reordering now follow the same toast promise pattern, maintaining consistency with other note operations.

Also applies to: 460-469


513-515: Visual enhancement for the sticky note icon

The StickyNote icon now conditionally receives a fill color when notes exist, providing a subtle visual indicator to users.

apps/mail/components/create/email-input.tsx (4)

14-14: Added email editing capability

New prop onEditEmail has been added to handle updates to emails by index and type, enabling inline editing functionality.

Also applies to: 29-29


35-39: Added state and refs for editing emails

The component now tracks which email is being edited (editingIndex), its temporary value (editValue), and maintains a reference to the edit input element (editInputRef). These additions support the new inline editing feature.


74-98: Well-implemented email chip editing handlers

The handlers for chip clicking and editing keydown events provide a smooth editing experience:

  • handleChipClick correctly sets up the editing state and focuses the input
  • handleEditKeyDown properly handles Enter to commit changes and Escape to cancel

113-133: Smooth conditional rendering for email editing

The component intelligently switches between display and edit modes for email chips, with appropriate styling and interaction handlers:

  • Edit mode shows an input with the current email and a visual enter key hint
  • Display mode shows a clickable span with the email text
i18n.json (1)

23-25: Inconsistent summary: Vietnamese locale still present
The AI-generated summary states that the Vietnamese locale was removed, but "vi" remains listed in the targets array.

Likely an incorrect or invalid review comment.

✨ 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 generate sequence diagram to generate a sequence diagram of the changes in 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

🧹 Nitpick comments (3)
apps/mail/scripts.ts (1)

1-53: Move test utility to appropriate location.

This appears to be a testing utility that would be better placed in a dedicated testing directory rather than in the main application codebase.

Consider moving this file to a scripts/ or tests/utils/ directory to better organize the codebase and separate test utilities from production code.

apps/mail/components/context/thread-context.tsx (1)

239-253: Thread deletion handler implemented with proper notifications

The handler is well-implemented with appropriate toast notifications for loading, success, and error states, and it correctly updates UI state by clearing selections and triggering mutation.

There's a minor inconsistency in the indentation on line 240 - it uses tabs instead of spaces, unlike the rest of the file.

-		try {
+    try {
apps/mail/actions/brain.ts (1)

13-18: Consider adding error logging in catch handler

The error handling has been simplified using promise chaining, which is good. However, errors aren't being logged, which might make debugging harder in production.

 return await axios
   .put(process.env.BRAIN_URL + `/subscribe/${connection.providerId}`, {
     connectionId: connection.id,
   })
-  .catch((error) => false)
+  .catch((error) => {
+    console.error('Error subscribing to brain:', error);
+    return false;
+  })
   .then(() => true);
🛑 Comments failed to post (4)
apps/mail/scripts.ts (2)

31-39: ⚠️ Potential issue

Fix missing API credentials and recipient email.

The Resend API key is empty and the recipient email address is not specified, which will prevent this script from working properly.

- const resend = new Resend('');
+ const resend = new Resend(process.env.RESEND_API_KEY);
- to: '',
+ to: process.env.TEST_RECIPIENT_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.

const runTest = async () => {
  const resend = new Resend(process.env.RESEND_API_KEY);
  for (const item of arr) {
    const response = await resend.emails.send({
      from: `${faker.person.firstName().toLowerCase()}@test.com`,
      to: process.env.TEST_RECIPIENT_EMAIL,
      subject: item.subject,
      html: item.text,
    });

52-52: 🛠️ Refactor suggestion

Remove or guard automatic script execution.

The script automatically runs when imported, which might not be intended for production use. Consider wrapping this in a condition or converting it to a manually invoked function.

-runTest();
+// Only run in development or when explicitly requested
+if (process.env.NODE_ENV === 'development' && process.env.RUN_TEST_EMAILS) {
+  runTest();
+}
+
+export { runTest };
📝 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.

// Only run in development or when explicitly requested
if (process.env.NODE_ENV === 'development' && process.env.RUN_TEST_EMAILS) {
  runTest();
}

export { runTest };
i18n.json (1)

23-25: 💡 Verification agent

🧩 Analysis chain

Add Chinese target locales: verify translation files
Locales "zh_CN" and "zh_TW" have been added to the targets array. Please ensure corresponding translation files exist under apps/mail/locales and are correctly populated.


🏁 Script executed:

#!/bin/bash
# Verify translation files for the new Chinese locales
for locale in zh_CN zh_TW; do
  if [ ! -f "apps/mail/locales/${locale}.json" ]; then
    echo "Missing translation file: apps/mail/locales/${locale}.json"
    exit 1
  fi
done
echo "All new locale files are present."

Length of output: 201


Add missing Chinese translation files

Translation file apps/mail/locales/zh_CN.json is currently missing. Please add this file (and verify that apps/mail/locales/zh_TW.json exists) and populate both with the appropriate translations before merging.

• Missing: apps/mail/locales/zh_CN.json
• Verify presence and content: apps/mail/locales/zh_TW.json

apps/mail/i18n/config.ts (1)

4-5: 💡 Verification agent

🧩 Analysis chain

Add Chinese language entries: verify support & maintain ordering
Entries for zh_TW and zh_CN have been added to LANGUAGES, in line with i18n.json. Please confirm the locale files exist under apps/mail/locales. For clarity, consider maintaining a consistent (e.g., alphabetical) order of entries in this object.


🏁 Script executed:

#!/bin/bash
# Check for new locale files in the mail app
for locale in zh_CN zh_TW; do
  if [ ! -f "apps/mail/locales/${locale}.json" ]; then
    echo "apps/mail/locales/${locale}.json is missing"
    exit 1
  fi
done
echo "New locale files verified."

Length of output: 171


🏁 Script executed:

#!/bin/bash
# Verify presence of both Chinese locale files in apps/mail/locales
for locale in zh_CN zh_TW; do
  if [ -f "apps/mail/locales/${locale}.json" ]; then
    echo "✔ apps/mail/locales/${locale}.json exists"
  else
    echo "✖ apps/mail/locales/${locale}.json is missing"
  fi
done

Length of output: 325


Missing locale files for Chinese (Simplified & Traditional)
The entries for zh_CN and zh_TW were added to apps/mail/i18n/config.ts, but their corresponding JSON files are not present under apps/mail/locales. Please add these files before merging:

• apps/mail/locales/zh_CN.json
• apps/mail/locales/zh_TW.json

Also, consider ordering the LANGUAGES object alphabetically to keep entries consistent:

 const LANGUAGES = {
-  en:    'English',
-  es:    'Spanish',
-  zh_TW: 'Chinese (Traditional)',
-  zh_CN: 'Chinese (Simplified)',
+  en:    'English',
+  es:    'Spanish',
+  zh_CN: 'Chinese (Simplified)',
+  zh_TW: 'Chinese (Traditional)',
 };
📝 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.

const LANGUAGES = {
  en:    'English',
  es:    'Spanish',
  zh_CN: 'Chinese (Simplified)',
  zh_TW: 'Chinese (Traditional)',
};

@MrgSub MrgSub merged commit 1f0cb1c into main Apr 25, 2025
5 checks passed
This was referenced Apr 25, 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.