Skip to content

Comments

Fix: Ai Chatbox fixes + Added option in shortcuts ui#1518

Closed
Pheewww wants to merge 1 commit intoMail-0:stagingfrom
Pheewww:fix/ai-chat-bugs
Closed

Fix: Ai Chatbox fixes + Added option in shortcuts ui#1518
Pheewww wants to merge 1 commit intoMail-0:stagingfrom
Pheewww:fix/ai-chat-bugs

Conversation

@Pheewww
Copy link
Contributor

@Pheewww Pheewww commented Jun 27, 2025

Fixes #1517

  1. Ai chat input should be disabled for free user
    https://github.com/user-attachments/assets/60ceae1b-dbcf-4f7d-a58e-f255064b91fc

  2. Open AI Assistant should be in shortcuts under navigation

Image
  1. Ai chat input should be disabled
image
  1. Open AI Assistant should be in shortcuts under navigation
image

Summary by CodeRabbit

  • New Features

    • Added a keyboard shortcut (mod + 0) to quickly open the AI assistant.
    • Introduced a new label for the AI assistant shortcut in the English interface.
  • Bug Fixes

    • The input area in the AI chat is now hidden when chat messages are disabled in billing, preventing user input in that state.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

Walkthrough

The changes introduce a conditional rendering of the AI chat input area based on billing status, add a new keyboard shortcut (mod+0) to open the AI assistant, and update the English locale to include a label for this shortcut. No exported or public code entities are modified.

Changes

File(s) Change Summary
apps/mail/components/create/ai-chat.tsx Conditionally renders the AI chat input area based on the chatMessages.enabled billing flag.
apps/mail/config/shortcuts.ts Adds a new keyboard shortcut (mod+0) to open the AI assistant under the navigation shortcuts.
apps/mail/locales/en.json Adds a new localization string for the "Open AI Assistant" shortcut action.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Billing
    participant AIChatComponent

    User->>AIChatComponent: Open AI Chat UI
    AIChatComponent->>Billing: Check chatMessages.enabled flag
    Billing-->>AIChatComponent: Returns enabled/disabled
    alt chatMessages.enabled == true
        AIChatComponent->>User: Render input area
    else chatMessages.enabled == false
        AIChatComponent->>User: Hide input area
    end

    User->>AIChatComponent: Presses mod+0
    AIChatComponent->>AIChatComponent: Triggers openAIAssistant action
Loading

Assessment against linked issues

Objective Addressed Explanation
Disable AI chat input for free users (#1517)
Add "Open AI Assistant" to navigation shortcuts (#1517)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • MrgSub

Poem

A shortcut appears, just mod and zero,
To summon the AI, your digital hero!
If billing says no, the input will hide,
But with a paid plan, you’ll chat with pride.
A tweak for the users, a hop and a cheer,
The AI assistant is now crystal clear! 🐇✨

✨ 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

@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 (1)
apps/mail/components/create/ai-chat.tsx (1)

397-398: Consider cleaner conditional rendering syntax.

The functionality is correct and properly disables the AI chat input for free users. However, the conditional rendering could be more readable.

Consider this cleaner approach:

-      { chatMessages && !chatMessages.enabled ?
-      (null) : (<div className={cn('mb-4 flex-shrink-0 px-4', isFullScreen ? 'px-0' : '')}>
+      {chatMessages?.enabled && (
+        <div className={cn('mb-4 flex-shrink-0 px-4', isFullScreen ? 'px-0' : '')}>
         ...
-      </div>)}
+        </div>
+      )}

This uses optional chaining and logical AND for cleaner conditional rendering.

Also applies to: 507-507

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3041531 and e07070a.

📒 Files selected for processing (3)
  • apps/mail/components/create/ai-chat.tsx (2 hunks)
  • apps/mail/config/shortcuts.ts (1 hunks)
  • apps/mail/locales/en.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
apps/mail/config/shortcuts.ts (1)
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
🧬 Code Graph Analysis (1)
apps/mail/components/create/ai-chat.tsx (1)
apps/mail/lib/utils.ts (1)
  • cn (51-51)
🔇 Additional comments (2)
apps/mail/locales/en.json (1)

489-489: LGTM! Clean localization addition.

The new localization string follows the existing pattern and provides clear labeling for the AI Assistant shortcut.

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

111-117: Verify shortcut key conflict with existing AI sidebar toggle.

The shortcut definition is well-formed, but there may be a conflict with the existing Cmd+0 handler in the AI chat component (lines 277-280 in apps/mail/components/create/ai-chat.tsx) that toggles the AI sidebar. Both shortcuts use the same key combination but serve different purposes.

#!/bin/bash
# Search for other uses of mod+0 or cmd+0 key combinations
rg -i "(mod|cmd|meta).*['\"]0['\"]|['\"]0['\"].*(mod|cmd|meta)" -A 3 -B 3

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.

Let's leave the input visible but make it readonly

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

Ai assistant bug

2 participants