Skip to content

Comments

context menu#708

Merged
MrgSub merged 5 commits intostagingfrom
context-menu
Apr 18, 2025
Merged

context menu#708
MrgSub merged 5 commits intostagingfrom
context-menu

Conversation

@nizzyabi
Copy link
Collaborator

@nizzyabi nizzyabi commented Apr 17, 2025

conetxt menu

Summary by CodeRabbit

  • New Features

    • Added support for opening reply, reply-all, and forward composers directly from the inbox using new navigation actions.
    • The composer state now synchronizes with URL parameters, enabling direct access to specific composer modes via the inbox.
  • Improvements

    • Primary email actions for reply, reply-all, and forward are now enabled and functional.
    • Closing the thread display now resets both the thread and composer mode states.
    • Simplified composer state management by unifying it under a single mode parameter.
    • Removed optimistic composer closing on mail item click to improve state consistency.
    • Disabled mail list hotkeys while keeping other hotkey functionalities active.
  • Style

    • Removed all shortcut keys from the context menu actions.

MrgSub and others added 2 commits April 17, 2025 14:52
Implement logout functionality and improve error handling across the app
@vercel
Copy link

vercel bot commented Apr 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
0 🛑 Canceled (Inspect) Apr 18, 2025 1:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 17, 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

This change introduces programmatic navigation for mail thread actions (reply, reply-all, forward) by using the Next.js router to update URL query parameters with the thread ID and action mode. The thread context menu handlers are updated to trigger these navigations, and shortcut keys are removed from the menu actions. In the thread display component, the state is synchronized with new mode and threadId query parameters, ensuring the appropriate mail composer UI opens when these parameters are set. The close handler now resets both parameters, and a new effect manages composer state based on the URL. Additionally, the reply composer and related components remove internal boolean state flags in favor of a unified mode query state, simplifying state management. The mail list no longer optimistically closes composers on mail click, and hotkeys for mail list are disabled.

Changes

File(s) Change Summary
apps/mail/components/context/thread-context.tsx Added router-based handlers for reply, reply-all, and forward actions; updated menu actions to use these handlers; removed shortcut keys from actions; refactored async handlers and toast notifications.
apps/mail/components/mail/thread-display.tsx Added mode query state; updated close handler to reset mode; updated reply/forward buttons to use mode; removed mode prop from ReplyCompose; synchronized composer open state with query params.
apps/mail/components/mail/reply-composer.tsx Removed global mail state flags for composer modes; replaced with single mode query state; simplified open/close logic; removed mode prop from ReplyCompose.
apps/mail/components/mail/mail-list.tsx Removed optimistic local state update closing reply/forward composers on mail item click; retained URL param update logic.
apps/mail/components/providers/hotkey-provider-wrapper.tsx Commented out <MailListHotkeys /> component to disable mail list hotkeys; reordered imports without logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ThreadContextMenu
    participant Router
    participant ThreadDisplay
    participant ReplyCompose

    User->>ThreadContextMenu: Selects Reply/Reply All/Forward
    ThreadContextMenu->>Router: Update URL with threadId and mode
    Router->>ThreadDisplay: Receives updated query params
    ThreadDisplay->>ReplyCompose: Opens composer based on mode
Loading

Possibly related PRs

  • Staging #673: Modifies ThreadDisplay to conditionally render the "Reply All" button, related to UI controls in the same component.
  • thread action buttons #597: Refactors ThreadDisplay with unread marking and thread ID handling, overlapping state management concerns.
  • refactoring & improvements #502: Modifies ThreadContextMenu internals related to thread fetching and state, closely related to the current PR’s component changes.

Suggested reviewers

  • nizzyabi

Poem

The rabbit hops through threads anew,
With routers guiding what to do—
Reply, reply-all, forward, too,
Each action now a path in view.
No shortcuts left, just clear intent,
The composer opens where you went!
🐇💌


🪧 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 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: 0

🧹 Nitpick comments (2)
apps/mail/components/context/thread-context.tsx (1)

189-199: Consider consolidating navigation handlers to reduce duplication.

The three handler functions have very similar code with only the mode parameter differing between them. This could be refactored into a single function that takes the mode as a parameter.

-const handleThreadReply = () => {
-  router.push(`/mail/inbox?threadId=${threadId}&mode=reply`);
-};
-
-const handleThreadReplyAll = () => {
-  router.push(`/mail/inbox?threadId=${threadId}&mode=replyAll`);
-};
-
-const handleThreadForward = () => {
-  router.push(`/mail/inbox?threadId=${threadId}&mode=forward`);
-};

+const handleThreadAction = (mode: 'reply' | 'replyAll' | 'forward') => {
+  router.push(`/mail/inbox?threadId=${threadId}&mode=${mode}`);
+};
apps/mail/components/mail/thread-display.tsx (1)

281-290: Effect synchronizes URL parameters with UI state.

This effect properly updates the mail composer state based on the URL query parameters, ensuring that the UI reflects the navigation state.

However, consider adding a cleanup function to reset the composer state when the effect dependencies change or the component unmounts.

useEffect(() => {
  if (mode && threadId) {
    setMail((prev) => ({
      ...prev,
      replyComposerOpen: mode === 'reply',
      replyAllComposerOpen: mode === 'replyAll',
      forwardComposerOpen: mode === 'forward',
    }));
  }
+  // Clean up when component unmounts or dependencies change
+  return () => {
+    if (!mode || !threadId) {
+      setMail((prev) => ({
+        ...prev,
+        replyComposerOpen: false,
+        replyAllComposerOpen: false,
+        forwardComposerOpen: false,
+      }));
+    }
+  };
}, [mode, threadId, setMail]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c41813e and f5b5b45.

📒 Files selected for processing (2)
  • apps/mail/components/context/thread-context.tsx (3 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
🔇 Additional comments (7)
apps/mail/components/context/thread-context.tsx (5)

33-33: Import addition looks good.

Adding useRouter from Next.js navigation is appropriate for implementing the programmatic navigation feature.


80-80: Router initialization is properly placed.

The useRouter hook is correctly initialized at the component level to enable navigation functionality.


206-208: Reply action implementation looks good.

The action now properly uses the navigation handler to open the reply composer.


213-215: Reply All action implementation looks good.

The action now properly uses the navigation handler to open the reply all composer.


220-222: Forward action implementation looks good.

The action now properly uses the navigation handler to open the forward composer.

apps/mail/components/mail/thread-display.tsx (2)

145-145: Query state addition is appropriate.

Adding the mode query state parameter is consistent with the existing pattern of using URL parameters for UI state.


195-196: HandleClose properly resets both query parameters.

Both threadId and the new mode parameter are reset when closing the thread view, maintaining consistent state.

@MrgSub MrgSub changed the base branch from main to staging April 18, 2025 01:32
@MrgSub MrgSub merged commit 4f755ca into staging Apr 18, 2025
3 of 4 checks passed
@MrgSub MrgSub deleted the context-menu branch April 18, 2025 01:34
@coderabbitai coderabbitai bot mentioned this pull request Apr 18, 2025
@nizzyabi
Copy link
Collaborator Author

nizzyabi commented Apr 18, 2025 via email

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