Skip to content

Comments

feat: selecting-deselecting-mails#615

Closed
TusharBhatt1 wants to merge 16 commits intoMail-0:stagingfrom
TusharBhatt1:feat/select-hovered-and-below-mails
Closed

feat: selecting-deselecting-mails#615
TusharBhatt1 wants to merge 16 commits intoMail-0:stagingfrom
TusharBhatt1:feat/select-hovered-and-below-mails

Conversation

@TusharBhatt1
Copy link

@TusharBhatt1 TusharBhatt1 commented Apr 7, 2025

Implements #338
Plus @nizzyabi mentioned some enhancements (second point below) : #615 (comment)

In total , we can now :

  • ctrl+a selects hovered and all below
  • Add/Remove from throughout the mail list
enhancements.mp4

Type of Change

Please delete options that are not relevant.

  • 🎨 UI/UX 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

Security Considerations

For changes involving data or authentication:

  • No sensitive data is exposed
  • Authentication checks are in place
  • Input validation is implemented
  • Rate limiting is considered (if applicable)

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

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced email selection behavior: Users can now select emails starting from the hovered email downward.
    • Added a clear selection control for bulk selection mode.
    • Updated keyboard shortcuts to align with the new selection logic.
    • Improved user interface with hover tracking for email threads.

@vercel
Copy link

vercel bot commented Apr 7, 2025

@TusharBhatt1 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 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces a new state variable, hoveredMailId, in the MailList component. A new function, selectHoveredAndBelow, replaces the previous selectAll logic to select emails starting from the hovered email downward. The update passes setHoveredMailId to the Thread component, which now uses it in its mouse enter/leave handlers to manage hover state. Additionally, hotkey handlers are updated to invoke this new selection logic, alongside minor JSX formatting adjustments.

Changes

File(s) Changes Summary
apps/mail/components/mail/mail-list.tsx Added hoveredMailId state variable; replaced selectAll with selectHoveredAndBelow to select emails from the hovered email downward; updated hotkey handlers; formatted JSX.
apps/mail/components/mail/Thread.tsx (assumed component file) Updated prop definitions to include setHoveredMailId; modified handleMouseEnter and handleMouseLeave to update hover state.

Possibly related PRs

  • fixing the virtual mail-list #475: The changes in the main PR are related to the modifications in the MailList component, specifically the refactor involving the Virtuoso component, which directly impacts the rendering logic and functionality of the same component.
  • fix: re-rendering #478: The changes in the main PR and the retrieved PR both modify the MailList component in mail-list.tsx, specifically altering the email selection logic and event handling for hotkeys, indicating a direct relationship between the two.
  • making the app faster #587: The changes in the main PR focus on modifying the email selection logic and introducing a new state variable in the MailList component, while the retrieved PR alters the state management for threadId and selection criteria in the same component, indicating a related focus on state handling and selection logic.

Suggested reviewers

  • ahmetskilinc
  • MrgSub

Poem

I hop along the code so free,
With a twitching nose in pure delight,
Hovering where emails come to be,
I select with grace—from day to night.
Bugs, beware, as I skip in glee! 🐇

Cheers from a rabbit who loves clean code!


🪧 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.

@TusharBhatt1 TusharBhatt1 changed the title feat: hover-and-select-mails-on-ctrl+a feat: select-hovered-and-below-mails-on-ctrl+a Apr 7, 2025
@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

while this is nice, what if the user wants to skip a few selected items and pick a single email a few spots below the rest? they will be forced to pick all of them. is this correct?

@TusharBhatt1
Copy link
Author

while this is nice, what if the user wants to skip a few selected items and pick a single email a few spots below the rest? they will be forced to pick all of them. is this correct?

Got it - makes sense ! however this PR implements what #338 asked , so can we pick this in a follow up PR as a built on top of feature , thoughts ?

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

wanna just add to this pr?

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

we can merge

@TusharBhatt1
Copy link
Author

TusharBhatt1 commented Apr 7, 2025

we can merge

If this can be merged , I'll add a new issue (feature - you mentioned) and share a follow up PR in some time - I believe that's a really cool but a different feature altogether

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

just build within this one plz

@TusharBhatt1
Copy link
Author

TusharBhatt1 commented Apr 7, 2025

just build within this one plz

No problem , let's get this in as well
Can you just clarify the exact behavior , do we want to give the feature to deselect from the list of selected mails ?

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

yes thats fine but this is what im try to say:

if i want to select 3 emails in the mail list:

one is in index 2
one is in index 5
one is in index 6

i don't want index 3 & 4 to be selected. i only want 2, 5, and 6 to be selected

@TusharBhatt1
Copy link
Author

yes thats fine but this is what im try to say:

if i want to select 3 emails in the mail list:

one is in index 2
one is in index 5
one is in index 6

