Skip to content

Comments

fixing small bugs#1204

Merged
MrgSub merged 4 commits intostagingfrom
06-05-fixing_small_bugs
Jun 5, 2025
Merged

fixing small bugs#1204
MrgSub merged 4 commits intostagingfrom
06-05-fixing_small_bugs

Conversation

@ahmetskilinc
Copy link
Contributor

@ahmetskilinc ahmetskilinc commented Jun 5, 2025

WIP

Icon Styling and Keyboard Shortcut Improvements

TL;DR

Improved icon styling and keyboard shortcuts for better user experience in the mail application.

What changed?

  • Fixed icon styling by changing --icon-color from black to currentColor for better theme compatibility
  • Enhanced the ExclamationCircle icon appearance with conditional styling based on importance status
  • Adjusted Star icon size for better visual consistency
  • Moved mouse event handlers from mail-list to mail layout component for proper scope management
  • Added Cmd+Z (Ctrl+Z) keyboard shortcut for undoing the last action
  • Fixed OldPhone icon SVG formatting
  • Implemented the undoLastAction handler in global hotkeys

How to test?

  1. Verify icon appearance in both light and dark themes
  2. Check that the ExclamationCircle icon properly changes appearance when marking emails as important
  3. Test the new Cmd+Z (Ctrl+Z) keyboard shortcut to undo actions
  4. Confirm that keyboard shortcuts work correctly when hovering over the mail list

Why make this change?

These changes improve the visual consistency of icons across themes and enhance the user experience by adding expected keyboard shortcuts like undo functionality. The refactoring of mouse event handlers ensures proper keyboard shortcut scope management when interacting with the mail list.

Summary by CodeRabbit

  • New Features

    • Added global keyboard shortcut (Cmd/Ctrl + Z) to undo the last action in the mail app.
  • Enhancements

    • Improved icon appearance with dynamic color inheritance and updated important/flagged icon styling.
    • Adjusted icon sizing for better consistency.
    • Hotkey scope for the mail list is now enabled or disabled based on mouse hover over the mail list panel.
  • Style

    • Minor formatting improvements to icon components.
  • Bug Fixes

    • Ensured undo shortcut prevents default browser behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update modifies icon color handling, keyboard shortcut configuration, and hotkey scope management in the mail application. It introduces dynamic icon coloring, updates the undo shortcut to 'mod+z', moves hotkey scope logic from the mail list to the mail layout, and connects the global undo shortcut to the optimistic actions system.

Changes

File(s) Change Summary
apps/mail/app/globals.css Changed --icon-color from black to currentColor for dynamic icon coloring in both light and dark themes.
apps/mail/components/icons/icons.tsx Commented out fill and fillOpacity in ExclamationCircle; reformatted OldPhone SVG opening tag attributes.
apps/mail/components/mail/mail-list.tsx Updated important toggle icon fill and stroke colors; removed mouse enter/leave hotkey scope handlers; changed label icon size to 12px.
apps/mail/components/mail/mail.tsx Added memoized handlers to enable/disable 'mail-list' hotkey scope on mouse enter/leave of mail list panel.
apps/mail/config/shortcuts.ts Activated undo shortcut as ['mod', 'z'] with preventDefault: true instead of commented-out 'z' key.
apps/mail/hooks/use-optimistic-actions.ts Added optional toastId to PendingAction; introduced undoLastAction method; tracked last action ID with ref.
apps/mail/lib/hotkeys/global-hotkeys.tsx Integrated undoLastAction from useOptimisticActions into global hotkeys handlers.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MailListPanel
    participant HotkeySystem

    User->>MailListPanel: Mouse enters panel
    MailListPanel->>HotkeySystem: enableScope('mail-list')
    User->>MailListPanel: Mouse leaves panel
    MailListPanel->>HotkeySystem: disableScope('mail-list')
Loading
sequenceDiagram
    participant User
    participant Keyboard
    participant GlobalHotkeys
    participant useOptimisticActions

    User->>Keyboard: Presses mod+z
    Keyboard->>GlobalHotkeys: Triggers 'undoLastAction' shortcut
    GlobalHotkeys->>useOptimisticActions: Calls undoLastAction()
Loading

Possibly related PRs

  • Fixes Optimstic Actions #1209: Refactors async handling and structure in useOptimisticActions, related to internal hook improvements.
  • hotfix #1207: Modifies internal async handling in useOptimisticActions without adding undo functionality; complements this PR’s undo feature.
  • UI Fixes #1199: Related to icon styling changes including modifications to the OldPhone icon component.

Suggested reviewers

  • ahmetskilinc

Poem

A rabbit hops with code so bright,
Icons now match the text in sight.
Undo’s a breeze with mod and Z,
Hotkeys follow where your mouse may be.
With every tweak and tidy line,
The mailbox shines—oh, how divine!
🐇✨


📜 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 08923ce and c88fd09.

📒 Files selected for processing (3)
  • apps/mail/components/icons/icons.tsx (2 hunks)
  • apps/mail/config/shortcuts.ts (1 hunks)
  • apps/mail/lib/hotkeys/global-hotkeys.tsx (3 hunks)
✨ 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 Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ahmetskilinc ahmetskilinc marked this pull request as ready for review June 5, 2025 00:31
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: 2

🔭 Outside diff range comments (2)
apps/mail/hooks/use-optimistic-actions.ts (1)

419-427: ⚠️ Potential issue

Critical: Missing undoLastAction function export.

The global hotkeys file is trying to import and use undoLastAction from this hook, but this function is not exported or implemented. The return statement only exports the existing optimistic action functions.

Add the missing undoLastAction implementation:

