Skip to content

Comments

Fix: Mark as Important Bugs#1497

Closed
Pheewww wants to merge 1 commit intoMail-0:stagingfrom
Pheewww:fix/mark-as-important-improvements
Closed

Fix: Mark as Important Bugs#1497
Pheewww wants to merge 1 commit intoMail-0:stagingfrom
Pheewww:fix/mark-as-important-improvements

Conversation

@Pheewww
Copy link
Contributor

@Pheewww Pheewww commented Jun 26, 2025

Fixes: #1496

  1. Toast gives failure message for successful mark as important.
    https://github.com/user-attachments/assets/98b6f76b-4f88-4efa-b7d9-edb323f14cb6

  2. Toggle Important doesnt change icon ui.
    https://github.com/user-attachments/assets/63e32042-f89b-4a41-98c5-ef6de3da101a

  3. Mark as Important/Remove as Important doesnt change on toggling ( the request is successful)
    https://github.com/user-attachments/assets/309bcbb4-bf92-4996-bc12-55d61bb8162b

Summary by CodeRabbit

  • Bug Fixes
    • Improved the accuracy of the "important" status indicator in mail threads, ensuring it updates correctly in response to both optimistic UI changes and server responses.
    • Updated the icon for marking threads as important for better visual clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

Walkthrough

The changes update the logic for toggling the "important" status in mail threads. They ensure UI state synchronizes with server responses, update memoization dependencies for importance, and switch the important icon to a new variant. No changes to exported entity signatures were made.

Changes

Files Change Summary
apps/mail/components/context/thread-context.tsx Updated useMemo dependency array for isImportant to include optimisticState.optimisticImportant.
apps/mail/components/mail/mail-list.tsx Swapped ExclamationCircle icon with ExclamationCircle2 for the important toggle button.
apps/mail/components/mail/thread-display.tsx Modified handleToggleImportant to update local isImportant state using server response data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ThreadDisplay
    participant Server

    User->>ThreadDisplay: Clicks "Toggle Important"
    ThreadDisplay->>Server: Sends toggle important request
    Server-->>ThreadDisplay: Returns updated thread data
    ThreadDisplay->>ThreadDisplay: Updates isImportant state from server data
    ThreadDisplay->>User: Updates icon and shows toast
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix: Toast gives failure message for successful mark as important (#1496)
Fix: Toggle Important doesn't change icon UI (#1496)
Fix: Mark as Important/Remove as Important doesn't change on toggling, despite successful request (#1496)

Possibly related PRs

  • Staging #1004: Refactored the "important" tag toggle feature and related UI/state management in the same components as this PR.
  • context #595: Added ThreadContextMenu component and context menu functionality in thread-context.tsx, related to thread UI and state management.

Suggested reviewers

  • MrgSub

Poem

A bunny hopped in, with code to refine,
Now "Important" toggles work just fine!
The icon's new face brings a cheerful glow,
State and server now dance in flow.
With every click, the UI's bright—
Bugs hop away, all feels 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 82a4927 and 1909962.

📒 Files selected for processing (3)
  • apps/mail/components/context/thread-context.tsx (1 hunks)
  • apps/mail/components/mail/mail-list.tsx (2 hunks)
  • apps/mail/components/mail/thread-display.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/mail/components/context/thread-context.tsx
  • apps/mail/components/mail/mail-list.tsx
  • apps/mail/components/mail/thread-display.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.

@Pheewww Pheewww force-pushed the fix/mark-as-important-improvements branch from 82a4927 to 1909962 Compare June 26, 2025 11:50
Copy link
Collaborator

@MrgSub MrgSub left a comment

Choose a reason for hiding this comment

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

Can we use optimistic actions for this?

Comment on lines +691 to 694
setIsImportant(isNowImportant);
if (isImportant) {
toast.success(t('common.mail.markedAsImportant'));
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

The toast message is using the stale isImportant value rather than the newly determined isNowImportant. Since React state updates are asynchronous, the condition should use the new value to display the correct toast message:

// Change this:
if (isImportant) {
  toast.success(t('common.mail.markedAsImportant'));
} else {
  toast.success(t('common.mail.removedAsImportant'));
}

// To this:
if (isNowImportant) {
  toast.success(t('common.mail.markedAsImportant'));
} else {
  toast.success(t('common.mail.removedAsImportant'));
}

This will ensure the toast message accurately reflects the action that was just performed.

Suggested change
setIsImportant(isNowImportant);
if (isImportant) {
toast.success(t('common.mail.markedAsImportant'));
} else {
setIsImportant(isNowImportant);
if (isNowImportant) {
toast.success(t('common.mail.markedAsImportant'));
} else {

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

This PR has merge conflicts and has been open for more than 3 days. It will be automatically closed. Please resolve the conflicts and reopen the PR if you'd like to continue working on it.

@github-actions github-actions bot closed this Aug 7, 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.

Mark as Important Bugs

2 participants