i don't want index 3 & 4 to be selected. i only want 2, 5, and 6 to be selected

Cool , I guess giving the feature to deselect from the selected list , would be ideal here

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

yes. we also need to make sure that the user can select individual emails across the list

@TusharBhatt1
Copy link
Author

yes. we also need to make sure that the user can select individual emails across the list

Cool , currently onClick of email (selected or not) we open the mail - is it ok to make it : onClick of selected , it deselects rather than opening ?

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

yes thats fine

@TusharBhatt1
Copy link
Author

TusharBhatt1 commented Apr 7, 2025

yes thats fine

Cool , will add these enhancements

@nizzyabi
Copy link
Collaborator

nizzyabi commented Apr 7, 2025

great, lmk if you need anything

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 (3)
apps/mail/components/mail/mail-list.tsx (3)

100-100: Inconsistent naming convention for state setter

The mail state uses setEmail as the setter function but the state variable is named mail. This inconsistency could be confusing.

-const [mail, setEmail] = useMail();
+const [mail, setMail] = useMail();

488-509: Core feature implementation looks good

The selectHoveredAndBelow function correctly implements the requested feature, allowing selection of emails from the hovered one downwards. The function also handles edge cases like empty lists and already-selected items.

However, consider adding a toast notification when selecting emails to provide feedback to the user:

 setMail((prev) => ({
   ...prev,
   bulkSelected: hoveredMailId ? allIdsFromHoveredAndBelow : allIds,
 }));
+toast.success(hoveredMailId 
+  ? t('common.mail.selectedFromHoveredDown') 
+  : t('common.mail.selectedAll'));

489-500: Consider visual hover indication

While the hover state is tracked internally, there's no clear visual indication to users which email is currently hovered. Consider adding a subtle visual cue.

 className={cn(
   'hover:bg-offsetLight hover:bg-primary/5 group relative flex cursor-pointer flex-col items-start overflow-clip rounded-lg border border-transparent px-4 py-3 text-left text-sm transition-all hover:opacity-100',
   isMailSelected || (!message.unread && 'opacity-50'),
   (isMailSelected || isMailBulkSelected || isKeyboardFocused) &&
     'border-border bg-primary/5 opacity-100',
   isKeyboardFocused && 'ring-primary/50 ring-2',
+  message.id === hoveredMailId && 'border-primary/30',
 )}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a2fd6a9 and 439bba9.

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

13-23: Import organization looks good

The addition of the X icon import and the reorganization of React imports with proper TypeScript types is well-structured.


91-98: Good prop extension for the hover functionality

The addition of the setHoveredMailId prop to the Thread component provides a clean way to communicate the hover state back to the parent component.


128-128: Well-implemented hover state management

The hover state is properly managed by setting the current email ID on mouse enter and clearing it on mouse leave.

Also applies to: 153-154


325-346: Great addition for email deselection

The clear selection button (X) allows users to easily deselect individual emails from their selection, enhancing usability. This is a thoughtful improvement that matches the PR discussion about allowing deselection.


347-362: Improved layout structure

Moving the date display to be next to the subject line creates a more logical and balanced UI layout.


486-487: Well-implemented hover state tracking

The addition of the hoveredMailId state variable properly tracks which email is currently being hovered over, which is essential for the new selection functionality.


561-562: Hotkey handlers updated correctly

All keyboard shortcuts are correctly updated to use the new selectHoveredAndBelow function, ensuring consistent behavior across different key combinations.

Also applies to: 566-567, 571-572, 576-577


594-603: Enhanced selection behavior

The updated mail selection logic allows users to add emails to their existing selection rather than replacing it, which significantly improves the multi-selection UX.


685-685: Proper prop passing

The setHoveredMailId function is correctly passed to each Thread component, establishing the necessary communication channel.

@TusharBhatt1
Copy link
Author

TusharBhatt1 commented Apr 7, 2025

great, lmk if you need anything

@nizzyabi we have it in 🚀 (haven't change the existing logic for selected mail and onClick - opens the mail , I feel it's really cool and useful) : #615 (comment)

@MrgSub MrgSub requested review from hiheyhello123 and nizzyabi April 7, 2025 23:06
@TusharBhatt1 TusharBhatt1 changed the title feat: select-hovered-and-below-mails-on-ctrl+a feat: selecting_mails Apr 8, 2025
@TusharBhatt1 TusharBhatt1 changed the title feat: selecting_mails feat: selecting_deselecting_mails Apr 8, 2025
@TusharBhatt1 TusharBhatt1 changed the title feat: selecting_deselecting_mails feat: selecting-deselecting-mails Apr 10, 2025
@TusharBhatt1
Copy link
Author

@nizzyabi @ahmetskilinc @MrgSub can you tell why this got closed - ig the feature is not live yet

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