Skip to content

examples with tagging#572

Merged
elie222 merged 2 commits intomainfrom
feat/example-mentions
Jul 16, 2025
Merged

examples with tagging#572
elie222 merged 2 commits intomainfrom
feat/example-mentions

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jul 16, 2025

Summary by CodeRabbit

  • New Features

    • Added tooltips with formatting instructions for email assistant rules, explaining how to use bullet points, labels, and quotes.
    • Example prompts now visually display labels in a user-friendly format across various screens and dialogs.
  • Improvements

    • Updated example prompts to use a new label mention format (@[Label]) for consistency.
    • Enhanced label mention parsing to support rendering even if a label does not exist.
    • Improved reliability of label mention handling, including support for nested or complex label syntax.
  • Tests

    • Added comprehensive tests for label mention conversion and display formatting.

@vercel
Copy link

vercel bot commented Jul 16, 2025

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

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview Jul 16, 2025 7:45am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Walkthrough

The changes update label mention formatting across the application, replacing quoted label syntax with a new bracketed format (@[Label]). Rendering logic for examples is updated to display labels in a user-friendly way using a new utility function. Label mention parsing is improved to handle missing labels and nested brackets, and comprehensive tests for the new conversion logic are added.

Changes

File(s) Change Summary
apps/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx Added tooltip explaining new label formatting; updated example rendering to use convertLabelsToDisplay; removed unused imports.
apps/web/app/(app)/[emailAccountId]/assistant/examples.ts Changed all label mentions from quoted format ("Label") to bracketed format (@[Label]) in prompt strings.
apps/web/app/(app)/onboarding/OnboardingEmailAssistant.tsx Updated example rendering to use convertLabelsToDisplay for label formatting.
apps/web/components/assistant-chat/examples-dialog.tsx Updated example rendering to use convertLabelsToDisplay for label formatting.
apps/web/components/editor/extensions/LabelMention.tsx Modified label mention parsing to allow rendering of non-existent labels with placeholders.
apps/web/utils/mention.ts Replaced regex-based mention parsing with bracket-aware parser; added convertLabelsToDisplay function.
apps/web/utils/mention.test.ts Added tests for convertLabelsToDisplay covering various mention scenarios and edge cases.
version.txt Updated version from v1.9.8 to v1.9.9.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant MentionUtils

    User->>UI_Component: Views example prompt
    UI_Component->>MentionUtils: convertLabelsToDisplay(prompt)
    MentionUtils-->>UI_Component: Prompt with labels as "Label"
    UI_Component-->>User: Renders formatted example
Loading
sequenceDiagram
    participant Editor
    participant LabelMentionParser

    Editor->>LabelMentionParser: Parse label mention @[Label]
    alt Label exists
        LabelMentionParser-->>Editor: Create mention node with label ID
    else Label missing
        LabelMentionParser-->>Editor: Create mention node with placeholder ID and label name
    end
Loading

Suggested reviewers

  • edulelis

Poem

In the warren of code, new labels appear,
Brackets replace quotes, the meaning is clear.
Prompts now display with a friendlier face,
Even lost labels still find their place.
With parsing improved and tooltips in tow,
This bunny hops forward—onward we go!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f9e780 and b94ed4b.

📒 Files selected for processing (1)
  • version.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • version.txt

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.

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.

@claude
Copy link

claude bot commented Jul 16, 2025

Claude finished @elie222's task —— View job


Pull Request Review

Reviewing the "examples with tagging" PR changes across 7 files.

Review Tasks:

  • Read and understand all changed files
  • Analyze tagging functionality implementation
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Provide comprehensive feedback

Summary

This PR implements a comprehensive tagging/mentions system for email assistant examples and prompts. The changes introduce a new @[LABEL] syntax for referencing labels in assistant prompts, with proper parsing, display, and editor integration.

Code Quality & Best Practices ✅

