Skip to content

perf: lower network requests after select all checkbox#1576

Merged
nizzyabi merged 3 commits intoMail-0:stagingfrom
retrogtx:requests
Jul 2, 2025
Merged

perf: lower network requests after select all checkbox#1576
nizzyabi merged 3 commits intoMail-0:stagingfrom
retrogtx:requests

Conversation

@retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Jul 1, 2025

decrease network requests trips

also removes the "select all x conversations" to make it more fast

perf.mp4

Summary by CodeRabbit

  • New Features

    • Added a toast notification with an action button to "Select all conversations" when selecting all on the current page. Clicking the button fetches and selects all matching conversations.
  • Refactor

    • Improved performance by deferring the fetching of all matching conversation IDs until explicitly requested, with caching to avoid redundant fetches.
  • Style

    • Enhanced user experience with clearer bulk selection flow and feedback.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Walkthrough

The SelectAllCheckbox component was refactored to defer fetching all matching thread IDs until the user explicitly requests it via a toast action. A caching mechanism for fetched IDs was introduced, and the maximum number of thread IDs fetched per page was increased. The component now manages fetching state and cache invalidation based on folder or query changes.

Changes

File(s) Change Summary
apps/mail/components/mail/select-all-checkbox.tsx Refactored to defer fetching all thread IDs until toast action; added caching; increased fetch limit; managed fetching state and cache invalidation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SelectAllCheckbox
    participant Toast
    participant ThreadFetcher
    participant BulkSelection

    User->>SelectAllCheckbox: Toggle "Select All"
    SelectAllCheckbox->>Toast: Show "Select all conversations" action
    User->>Toast: Click "Select all conversations"
    alt IDs not cached
        SelectAllCheckbox->>ThreadFetcher: Fetch all matching thread IDs
        ThreadFetcher-->>SelectAllCheckbox: Return thread IDs
        SelectAllCheckbox->>BulkSelection: Update with all IDs
        SelectAllCheckbox->>SelectAllCheckbox: Cache IDs
    else IDs cached
        SelectAllCheckbox->>BulkSelection: Update with cached IDs
    end
Loading

Possibly related PRs

Suggested reviewers

  • MrgSub

Poem

In the meadow of code, a checkbox anew,
Waits for your click to know what to do.
“Select them all!”—but wait for the toast,
Fetching IDs only when needed most.
With cache in its burrow, it’s speedy and spry,
A clever new trick for this rabbit to try! 🐇✨


📜 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 a9dacac and e4b5b17.

📒 Files selected for processing (1)
  • apps/mail/components/mail/select-all-checkbox.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/mail/components/mail/select-all-checkbox.tsx
✨ 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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Optimized select-all checkbox functionality to reduce network overhead in the mail application's thread selection system.

  • Implemented thread ID caching using useRef in apps/mail/components/mail/select-all-checkbox.tsx to prevent redundant fetching
  • Increased MAX_PER_PAGE from 100 to 500 threads to minimize pagination requests
  • Deferred thread ID fetching to toast action callback for better performance
  • Added cache clearing mechanism via useEffect when folder or search parameters change
  • Simplified UI by removing specific thread count from selection toast

1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

retrogtx and others added 2 commits July 1, 2025 12:06
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@nizzyabi nizzyabi merged commit 138c367 into Mail-0:staging Jul 2, 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