Skip to content

Comments

feat: add select all checkbox to mail layout#1467

Merged
MrgSub merged 4 commits intoMail-0:stagingfrom
retrogtx:checkbox
Jun 27, 2025
Merged

feat: add select all checkbox to mail layout#1467
MrgSub merged 4 commits intoMail-0:stagingfrom
retrogtx:checkbox

Conversation

@retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Jun 24, 2025

now you can select all mails in the current view, and all of them that are not visible in the current view too.

checkbox.mp4

Summary by CodeRabbit

  • New Features

    • Added a "Select All" checkbox in the mail sidebar to enable bulk selection of email threads, with support for selecting all conversations matching the current search.
    • Displays notifications for selection actions and handles errors gracefully.
  • User Interface

    • The new checkbox appears next to the sidebar toggle button and visually indicates selection status (checked, unchecked, or partial).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Warning

Rate limit exceeded

@retrogtx has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b6e76dc and 121c249.

📒 Files selected for processing (1)
  • apps/mail/components/mail/mail.tsx (2 hunks)

"""

Walkthrough

A new SelectAllCheckbox React component is introduced and integrated into the mail application's sidebar header. This checkbox manages bulk selection of email threads, handling selection state, asynchronous fetching of all matching thread IDs, and user feedback via toasts. No existing exported entities are altered.

Changes

File(s) Change Summary
apps/mail/components/mail/mail.tsx Imported and rendered the new SelectAllCheckbox component in the sidebar header.
apps/mail/components/mail/select-all-checkbox.tsx Added the SelectAllCheckbox component, handling bulk selection logic, async fetching, and toasts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SelectAllCheckbox
    participant MailState
    participant API
    participant Toast

    User->>SelectAllCheckbox: Toggle checkbox
    alt Some threads selected
        SelectAllCheckbox->>MailState: Clear selection
    else None selected
        SelectAllCheckbox->>MailState: Select all loaded threads
        SelectAllCheckbox->>API: Fetch all matching thread IDs (paginated)
        API-->>SelectAllCheckbox: Return all thread IDs
        SelectAllCheckbox->>MailState: Select all fetched threads
        SelectAllCheckbox->>Toast: Show selection count and "select all" action
    end
    Note right of SelectAllCheckbox: Handles loading, indeterminate state, and errors
Loading

Suggested labels

design

Suggested reviewers

  • MrgSub

Poem

In the mailbox where threads abound,
A checkbox now can all surround.
With clicks it fetches, counts, and shows,
The power bulk selection knows!
Toasts pop up with cheerful cheer,
The rabbit coder hops, "All clear!"
🐇✅📬
"""

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/mail/components/mail/select-all-checkbox.tsx (1)

31-56: Consider adding request cancellation for better UX.

The pagination logic is well-implemented with proper error handling. However, for large datasets, consider adding an AbortController to allow cancelling the fetch operation if the user changes their mind.

const fetchAllMatchingThreadIds = useCallback(async (): Promise<string[]> => {
+ const abortController = new AbortController();
  const ids: string[] = [];
  let cursor = '';
  const MAX_PER_PAGE = 100;

  try {
    while (true) {
+     if (abortController.signal.aborted) break;
      const page = await trpcClient.mail.listThreads.query({
        folder,
        q: query,
        max: MAX_PER_PAGE,
        cursor,
      });
      // ... rest of logic
    }
  } catch (err: any) {
+   if (err.name === 'AbortError') return ids;
    console.error('Failed to fetch all thread IDs', err);
    toast.error(err?.message ?? 'Failed to select all emails');
  }

  return ids;
}, [folder, query]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 027e913 and 0f9d1be.

📒 Files selected for processing (2)
  • apps/mail/components/mail/mail.tsx (2 hunks)
  • apps/mail/components/mail/select-all-checkbox.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/mail/components/mail/select-all-checkbox.tsx

[error] 13-13: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)

🔇 Additional comments (6)
apps/mail/components/mail/select-all-checkbox.tsx (4)

1-9: LGTM! Well-organized imports.

All necessary dependencies are properly imported and the imports are logically grouped.


20-29: LGTM! Well-implemented state calculations.

The computed values properly handle the three checkbox states with appropriate memoization dependencies.


58-81: LGTM! Excellent UX design for bulk selection.

The two-step selection process provides immediate feedback while fetching all threads asynchronously. The toast notification with action button is a great UX pattern.


83-91: LGTM! Clean component rendering with proper state handling.

The checkbox correctly reflects selection state and provides appropriate user feedback during loading.

apps/mail/components/mail/mail.tsx (2)

68-68: LGTM! Proper import statement.

The import follows the project's conventions and uses the correct relative path.


496-496: LGTM! Well-positioned component integration.

The SelectAllCheckbox is appropriately placed in the sidebar header with proper spacing and integrates seamlessly with the existing UI.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1fa6c86 and b6e76dc.

📒 Files selected for processing (1)
  • apps/mail/components/mail/mail.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/mail/components/mail/mail.tsx (1)
apps/mail/components/mail/select-all-checkbox.tsx (1)
  • SelectAllCheckbox (11-92)
🪛 Biome (1.9.4)
apps/mail/components/mail/mail.tsx

[error] 69-69: Shouldn't redeclare 'IConnection'. Consider to delete it or rename it.

'IConnection' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (2)
apps/mail/components/mail/mail.tsx (2)

70-70: LGTM! Clean import of the new component.

The import of SelectAllCheckbox is properly structured and follows the project's import conventions.


496-496: Excellent integration of the SelectAllCheckbox component.

The component is placed appropriately in the sidebar header next to the SidebarToggle button with proper spacing (ml-2). This aligns perfectly with the PR objective of adding select all functionality to the mail layout.

@MrgSub MrgSub merged commit 3041531 into Mail-0:staging Jun 27, 2025
3 checks passed
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