Strengths:

  • Excellent test coverage: mention.test.ts provides comprehensive test cases covering edge cases, malformed input, nested brackets, and multiline text
  • Clean separation of concerns: The mention.ts utility functions are well-focused and reusable
  • Proper error handling: LabelMention.tsx includes robust error handling with try-catch blocks and cleanup functions
  • Type safety: Good use of TypeScript types throughout the implementation
  • Documentation: Functions are well-documented with clear JSDoc comments

Areas for improvement:

  • Consider adding JSDoc comments to the test files for better documentation
  • Some functions could benefit from more explicit return types (e.g., getActionType in RulesPrompt.tsx:395)

Technical Implementation 🔧

Mention Processing (utils/mention.ts:21-61)

  • Implements proper bracket matching algorithm that handles nested brackets correctly
  • Clean API design with two main functions: convertMentionsToLabels and convertLabelsToDisplay
  • Good performance with single-pass parsing

Editor Integration (LabelMention.tsx:145-226)

  • Smart markdown serialization/parsing that maintains round-trip fidelity
  • Proper handling of placeholder labels for examples that don't exist in Gmail yet
  • Robust cleanup mechanisms to prevent memory leaks

Potential Issues 🐛

Minor Issues:

  1. Type assertion in LabelMention.tsx:123: const label = props as UserLabel; - Consider using proper type guards instead of assertion
  2. Console warnings: The cleanup function in LabelMention.tsx:40 uses console.warn which might be noisy in production
  3. Hardcoded example URLs: Many examples in examples.ts use placeholder URLs like https://cal.com/example which could be confusing for users

Potential Edge Cases:

  • The mention parser handles malformed input gracefully, but consider adding validation for extremely long label names
  • The @[LABEL] syntax could potentially conflict with existing email patterns (though unlikely)

Performance Considerations ⚡

Positive aspects:

  • Efficient single-pass parsing algorithm
  • Proper memoization of Examples component (RulesPrompt.tsx:393)
  • Limited suggestion results to 10 items (LabelMention.tsx:23)

Recommendations:

  • Consider debouncing the mention search if performance becomes an issue with large label lists
  • The processMentions function could potentially be optimized for very large texts, but current implementation is adequate

Security Considerations 🔒

No major security concerns identified:

  • Input sanitization is handled properly through the bracket matching algorithm
  • No direct DOM manipulation or HTML injection vulnerabilities
  • The mention system doesn't process user input in unsafe ways

Good practices observed:

  • Proper escaping in markdown parsing
  • No eval() or similar dangerous operations
  • Clean separation between data and presentation

Specific Code Comments

utils/mention.ts:30-42: The bracket counting logic is well-implemented and handles nested brackets correctly. This is a robust approach.

examples.ts:24-47: The extensive update to use @[LABEL] syntax throughout all examples is comprehensive and consistent. Good migration of existing examples.

LabelMention.tsx:111-143: The command function properly handles space insertion and type safety. The fix for the type error with proper type guards is well done.

Recommendations

  1. Add validation for label names: Consider adding validation to ensure label names don't contain special characters that could break the parsing
  2. Consider i18n: If internationalization is planned, the @[LABEL] syntax should be documented as language-agnostic
  3. Performance monitoring: Consider adding performance monitoring for the mention parsing if it will be used with very large texts
  4. User feedback: The examples use placeholder URLs - consider providing user guidance on customizing these

Overall Assessment

This is a well-implemented feature with:

  • ✅ Excellent test coverage
  • ✅ Clean, maintainable code
  • ✅ Proper error handling
  • ✅ Good performance characteristics
  • ✅ No security vulnerabilities

The implementation demonstrates good software engineering practices with comprehensive testing, proper separation of concerns, and robust error handling. The tagging system will significantly improve the user experience for email assistant configuration.

Recommendation: Approve with minor suggestions for improvement


@claude
Copy link

claude bot commented Jul 16, 2025

Claude finished @elie222's task —— View job


Pull Request Review

Reviewing the "examples with tagging" PR changes across 7 files.

