Skip to content

Comments

fix #1654 added counter for remaining labels.#1660

Closed
anuragnegi000 wants to merge 19 commits intoMail-0:stagingfrom
anuragnegi000:anurag
Closed

fix #1654 added counter for remaining labels.#1660
anuragnegi000 wants to merge 19 commits intoMail-0:stagingfrom
anuragnegi000:anurag

Conversation

@anuragnegi000
Copy link

@anuragnegi000 anuragnegi000 commented Jul 7, 2025

Description

Please provide a clear description of your changes.

Fixed the draft, send, archive count display in the sidebar navigation. The issue was that the draft, sent, archive folder was showing no message count.


Type of Change

Please delete options that are not relevant.

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🎨 UI/UX improvement

Areas Affected

Please check all that apply:

  • User Interface/Experience

Testing Done

Describe the tests you've done:

  • Manual testing performed
  • Cross-browser testing (if UI changes)
  • Mobile responsiveness verified (if UI changes)

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)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • I have updated the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix/feature works
  • All tests pass locally
  • Any dependent changes are merged and published

Additional Notes

Add any other context about the pull request here.

Screenshots/Recordings

Add screenshots or recordings here if applicable.

Before:-

Screenshot 2025-07-06 at 3 33 34 PM

After:-

Screenshot 2025-07-07 at 7 04 15 PM

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

Summary by CodeRabbit

  • New Features

    • Improved badge display in navigation by showing message counts for more folders, including archive, with formatted counts for better readability.
    • Added support for displaying archive message counts.
    • Added a debug utility for detailed Gmail label information (for internal use).
  • Bug Fixes

    • Badges now only appear when there are messages to display, preventing empty or zero-count badges.
  • Chores

    • Enhanced server-side logging for mail count queries to aid tracing and debugging.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

The changes update badge rendering logic in the mail navigation UI, revise backend label count calculation to use total messages and include an archive count, add a debug method for Gmail labels, and enhance logging in the mail count API endpoint. No exported/public API signatures are altered except for the new debug method.

Changes

File(s) Change Summary
apps/mail/components/ui/nav-main.tsx Refactored badge rendering logic: centralized count retrieval via getItemCount, removed folder exclusions, simplified badge display conditions.
apps/server/src/lib/driver/google.ts Changed label counting to use total messages, added archive count label, introduced debugLabels method, removed Effect usage.
apps/server/src/trpc/routes/mail.ts Added logging to mail count API endpoint; refactored count call to assign before return; added unused import.

Sequence Diagram(s)

sequenceDiagram
    participant UI as NavMain (UI)
    participant API as mailRouter (API)
    participant Agent as GoogleMailManager

    UI->>API: GET /mail/count
    API->>API: Log "mail.count endpoint called"
    API->>Agent: agent.count()
    Agent->>Agent: Calculate total messages per label
    Agent->>Agent: Query archive count
    Agent->>API: Return label counts including archive
    API->>UI: Return label counts
    UI->>UI: Render badges where count > 0 using getItemCount
Loading

Possibly related PRs

  • Staging #1054: The main PR refactors badge count retrieval in NavMain and NavItem by introducing a memoized count map and a getItemCount callback, while the retrieved PR adds a count prop to folder-related components and passes counts down for badge display; both modify badge count handling in apps/mail/components/ui/nav-main.tsx but differ in implementation details and component scope.
  • hotfix stuff #1703: The main PR refactors the count method in GoogleMailManager to replace the previous Effect-based concurrency with direct Promise.all calls and changes the label count logic, while the retrieved PR (hotfix stuff #1703) does the opposite by refactoring the same count method to use Effect concurrency primitives instead of Promise.all; thus, both PRs modify the same method but in opposite ways, making them directly related.

Suggested reviewers

  • MrgSub

Poem