+  const undoLastAction = useCallback(() => {
+    // Get the most recent action from pendingActionsRef and execute its undo
+    const actions = Array.from(pendingActionsRef.current.values());
+    if (actions.length > 0) {
+      const mostRecentAction = actions[actions.length - 1];
+      mostRecentAction.undo();
+      pendingActionsRef.current.delete(mostRecentAction.id);
+      pendingActionsByTypeRef.current.get(mostRecentAction.type)?.delete(mostRecentAction.id);
+    }
+  }, []);
+
   return {
     optimisticMarkAsRead,
     optimisticMarkAsUnread,
     optimisticToggleStar,
     optimisticMoveThreadsTo,
     optimisticDeleteThreads,
     optimisticToggleImportant,
+    undoLastAction,
   };
apps/mail/components/mail/mail-list.tsx (1)

214-219: 💡 Verification agent

🧩 Analysis chain

Verify potential duplicate mouse event handlers.

The AI summary indicates that mouse event handlers were moved from the mail list to the mail layout component, but these onMouseEnter and onMouseLeave handlers are still present here. This could result in duplicate event handling if similar handlers were added to the parent component.


🏁 Script executed:

#!/bin/bash
# Description: Check for duplicate mouse event handlers in the mail layout component
# Expected: Find if similar onMouseEnter/onMouseLeave handlers exist in mail.tsx

# Search for mouse event handlers in mail components
rg -A 3 -B 3 "onMouseEnter|onMouseLeave" --type tsx --type ts apps/mail/components/mail/

Length of output: 118


🏁 Script executed:

#!/bin/bash
# Re-run search for duplicate onMouseEnter/onMouseLeave handlers in TSX files under apps/mail/components
rg -g '*.tsx' -A3 -B3 "onMouseEnter|onMouseLeave" apps/mail/components

Length of output: 9874


Remove duplicate mouse event handlers in mail-list.tsx

The onMouseEnter/onMouseLeave handlers at apps/mail/components/mail/mail-list.tsx (lines ~214–219) fire the same global events as the handlers in apps/mail/components/mail/mail.tsx. This leads to duplicate side-effects on hover. Consolidate these into the layout component and remove from the list:

• File: apps/mail/components/mail/mail-list.tsx
Lines: ~214–219

Suggested diff:

-          onMouseEnter={() => {
-            window.dispatchEvent(new CustomEvent('emailHover', { detail: { id: idToUse } }));
-          }}
-          onMouseLeave={() => {
-            window.dispatchEvent(new CustomEvent('emailHover', { detail: { id: null } }));
-          }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9280899 and 0ab31b4.

📒 Files selected for processing (7)
  • apps/mail/app/globals.css (1 hunks)
  • apps/mail/components/icons/icons.tsx (2 hunks)
  • apps/mail/components/mail/mail-list.tsx (2 hunks)
  • apps/mail/components/mail/mail.tsx (1 hunks)
  • apps/mail/config/shortcuts.ts (1 hunks)
  • apps/mail/hooks/use-optimistic-actions.ts (1 hunks)
  • apps/mail/lib/hotkeys/global-hotkeys.tsx (1 hunks)
🔇 Additional comments (8)
apps/mail/hooks/use-optimistic-actions.ts (1)

6-6: LGTM: Import reordering.

The import reordering doesn't affect functionality and is purely cosmetic.

apps/mail/app/globals.css (1)

51-51: Excellent: Improved theme compatibility.

Changing from hardcoded black to currentColor allows icons to inherit the current text color, making them automatically adapt to different themes and improving visual consistency.

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

121-128: LGTM: Standard undo shortcut implementation.

The change to use ['mod', 'z'] with preventDefault: true follows standard conventions for undo shortcuts (Cmd+Z on Mac, Ctrl+Z on PC) and properly prevents default browser behavior.

apps/mail/lib/hotkeys/global-hotkeys.tsx (1)

2-2: Integration pattern looks good.

The import follows the existing pattern in the file.

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

428-429: Good change to enable dynamic icon styling.

Commenting out the fixed fill and fillOpacity attributes allows the ExclamationCircle icon to be styled dynamically through props or external CSS. This supports the PR objective of making the icon visually reflect email importance status.


1760-1767: LGTM! Good formatting improvement.

The multi-line SVG tag format improves code readability and maintainability. This formatting correction aligns with the PR objectives and represents a good code quality improvement.

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

274-280: LGTM! Enhanced visual feedback for importance status.

The conditional styling approach provides clear visual distinction between important and non-important emails using fill and stroke colors instead of opacity. This aligns well with the PR objective to improve icon appearance across different themes.


948-948: LGTM! Improved icon consistency with explicit dimensions.

Using explicit pixel dimensions (h-[12px] w-[12px]) instead of relative units provides more consistent icon sizing across different contexts, which aligns with the PR objective for visual consistency.

@graphite-app
Copy link
Contributor

graphite-app bot commented Jun 5, 2025

Merge activity

  • Jun 5, 11:20 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Jun 5, 11:20 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Jun 5, 6:43 PM UTC: Graphite couldn't merge this PR because it had conflicts with the trunk branch.
  • Jun 5, 6:44 PM UTC: Graphite couldn't merge this PR because it had conflicts with the trunk branch.
  • Jun 5, 11:30 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 5, 11:31 PM UTC: @MrgSub merged this pull request with Graphite.

@ahmetskilinc ahmetskilinc force-pushed the 06-05-fixing_small_bugs branch from b87f4de to 08923ce Compare June 5, 2025 11:27
@MrgSub MrgSub merged commit 2bc5976 into staging Jun 5, 2025
2 of 3 checks passed
@MrgSub MrgSub deleted the 06-05-fixing_small_bugs branch June 5, 2025 23:31
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