Review Tasks:

  • Read and understand all changed files
  • Analyze tagging functionality implementation
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Provide comprehensive feedback

Summary

This PR implements a comprehensive tagging/mentions system for email assistant examples and prompts. The changes introduce a new @[LABEL] syntax for referencing labels in assistant prompts, with proper parsing, display, and editor integration.

Code Quality & Best Practices ✅

Strengths:

  • Excellent test coverage: mention.test.ts provides comprehensive test cases covering edge cases, malformed input, nested brackets, and multiline text
  • Clean separation of concerns: The mention.ts utility functions are well-focused and reusable
  • Proper error handling: LabelMention.tsx includes robust error handling with try-catch blocks and cleanup functions
  • Type safety: Good use of TypeScript types throughout the implementation
  • Documentation: Functions are well-documented with clear JSDoc comments

Areas for improvement:

  • Consider adding JSDoc comments to the test files for better documentation
  • Some functions could benefit from more explicit return types (e.g., getActionType in RulesPrompt.tsx:395)

Technical Implementation 🔧

Mention Processing (utils/mention.ts:21-61)

  • Implements proper bracket matching algorithm that handles nested brackets correctly
  • Clean API design with two main functions: convertMentionsToLabels and convertLabelsToDisplay
  • Good performance with single-pass parsing

Editor Integration (LabelMention.tsx:145-226)

  • Smart markdown serialization/parsing that maintains round-trip fidelity
  • Proper handling of placeholder labels for examples that don't exist in Gmail yet
  • Robust cleanup mechanisms to prevent memory leaks

Potential Issues 🐛

Minor Issues:

  1. Type assertion in LabelMention.tsx:123: const label = props as UserLabel; - Consider using proper type guards instead of assertion
  2. Console warnings: The cleanup function in LabelMention.tsx:40 uses console.warn which might be noisy in production
  3. Hardcoded example URLs: Many examples in examples.ts use placeholder URLs like https://cal.com/example which could be confusing for users

Potential Edge Cases:

  • The mention parser handles malformed input gracefully, but consider adding validation for extremely long label names
  • The @[LABEL] syntax could potentially conflict with existing email patterns (though unlikely)

Performance Considerations ⚡

Positive aspects:

  • Efficient single-pass parsing algorithm
  • Proper memoization of Examples component (RulesPrompt.tsx:393)
  • Limited suggestion results to 10 items (LabelMention.tsx:23)

Recommendations:

  • Consider debouncing the mention search if performance becomes an issue with large label lists
  • The processMentions function could potentially be optimized for very large texts, but current implementation is adequate

Security Considerations 🔒

No major security concerns identified:

  • Input sanitization is handled properly through the bracket matching algorithm
  • No direct DOM manipulation or HTML injection vulnerabilities
  • The mention system doesn't process user input in unsafe ways

Good practices observed:

  • Proper escaping in markdown parsing
  • No eval() or similar dangerous operations
  • Clean separation between data and presentation

Specific Code Comments

utils/mention.ts:30-42: The bracket counting logic is well-implemented and handles nested brackets correctly. This is a robust approach.

examples.ts:24-47: The extensive update to use @[LABEL] syntax throughout all examples is comprehensive and consistent. Good migration of existing examples.

LabelMention.tsx:111-143: The command function properly handles space insertion and type safety. The fix for the type error with proper type guards is well done.

Recommendations

  1. Add validation for label names: Consider adding validation to ensure label names don't contain special characters that could break the parsing
  2. Consider i18n: If internationalization is planned, the @[LABEL] syntax should be documented as language-agnostic
  3. Performance monitoring: Consider adding performance monitoring for the mention parsing if it will be used with very large texts
  4. User feedback: The examples use placeholder URLs - consider providing user guidance on customizing these

Overall Assessment

This is a well-implemented feature with:

  • ✅ Excellent test coverage
  • ✅ Clean, maintainable code
  • ✅ Proper error handling
  • ✅ Good performance characteristics
  • ✅ No security vulnerabilities