In the warren, badges shine anew,
With counts that match what’s truly true.
Archive and inbox, all now clear,
Debugging tools are hopping near!
Logs abound, the code is spry—
A bunny’s work, oh my oh my!
🐇✨
"""


📜 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 437ee67 and d76a365.

📒 Files selected for processing (1)
  • apps/server/src/lib/driver/google.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/server/src/lib/driver/google.ts
✨ 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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Fixed folder message count display in the sidebar navigation by implementing proper label counting for draft, sent, and archive folders across mail providers.

  • Enhanced Gmail label counting in apps/server/src/lib/driver/google.ts to use messagesTotal instead of threadsUnread
  • Improved folder mapping in apps/mail/components/ui/nav-main.tsx with case-insensitive label matching
  • Added debug logging in apps/server/src/trpc/routes/mail.ts for count endpoint troubleshooting
  • Removed unused 'arch' import from mail.ts that should be cleaned up

3 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

anuragnegi000 and others added 2 commits July 7, 2025 19:15
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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

🧹 Nitpick comments (3)
apps/server/src/lib/driver/google.ts (2)

208-220: Remove debug logging and consider performance implications.

The console.log statement should be removed for production code. Additionally, the archive search with in:archive query might be slow for users with large archives since it processes all archived messages.

-        console.log("Archive count from search:", archiveCount);

Consider caching this count or making it optional if performance becomes an issue.


1287-1328: LGTM! Consider adding documentation.

The debug method is well-implemented and follows existing patterns. Consider adding JSDoc comments to clarify this is for debugging purposes only.

+ /**
+  * Debug method to retrieve detailed information about all Gmail labels.
+  * This method is intended for debugging purposes only.
+  */
  public async debugLabels() {
apps/server/src/trpc/routes/mail.ts (1)

59-65: Consider using proper logging levels instead of console.log.

While the debug logging is helpful for development, consider using a proper logging framework with appropriate log levels for production code.

-      console.log('🎯 TRPC mail.count endpoint called!');
+      // Consider using logger.debug() instead
-      console.log('🤖 Agent created, calling count()...');
+      // Consider using logger.debug() instead  
-      console.log('📊 Count result received:', result?.length, 'labels');
+      // Consider using logger.debug() instead
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8a17b37 and aaa8249.

📒 Files selected for processing (3)
  • apps/mail/components/ui/nav-main.tsx (1 hunks)
  • apps/server/src/lib/driver/google.ts (2 hunks)
  • apps/server/src/trpc/routes/mail.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 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/server/src/trpc/routes/mail.ts (2)
Learnt from: retrogtx
PR: Mail-0/Zero#1468
File: apps/server/src/trpc/routes/mail.ts:386-391
Timestamp: 2025-06-27T04:59:29.731Z
Learning: In apps/server/src/trpc/routes/mail.ts, the attachment processing logic conditionally handles mixed attachment types - it preserves existing File-like objects with arrayBuffer methods while only converting serialized attachments that need processing through toAttachmentFiles.
Learnt from: retrogtx
PR: Mail-0/Zero#1468
File: apps/server/src/trpc/routes/mail.ts:331-331
Timestamp: 2025-06-28T03:56:09.376Z
Learning: In apps/server/src/trpc/routes/mail.ts, the user indicated they are not using ISO format for the scheduleAt parameter, despite the frontend code showing toISOString() usage in the ScheduleSendPicker component.
apps/mail/components/ui/nav-main.tsx (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.
apps/server/src/lib/driver/google.ts (1)
Learnt from: retrogtx
PR: Mail-0/Zero#1622
File: apps/server/src/lib/email-verification.ts:189-189
Timestamp: 2025-07-05T05:27:24.592Z
Learning: During testing phases, debug logging should be kept active in apps/server/src/lib/email-verification.ts for BIMI validation and email verification debugging, even if it's verbose.
🪛 Biome (1.9.4)
apps/mail/components/ui/nav-main.tsx

[error] 328-328: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@anuragnegi000
Copy link
Author

@MrgSub PTAL

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/ui/nav-main.tsx (1)

64-91: Excellent optimization with proper memoization.

The statsMap implementation effectively addresses the previous feedback to move logic outside the render function. The memoization correctly:

  • Maps both stat labels and folder IDs to their counts
  • Filters for positive counts only
  • Handles case-insensitive matching appropriately

However, consider adding a trailing comma to the idToLabelMap object for better diff readability:

const idToLabelMap: Record<string, string> = {
  'inbox': 'INBOX',
  'drafts': 'DRAFT',
  'sent': 'SENT',
  'spam': 'SPAM',
  'trash': 'TRASH',
- 'archive': 'ARCHIVE'
+ 'archive': 'ARCHIVE',
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3167bf and c2f4cea.

📒 Files selected for processing (1)
  • apps/mail/components/ui/nav-main.tsx (5 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/components/ui/nav-main.tsx (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.
🪛 Biome (1.9.4)
apps/mail/components/ui/nav-main.tsx

[error] 310-310: Shouldn't redeclare 'NavItem'. Consider to delete it or rename it.

'NavItem' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (5)
apps/mail/components/ui/nav-main.tsx (5)

19-19: Import additions look good.

The added imports for useCallback, useRef, and useMemo are appropriately used in the optimization changes.


93-98: Clean and efficient callback implementation.

The getItemCount callback properly handles edge cases and provides a clean interface for retrieving item counts. The memoization dependency on statsMap ensures optimal performance.


268-268: Proper callback passing to NavItem.

The getItemCount callback is correctly passed to the NavItem component, enabling the optimized badge rendering.


310-310: Address the static analysis warning about function redeclaration.

The static analysis tool is incorrectly flagging this as a redeclaration. This is actually a function definition, not a redeclaration. The NavItem interface is defined at line 32, and this is the function implementation. The static analysis tool is producing a false positive.

The function signature correctly includes the new getItemCount parameter.


352-359: Simplified and efficient badge rendering logic.

The updated badge rendering logic is much cleaner and more efficient than the previous implementation. It:

  • Uses the memoized getItemCount callback
  • Eliminates the need for complex conditional checks
  • Properly handles zero counts by returning null
  • Maintains proper localization formatting

This change successfully addresses the PR objective of showing message counts for all folders including archive.

@anuragnegi000
Copy link
Author

anuragnegi000 commented Jul 8, 2025

@MrgSub shifted logic to the top of the file, PTAL

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/ui/nav-main.tsx (1)

64-91: Excellent optimization that addresses previous feedback.

The statsMap memoization effectively moves the label mapping logic outside of render functions, addressing the concern raised in previous reviews. The implementation correctly:

  • Maps both uppercase labels and corresponding folder IDs to their counts
  • Only includes positive counts to avoid displaying zero badges
  • Uses proper memoization with stats as the dependency

However, consider adding the trailing comma as suggested in previous reviews:

      'trash': 'TRASH',
-     'archive': 'ARCHIVE'
+     'archive': 'ARCHIVE',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c2f4cea and 0bab05c.

📒 Files selected for processing (1)
  • apps/mail/components/ui/nav-main.tsx (5 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/components/ui/nav-main.tsx (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/ui/nav-main.tsx (4)
apps/mail/config/navigation.ts (1)
  • NavItem (24-35)
apps/server/src/lib/driver/google.ts (1)
  • count (181-225)
apps/server/src/lib/driver/microsoft.ts (1)
  • count (170-227)
apps/mail/components/ui/badge.tsx (1)
  • Badge (38-38)
🪛 Biome (1.9.4)
apps/mail/components/ui/nav-main.tsx

[error] 308-308: Shouldn't redeclare 'NavItem'. Consider to delete it or rename it.

'NavItem' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (5)
apps/mail/components/ui/nav-main.tsx (5)

19-19: Good addition of required React hooks.

The addition of useCallback and useMemo imports is necessary for the performance optimizations implemented in this component.


93-98: Well-implemented callback function.

The getItemCount callback is properly memoized and provides a clean API for retrieving item counts. The implementation correctly handles undefined itemId values and returns 0 when no count is available.


268-268: Proper prop passing to NavItem.

The getItemCount function is correctly passed as a prop to enable the badge rendering functionality in the NavItem component.


308-308: Function signature update correctly implements the feature.

The updated NavItem function signature properly includes the optional getItemCount parameter, allowing the component to display message counts when available.

Note: The static analysis warning about redeclaring NavItem appears to be a false positive - this is defining a function component, not redeclaring a variable.


350-357: Simplified and improved badge rendering logic.

The new badge rendering implementation is much cleaner and addresses the previous optional chaining concerns. The logic now:

  • Uses the memoized getItemCount function instead of inline calculations
  • Properly handles undefined values without optional chaining issues
  • Only renders badges for positive counts
  • Maintains the same visual styling and formatting

This successfully implements the PR objective of showing message counts for all navigation items including draft, sent, and archive folders.

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 (4)
apps/mail/components/ui/nav-main.tsx (2)

64-77: Consider optimizing the statsMap to avoid duplicate entries.

The current implementation stores each count twice (lowercase and uppercase). Consider storing normalized keys only:

  const statsMap = useMemo(() => {
    if (!stats) return new Map<string, number>();
    
    const map = new Map<string, number>();
    
    stats.forEach(stat => {
      if (stat.label && stat.count && stat.count > 0) {
-       map.set(stat.label.toLowerCase(), stat.count);
-       map.set(stat.label.toUpperCase(), stat.count);
+       // Store with normalized key (lowercase)
+       map.set(stat.label.toLowerCase(), stat.count);
      }
    });
    
    return map;
  }, [stats]);

79-89: Simplify getItemCount to match normalized statsMap.

If you optimize statsMap to store only lowercase keys, update this function accordingly:

  const getItemCount = useCallback((itemId: string | undefined) => {
    if (!itemId || !statsMap.size) return 0;
    
-   const lowerItemId = itemId.toLowerCase();
-   if (statsMap.has(lowerItemId)) {
-     return statsMap.get(lowerItemId) || 0;
-   }
-   
-   const upperItemId = itemId.toUpperCase();
-   return statsMap.get(upperItemId) || 0;
+   // Always check with normalized key (lowercase)
+   return statsMap.get(itemId.toLowerCase()) || 0;
  }, [statsMap]);
apps/server/src/lib/driver/google.ts (2)

228-249: Optimize the enhancedCounts construction to avoid redundant loops.

The current implementation loops through labelCounts twice. Consider combining the logic:

  const enhancedCounts: Array<{ label: string; count: number }> = [];
  
-  labelCounts.forEach(stat => {
-    if (stat.count > 0) {
-      enhancedCounts.push(stat);
-    }
-  });
-  
-  labelCounts.forEach(stat => {
-    if (stat.label && stat.count > 0) {
-      Object.entries(idToLabelMap).forEach(([id, gmailLabel]) => {
-        if (stat.label.toUpperCase() === gmailLabel) {
-          enhancedCounts.push({
-            label: id,
-            count: stat.count
-          });
-        }
-      });
-    }
-  });
+  labelCounts.forEach(stat => {
+    if (stat.label && stat.count > 0) {
+      // Add original label
+      enhancedCounts.push(stat);
+      
+      // Add mapped label ID if exists
+      const mappedEntry = Object.entries(idToLabelMap).find(
+        ([_, gmailLabel]) => stat.label.toUpperCase() === gmailLabel
+      );
+      if (mappedEntry) {
+        enhancedCounts.push({
+          label: mappedEntry[0],
+          count: stat.count
+        });
+      }
+    }
+  });

1318-1358: Consider restricting debugLabels access in production.

The debugLabels method exposes detailed label information and generates verbose logs. Consider making it private or adding a debug flag guard to prevent accidental usage in production.

- public async debugLabels() {
+ private async debugLabels() {
    return this.withErrorHandler(
      'debugLabels',
      async () => {
+       // Only run in development or when debug flag is set
+       if (process.env.NODE_ENV === 'production' && !env.DEBUG_LABELS) {
+         return [];
+       }
        const userLabels = await this.gmail.users.labels.list({
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0bab05c and c7ffe9a.

📒 Files selected for processing (2)
  • apps/mail/components/ui/nav-main.tsx (5 hunks)
  • apps/server/src/lib/driver/google.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 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/server/src/lib/driver/google.ts (1)
Learnt from: retrogtx
PR: Mail-0/Zero#1622
File: apps/server/src/lib/email-verification.ts:189-189
Timestamp: 2025-07-05T05:27:24.592Z
Learning: During testing phases, debug logging should be kept active in apps/server/src/lib/email-verification.ts for BIMI validation and email verification debugging, even if it's verbose.
apps/mail/components/ui/nav-main.tsx (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/ui/nav-main.tsx (4)
apps/mail/config/navigation.ts (1)
  • NavItem (24-35)
apps/server/src/lib/driver/google.ts (1)
  • count (181-253)
apps/server/src/lib/driver/microsoft.ts (1)
  • count (170-227)
apps/mail/components/ui/badge.tsx (1)
  • Badge (38-38)
🪛 Biome (1.9.4)
apps/mail/components/ui/nav-main.tsx

[error] 299-299: Shouldn't redeclare 'NavItem'. Consider to delete it or rename it.

'NavItem' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (2)
apps/mail/components/ui/nav-main.tsx (1)

341-348: LGTM! Clean implementation of badge rendering.

The simplified badge rendering logic successfully addresses the reviewer's feedback about moving logic outside the render function. The implementation correctly displays counts when available.

apps/server/src/lib/driver/google.ts (1)

217-226: Good implementation of archive count retrieval.

The archive search correctly uses resultSizeEstimate for efficient count retrieval without fetching actual messages.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c7ffe9a and 66c1d76.

📒 Files selected for processing (3)
  • apps/mail/components/ui/nav-main.tsx (5 hunks)
  • apps/server/src/lib/driver/google.ts (2 hunks)
  • apps/server/src/trpc/routes/mail.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/server/src/trpc/routes/mail.ts
  • apps/server/src/lib/driver/google.ts
🧰 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/components/ui/nav-main.tsx (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.
🪛 Biome (1.9.4)
apps/mail/components/ui/nav-main.tsx

[error] 299-299: Shouldn't redeclare 'NavItem'. Consider to delete it or rename it.

'NavItem' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (4)
apps/mail/components/ui/nav-main.tsx (4)

19-19: Import statement looks good.

The added imports are properly used in the new memoization and callback logic.


79-89: Efficient count lookup implementation.

The getItemCount callback provides a clean abstraction for retrieving item counts with proper memoization. The logic correctly handles both lowercase and uppercase label matching.


259-259: Correct prop passing.

The getItemCount prop is properly passed to the NavItem component.


341-348: Excellent refactoring of badge logic.

The new implementation is much cleaner and more efficient than the previous complex inline logic. Moving the logic outside the render function addresses the previous review feedback perfectly. The count check and badge rendering is now straightforward and readable.

@MrgSub
Copy link
Collaborator

MrgSub commented Jul 11, 2025

please rebase @anuragnegi000

@MrgSub MrgSub closed this Jul 11, 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.

2 participants