The implementation demonstrates good software engineering practices with comprehensive testing, proper separation of concerns, and robust error handling. The tagging system will significantly improve the user experience for email assistant configuration.

Recommendation: Approve with minor suggestions for improvement


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/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx (1)

18-18: Consider using type-only import for TypeScript type.

The import appears to be for a TypeScript type based on the SaveRulesPromptBody naming convention.

-import type { SaveRulesPromptBody } from "@/utils/actions/rule.validation";
+import type { SaveRulesPromptBody } from "@/utils/actions/rule.validation";

Wait, this already appears to be a type-only import. The change looks correct as-is.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a189b10 and 5f9e780.

📒 Files selected for processing (7)
  • apps/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx (5 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/examples.ts (12 hunks)
  • apps/web/app/(app)/onboarding/OnboardingEmailAssistant.tsx (2 hunks)
  • apps/web/components/assistant-chat/examples-dialog.tsx (2 hunks)
  • apps/web/components/editor/extensions/LabelMention.tsx (1 hunks)
  • apps/web/utils/mention.test.ts (2 hunks)
  • apps/web/utils/mention.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/web/**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • apps/web/CLAUDE.md
apps/web/app/**/*

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • apps/web/CLAUDE.md
apps/web/**/*.tsx

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • apps/web/CLAUDE.md
**/*.tsx

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/data-fetching.mdc
  • .cursor/rules/form-handling.mdc
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/form-handling.mdc
🧠 Learnings (5)
apps/web/app/(app)/onboarding/OnboardingEmailAssistant.tsx (8)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-03T12:02:53.001Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive error messages
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-06-23T12:26:14.189Z
Learning: Always use wrapper functions from the utils folder (e.g., apps/web/utils/gmail/message.ts) to interact with provider APIs, ensuring maintainability and easier future provider support.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Follow consistent naming conventions (PascalCase for components)
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available
Learnt from: elie222
PR: elie222/inbox-zero#537
File: apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx:30-34
Timestamp: 2025-07-08T13:14:07.449Z
Learning: The clean onboarding page in apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx is intentionally Gmail-specific and should show an error for non-Google email accounts rather than attempting to support multiple providers.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Ensure responsive design with mobile-first approach
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.{ts,tsx} : Format code with Prettier
apps/web/components/assistant-chat/examples-dialog.tsx (2)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-03T12:02:53.001Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive error messages
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available
apps/web/utils/mention.test.ts (2)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-06-23T12:26:27.693Z
Learning: When writing tests for LLM-related functionality in TypeScript (e.g., in 'apps/web/__tests__/*.test.ts'), always create helper functions for common test data to ensure consistency and reduce duplication.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-23T12:27:30.570Z
Learning: When mocking Prisma in Vitest, import the Prisma mock from '@/utils/__mocks__/prisma', mock '@/utils/prisma', and clear all mocks in a beforeEach hook to ensure test isolation.
apps/web/app/(app)/[emailAccountId]/assistant/examples.ts (1)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-06-23T12:26:36.694Z
Learning: System prompts and user prompts should always be kept separate: the system prompt defines the LLM's role and task, while the user prompt provides data and context.
apps/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx (16)
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/cursor-rules.mdc:0-0
Timestamp: 2025-07-03T12:02:24.598Z
Learning: Applies to .cursor/rules/*.mdc : Cursor rule files must use markdown formatting for main content, including step-by-step instructions, code examples, and guidelines
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-03T12:02:53.001Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive error messages
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/cursor-rules.mdc:0-0
Timestamp: 2025-07-03T12:02:24.598Z
Learning: Applies to .cursor/rules/*.mdc : Make Cursor rule file names descriptive of the rule's purpose
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: For data fetching in custom React hooks, prefer using the useSWR hook. The custom hook should typically wrap useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially the mutate function from SWR.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:47.630Z
Learning: In deeply nested React components within the Next.js app directory, use the SWR library to fetch data via API instead of loading data directly in the component.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: Custom React hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:59.468Z
Learning: Use SWR for data fetching in deeply nested components in Next.js App Router projects to enable efficient client-side data fetching and caching.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-06-23T12:27:33.499Z
Learning: When fetching data from an API in a Next.js React application, use the `swr` package for GET requests to the server. This provides built-in caching, revalidation, and error handling.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-06-23T12:26:16.769Z
Learning: Each custom React hook should have a single responsibility and be kept as simple as possible.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-06-23T12:26:59.468Z
Learning: For components with onClick handlers in Next.js App Router, ensure they are client components by including the 'use client' directive at the top of the file.
Learnt from: elie222
PR: elie222/inbox-zero#485
File: apps/web/app/(landing)/login/page.tsx:41-43
Timestamp: 2025-06-05T09:49:12.168Z
Learning: In Next.js App Router, components that use the `useSearchParams` hook require a Suspense boundary to handle the asynchronous nature of search parameter access. The Suspense wrapper is necessary and should not be removed when a component uses useSearchParams.
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:02:16.137Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-03T12:02:53.001Z
Learning: Applies to **/*.tsx : Validate form inputs before submission
Learnt from: aryanprince
PR: elie222/inbox-zero#210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning: `MoreDropdown` is a React component and `useUnsubscribeButton` is a custom React hook, and they should not be imported using `import type`.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-06-23T12:27:33.499Z
Learning: For form text inputs in React using Shadcn UI, use the `Input` component with `registerProps` from a form library (such as react-hook-form) and pass any validation errors to the `error` prop.
🧬 Code Graph Analysis (3)
apps/web/app/(app)/onboarding/OnboardingEmailAssistant.tsx (1)
apps/web/utils/mention.ts (1)
  • convertLabelsToDisplay (14-16)
apps/web/components/assistant-chat/examples-dialog.tsx (1)
apps/web/utils/mention.ts (1)
  • convertLabelsToDisplay (14-16)
apps/web/utils/mention.test.ts (1)
apps/web/utils/mention.ts (1)
  • convertLabelsToDisplay (14-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: claude-review
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (29)
apps/web/utils/mention.ts (3)

7-8: Good refactoring to use the new parser-based approach.

The change from regex-based replacement to using the processMentions helper provides better handling of nested brackets and complex mention syntax.


10-16: Well-designed inverse function for UI display.

The convertLabelsToDisplay function provides a clean way to convert mentions to a user-friendly quoted format. The implementation is concise and leverages the same robust parsing logic.


21-61: Robust bracket-matching implementation.

The processMentions helper function correctly handles nested brackets by maintaining a bracket count. The logic properly handles edge cases like unmatched brackets and processes the string character by character.

The implementation is well-structured with clear comments and proper error handling for malformed mentions.

apps/web/components/assistant-chat/examples-dialog.tsx (2)

21-21: Correct import of the new utility function.

The import follows the established path alias pattern using @/utils/mention.


148-148: Proper application of display formatting.

The convertLabelsToDisplay function is correctly applied to transform mention labels from @[Label] format to "Label" format for better UI readability.

apps/web/app/(app)/onboarding/OnboardingEmailAssistant.tsx (2)

33-33: Consistent import pattern.

The import follows the established path alias pattern and maintains consistency with other files using the same utility.


131-131: Consistent UI formatting across components.

The application of convertLabelsToDisplay ensures consistent mention formatting across the onboarding flow, aligning with the same pattern used in other UI components.

apps/web/components/editor/extensions/LabelMention.tsx (2)

184-185: Clear documentation of the behavioral change.

The comment explains why the parsing now allows mentions even when labels don't exist, providing good context for future maintainers.


186-200: Logical enhancement to support missing labels.

The modification allows the editor to handle mentions gracefully even when the referenced label doesn't exist in the labels array. This is particularly useful for examples and templates where labels might not be created yet.

The implementation correctly:

  • Uses optional chaining (label?.id)
  • Provides fallback values (placeholder-${labelName})
  • Maintains the same token structure regardless of label existence
apps/web/utils/mention.test.ts (2)

2-2: Import updated correctly.

The import statement properly includes the new convertLabelsToDisplay function alongside the existing import.


114-210: Comprehensive test coverage for the new function.

The test suite for convertLabelsToDisplay is thorough and covers:

  • Basic single and multiple mention transformations
  • Edge cases like empty strings and text without mentions
  • Special characters, numbers, and symbols in labels
  • Malformed and nested bracket scenarios
  • Multiline text handling
  • Preservation of non-mention @ symbols

The tests mirror the existing test structure for convertMentionsToLabels, ensuring consistency and maintainability. The expected outputs correctly show the transformation from @[Label] to "Label" format.

apps/web/app/(app)/[emailAccountId]/assistant/examples.ts (14)

25-26: LGTM! Consistent label format standardization.

The systematic replacement of quoted label syntax with the new bracketed format (@[Label]) is well-executed and consistent across all prompt entries.


31-46: Consistent format conversion across example prompts.

All label mentions have been properly converted to the new @[Label] format, maintaining consistency with the overall label mention system update.


52-57: Consistent format conversion in persona-specific prompts.

The founder persona prompts correctly follow the new label mention format, ensuring consistency across all persona types.


72-83: Proper format conversion in influencer persona prompts.

The influencer-specific prompts have been updated to use the new bracketed label format consistently, including in multi-line template strings.


93-101: Consistent label format in realtor persona prompts.

All realtor-specific prompts properly implement the new @[Label] format, maintaining consistency with the system-wide update.


112-124: Consistent format conversion in investor persona prompts.

The investor persona prompts have been systematically updated to use the new bracketed label format across all entries.


141-149: Consistent format conversion in developer persona prompts.

All developer-specific prompts correctly use the new @[Label] format, maintaining consistency with the broader system update.


159-167: Consistent format conversion in designer persona prompts.

The designer persona prompts have been properly updated to use the new bracketed label format throughout.


177-188: Consistent format conversion in sales persona prompts.

All sales-specific prompts correctly implement the new @[Label] format, ensuring consistency across the entire system.


198-205: Consistent format conversion in marketer persona prompts.

The marketer persona prompts have been systematically updated to use the new bracketed label format.


215-226: Consistent format conversion in support persona prompts.

All support-specific prompts correctly follow the new @[Label] format, maintaining consistency with the system-wide update.


236-254: Consistent format conversion in recruiter persona prompts.

The recruiter persona prompts have been properly updated to use the new bracketed label format across all entries.


263-270: Consistent format conversion in student persona prompts.

All student-specific prompts correctly implement the new @[Label] format, ensuring consistency with the broader system update.


279-279: Consistent format conversion in outreach persona prompts.

The outreach persona prompt has been updated to use the new bracketed label format consistently.

apps/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx (4)

5-5: Good addition of help icon for user guidance.

The HelpCircleIcon import supports the new tooltip functionality that provides helpful formatting instructions to users.


27-27: Good integration of label display conversion utility.

The convertLabelsToDisplay import enables proper conversion of the new bracketed label format back to user-friendly display format.


219-253: Excellent user experience enhancement with formatting tooltip.

The tooltip provides clear, helpful guidance on formatting options with proper visual styling and good UX patterns. The use of font-mono and color coding makes the formatting instructions easy to understand.


380-382: Proper integration of label display conversion.

The convertLabelsToDisplay function correctly converts the new bracketed label format (@[Label]) back to user-friendly quoted format for display in the examples, ensuring consistency with the overall label mention system update.

@elie222 elie222 merged commit b86c3e2 into main Jul 16, 2025
14 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 1, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 2, 2025
@elie222 elie222 deleted the feat/example-mentions branch December 18, 2025 23:02
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.

1 participant

Comments