Skip to content

Migrate to ai sdk v5#592

Merged
elie222 merged 51 commits intomainfrom
feat/ai-sdk-v5
Aug 6, 2025
Merged

Migrate to ai sdk v5#592
elie222 merged 51 commits intomainfrom
feat/ai-sdk-v5

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jul 24, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a right-hand chat sidebar for AI chat, accessible via a new "AI Chat" button and sidebar trigger.
    • Added a new chat provider to manage chat state, input, and message handling across the app.
  • Improvements

    • Enhanced chat experience with more granular tool handling, clearer error messages, and improved message editing.
    • Updated sidebar system to support multiple named sidebars (e.g., left and chat sidebars) with independent state and toggling.
    • Upgraded AI SDK and related dependencies for improved performance and compatibility.
    • Refined chat message types and tool integrations for more robust assistant interactions.
    • Simplified and clarified prop types in various components for better maintainability.
    • Reorganized chat message persistence and streaming logic for improved error handling and efficiency.
    • Improved UI feedback on tool invocation states and error display in chat messages.
  • Bug Fixes

    • Improved error handling and user feedback in chat and AI assistant features.
  • Refactor

    • Centralized and modularized chat tool definitions and message conversion logic.
    • Removed deprecated or redundant chat components and context files.
    • Updated type usage and imports throughout the chat and assistant modules.
    • Simplified chat state management by consolidating hooks and removing SWR hacks.
    • Refactored sidebar and chat components to use new multi-sidebar state management.
  • Chores

    • Updated dependency versions and cleaned up unused imports.
    • Removed unused parameters and improved code formatting.
  • Style

    • Minor UI text and layout adjustments for clarity and consistency.

@vercel
Copy link

vercel bot commented Jul 24, 2025

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

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview Aug 6, 2025 10:46am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

Walkthrough

This update delivers a major refactor and modernization of the chat assistant architecture and UI. It introduces a new context-based ChatProvider, modularizes tool definitions, updates types for message and tool handling, and upgrades AI SDK dependencies. The sidebar system is reworked to support multiple named sidebars, and chat state management is centralized. Numerous components are updated or removed to align with these changes.

Changes

Cohort / File(s) Change Summary
Chat State Management Refactor
apps/web/components/assistant-chat/ChatContext.tsx, apps/web/providers/ChatProvider.tsx, apps/web/providers/AppProviders.tsx, apps/web/components/assistant-chat/chat.tsx, apps/web/app/(app)/[emailAccountId]/assistant/History.tsx, apps/web/app/(app)/[emailAccountId]/assistant/Pending.tsx, apps/web/app/(app)/[emailAccountId]/assistant/ProcessRules.tsx, apps/web/app/(app)/[emailAccountId]/assistant/page.tsx, apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx, apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx, apps/web/components/assistant-chat/helpers.ts, apps/web/components/assistant-chat/examples-dialog.tsx, apps/web/components/assistant-chat/overview.tsx, apps/web/components/assistant-chat/messages.tsx, apps/web/components/assistant-chat/message.tsx, apps/web/components/assistant-chat/message-editor.tsx, apps/web/components/assistant-chat/multimodal-input.tsx
Removes legacy chat context, introduces a centralized ChatProvider for chat state, updates all chat-related components to use new context and types, and removes or updates related hooks and props.
Sidebar System Overhaul
apps/web/components/ui/sidebar.tsx, apps/web/components/SideNavWithTopNav.tsx, apps/web/components/SidebarRight.tsx, apps/web/components/SideNav.tsx
Refactors sidebar logic to support multiple named sidebars, updates state management, toggling, and component props to handle arrays of sidebar names, and adds a right sidebar for chat.
AI Tooling and Assistant Chat Modularization
apps/web/utils/ai/assistant/chat.ts, apps/web/components/assistant-chat/tools.tsx, apps/web/components/assistant-chat/types.ts, apps/web/utils/ai/choose-rule/ai-choose-args.ts, apps/web/utils/ai/choose-rule/match-rules.ts, apps/web/utils/ai/actions.ts
Extracts tool logic into modular factory functions, updates tool types and schemas, aligns error and schema naming, and updates related chat and tool type definitions.
AI SDK and Model Integration Update
apps/web/package.json, apps/web/utils/llms/index.ts, apps/web/utils/llms/model.ts, apps/web/utils/usage.ts, apps/web/utils/redis/usage.ts
Upgrades AI SDK dependencies, updates model and usage types, refactors LLM integration to use new types and error handling, and updates cost calculation and Redis usage tracking.
API and Backend Chat Refactor
apps/web/app/api/chat/route.ts
Refactors API chat route to use unified message conversion, batch persistence, improved error handling, and new streaming logic.
Component and UI Modernization
apps/web/components/assistant-chat/data-stream-handler.tsx, apps/web/components/assistant-chat/suggested-actions.tsx, apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx, apps/web/components/AccountSwitcher.tsx, apps/web/components/ui/calendar.tsx, apps/web/components/editor/extensions/MentionList.tsx, apps/web/app/(app)/[emailAccountId]/usage/usage.tsx, apps/web/app/(app)/[emailAccountId]/automation/page.tsx, apps/web/app/(app)/[emailAccountId]/assistant/AIChatButton.tsx, apps/web/app/(app)/layout.tsx, apps/web/app/(marketing), apps/web/providers/PostHogProvider.tsx, apps/web/app/api/lemon-squeezy/webhook/route.ts, apps/web/utils/outlook/filter.ts, apps/web/utils/outlook/mail.ts, apps/web/utils/auth.ts
Removes obsolete components, updates prop types, improves UI feedback, adjusts import paths, introduces new components (e.g., AIChatButton), and applies minor bugfixes and code cleanup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatUI
    participant ChatProvider
    participant BackendAPI
    participant AI SDK

    User->>ChatUI: Types message / interacts
    ChatUI->>ChatProvider: setInput / setNewChat / submit
    ChatProvider->>BackendAPI: POST /api/chat (with messages)
    BackendAPI->>AI SDK: Process chat with tools
    AI SDK-->>BackendAPI: Stream assistant messages
    BackendAPI-->>ChatProvider: Stream UI messages
    ChatProvider->>ChatUI: Update messages, status
    ChatProvider->>BackendAPI: Save chat messages (batch)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Create label inline tiptap #615: Updates the MentionList.tsx component and props, matching the changes here for label creation UI.
  • Use chat fix #462: Refactors FixWithChat to simplify setInput usage, directly relating to similar changes in this PR.
  • Chat history #441: Refactors chat API route for persistent chat state and message handling, closely related to chat backend changes in this PR.

Suggested reviewers

  • edulelis

Poem

🐇✨
In fields of code where sidebars grow,
The chat now hops with state in tow.
Tools modular, types anew,
The bunny’s chat is crisp and true.
Sidebars left and right, what fun!
This refactor’s work is never done—
But oh, what joy when code can run!
🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ai-sdk-v5

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate unit tests to generate unit tests 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.

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: 2

🔭 Outside diff range comments (2)
apps/web/components/assistant-chat/message-editor.tsx (1)

88-102: Fix the type incompatibility issue instead of suppressing it.

The @ts-expect-error comment indicates a type mismatch with setMessages. This should be properly resolved rather than suppressed with a comment.

The issue might be that setMessages expects a different message type. Consider updating the type definitions or the message transformation logic to ensure type safety. Here's a potential approach:

-            // @ts-expect-error todo: support UIMessage in setMessages
             setMessages((messages) => {

Please investigate why the type mismatch occurs and implement a proper fix.

apps/web/components/assistant-chat/chat.tsx (1)

327-334: Use SDK’s built-in ID generation instead of a custom UUID

The AI SDK v5 already provides generateId() (and createIdGenerator()) for message/chat IDs. Please replace your custom generateUUID() with the SDK utility to ensure consistency across hooks and streaming methods.

• File: apps/web/components/assistant-chat/chat.tsx
Lines: 327–334

Proposed change:

- // NOTE: not sure why we don't just use the default from AI SDK
- function generateUUID(): string {
-   return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
-     const r = (Math.random() * 16) | 0;
-     const v = c === "x" ? r : (r & 0x3) | 0x8;
-     return v.toString(16);
-   });
- }
+ import { generateId } from 'ai';
+
+ // Use SDK’s ID generator for message/chat IDs
+ const generateUUID = () => generateId();

If you need a custom prefix or length, you can also use:

import { createIdGenerator } from 'ai';
const generateUUID = createIdGenerator({ prefix: 'msg', size: 16 });

This aligns with how useChat and streamText produce IDs internally and avoids maintaining a separate UUID scheme.

🧹 Nitpick comments (8)
apps/web/utils/redis/usage.ts (1)

36-46: Update Redis schema and field naming consistency.

The comment indicates this isn't OpenAI-specific anymore, but the Redis field names still use "openai" prefixes. Consider updating the schema to use generic names for consistency.

The Redis field names should reflect the generic nature of the usage tracking:

-    redis.hincrby(key, "openaiCalls", 1),
-    redis.hincrby(key, "openaiTokensUsed", usage.totalTokens ?? 0),
-    redis.hincrby(key, "openaiCompletionTokensUsed", usage.outputTokens ?? 0),
-    redis.hincrby(key, "openaiPromptTokensUsed", usage.inputTokens ?? 0),
+    redis.hincrby(key, "llmCalls", 1),
+    redis.hincrby(key, "totalTokensUsed", usage.totalTokens ?? 0),
+    redis.hincrby(key, "outputTokensUsed", usage.outputTokens ?? 0),
+    redis.hincrby(key, "inputTokensUsed", usage.inputTokens ?? 0),

This would require updating the schema and migration of existing data.

apps/web/components/assistant-chat/types.ts (2)

15-20: Remove commented-out code to improve maintainability.

Large blocks of commented code reduce readability. If these types are planned for future use, consider tracking them in a TODO comment or GitHub issue instead.

-// export type DataPart = { type: "append-message"; message: string };
-
-// export const messageMetadataSchema = z.object({ createdAt: z.string() });
-
-// export type MessageMetadata = z.infer<typeof messageMetadataSchema>;
-

 export type ChatTools = {

And similarly for the CustomUIDataTypes:

-// biome-ignore lint/complexity/noBannedTypes: <explanation>
 export type CustomUIDataTypes = {
-  // textDelta: string;
-  // // suggestion: Suggestion;
-  // appendMessage: string;
-  // id: string;
-  // title: string;
-  // clear: null;
-  // finish: null;
-  // ruleId: string | null;
+  // TODO: Add custom UI data types as needed
 };

Also applies to: 32-42


44-49: Add explanation to the biome-ignore comment.

The biome-ignore comment should include a proper explanation for why the lint rule is being ignored.

 export type ChatMessage = UIMessage<
-  // biome-ignore lint/complexity/noBannedTypes: <explanation>
+  // biome-ignore lint/complexity/noBannedTypes: Empty object is intentional as metadata is not used
   {}, // MessageMetadata,
   CustomUIDataTypes,
   ChatTools
 >;
apps/web/app/api/chat/route.ts (1)

1-1: Consider moving shared helpers to a common utilities location.

The convertToUIMessages helper is imported from the components directory into an API route. Consider moving shared utilities to a common location like utils/assistant-chat/ to maintain better separation of concerns.

Also applies to: 9-11

apps/web/components/assistant-chat/message.tsx (1)

111-338: Consider reducing code duplication in tool error handling.

While the explicit handling of each tool type improves type safety and UI specificity, there's significant duplication in the error handling pattern. Consider extracting a common pattern.

Here's a suggested approach to reduce duplication:

// Helper function to handle tool states
function renderToolState<T extends { state: string; toolCallId: string }>(
  part: T,
  inputRenderer: () => React.ReactNode,
  outputRenderer: (output: any) => React.ReactNode,
) {
  const { toolCallId, state } = part;

  if (state === "input-available") {
    return inputRenderer();
  }

  if (state === "output-available") {
    const { output } = part as any;
    
    if ("error" in output) {
      return <ErrorToolCard key={toolCallId} error={String(output.error)} />;
    }
    
    return outputRenderer(output);
  }
  
  return null;
}

// Example usage for one tool:
if (type === "tool-getUserRulesAndSettings") {
  return renderToolState(
    part,
    () => <BasicToolInfo key={part.toolCallId} text="Reading rules and settings..." />,
    () => <BasicToolInfo text="Read rules and settings" />
  );
}

This pattern would significantly reduce the repetitive error handling code while maintaining type safety and readability.

apps/web/components/assistant-chat/tools.tsx (1)

391-409: Consider extracting confirmation dialog

While the current implementation works, consider using a proper confirmation dialog component instead of the browser's confirm() for better UX consistency and mobile compatibility.

You could use a dialog component like:

-const yes = confirm("Are you sure you want to delete this rule?");
-if (yes) {
+// Use a confirmation dialog component
+openConfirmDialog({
+  title: "Delete Rule",
+  description: "Are you sure you want to delete this rule? This action cannot be undone.",
+  onConfirm: async () => {
apps/web/utils/llms/index.ts (1)

301-352: Remove commented code

This function appears to be unused. If it's no longer needed, please remove it entirely rather than keeping it commented out.

apps/web/utils/ai/assistant/chat.ts (1)

160-162: Consider extracting common error messages

The "Rule not found" error message is duplicated across multiple tools. Consider extracting it to a constant for better maintainability.

const ERROR_MESSAGES = {
  RULE_NOT_FOUND: "Rule not found. Try listing the rules again. The user may have made changes since you last checked.",
  ACCOUNT_NOT_FOUND: "Account not found",
  // ... other common messages
} as const;

Also applies to: 289-293, 408-411, 496-501

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac3511 and 7f7682d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx (1 hunks)
  • apps/web/app/api/chat/route.ts (3 hunks)
  • apps/web/components/assistant-chat/ChatContext.tsx (1 hunks)
  • apps/web/components/assistant-chat/chat.tsx (5 hunks)
  • apps/web/components/assistant-chat/data-stream-handler.tsx (0 hunks)
  • apps/web/components/assistant-chat/helpers.ts (1 hunks)
  • apps/web/components/assistant-chat/message-editor.tsx (4 hunks)
  • apps/web/components/assistant-chat/message.tsx (4 hunks)
  • apps/web/components/assistant-chat/messages.tsx (2 hunks)
  • apps/web/components/assistant-chat/multimodal-input.tsx (3 hunks)
  • apps/web/components/assistant-chat/overview.tsx (2 hunks)
  • apps/web/components/assistant-chat/tools.tsx (8 hunks)
  • apps/web/components/assistant-chat/types.ts (1 hunks)
  • apps/web/package.json (3 hunks)
  • apps/web/utils/ai/assistant/chat.ts (5 hunks)
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts (4 hunks)
  • apps/web/utils/llms/index.ts (8 hunks)
  • apps/web/utils/llms/model.ts (4 hunks)
  • apps/web/utils/redis/usage.ts (2 hunks)
  • apps/web/utils/usage.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/components/assistant-chat/data-stream-handler.tsx
🧰 Additional context used
📓 Path-based instructions (27)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/utils/redis/usage.ts
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/utils/ai/assistant/chat.ts
apps/web/app/**

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

NextJS app router structure with (app) directory

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/app/api/chat/route.ts
apps/web/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Use result?.serverError with toastError and toastSuccess
Use LoadingContent component to handle loading and error states consistently
Pass loading, error, and children props to LoadingContent

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
!{.cursor/rules/*.mdc}

📄 CodeRabbit Inference Engine (.cursor/rules/cursor-rules.mdc)

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/utils/redis/usage.ts
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/package.json
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/utils/ai/assistant/chat.ts
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/utils/redis/usage.ts
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/utils/ai/assistant/chat.ts
apps/web/app/(app)/*/**

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
apps/web/app/(app)/*/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
apps/web/app/(app)/*/**/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

If we're in a deeply nested component we will use swr to fetch via API

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
apps/web/app/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Components with onClick must be client components with use client directive

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/utils/redis/usage.ts
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/utils/ai/assistant/chat.ts
!pages/_document.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/utils/redis/usage.ts
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/package.json
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
  • apps/web/utils/ai/assistant/chat.ts
**/*.{jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
**/*.{html,jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...

Files:

  • apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/utils/redis/usage.ts
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/components/assistant-chat/types.ts
  • apps/web/app/api/chat/route.ts
  • apps/web/utils/llms/index.ts
  • apps/web/utils/ai/assistant/chat.ts
apps/web/utils/{ai,llms}/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*: LLM-related code must be organized in the directories: apps/web/utils/ai/, apps/web/utils/llms/, and apps/web/tests/ for LLM-specific tests.
Keep related AI functions in the same file or directory.

Files:

  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/utils/llms/model.ts
  • apps/web/utils/llms/index.ts
  • apps/web/utils/ai/assistant/chat.ts
apps/web/utils/{ai,llms}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*.ts: Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
Keep system prompts and user prompts separate in LLM-related code.
System prompt should define the LLM's role and task specifications.
User prompt should contain the actual data and context.
Always define a Zod schema for response validation in LLM-related functions.
Make Zod schemas as specific as possible to guide the LLM output.
Use descriptive scoped loggers for each LLM feature.
Log inputs and outputs with appropriate log levels in LLM-related functions.
Include relevant context in log messages for LLM-related code.
Implement early returns for invalid inputs in LLM-related functions.
Use proper error types and logging in LLM-related code.
Implement fallbacks for AI failures in LLM-related functions.
Add retry logic for transient failures using withRetry in LLM-related code.
Use XML-like tags to structure data in LLM prompts.
Remove excessive whitespace and truncate long inputs in LLM prompts.
Format data consistently across similar LLM-related functions.
Use TypeScript types for all parameters and return values in LLM-related code.
Define clear interfaces for complex input/output structures in LLM-related code.
Extract common patterns into utility functions in LLM-related code.
Document complex AI logic with clear comments in LLM-related code.

Files:

  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/utils/llms/model.ts
  • apps/web/utils/llms/index.ts
  • apps/web/utils/ai/assistant/chat.ts
apps/web/utils/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/utils/redis/usage.ts
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/utils/llms/index.ts
  • apps/web/utils/ai/assistant/chat.ts
apps/web/utils/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/utils/redis/usage.ts
  • apps/web/utils/llms/model.ts
  • apps/web/utils/usage.ts
  • apps/web/utils/llms/index.ts
  • apps/web/utils/ai/assistant/chat.ts
apps/web/components/!(ui)/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

All other components are in components/

Files:

  • apps/web/components/assistant-chat/helpers.ts
  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/types.ts
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
apps/web/components/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

Use React Hook Form with Zod validation for form handling

Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Use PascalCase for components (e.g. components/Button.tsx)

Files:

  • apps/web/components/assistant-chat/ChatContext.tsx
  • apps/web/components/assistant-chat/overview.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
  • apps/web/components/assistant-chat/message.tsx
  • apps/web/components/assistant-chat/messages.tsx
  • apps/web/components/assistant-chat/tools.tsx
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/components/assistant-chat/chat.tsx
apps/web/utils/llms/model.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

Model definitions and configurations must be placed in utils/llms/model.ts.

Files:

  • apps/web/utils/llms/model.ts
apps/web/utils/usage.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

LLM usage tracking and monitoring must be implemented in utils/usage.ts.

Files:

  • apps/web/utils/usage.ts
apps/web/app/api/**/route.ts

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/app/api/**/route.ts: Use withAuth for user-level operations
Use withEmailAccount for email-account-level operations
Do NOT use POST API routes for mutations - use server actions instead
No need for try/catch in GET routes when using middleware
Export response types from GET routes

apps/web/app/api/**/route.ts: Wrap all GET API route handlers with withAuth or withEmailAccount middleware for authentication and authorization.
Export response types from GET API routes for type-safe client usage.
Do not use try/catch in GET API routes when using authentication middleware; rely on centralized error handling.

Files:

  • apps/web/app/api/chat/route.ts
**/api/**/route.ts

📄 CodeRabbit Inference Engine (.cursor/rules/security.mdc)

**/api/**/route.ts: ALL API routes that handle user data MUST use appropriate authentication and authorization middleware (withAuth or withEmailAccount).
ALL database queries in API routes MUST be scoped to the authenticated user/account (e.g., include userId or emailAccountId in query filters).
Always validate that resources belong to the authenticated user before performing operations (resource ownership validation).
Use withEmailAccount middleware for API routes that operate on a specific email account (i.e., use or require emailAccountId).
Use withAuth middleware for API routes that operate at the user level (i.e., use or require only userId).
Use withError middleware (with proper validation) for public endpoints, custom authentication, or cron endpoints.
Cron endpoints MUST use withError middleware and validate the cron secret using hasCronSecret(request) or hasPostCronSecret(request).
Cron endpoints MUST capture unauthorized attempts with captureException and return a 401 status for unauthorized requests.
All parameters in API routes MUST be validated for type, format, and length before use.
Request bodies in API routes MUST be validated using Zod schemas before use.
All Prisma queries in API routes MUST only return necessary fields and never expose sensitive data.
Error messages in API routes MUST not leak internal information or sensitive data; use generic error messages and SafeError where appropriate.
API routes MUST use a consistent error response format, returning JSON with an error message and status code.
All findUnique and findFirst Prisma calls in API routes MUST include ownership filters (e.g., userId or emailAccountId).
All findMany Prisma calls in API routes MUST be scoped to the authenticated user's data.
Never use direct object references in API routes without ownership checks (prevent IDOR vulnerabilities).
Prevent mass assignment vulnerabilities by only allowing explicitly whitelisted fields in update operations in AP...

Files:

  • apps/web/app/api/chat/route.ts
apps/web/app/api/**/*.{ts,js}

📄 CodeRabbit Inference Engine (.cursor/rules/security-audit.mdc)

apps/web/app/api/**/*.{ts,js}: All API route handlers in 'apps/web/app/api/' must use authentication middleware: withAuth, withEmailAccount, or withError (with custom authentication logic).
All Prisma queries in API routes must include user/account filtering (e.g., emailAccountId or userId in WHERE clauses) to prevent unauthorized data access.
All parameters used in API routes must be validated before use; do not use parameters from 'params' or request bodies directly in queries without validation.
Request bodies in API routes should use Zod schemas for validation.
API routes should only return necessary fields using Prisma's 'select' and must not include sensitive data in error messages.
Error messages in API routes must not reveal internal details; use generic errors and SafeError for user-facing errors.
All QStash endpoints (API routes called via publishToQstash or publishToQstashQueue) must use verifySignatureAppRouter to verify request authenticity.
All cron endpoints in API routes must use hasCronSecret or hasPostCronSecret for authentication.
Do not hardcode weak or plaintext secrets in API route files; secrets must not be directly assigned as string literals.
Review all new withError usage in API routes to ensure custom authentication is implemented where required.

Files:

  • apps/web/app/api/chat/route.ts
apps/web/utils/llms/index.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

The core LLM functionality must be implemented in utils/llms/index.ts.

Files:

  • apps/web/utils/llms/index.ts
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.
apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx (16)

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
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-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Name custom hooks with the use prefix (e.g., useAccounts.ts).

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Make sure all dependencies are correctly specified in React hooks.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Keep custom hooks focused on a single responsibility.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Create dedicated hooks for specific data types (e.g., useAccounts, useLabels).

Learnt from: aryanprince
PR: #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: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Custom 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/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Make sure all React hooks are called from the top level of component functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : For fetching data from API endpoints in custom hooks, prefer using useSWR.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.226Z
Learning: Applies to apps/web/app/(app)//**/.tsx : If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Applies to apps/web/app/**/*.tsx : Components with onClick must be client components with use client directive

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use LoadingContent component for async data

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the LoadingContent component to handle loading states

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/components/**/*.tsx : Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use LoadingContent component to handle loading and error states consistently

apps/web/utils/ai/choose-rule/ai-choose-args.ts (17)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement early returns for invalid inputs in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.554Z
Learning: Applies to apps/web/tests/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in the corresponding .validation.ts file. These schemas are used by next-safe-action (.schema()) and can also be reused on the client for form validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.952Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Request bodies in API routes should use Zod schemas for validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.098Z
Learning: Applies to **/*.ts : Define validation schemas using Zod

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-07-18T17:27:46.378Z
Learning: Applies to /api//route.ts : Request bodies in API routes MUST be validated using Zod schemas before use.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/app/api/**/route.ts : Use withEmailAccount for email-account-level operations

apps/web/components/assistant-chat/helpers.ts (10)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

apps/web/components/assistant-chat/ChatContext.tsx (15)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Name custom hooks with the use prefix (e.g., useAccounts.ts).

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Keep custom hooks focused on a single responsibility.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Make sure all React hooks are called from the top level of component functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Create dedicated hooks for specific data types (e.g., useAccounts, useLabels).

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Make sure all dependencies are correctly specified in React hooks.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Custom 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/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.388Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Keep all feature flag hooks centralized in useFeatureFlags.ts

Learnt from: elie222
PR: #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: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Access necessary context (like userId, emailAccountId, etc.) provided by the safe action client via the ctx object in the .action() handler.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component for text inputs, passing registerProps and error props for form handling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : For fetching data from API endpoints in custom hooks, prefer using useSWR.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.618Z
Learning: Guidelines for creating custom React hooks

apps/web/utils/redis/usage.ts (17)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/usage.ts : LLM usage tracking and monitoring must be implemented in utils/usage.ts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Log inputs and outputs with appropriate log levels in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Applies to apps/web/utils/actions/*.ts : Server action files must start with use server

apps/web/components/assistant-chat/overview.tsx (17)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component with autosizeTextarea and appropriate props for text areas

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component for text inputs, passing registerProps and error props for form handling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Use semantic elements instead of role attributes in JSX.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Learnt from: aryanprince
PR: #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-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
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-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Create dedicated hooks for specific data types (e.g., useAccounts, useLabels).

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the LoadingContent component to handle loading states

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.098Z
Learning: Applies to **/*.tsx : Validate form inputs before submission

apps/web/package.json (12)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: In this project, Prisma should be imported using 'import prisma from "@/utils/prisma";' in TypeScript files.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: The project uses PostgreSQL as the database with Prisma.

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.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.618Z
Learning: How to use Prisma

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Make sure all dependencies are correctly specified in React hooks.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use next/image package for images

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to {components,app}/**/*.tsx : For API get requests to server use the swr package

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-07-18T15:04:44.809Z
Learning: Applies to {app,components}/**/*.{ts,tsx} : For API GET requests to server, use the swr package

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.554Z
Learning: Run AI tests with: pnpm test-ai your-feature

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.554Z
Learning: Applies to apps/web/tests/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

apps/web/utils/llms/model.ts (13)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/llms/model.ts : Model definitions and configurations must be placed in utils/llms/model.ts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.554Z
Learning: Applies to apps/web/tests/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use XML-like tags to structure data in LLM prompts.

apps/web/utils/usage.ts (14)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/usage.ts : LLM usage tracking and monitoring must be implemented in utils/usage.ts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use descriptive scoped loggers for each LLM feature.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Log inputs and outputs with appropriate log levels in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

apps/web/components/assistant-chat/message-editor.tsx (14)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Learnt from: edulelis
PR: #576
File: packages/resend/emails/digest.tsx:78-83
Timestamp: 2025-07-17T04:19:57.099Z
Learning: In packages/resend/emails/digest.tsx, the DigestEmailProps type uses [key: string]: DigestItem[] | undefined | string | Date | undefined instead of intersection types like & Record<string, DigestItem[] | undefined> due to implementation constraints. This was the initial implementation approach and cannot be changed to more restrictive typing.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component with autosizeTextarea and appropriate props for text areas

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Use as const instead of literal types and type annotations.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Use import type for types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Use adminActionClient for actions restricted to admin users.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Use actionClientUser when only authenticated user context (userId) is needed.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Access necessary context (like userId, emailAccountId, etc.) provided by the safe action client via the ctx object in the .action() handler.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Use actionClient when both authenticated user context and a specific emailAccountId are needed. The emailAccountId must be bound when calling the action from the client.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Applies to apps/web/app/**/*.tsx : Components with onClick must be client components with use client directive

Learnt from: aryanprince
PR: #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.

apps/web/components/assistant-chat/types.ts (11)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component with autosizeTextarea and appropriate props for text areas

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

apps/web/components/assistant-chat/message.tsx (29)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.226Z
Learning: Applies to apps/web/app/(app)//**/.tsx : If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Applies to apps/web/app/**/*.tsx : Components with onClick must be client components with use client directive

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
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-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Custom hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.

Learnt from: aryanprince
PR: #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-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/hooks/**/*.ts : Use SWR for client-side data fetching and caching.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Create dedicated hooks for specific data types (e.g., useAccounts, useLabels).

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Name custom hooks with the use prefix (e.g., useAccounts.ts).

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-07-18T15:04:44.809Z
Learning: Applies to {app,components}/**/*.{ts,tsx} : Use result?.serverError with toastError and toastSuccess for error handling; success toast is optional

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use LoadingContent component to handle loading and error states consistently

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/components/**/*.tsx : Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/components/**/*Form.tsx : Use result?.serverError with toastError and toastSuccess for error and success notifications in form submission handlers.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.098Z
Learning: Applies to **/*.tsx : Show validation errors inline next to form fields

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use result?.serverError with toastError and toastSuccess

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component for text inputs, passing registerProps and error props for form handling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Use SafeError for expected/handled errors within actions if needed. next-safe-action provides centralized error handling.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Pass loading, error, and children props to LoadingContent

apps/web/components/assistant-chat/messages.tsx (8)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Don't assign to React component props.

Learnt from: aryanprince
PR: #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: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks

apps/web/app/api/chat/route.ts (21)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use server actions (with next-safe-action) for all mutations (create/update/delete operations); do NOT use POST API routes for mutations.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/get-api-route.mdc:0-0
Timestamp: 2025-07-18T15:05:26.685Z
Learning: Applies to app/api/**/route.ts : Use Prisma for database queries in GET API routes.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.952Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Review all new withError usage in API routes to ensure custom authentication is implemented where required.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: In this project, Prisma should be imported using 'import prisma from "@/utils/prisma";' in TypeScript files.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-19T17:50:28.259Z
Learning: The utils folder also contains core app logic such as Next.js Server Actions and Gmail API requests.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.952Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Request bodies in API routes should use Zod schemas for validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in the corresponding .validation.ts file. These schemas are used by next-safe-action (.schema()) and can also be reused on the client for form validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-07-18T17:27:46.378Z
Learning: Applies to /api//route.ts : Request bodies in API routes MUST be validated using Zod schemas before use.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.098Z
Learning: Applies to **/*.ts : Define validation schemas using Zod

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.618Z
Learning: How to use Prisma

apps/web/utils/llms/index.ts (17)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Log inputs and outputs with appropriate log levels in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Add retry logic for transient failures using withRetry in LLM-related code.

apps/web/components/assistant-chat/tools.tsx (18)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{jsx,tsx} : Use semantic elements instead of role attributes in JSX.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Applies to apps/web/components/**/*.tsx : Use PascalCase for components (e.g. components/Button.tsx)

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-07-18T15:04:44.809Z
Learning: Applies to app/**/*.{ts,tsx} : For mutating data, use Next.js server actions

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: In this project, Prisma should be imported using 'import prisma from "@/utils/prisma";' in TypeScript files.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.ts : Implement all server actions using the next-safe-action library for type safety, input validation, context management, and error handling. Refer to apps/web/utils/actions/safe-action.ts for client definitions (actionClient, actionClientUser, adminActionClient).

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use server actions for all mutations (create/update/delete operations)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Use either T[] or Array consistently.

apps/web/components/assistant-chat/multimodal-input.tsx (13)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component with autosizeTextarea and appropriate props for text areas

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component for text inputs, passing registerProps and error props for form handling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Use as const instead of literal types and type annotations.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
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-18T15:04:57.098Z
Learning: Applies to **/*.tsx : Validate form inputs before submission

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.287Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

apps/web/components/assistant-chat/chat.tsx (24)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/hooks/**/*.ts : Call mutate() after successful mutations to refresh SWR data on the client.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/hooks/**/*.ts : Use SWR for client-side data fetching and caching.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/hooks/**/*.ts : Use SWR for efficient data fetching and caching

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.226Z
Learning: Applies to apps/web/app/(app)////.tsx : If we're in a deeply nested component we will use swr to fetch via API

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to {components,app}/**/*.tsx : For API get requests to server use the swr package

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : For fetching data from API endpoints in custom hooks, prefer using useSWR.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component with autosizeTextarea and appropriate props for text areas

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-07-18T15:04:44.809Z
Learning: Applies to {app,components}/**/*.{ts,tsx} : For API GET requests to server, use the swr package

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Use swr for data fetching in deeply nested components

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.618Z
Learning: Fetching data from the API using SWR

Learnt from: aryanprince
PR: #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: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.226Z
Learning: Applies to apps/web/app/(app)//**/.tsx : If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Implement responsive design with Tailwind CSS using a mobile-first approach

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/components/**/*.tsx : Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use LoadingContent component to handle loading and error states consistently

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/**/*.tsx : Use LoadingContent component for async data

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the LoadingContent component to handle loading states

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.696Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Custom hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/hooks/**/*.{ts,tsx} : Call mutate() after successful mutations to refresh data

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.043Z
Learning: Applies to components/**/*.tsx : Use the Input component for text inputs, passing registerProps and error props for form handling

apps/web/utils/ai/assistant/chat.ts (18)

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.554Z
Learning: Applies to apps/web/tests/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.220Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in the corresponding .validation.ts file. These schemas are used by next-safe-action (.schema()) and can also be reused on the client for form validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.118Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.448Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.243Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

🧬 Code Graph Analysis (8)
apps/web/components/assistant-chat/overview.tsx (1)
apps/web/components/Typography.tsx (2)
  • TypographyH3 (112-112)
  • MessageText (115-115)
apps/web/utils/llms/model.ts (2)
apps/web/utils/llms/config.ts (1)
  • providerOptions (39-49)
apps/web/env.ts (1)
  • env (15-225)
apps/web/components/assistant-chat/message-editor.tsx (1)
apps/web/components/assistant-chat/types.ts (1)
  • ChatMessage (44-49)
apps/web/components/assistant-chat/types.ts (1)
apps/web/utils/ai/assistant/chat.ts (8)
  • GetUserRulesAndSettingsTool (120-122)
  • GetLearnedPatternsTool (171-173)
  • CreateRuleTool (239-239)
  • UpdateRuleConditionsTool (340-342)
  • UpdateRuleActionsTool (454-456)
  • UpdateLearnedPatternsTool (557-559)
  • UpdateAboutTool (594-594)
  • AddToKnowledgeBaseTool (635-637)
apps/web/components/assistant-chat/message.tsx (2)
apps/web/components/assistant-chat/types.ts (1)
  • ChatMessage (44-49)
apps/web/components/assistant-chat/tools.tsx (7)
  • BasicToolInfo (23-29)
  • CreatedRuleToolCard (31-102)
  • UpdatedRuleConditions (104-191)
  • UpdatedRuleActions (193-279)
  • UpdatedLearnedPatterns (281-335)
  • UpdateAbout (337-344)
  • AddToKnowledgeBase (346-369)
apps/web/components/assistant-chat/messages.tsx (1)
apps/web/components/assistant-chat/types.ts (1)
  • ChatMessage (44-49)
apps/web/utils/llms/index.ts (1)
apps/web/utils/usage.ts (1)
  • saveAiUsage (8-41)
apps/web/components/assistant-chat/multimodal-input.tsx (1)
apps/web/components/assistant-chat/types.ts (1)
  • ChatMessage (44-49)
⏰ 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: Socket Security: Pull Request Alerts
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (50)
apps/web/app/(app)/[emailAccountId]/simple/Summary.tsx (1)

3-3: LGTM! Import updated for AI SDK v5 migration.

The import change from "ai/react" to "@ai-sdk/react" correctly aligns with the AI SDK v5 migration while maintaining the same useCompletion hook interface.

apps/web/components/assistant-chat/ChatContext.tsx (1)

27-27: Improved error handling for context usage.

Replacing the fallback return with an error throw enforces correct usage of the useChat hook within a ChatProvider. This follows React context best practices and provides clearer debugging when the hook is misused.

apps/web/utils/ai/choose-rule/ai-choose-args.ts (4)

2-2: Updated error import for AI SDK v5.

The import change from InvalidToolArgumentsError to InvalidArgumentError aligns with the AI SDK v5 error naming conventions.


83-83: Updated tool schema property name.

The change from parameters to inputSchema follows the new AI SDK v5 tool configuration API.


97-97: Updated retry condition for new error type.

The retry condition correctly uses the new InvalidArgumentError class with its isInstance method, maintaining proper error handling logic.


107-107: Updated tool call property access.

The change from args to input reflects the updated tool call response structure in AI SDK v5.

apps/web/components/assistant-chat/overview.tsx (3)

10-10: Simplified prop type definition.

The direct function type (input: string) => void is clearer and removes the dependency on UseChatHelpers, making the component interface more explicit.


27-27: Updated assistant branding.

The removal of "AI" from "AI email assistant" to "email assistant" appears to be a deliberate branding/UX decision.


30-30: Added explicit font size styling.

The text-base class provides explicit font size control for the MessageText component, improving styling consistency.

apps/web/components/assistant-chat/helpers.ts (1)

9-20: Well-structured utility function for message conversion.

This helper function effectively centralizes the message conversion logic from GetChatResponse to ChatMessage[]. The null safety handling and type casting are appropriate for the AI SDK migration. The commented metadata section suggests future extensibility.

apps/web/package.json (2)

16-22: Beta AI SDK dependencies appear stable – no known breaking changes or security vulnerabilities

After reviewing the v5.0.0-beta changelog and querying NPM security advisories, no breaking changes or critical vulnerabilities were identified in the following packages:

  • @ai-sdk/amazon-bedrock@3.0.0-beta.9
  • @ai-sdk/anthropic@2.0.0-beta.8
  • @ai-sdk/google@2.0.0-beta.13
  • @ai-sdk/groq@2.0.0-beta.6
  • @ai-sdk/openai@2.0.0-beta.11
  • @ai-sdk/provider@2.0.0-beta.1
  • @ai-sdk/react@2.0.0-beta.25

You can proceed with these beta versions in production, continuing to monitor patch releases for any minor fixes.


43-43: Verify AI SDK v5 Compatibility for @openrouter/ai-sdk-provider Upgrade

Please ensure that upgrading to @openrouter/ai-sdk-provider@1.0.0-beta.5 aligns with the new AI SDK v5 requirements:

• Convert UIMessage → ModelMessage before sending to the model
• Update tool‐call handling to use tool-${toolName} naming conventions
• Configure useChat with the new transport‐based setup
• Ensure your app supports SSE for streaming responses
• Create provider instances using the v5‐compatible methods
• Adopt the new model interfaces introduced in AI SDK v5

Refer to the official v5 migration guide for detailed steps:
https://v5.ai-sdk.dev/docs/migration-guides/migration-guide-5-0?utm_source=openai

apps/web/utils/usage.ts (2)

1-1: LGTM! Consistent migration to AI SDK v5 types.

The migration to LanguageModelUsage type from the "ai" package provides better type safety and consistency across the codebase. The updated property names (inputTokens/outputTokens) align with the new SDK conventions.

Also applies to: 18-18, 29-31


29-31: Good defensive programming with nullish coalescing.

The addition of nullish coalescing (?? 0) for token counts prevents potential runtime errors if these properties are undefined in different AI provider responses.

Also applies to: 144-144

apps/web/utils/llms/model.ts (3)

8-8: Clear communication about Ollama removal.

The removal of Ollama support is handled well with a clear error message directing users to revert to an older version. This provides a migration path for users who depend on Ollama.

The error message and commented code clearly communicate the change while preserving the implementation for reference.

Also applies to: 110-119


259-269: Minor improvement: cleaner variable initialization.

The reordering of variable declarations makes the code more readable by grouping the aiApiKey initialization with the provider and model logic.


1-1: No remaining LanguageModelV1 references detected
Searches for LanguageModelV1 across apps/web/ and for llmModel. in apps/web/utils/ & apps/web/components/ returned no matches. All consuming code now targets LanguageModelV2. No further action required.

apps/web/components/assistant-chat/multimodal-input.tsx (1)

14-14: Excellent type safety improvements with ChatMessage generic.

The explicit specification of ChatMessage as the generic parameter for UseChatHelpers provides better type safety and IntelliSense support. This ensures all chat-related props are properly typed according to the ChatMessage interface defined in types.ts.

These changes align perfectly with the broader refactoring to use consistent typing across the assistant chat components.

Also applies to: 29-31, 36-36, 38-38, 172-172

apps/web/components/assistant-chat/message-editor.tsx (4)

3-3: LGTM! Good use of type imports.

The imports correctly use import type syntax for type-only imports, which aligns with TypeScript best practices.

Also applies to: 14-14


17-22: Type updates align with the new chat message architecture.

The specialization of UseChatHelpers with ChatMessage and the rename from reload to regenerate are consistent with the broader refactoring across the assistant chat components.


28-34: Proper handling of the new message structure.

Good use of the getTextFromMessage helper to extract text content from the new part-based message structure.


115-120: Well-implemented text extraction helper.

The getTextFromMessage function correctly extracts and concatenates text parts from the message structure.

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

8-8: Consistent type updates across the component.

The specialization of UseChatHelpers with ChatMessage and the simplified setInput type improve type clarity and consistency.

Also applies to: 11-16


23-23: Consistent prop renaming throughout the component.

The reload to regenerate rename is properly propagated through the component hierarchy.

Also applies to: 42-42

apps/web/components/assistant-chat/types.ts (2)

1-13: Well-structured type imports and definitions.

Good use of import type for all type imports and clear definition of SetInputFunction.


21-30: Well-structured tool type aggregation.

The ChatTools type provides a centralized, type-safe definition of all available assistant tools.

apps/web/app/api/chat/route.ts (2)

62-62: Clean and consistent message handling.

The use of conversion helpers and the simplified stream response with bulk message saving improves code clarity and maintainability.

Also applies to: 73-73, 78-82


124-139: Well-implemented bulk save with proper error handling.

The function efficiently saves multiple messages in a single operation and includes comprehensive error handling with logging and exception capture.

apps/web/components/assistant-chat/message.tsx (3)

12-21: Proper imports and type updates for the new tool architecture.

The imports correctly bring in all the specialized tool components, and the prop types are updated consistently with the new ChatMessage type and regenerate method.

Also applies to: 27-32


27-27: Consistent prop renaming.

The reload to regenerate rename is properly propagated.

Also applies to: 104-104


347-349: Simple and effective error display component.

The ErrorToolCard provides clear error visibility with appropriate styling.

apps/web/components/assistant-chat/tools.tsx (6)

4-11: LGTM! Clean type imports

The tool type imports are well-organized and follow the established pattern of using typed tool definitions from the AI assistant module.


31-102: Well-structured rule creation component

The component properly handles conditional rendering, null checking, and displays rule information in a clear hierarchical structure. Good use of the filterNullProperties pattern for clean data display.


104-191: Excellent diff visualization implementation

The component provides a clean UI for viewing rule condition updates with collapsible diff views. Good state management and proper type usage throughout.


212-216: Good use of generic constraints

The generic type parameter T is properly constrained to ensure type safety while maintaining flexibility for different action formats.


281-335: Clean pattern visualization

The component effectively displays learned patterns with clear separation between include and exclude rules. Good defensive programming with null checks.


337-369: Well-integrated navigation components

Both components follow consistent patterns. The AddToKnowledgeBase component's integration with query state for navigation is a nice touch for user experience.

apps/web/utils/llms/index.ts (4)

4-4: Type migration looks good

The migration from CoreMessage to ModelMessage aligns with the AI SDK v5 update.


136-136: Correct SDK v5 syntax

Adding output: "object" is the correct way to specify object generation in the new SDK version.


194-194: Updated step limiting pattern

The migration to stopWhen with stepCountIs is the correct approach for the new SDK version.


200-210: Efficient concurrent execution

Good use of Promise.all to avoid blocking the callback on usage saving. Since saveAiUsage handles errors internally, this pattern is safe and performant.

apps/web/components/assistant-chat/chat.tsx (4)

73-79: Clean removal of SWR wrapper

Good simplification by removing the unnecessary SWR config wrapper and using the helper function for message conversion.


97-143: Well-structured state management

The local input state and explicit handleSubmit function provide better control over the chat flow. The DefaultChatTransport configuration with custom request preparation is a clean approach.


178-187: Improved component interface

The explicit prop interface makes the component's dependencies clear and improves testability.


192-196: Good UX consideration

The message limit warning provides clear feedback to users when conversations become too long.

apps/web/utils/ai/assistant/chat.ts (5)

1-1: Excellent type imports for AI SDK v5

The migration to InferUITool, tool, and ModelMessage from the "ai" package aligns perfectly with the SDK upgrade.


25-119: Well-structured tool factory pattern

The getUserRulesAndSettingsTool factory encapsulates all logic nicely. Good use of filterNullProperties to clean up the response data.


183-237: Robust error handling in createRuleTool

Good error handling with proper logging and user-friendly error messages. The try-catch pattern with specific error message extraction is well implemented.


505-543: Clean pattern transformation logic

The conversion from the input pattern format to the database format is well-implemented with clear handling of include/exclude cases.


639-934: Excellent modularization of the main function

The simplified aiProcessAssistantChat function with tool initialization is much cleaner than inline tool definitions. The system prompt is comprehensive with good examples.

@socket-security
Copy link

socket-security bot commented Jul 24, 2025

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 55a49fd and 1407721.

⛔ Files ignored due to path filters (5)
  • apps/web/public/images/testimonials/joel.jpeg is excluded by !**/*.jpeg
  • apps/web/public/images/testimonials/slim.png is excluded by !**/*.png
  • apps/web/public/images/testimonials/valentine.png is excluded by !**/*.png
  • apps/web/public/images/testimonials/will.jpeg is excluded by !**/*.jpeg
  • apps/web/public/images/testimonials/yoni.jpeg is excluded by !**/*.jpeg
📒 Files selected for processing (20)
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx (0 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/automation/page.tsx (2 hunks)
  • apps/web/app/(landing)/home/Testimonials.tsx (7 hunks)
  • apps/web/components/assistant-chat/multimodal-input.tsx (3 hunks)
  • apps/web/components/assistant-chat/tools.tsx (8 hunks)
  • apps/web/components/editor/extensions/LabelMention.tsx (7 hunks)
  • apps/web/components/editor/extensions/MentionList.tsx (3 hunks)
  • apps/web/hooks/useFeatureFlags.ts (0 hunks)
  • apps/web/utils/actions/rule.ts (5 hunks)
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts (4 hunks)
  • apps/web/utils/auth.ts (1 hunks)
  • apps/web/utils/gmail/message.ts (1 hunks)
  • apps/web/utils/llms/index.ts (8 hunks)
  • apps/web/utils/outlook/message.ts (1 hunks)
  • version.txt (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/web/hooks/useFeatureFlags.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
✅ Files skipped from review due to trivial changes (4)
  • version.txt
  • apps/web/utils/auth.ts
  • apps/web/utils/actions/rule.ts
  • apps/web/app/(app)/[emailAccountId]/automation/page.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/components/assistant-chat/multimodal-input.tsx
  • apps/web/utils/llms/index.ts
  • apps/web/components/assistant-chat/tools.tsx
🧰 Additional context used
📓 Path-based instructions (20)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/utils/outlook/message.ts
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
apps/web/app/**

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

NextJS app router structure with (app) directory

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
apps/web/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Use result?.serverError with toastError and toastSuccess
Use LoadingContent component to handle loading and error states consistently
Pass loading, error, and children props to LoadingContent

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
!{.cursor/rules/*.mdc}

📄 CodeRabbit Inference Engine (.cursor/rules/cursor-rules.mdc)

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/utils/outlook/message.ts
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/utils/outlook/message.ts
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
apps/web/app/(app)/*/**

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/(app)/*/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/(app)/*/**/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/page-structure.mdc)

If we're in a deeply nested component we will use swr to fetch via API

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Components with onClick must be client components with use client directive

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/utils/outlook/message.ts
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
!pages/_document.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/utils/outlook/message.ts
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
**/*.{jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
**/*.{html,jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...

Files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/app/(landing)/home/Testimonials.tsx
  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/gmail/message.ts
  • apps/web/utils/outlook/message.ts
apps/web/utils/gmail/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/gmail-api.mdc)

Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')

Files:

  • apps/web/utils/gmail/message.ts
apps/web/utils/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/gmail/message.ts
  • apps/web/utils/outlook/message.ts
apps/web/utils/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/gmail/message.ts
  • apps/web/utils/outlook/message.ts
apps/web/components/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

Use React Hook Form with Zod validation for form handling

Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Use PascalCase for components (e.g. components/Button.tsx)

Files:

  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
apps/web/components/!(ui)/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

All other components are in components/

Files:

  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
🧠 Learnings (42)
📓 Common learnings
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
📚 Learning: applies to *{tasks,assistant_chat,*.md} : keep the 'relevant files' section updated with file paths,...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/task-list.mdc:0-0
Timestamp: 2025-07-18T17:28:14.639Z
Learning: Applies to *{TASKS,ASSISTANT_CHAT,*.md} : Keep the 'Relevant Files' section updated with file paths, brief descriptions of each file's purpose, and status indicators (e.g., ✅) for completed components.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
📚 Learning: applies to apps/web/utils/gmail/**/*.ts : keep provider-specific implementation details isolated in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-07-18T15:05:34.899Z
Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/utils/gmail/message.ts
  • apps/web/utils/outlook/message.ts
📚 Learning: applies to apps/web/**/*.{ts,tsx} : path aliases: use `@/` for imports from project root...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/**/*.{ts,tsx} : Path aliases: Use `@/` for imports from project root

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
📚 Learning: applies to apps/web/app/(app)/*/ : components for the page are either in `page.tsx` or in the `apps/...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.505Z
Learning: Applies to apps/web/app/(app)/*/ : Components for the page are either in `page.tsx` or in the `apps/web/app/(app)/PAGE_NAME` folder

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
📚 Learning: in packages/resend/emails/digest.tsx, the digestemailprops type uses `[key: string]: digestitem[] | ...
Learnt from: edulelis
PR: elie222/inbox-zero#576
File: packages/resend/emails/digest.tsx:78-83
Timestamp: 2025-07-17T04:19:57.099Z
Learning: In packages/resend/emails/digest.tsx, the DigestEmailProps type uses `[key: string]: DigestItem[] | undefined | string | Date | undefined` instead of intersection types like `& Record<string, DigestItem[] | undefined>` due to implementation constraints. This was the initial implementation approach and cannot be changed to more restrictive typing.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/app/(app)/*/** : components for the page are either put in page.tsx, or in the a...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.269Z
Learning: Applies to apps/web/app/(app)/*/** : Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
📚 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-18T15:04:30.467Z
Learning: Applies to apps/web/**/*.tsx : Follow consistent naming conventions (PascalCase for components)

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx
📚 Learning: applies to apps/web/hooks/usefeatureflags.ts : use 'use[featurename]enabled' for boolean flag hook n...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.415Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Use 'use[FeatureName]Enabled' for boolean flag hook names and 'use[FeatureName]Variant' for variant flag hook names

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: `moredropdown` is a react component and `useunsubscribebutton` is a custom react hook, and they shou...
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`.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 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-18T15:04:30.467Z
Learning: Applies to apps/web/**/*.tsx : Prefer functional components with hooks

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/**/*.tsx : use shadcn/ui components when available...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/**/*.tsx : Use shadcn/ui components when available

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/hooks/usefeatureflags.ts : keep all feature flag hooks centralized in usefeature...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.415Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Keep all feature flag hooks centralized in useFeatureFlags.ts

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/utils/actions/*.ts : use `actionclient` when both authenticated user context and...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `actionClient` when both authenticated user context and a specific `emailAccountId` are needed. The `emailAccountId` must be bound when calling the action from the client.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to {app,components}/**/*.{ts,tsx} : use `result?.servererror` with `toasterror` and `toastsu...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/data-fetching.mdc:0-0
Timestamp: 2025-07-18T15:04:44.818Z
Learning: Applies to {app,components}/**/*.{ts,tsx} : Use `result?.serverError` with `toastError` and `toastSuccess` for error handling; success toast is optional

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 Learning: applies to apps/web/utils/actions/*.ts : access necessary context (like `userid`, `emailaccountid`, ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.ts : Access necessary context (like `userId`, `emailAccountId`, etc.) provided by the safe action client via the `ctx` object in the `.action()` handler.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/app/(app)/*/**/*.tsx : if you need to use onclick in a component, that component...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.269Z
Learning: Applies to apps/web/app/(app)/*/**/*.tsx : If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 Learning: applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : create dedicated hooks for specific data types (e.g...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.705Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Create dedicated hooks for specific data types (e.g., `useAccounts`, `useLabels`).

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/components/editor/extensions/MentionList.tsx
📚 Learning: guidelines for creating custom react hooks...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.644Z
Learning: Guidelines for creating custom React hooks

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 Learning: applies to apps/web/app/**/*.tsx : components with `onclick` must be client components with `use cli...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.505Z
Learning: Applies to apps/web/app/**/*.tsx : Components with `onClick` must be client components with `use client` directive

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 Learning: applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : custom hooks should encapsulate reusable stateful l...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/hooks.mdc:0-0
Timestamp: 2025-07-18T15:05:41.705Z
Learning: Applies to apps/web/hooks/use*.{js,jsx,ts,tsx} : Custom hooks should encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx
📚 Learning: guidelines for working with gmail api...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.644Z
Learning: Guidelines for working with Gmail API

Applied to files:

  • apps/web/utils/gmail/message.ts
📚 Learning: applies to apps/web/hooks/usefeatureflags.ts : use kebab-case for feature flag keys (e.g., 'inbox-cl...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.415Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Use kebab-case for feature flag keys (e.g., 'inbox-cleaner', 'pricing-options-2')

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/hooks/usefeatureflags.ts : all feature flag hooks should be defined in apps/web/...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.415Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : All feature flag hooks should be defined in apps/web/hooks/useFeatureFlags.ts

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/hooks/usefeatureflags.ts : always define types for variant flags...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-07-18T15:07:12.415Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Always define types for variant flags

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to **/*.{jsx,tsx} : use semantic elements instead of role attributes in jsx....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Use semantic elements instead of role attributes in JSX.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to apps/web/components/**/*form.tsx : use react hook form with zod resolver for form handlin...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.146Z
Learning: Applies to apps/web/components/**/*Form.tsx : Use React Hook Form with Zod resolver for form handling and validation.

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/components/**/*.tsx : use react hook form with zod validation for form handling...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/components/**/*.tsx : Use React Hook Form with Zod validation for form handling

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to components/**/*.tsx : use shadcn ui and tailwind for components and styling...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-07-19T17:50:22.078Z
Learning: Applies to components/**/*.tsx : Use Shadcn UI and Tailwind for components and styling

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/app/api/**/route.ts : use `withemailaccount` for email-account-level operations...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/app/api/**/route.ts : Use `withEmailAccount` for email-account-level operations

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: form handling using react hook form and zod...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/index.mdc:0-0
Timestamp: 2025-07-18T15:05:56.644Z
Learning: Form handling using React Hook Form and Zod

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to **/*.tsx : use react hook form with zod for validation...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.115Z
Learning: Applies to **/*.tsx : Use React Hook Form with Zod for validation

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to **/api/**/route.ts : use `withemailaccount` middleware for api routes that operate on a s...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-07-18T17:27:46.389Z
Learning: Applies to **/api/**/route.ts : Use `withEmailAccount` middleware for API routes that operate on a specific email account (i.e., use or require `emailAccountId`).

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/hooks/**/*.{ts,tsx} : call `mutate()` after successful mutations to refresh data...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/hooks/**/*.{ts,tsx} : Call `mutate()` after successful mutations to refresh data

Applied to files:

  • apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : include standard test cases: happy path, error handling...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Include standard test cases: happy path, error handling, edge cases (empty input, null values), different user configurations, and various input formats in LLM-related tests

Applied to files:

  • apps/web/app/(landing)/home/Testimonials.tsx
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : use descriptive console.debug statements for generated ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use descriptive console.debug statements for generated content in LLM-related tests

Applied to files:

  • apps/web/app/(landing)/home/Testimonials.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : make sure label elements have text content and are associated with ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Make sure label elements have text content and are associated with an input.

Applied to files:

  • apps/web/components/editor/extensions/MentionList.tsx
  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : don't use unnecessary labels....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't use unnecessary labels.

Applied to files:

  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : remove excessive whitespace and truncate long inputs i...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Applied to files:

  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : don't use duplicate case labels....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't use duplicate case labels.

Applied to files:

  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to **/*.{jsx,tsx} : don't assign to react component props....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Don't assign to React component props.

Applied to files:

  • apps/web/components/editor/extensions/LabelMention.tsx
📚 Learning: applies to **/*.{jsx,tsx} : use <>... instead of .......
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Use <>...</> instead of <Fragment>...</Fragment>.

Applied to files:

  • apps/web/components/editor/extensions/LabelMention.tsx
🧬 Code Graph Analysis (4)
apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx (1)
apps/web/components/Button.tsx (1)
  • Button (60-87)
apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx (1)
apps/web/components/LoadingContent.tsx (1)
  • LoadingContent (13-27)
apps/web/utils/outlook/message.ts (1)
apps/web/app/api/outlook/webhook/logger.ts (1)
  • logger (3-3)
apps/web/components/editor/extensions/MentionList.tsx (1)
apps/web/hooks/useLabels.ts (1)
  • UserLabel (6-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). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (23)
apps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx (2)

331-331: LGTM: Digest action type now unconditionally available

The addition of the Digest action type to the typeOptions array is correct and aligns with the removal of the useDigestEnabled feature flag.


335-335: LGTM: Dependency array correctly updated

The empty dependency array is appropriate since typeOptions no longer depends on any reactive values after removing the digestEnabled feature flag.

apps/web/components/editor/extensions/MentionList.tsx (1)

6-7: LGTM! Clean implementation of the create new label feature.

The extension of UserLabel with an optional isCreateNew property is well-structured, and the conditional rendering provides clear visual distinction between existing labels and the create option.

Also applies to: 82-91

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

7-87: LGTM! Well-implemented create new label feature with proper type safety.

The implementation correctly:

  • Limits suggestions to prevent UI overflow
  • Performs case-insensitive matching to prevent duplicates
  • Adds comprehensive TypeScript interfaces for markdown operations
  • Includes the create option only when there's no exact match

134-138: Good defensive programming to prevent race conditions.

The null checks and warning logs will help diagnose issues without crashing the application.


78-78: Good consistency in ID normalization.

Using toLowerCase() for both the create new ID and placeholder ID ensures consistent handling regardless of user input casing.

Also applies to: 257-261

apps/web/app/(landing)/home/Testimonials.tsx (5)

55-99: LGTM! Well-structured testimonial additions.

The new testimonial objects follow the existing pattern consistently and include meaningful user feedback with proper author attribution.


131-137: Good reorganization of testimonial display structure.

The desktop testimonials array has been restructured to include the new testimonials in a balanced layout. The grouping appears logical for visual presentation.


141-148: Improved mobile testimonial selection.

The mobile testimonials array has been updated to include a good mix of the new testimonials, ensuring mobile users see diverse feedback.


200-200: Consistent handle display formatting.

The removal of conditional "@" prefix logic creates a cleaner, more consistent display where handles are shown as-is from the data. This is a good UX improvement for uniformity.

Also applies to: 227-229, 281-281


49-62: Image assets existence confirmed

  • apps/web/public/images/testimonials/yoni.jpeg ✔
  • apps/web/public/images/testimonials/slim.png ✔

All other testimonial images (will.jpeg, valentine.png, joel.jpeg, steve-rad.png) are present in their respective public/images directories.
Testimonial data structures and image paths are accurate—no further action required.

apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsx (2)

1-4: LGTM! Clean import path updates and new component addition.

The import paths have been correctly updated to include the settings subdirectory, and the new DraftKnowledgeSetting component is properly imported.


10-10: Good component placement for logical grouping.

The DraftKnowledgeSetting component is well-positioned between DraftReplies and AboutSetting, keeping draft-related settings grouped together.

apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsx (2)

14-14: LGTM! Clean prop addition for feature control.

The enabled boolean prop is properly typed and provides clear control over the dialog's availability.


18-18: Correct disabled state logic.

The button is properly disabled when enabled is false, preventing interaction when the draft replies feature is not enabled.

apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsx (2)

35-46: LGTM! Clean LoadingContent implementation.

The loading, error handling, and skeleton loading state are properly implemented for the toggle component.


51-51: Good refactoring to export the hook for reusability.

Exporting useDraftReplies allows other components like DraftKnowledgeSetting to access the draft replies state, promoting code reuse and consistency.

apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsx (3)

1-1: Correct client directive usage.

The component properly uses the "use client" directive since it utilizes React hooks.


8-12: Clean state management and logic.

The component correctly uses the useDraftReplies hook and derives the isEnabled state with proper loading consideration.


20-27: Excellent UX with tooltip guidance.

The conditional rendering provides clear user guidance through the tooltip when the feature is disabled, explaining that draft replies must be enabled first. The wrapping <span> ensures the tooltip works correctly with the disabled button.

apps/web/utils/outlook/message.ts (1)

104-110: LGTM! Improved API consistency.

The refactoring to use an options object parameter improves consistency with other functions and makes the API more maintainable.

apps/web/utils/gmail/message.ts (2)

274-279: LGTM! Consistent API design.

The refactoring to use an options object parameter maintains consistency with the Outlook implementation and improves the function's API design.


280-293: LGTM! Proper rate limiting implementation.

The implementation correctly caps maxResults at 20 and logs a warning instead of throwing an error. This approach is more user-friendly and aligns with Gmail's actual rate limiting behavior.

Comment on lines 113 to 125
const MAX_RESULTS = 20;

const maxResults = Math.min(options.maxResults || MAX_RESULTS, MAX_RESULTS);

// Is this true for Microsoft Graph API or was it copy pasted from Gmail?
if (options.maxResults && options.maxResults > MAX_RESULTS) {
logger.warn(
"Max results is greater than 20, which will cause rate limiting",
{
maxResults,
},
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the rate limiting comment for Microsoft Graph API.

The implementation correctly caps maxResults at 20 and logs a warning instead of throwing an error. However, the comment raises a valid question about whether this rate limit applies to Microsoft Graph API.


🌐 Web query:

What are the rate limits and batch size limits for Microsoft Graph API /me/messages endpoint?

💡 Result:

The Microsoft Graph API imposes specific rate limits and concurrency restrictions to ensure optimal performance and service stability. For the /me/messages endpoint, which retrieves messages from the signed-in user's mailbox, the following limits apply:

Rate Limits:

  • Global Limit: An application can make up to 130,000 requests per 10 seconds across all tenants. (learn.microsoft.com)

  • Mailbox-Specific Limits: Each mailbox has its own set of limits:

    • Requests: Up to 10,000 API requests in a 10-minute period per mailbox.
    • Concurrent Requests: A maximum of four concurrent requests per mailbox. (learn.microsoft.com)

Batching:

  • Batch Request Limit: Microsoft Graph allows batching of up to 20 individual requests in a single HTTP call. (learn.microsoft.com)

  • Concurrency in Batches: When batching requests to the /me/messages endpoint, be aware that the mailbox concurrency limit of four concurrent requests still applies. This means that even within a batch, only four requests can be processed simultaneously. To manage this, you can use the dependsOn property to sequence requests within the batch, ensuring they execute sequentially and adhere to the concurrency limit. (gsexdev.blogspot.com)

Best Practices to Avoid Throttling:

  • Optimize Data Retrieval: Use query parameters like $select to retrieve only the necessary fields and $filter to narrow down results, reducing the amount of data processed and minimizing the risk of throttling. (mrmicrosoft.com)

  • Implement Exponential Backoff: If your application receives a 429 Too Many Requests response, implement a retry strategy that waits for the duration specified in the Retry-After header before retrying the request. This approach helps in managing request rates and adhering to service limits. (mrmicrosoft.com)

By understanding and adhering to these rate limits and best practices, you can ensure efficient and reliable interactions with the Microsoft Graph API's /me/messages endpoint.

Citations:


Clarify Microsoft Graph /me/messages limits and adjust MAX_RESULTS

Microsoft Graph does not impose a 20-item page size on /me/messages—that cap only applies to batch payloads (you can include up to 20 sub-requests in one batch). In fact, you can request up to 1,000 messages in a single GET via the $top parameter, and Graph’s throttling is governed by overall/global quotas (130 k requests/10 s), mailbox-specific quotas (10 k requests/10 min, 4 concurrent), and 429 responses with Retry-After.

Action items:

  • Decide whether MAX_RESULTS is meant to limit • page size (GET /me/messages via $top, max 1000) or • batch size (max 20 sub-requests per /batch).
  • If it’s page size, raise or remove the 20-item cap and update the default accordingly.
  • If it’s batch size, rename MAX_RESULTS (e.g. MAX_BATCH_REQUESTS) and adjust the warning to say “Batch size greater than 20 may be rejected” instead of “rate limiting.”
  • Update the logger message to reference the correct Graph API limits (batch vs. concurrency) and suggest handling 429/Retry-After for throttling.
🤖 Prompt for AI Agents
In apps/web/utils/outlook/message.ts around lines 113 to 125, clarify the
purpose of MAX_RESULTS by determining if it limits the page size for GET
/me/messages or the batch size for /batch requests. If it limits page size,
increase or remove the 20-item cap and update the default accordingly. If it
limits batch size, rename MAX_RESULTS to MAX_BATCH_REQUESTS and revise the
warning message to indicate that batch sizes over 20 may be rejected, not just
rate limited. Also, update the logger message to accurately reflect Microsoft
Graph API limits and recommend handling 429 responses with Retry-After headers
for throttling.

Copy link

@johnlowe399-blip johnlowe399-blip left a comment

Choose a reason for hiding this comment

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

apps/web/app/(app)/[emailAccountId]/usage/usage.tsx

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: 1

🔭 Outside diff range comments (2)
apps/web/components/email-list/EmailMessage.tsx (2)

176-179: Fix misplaced onClick handler.

The onClick handler is incorrectly placed on the ForwardIcon instead of the Button element.

-            <Tooltip content="Forward">
-              <Button variant="ghost" size="icon">
-                <ForwardIcon className="h-4 w-4" onClick={onForward} />
-                <span className="sr-only">Forward</span>
-              </Button>
-            </Tooltip>
+            <Tooltip content="Forward">
+              <Button variant="ghost" size="icon" onClick={onForward}>
+                <ForwardIcon className="h-4 w-4" />
+                <span className="sr-only">Forward</span>
+              </Button>
+            </Tooltip>

246-246: Remove console usage.

According to the coding guidelines, console usage should be avoided in production code.

-        console.error(result);
+        // Handle error appropriately - consider using a proper error logging service
+        // or displaying user-friendly error message

Consider using a proper logging service or displaying a user-friendly error message instead.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c16439 and ad4391f.

📒 Files selected for processing (14)
  • apps/web/components/AccountSwitcher.tsx (1 hunks)
  • apps/web/components/Combobox.tsx (0 hunks)
  • apps/web/components/PlanBadge.tsx (1 hunks)
  • apps/web/components/ReferralDialog.tsx (1 hunks)
  • apps/web/components/SideNav.tsx (2 hunks)
  • apps/web/components/SideNavMenu.tsx (1 hunks)
  • apps/web/components/assistant-chat/message-editor.tsx (3 hunks)
  • apps/web/components/email-list/EmailMessage.tsx (1 hunks)
  • apps/web/components/ui/sidebar.tsx (16 hunks)
  • apps/web/utils/ai/example-matches/find-example-matches.ts (3 hunks)
  • apps/web/utils/ai/group/create-group.ts (5 hunks)
  • apps/web/utils/ai/rule/generate-rules-prompt.ts (2 hunks)
  • apps/web/utils/ai/rule/prompt-to-rules.ts (2 hunks)
  • apps/web/utils/redis/subscriber.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/components/Combobox.tsx
✅ Files skipped from review due to trivial changes (3)
  • apps/web/utils/redis/subscriber.ts
  • apps/web/components/SideNavMenu.tsx
  • apps/web/components/ReferralDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/components/AccountSwitcher.tsx
  • apps/web/components/SideNav.tsx
  • apps/web/components/ui/sidebar.tsx
  • apps/web/components/assistant-chat/message-editor.tsx
🧰 Additional context used
📓 Path-based instructions (16)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
!{.cursor/rules/*.mdc}

📄 CodeRabbit Inference Engine (.cursor/rules/cursor-rules.mdc)

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
apps/web/utils/{ai,llms}/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*: LLM-related code must be organized in the directories: apps/web/utils/ai/, apps/web/utils/llms/, and apps/web/tests/ for LLM-specific tests.
Keep related AI functions in the same file or directory.

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
apps/web/utils/{ai,llms}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*.ts: Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
Keep system prompts and user prompts separate in LLM-related code.
System prompt should define the LLM's role and task specifications.
User prompt should contain the actual data and context.
Always define a Zod schema for response validation in LLM-related functions.
Make Zod schemas as specific as possible to guide the LLM output.
Use descriptive scoped loggers for each LLM feature.
Log inputs and outputs with appropriate log levels in LLM-related functions.
Include relevant context in log messages for LLM-related code.
Implement early returns for invalid inputs in LLM-related functions.
Use proper error types and logging in LLM-related code.
Implement fallbacks for AI failures in LLM-related functions.
Add retry logic for transient failures using withRetry in LLM-related code.
Use XML-like tags to structure data in LLM prompts.
Remove excessive whitespace and truncate long inputs in LLM prompts.
Format data consistently across similar LLM-related functions.
Use TypeScript types for all parameters and return values in LLM-related code.
Define clear interfaces for complex input/output structures in LLM-related code.
Extract common patterns into utility functions in LLM-related code.
Document complex AI logic with clear comments in LLM-related code.

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
apps/web/utils/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
apps/web/utils/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
!pages/_document.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
apps/web/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Use result?.serverError with toastError and toastSuccess
Use LoadingContent component to handle loading and error states consistently
Pass loading, error, and children props to LoadingContent

Files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
apps/web/components/**/*.tsx

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

Use React Hook Form with Zod validation for form handling

Use the LoadingContent component to handle loading and error states consistently in data-fetching components.

Use PascalCase for components (e.g. components/Button.tsx)

Files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields

Files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
**/*.{jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.

Files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
**/*.{html,jsx,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...

Files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
apps/web/components/!(ui)/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

All other components are in components/

Files:

  • apps/web/components/email-list/EmailMessage.tsx
🧠 Learnings (48)
📓 Common learnings
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : make zod schemas as specific as possible to guide the ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : extract common patterns into utility functions in llm-...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : test both ai and non-ai paths in llm-related tests...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : implement fallbacks for ai failures in llm-related fun...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use typescript types for all parameters and return val...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : define clear interfaces for complex input/output struc...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : document complex ai logic with clear comments in llm-r...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : format data consistently across similar llm-related fu...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : follow the standard structure for llm-related function...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use proper error types and logging in llm-related code...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
📚 Learning: the `utils` folder also contains core app logic such as next.js server actions and gmail api request...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-19T17:50:28.270Z
Learning: The `utils` folder also contains core app logic such as Next.js Server Actions and Gmail API requests.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
📚 Learning: applies to apps/web/utils/gmail/**/*.ts : keep provider-specific implementation details isolated in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-07-18T15:05:34.899Z
Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : always define a zod schema for response validation in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : remove excessive whitespace and truncate long inputs i...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Applied to files:

  • apps/web/utils/ai/example-matches/find-example-matches.ts
  • apps/web/utils/ai/group/create-group.ts
  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : don't use useless case statements in switch statements....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't use useless case statements in switch statements.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : don't use duplicate case labels....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't use duplicate case labels.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : don't use unnecessary labels....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't use unnecessary labels.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : make sure default clauses in switch statements come last....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure default clauses in switch statements come last.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{ts,tsx} : don't use the typescript directive @ts-ignore....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{ts,tsx} : Don't use the TypeScript directive ts-ignore.

Applied to files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{ts,tsx} : don't use primitive type aliases or misleading types....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{ts,tsx} : Don't use primitive type aliases or misleading types.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : don't use explicit role property that's the same as the implicit/de...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Don't use explicit role property that's the same as the implicit/default role.

Applied to files:

  • apps/web/components/PlanBadge.tsx
  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : make sure to pass a message value when creating a built-in error....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to apps/web/utils/actions/*.ts : use the `.metadata({ name: "actionname" })` method to provi...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.ts : Use the `.metadata({ name: "actionName" })` method to provide a meaningful name for monitoring. Sentry instrumentation is automatically applied via `withServerActionInstrumentation` within the safe action clients.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to apps/web/utils/actions/*.ts : use `actionclient` when both authenticated user context and...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `actionClient` when both authenticated user context and a specific `emailAccountId` are needed. The `emailAccountId` must be bound when calling the action from the client.

Applied to files:

  • apps/web/components/PlanBadge.tsx
📚 Learning: applies to **/*.{jsx,tsx} : don't insert comments as text nodes....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Don't insert comments as text nodes.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{jsx,tsx} : use semantic elements instead of role attributes in jsx....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Use semantic elements instead of role attributes in JSX.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{jsx,tsx} : don't use event handlers on non-interactive elements....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Don't use event handlers on non-interactive elements.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : don't assign interactive aria roles to non-interactive html element...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Don't assign interactive ARIA roles to non-interactive HTML elements.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{jsx,tsx} : don't use unnecessary fragments....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Don't use unnecessary fragments.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: in packages/resend/emails/digest.tsx, the digestemailprops type uses `[key: string]: digestitem[] | ...
Learnt from: edulelis
PR: elie222/inbox-zero#576
File: packages/resend/emails/digest.tsx:78-83
Timestamp: 2025-07-17T04:19:57.099Z
Learning: In packages/resend/emails/digest.tsx, the DigestEmailProps type uses `[key: string]: DigestItem[] | undefined | string | Date | undefined` instead of intersection types like `& Record<string, DigestItem[] | undefined>` due to implementation constraints. This was the initial implementation approach and cannot be changed to more restrictive typing.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
  • apps/web/utils/ai/group/create-group.ts
📚 Learning: applies to **/*.{html,jsx,tsx} : don't add aria roles, states, and properties to elements that don't...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Don't add ARIA roles, states, and properties to elements that don't support them.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : accompany onclick with at least one of: onkeyup, onkeydown, or onke...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{jsx,tsx} : don't use array index in keys....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{jsx,tsx} : Don't use Array index in keys.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : accompany onmouseover/onmouseout with onfocus/onblur....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Accompany onMouseOver/onMouseOut with onFocus/onBlur.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : make static elements with click handlers use a valid role attribute...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Make static elements with click handlers use a valid role attribute.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to apps/web/app/**/*.tsx : components with `onclick` must be client components with `use cli...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.505Z
Learning: Applies to apps/web/app/**/*.tsx : Components with `onClick` must be client components with `use client` directive

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : make sure anchors have content that's accessible to screen readers....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Make sure anchors have content that's accessible to screen readers.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to apps/web/app/(app)/*/**/*.tsx : if you need to use onclick in a component, that component...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-07-18T15:07:00.269Z
Learning: Applies to apps/web/app/(app)/*/**/*.tsx : If you need to use onClick in a component, that component is a client component and file must start with 'use client'

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to **/*.{html,jsx,tsx} : don't set aria-hidden="true" on focusable elements....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{html,jsx,tsx} : Don't set aria-hidden="true" on focusable elements.

Applied to files:

  • apps/web/components/email-list/EmailMessage.tsx
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : system prompt should define the llm's role and task sp...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Applied to files:

  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : user prompt should contain the actual data and context...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Applied to files:

  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : keep system prompts and user prompts separate in llm-r...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use xml-like tags to structure data in llm prompts....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use XML-like tags to structure data in LLM prompts.

Applied to files:

  • apps/web/utils/ai/rule/generate-rules-prompt.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/app/api/**/route.ts : use `withemailaccount` for email-account-level operations...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/app/api/**/route.ts : Use `withEmailAccount` for email-account-level operations

Applied to files:

  • apps/web/utils/ai/rule/generate-rules-prompt.ts
📚 Learning: applies to apps/web/utils/actions/**/*.ts : use zod schemas for validation on both client and server...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Applied to files:

  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/actions/*.validation.ts : define zod schemas for validation in dedicated f...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.146Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Applied to files:

  • apps/web/utils/ai/rule/prompt-to-rules.ts
📚 Learning: applies to apps/web/utils/actions/*.validation.ts : define input validation schemas using zod in the...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in the corresponding `.validation.ts` file. These schemas are used by `next-safe-action` (`.schema()`) and can also be reused on the client for form validation.

Applied to files:

  • apps/web/utils/ai/rule/prompt-to-rules.ts
⏰ 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: Jit Security
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (16)
apps/web/components/PlanBadge.tsx (2)

165-165: LGTM: Lint comment simplification.

The simplification from <explanation> to ignore is cleaner and more direct for the intentional fallthrough case.


170-170: LGTM: Lint comment simplification.

The simplification from <explanation> to ignore is cleaner and more direct for the intentional fallthrough case.

apps/web/utils/ai/rule/prompt-to-rules.ts (3)

1-1: LGTM - Import addition for AI SDK v5 migration.

The import of tool from "ai" package is necessary for the new tool definition pattern and follows TypeScript import guidelines.


81-85: LGTM - Tool definition updated to AI SDK v5 pattern.

The migration from object literal to tool() function call with inputSchema correctly adopts the new AI SDK v5 conventions and improves type inference.


90-95: LGTM - Improved tool call result extraction.

The change to search for the specific tool call by toolName rather than assuming it's the first element is more robust. Using input instead of args and TypeScript inference for type casting follows the new AI SDK v5 conventions.

apps/web/utils/ai/example-matches/find-example-matches.ts (3)

1-1: LGTM - Consistent import for AI SDK v5 migration.

The import addition is consistent with the broader migration pattern across AI utility files.


101-105: LGTM - Tool definition follows new conventions.

The migration to tool() function with inputSchema is correctly implemented. Using the computed property name with the FIND_EXAMPLE_MATCHES constant is good practice for maintainability.


116-118: LGTM - Tool call result extraction updated correctly.

The change from args to input in the destructuring correctly implements the new AI SDK v5 API while maintaining the existing logic.

apps/web/utils/ai/rule/generate-rules-prompt.ts (3)

1-1: LGTM - Standard import for AI SDK v5 migration.

Consistent import pattern with other AI utility files in the migration.


117-126: LGTM - Conditional tool definition correctly migrated.

The ternary operator correctly selects between different schemas based on the hasSnippets flag, and both branches properly use the new tool() function with inputSchema.


131-135: LGTM - Robust tool call result extraction.

Using find() to locate the specific tool call by name and accessing input instead of args follows the new API conventions and is more robust than array indexing.

apps/web/utils/ai/group/create-group.ts (5)

1-1: LGTM - Consistent import pattern.

The import follows the same pattern as other migrated AI utility files.


99-103: LGTM - First tool definition migrated correctly.

The GENERATE_GROUP_ITEMS tool definition correctly uses the tool() function with inputSchema and maintains the computed property name pattern.


117-118: LGTM - Tool call extraction in reduce function updated correctly.

The change from args to input in the reduce function correctly implements the new API while preserving the aggregation logic.


170-174: LGTM - Second tool definition follows migration pattern.

The VERIFY_GROUP_ITEMS tool definition is consistently migrated using the same pattern as other tools in the file.


188-193: LGTM - Final tool call extraction updated correctly.

The extraction of the verification result correctly uses input instead of args and maintains the logic of using the last tool call result.


return (
// biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
// biome-ignore lint/a11y/useKeyWithClickEvents: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Address the accessibility violation instead of ignoring it.

The biome linter is flagging a real accessibility issue - the <li> element has an onClick handler without corresponding keyboard event handlers, making it inaccessible to keyboard users.

Instead of ignoring this lint rule, fix the accessibility issue by adding keyboard support:

-    // biome-ignore lint/a11y/useKeyWithClickEvents: ignore
+    <li
+      className={cn(
+        "bg-background p-4 shadow sm:rounded-lg",
+        !expanded && "cursor-pointer",
+      )}
+      onClick={onExpand}
+      onKeyDown={(e) => {
+        if (e.key === 'Enter' || e.key === ' ') {
+          e.preventDefault();
+          onExpand();
+        }
+      }}
+      tabIndex={expanded ? undefined : 0}
+      role={expanded ? undefined : "button"}
+      aria-expanded={expanded}
+    >

Or consider using a <button> element instead of <li> for the interactive functionality while maintaining the list structure with proper semantic markup.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/web/components/email-list/EmailMessage.tsx at line 68, the <li> element
has an onClick handler but lacks keyboard event handlers, causing an
accessibility violation. Fix this by adding appropriate keyboard event handlers
(e.g., onKeyDown or onKeyPress) to support keyboard interaction, or replace the
<li> with a <button> element styled to fit within the list while preserving
semantic meaning and accessibility.

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: 1

🧹 Nitpick comments (2)
apps/web/utils/ai/rule/diff-rules.ts (1)

22-30: Complete LLM function structure compliance.

Consider adding input logging and error handling to fully comply with LLM coding guidelines.

Add input logging and error handling:

 export async function aiDiffRules({
   emailAccount,
   oldPromptFile,
   newPromptFile,
 }: {
   // ... existing params
 }) {
+  logger.info("Analyzing rule differences", {
+    oldPromptLength: oldPromptFile.length,
+    newPromptLength: newPromptFile.length,
+  });
+
+  try {
     const diff = createPatch("prompt", oldPromptFile, newPromptFile);
     // ... rest of existing logic
     
     logger.trace("Result", { parsedRules });
     
     return parsedRules;
+  } catch (error) {
+    logger.error("Failed to diff rules", { error });
+    throw error;
+  }
 }
apps/web/utils/ai/rule/create-rule.ts (1)

11-14: Consider adding complete LLM function structure compliance.

To fully follow the LLM coding guidelines, consider adding input logging and error handling.

Add input logging and error handling:

 export async function aiCreateRule(
   instructions: string,
   emailAccount: EmailAccountWithAI,
 ): Promise<CreateOrUpdateRuleSchemaWithCategories> {
+  logger.info("Creating rule", {
+    instructionsLength: instructions.length,
+    userEmail: emailAccount.email,
+  });
+
+  try {
     const system =
       "You are an AI assistant that helps people manage their emails.";
     const prompt = `Generate a rule for these instructions:\n${instructions}`;
     
     // ... rest of existing logic
     
     logger.trace("Result", { result });
     
     return result as CreateOrUpdateRuleSchemaWithCategories;
+  } catch (error) {
+    logger.error("Failed to create rule", { error, instructions });
+    throw error;
+  }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e362bf1 and b8dd4a6.

📒 Files selected for processing (9)
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts (2 hunks)
  • apps/web/utils/ai/choose-rule/choose-args.ts (0 hunks)
  • apps/web/utils/ai/clean/ai-clean-select-labels.ts (1 hunks)
  • apps/web/utils/ai/rule/create-rule.ts (2 hunks)
  • apps/web/utils/ai/rule/diff-rules.ts (2 hunks)
  • apps/web/utils/ai/rule/find-existing-rules.ts (2 hunks)
  • apps/web/utils/ai/rule/prompt-to-rules.ts (4 hunks)
  • apps/web/utils/assistant/process-assistant-email.ts (1 hunks)
  • apps/web/utils/llms/index.ts (12 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/utils/ai/choose-rule/choose-args.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/web/utils/ai/clean/ai-clean-select-labels.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/utils/ai/choose-rule/ai-choose-args.ts
  • apps/web/utils/ai/rule/prompt-to-rules.ts
🧰 Additional context used
📓 Path-based instructions (11)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
!{.cursor/rules/*.mdc}

📄 CodeRabbit Inference Engine (.cursor/rules/cursor-rules.mdc)

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
apps/web/utils/{ai,llms}/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*: LLM-related code must be organized in the directories: apps/web/utils/ai/, apps/web/utils/llms/, and apps/web/tests/ for LLM-specific tests.
Keep related AI functions in the same file or directory.

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
apps/web/utils/{ai,llms}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*.ts: Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
Keep system prompts and user prompts separate in LLM-related code.
System prompt should define the LLM's role and task specifications.
User prompt should contain the actual data and context.
Always define a Zod schema for response validation in LLM-related functions.
Make Zod schemas as specific as possible to guide the LLM output.
Use descriptive scoped loggers for each LLM feature.
Log inputs and outputs with appropriate log levels in LLM-related functions.
Include relevant context in log messages for LLM-related code.
Implement early returns for invalid inputs in LLM-related functions.
Use proper error types and logging in LLM-related code.
Implement fallbacks for AI failures in LLM-related functions.
Add retry logic for transient failures using withRetry in LLM-related code.
Use XML-like tags to structure data in LLM prompts.
Remove excessive whitespace and truncate long inputs in LLM prompts.
Format data consistently across similar LLM-related functions.
Use TypeScript types for all parameters and return values in LLM-related code.
Define clear interfaces for complex input/output structures in LLM-related code.
Extract common patterns into utility functions in LLM-related code.
Document complex AI logic with clear comments in LLM-related code.

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
apps/web/utils/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
apps/web/utils/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
!pages/_document.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
apps/web/utils/llms/index.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

The core LLM functionality must be implemented in utils/llms/index.ts.

Files:

  • apps/web/utils/llms/index.ts
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : follow the standard structure for llm-related function...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : document complex ai logic with clear comments in llm-r...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : make zod schemas as specific as possible to guide the ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Make Zod schemas as specific as possible to guide the LLM output.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : implement fallbacks for ai failures in llm-related fun...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/assistant/process-assistant-email.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : extract common patterns into utility functions in llm-...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Extract common patterns into utility functions in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : define clear interfaces for complex input/output struc...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use typescript types for all parameters and return val...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use proper error types and logging in llm-related code...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use proper error types and logging in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : include relevant context in log messages for llm-relat...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Include relevant context in log messages for LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : format data consistently across similar llm-related fu...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format data consistently across similar LLM-related functions.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use descriptive scoped loggers for each llm feature....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use descriptive scoped loggers for each LLM feature.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : always define a zod schema for response validation in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Always define a Zod schema for response validation in LLM-related functions.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : log inputs and outputs with appropriate log levels in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Log inputs and outputs with appropriate log levels in LLM-related functions.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : user prompt should contain the actual data and context...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : keep system prompts and user prompts separate in llm-r...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Keep system prompts and user prompts separate in LLM-related code.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : system prompt should define the llm's role and task sp...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Applied to files:

  • apps/web/utils/ai/rule/diff-rules.ts
  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/ai/rule/create-rule.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : remove excessive whitespace and truncate long inputs i...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Remove excessive whitespace and truncate long inputs in LLM prompts.

Applied to files:

  • apps/web/utils/assistant/process-assistant-email.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : test both ai and non-ai paths in llm-related tests...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Applied to files:

  • apps/web/utils/ai/rule/find-existing-rules.ts
📚 Learning: applies to apps/web/utils/actions/**/*.ts : use zod schemas for validation on both client and server...
Learnt from: CR
PR: elie222/inbox-zero#0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use Zod schemas for validation on both client and server

Applied to files:

  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/actions/*.validation.ts : define zod schemas for validation in dedicated f...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-07-18T15:05:16.146Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod schemas for validation in dedicated files and use them for both client and server validation.

Applied to files:

  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/actions/*.validation.ts : define input validation schemas using zod in the...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-07-18T17:27:58.249Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in the corresponding `.validation.ts` file. These schemas are used by `next-safe-action` (`.schema()`) and can also be reused on the client for form validation.

Applied to files:

  • apps/web/utils/ai/rule/find-existing-rules.ts
  • apps/web/utils/llms/index.ts
📚 Learning: applies to **/*.{js,jsx,ts,tsx} : make sure to pass a message value when creating a built-in error....
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.

Applied to files:

  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/app/api/**/*.{ts,js} : request bodies in api routes should use zod schemas for v...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.968Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Request bodies in API routes should use Zod schemas for validation.

Applied to files:

  • apps/web/utils/llms/index.ts
📚 Learning: applies to **/*.ts : define validation schemas using zod...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-07-18T15:04:57.115Z
Learning: Applies to **/*.ts : Define validation schemas using Zod

Applied to files:

  • apps/web/utils/llms/index.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : add retry logic for transient failures using withretry...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Add retry logic for transient failures using withRetry in LLM-related code.

Applied to files:

  • apps/web/utils/llms/index.ts
🧬 Code Graph Analysis (2)
apps/web/utils/ai/rule/find-existing-rules.ts (1)
apps/web/utils/llms/index.ts (1)
  • chatCompletionObject (111-115)
apps/web/utils/llms/index.ts (4)
apps/web/utils/usage.ts (1)
  • saveAiUsage (8-41)
apps/web/utils/error.ts (1)
  • captureException (63-75)
apps/web/utils/llms/types.ts (1)
  • UserAIFields (3-9)
apps/web/utils/llms/model.ts (1)
  • ModelType (16-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: Jit Security
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
apps/web/utils/assistant/process-assistant-email.ts (1)

224-225: LGTM! Tool input property access updated correctly.

The change from lastToolCall.args.content to lastToolCall.input.content aligns with the AI SDK v5 migration where tool call inputs are now accessed via the input property. The fallback to empty string maintains proper error handling.

apps/web/utils/ai/rule/find-existing-rules.ts (2)

2-2: LGTM! Updated to use chatCompletionObject API.

The import change aligns with the AI SDK v5 migration to use the new chatCompletionObject function.


47-58: LGTM! Simplified API call with schema-driven approach.

The migration from chatCompletionTools to chatCompletionObject with direct schema parameters is cleaner and more consistent. The parameter rename from label to usageLabel aligns with the updated API.

apps/web/utils/ai/rule/diff-rules.ts (2)

3-7: LGTM! Proper imports for the updated API and logging.

Good addition of chatCompletionObject and scoped logger imports to support the AI SDK v5 migration.


60-72: LGTM! Excellent migration to chatCompletionObject with logging.

The update to use chatCompletionObject with direct schema parameters is clean and consistent with the AI SDK v5 migration. The simplified response parsing and added trace logging improve observability.

apps/web/utils/ai/rule/create-rule.ts (2)

2-9: LGTM! Proper imports for the updated API and logging.

Good additions to support the AI SDK v5 migration with chatCompletionObject and scoped logger.


19-34: LGTM! Clean migration to chatCompletionObject with logging.

The update to use direct schema parameters and simplified response parsing is excellent. The added trace logging and explicit type casting improve code quality and observability.

apps/web/utils/llms/index.ts (8)

4-16: LGTM! Updated imports for AI SDK v5.

The imports correctly reflect the AI SDK v5 migration with ModelMessage replacing older message types, and new streaming utilities like stepCountIs for more flexible step control.


94-96: LGTM! Enhanced schema support for chatCompletionObject.

The addition of optional schemaName and schemaDescription parameters provides better schema documentation and debugging capabilities.


107-108: LGTM! Updated message type for consistency.

Using ModelMessage[] aligns with the AI SDK v5 migration and provides better type safety.


141-144: LGTM! Proper schema configuration for object generation.

The explicit output: "object" configuration and schema parameters ensure correct object generation behavior with the updated AI SDK.


201-234: Excellent improvement to streaming callback handling.

The changes implement several best practices:

  1. stepCountIs(maxSteps) provides more flexible step control
  2. Concurrent promise handling with Promise.all() improves performance
  3. Comprehensive error handling with proper logging and exception capture
  4. Detailed context in error logs for debugging

254-290: LGTM! Enhanced type safety with generic tools support.

The addition of generic typing <TOOLS extends ToolSet = ToolSet> provides better type safety for tool definitions while maintaining backward compatibility with the default ToolSet.


304-304: LGTM! Consistent use of stepCountIs pattern.

The migration from maxSteps parameter to stepCountIs(maxSteps) provides a more flexible and consistent approach to step control across all streaming functions.


327-378: LGTM! Commented function follows updated patterns.

Good practice to keep the unused function as a reference while updating it to follow the new patterns (stepCountIs, concurrent promise handling). The implementation demonstrates the same improvements seen in the active streaming functions.

const parsedRules = aiResponse.toolCalls[0]?.args as z.infer<
typeof parameters
>;
const parsedRules = aiResponse.object;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add missing LLM function structure compliance.

This LLM-related function should follow the standard structure outlined in the coding guidelines. Consider adding:

  1. Scoped logger with input/output logging
  2. Error handling with fallbacks
  3. Input validation

Add the missing structure:

+import { createScopedLogger } from "@/utils/logger";
+
+const logger = createScopedLogger("ai-find-existing-rules");
+
 export async function aiFindExistingRules({
   emailAccount,
   promptRulesToEdit,
   promptRulesToRemove,
   databaseRules,
 }: {
   // ... existing params
 }) {
+  logger.info("Finding existing rules", {
+    promptRulesToEditCount: promptRulesToEdit.length,
+    promptRulesToRemoveCount: promptRulesToRemove.length,
+    databaseRulesCount: databaseRules.length,
+  });
+
+  try {
     // ... existing logic
     
+    logger.trace("AI Response", { parsedRules });
     
     return {
       editedRules: existingRules.filter((rule) => rule.toEdit),
       removedRules: existingRules.filter((rule) => rule.toRemove),
     };
+  } catch (error) {
+    logger.error("Failed to find existing rules", { error });
+    // Add appropriate fallback logic
+    throw error;
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const parsedRules = aiResponse.object;
import { createScopedLogger } from "@/utils/logger";
const logger = createScopedLogger("ai-find-existing-rules");
export async function aiFindExistingRules({
emailAccount,
promptRulesToEdit,
promptRulesToRemove,
databaseRules,
}: {
// ... existing params
}) {
logger.info("Finding existing rules", {
promptRulesToEditCount: promptRulesToEdit.length,
promptRulesToRemoveCount: promptRulesToRemove.length,
databaseRulesCount: databaseRules.length,
});
try {
const parsedRules = aiResponse.object;
// ... existing logic
logger.trace("AI Response", { parsedRules });
return {
editedRules: existingRules.filter((rule) => rule.toEdit),
removedRules: existingRules.filter((rule) => rule.toRemove),
};
} catch (error) {
logger.error("Failed to find existing rules", { error });
// Add appropriate fallback logic
throw error;
}
}
🤖 Prompt for AI Agents
In apps/web/utils/ai/rule/find-existing-rules.ts at line 58, the assignment to
parsedRules lacks the standard LLM function structure. Refactor the function to
include a scoped logger that logs inputs and outputs, add proper error handling
with fallback values to prevent crashes, and implement input validation to
ensure the function receives valid data before processing.

@elie222 elie222 changed the title WIP: migrate to ai sdk v5 Migrate to ai sdk v5 Aug 6, 2025
@claude
Copy link

claude bot commented Aug 6, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude
Copy link

claude bot commented Aug 6, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

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: 1

🔭 Outside diff range comments (1)
apps/web/utils/llms/model.test.ts (1)

34-36: Remove unused Ollama mock.

Since Ollama support has been removed and the related test is commented out, this mock is no longer needed and should be removed to keep the test file clean.

Apply this diff to remove the unused mock:

-vi.mock("ollama-ai-provider", () => ({
-  createOllama: vi.fn(() => (model: string) => ({ model })),
-}));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a61d5f8 and 994735d.

📒 Files selected for processing (1)
  • apps/web/utils/llms/model.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use @/ for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX

Files:

  • apps/web/utils/llms/model.test.ts
!{.cursor/rules/*.mdc}

📄 CodeRabbit Inference Engine (.cursor/rules/cursor-rules.mdc)

Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location

Files:

  • apps/web/utils/llms/model.test.ts
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/form-handling.mdc)

**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod

Files:

  • apps/web/utils/llms/model.test.ts
apps/web/utils/{ai,llms}/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*: LLM-related code must be organized in the directories: apps/web/utils/ai/, apps/web/utils/llms/, and apps/web/tests/ for LLM-specific tests.
Keep related AI functions in the same file or directory.

Files:

  • apps/web/utils/llms/model.test.ts
apps/web/utils/{ai,llms}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/llm.mdc)

apps/web/utils/{ai,llms}/**/*.ts: Follow the standard structure for LLM-related functions: use a scoped logger, define a Zod schema for output, validate inputs early, separate system and user prompts, log inputs and outputs, call chatCompletionObject with proper configuration, and return validated results.
Keep system prompts and user prompts separate in LLM-related code.
System prompt should define the LLM's role and task specifications.
User prompt should contain the actual data and context.
Always define a Zod schema for response validation in LLM-related functions.
Make Zod schemas as specific as possible to guide the LLM output.
Use descriptive scoped loggers for each LLM feature.
Log inputs and outputs with appropriate log levels in LLM-related functions.
Include relevant context in log messages for LLM-related code.
Implement early returns for invalid inputs in LLM-related functions.
Use proper error types and logging in LLM-related code.
Implement fallbacks for AI failures in LLM-related functions.
Add retry logic for transient failures using withRetry in LLM-related code.
Use XML-like tags to structure data in LLM prompts.
Remove excessive whitespace and truncate long inputs in LLM prompts.
Format data consistently across similar LLM-related functions.
Use TypeScript types for all parameters and return values in LLM-related code.
Define clear interfaces for complex input/output structures in LLM-related code.
Extract common patterns into utility functions in LLM-related code.
Document complex AI logic with clear comments in LLM-related code.

Files:

  • apps/web/utils/llms/model.test.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)

**/*.{ts,tsx}: Use createScopedLogger for logging in backend TypeScript files
Typically add the logger initialization at the top of the file when using createScopedLogger
Only use .with() on a logger instance within a specific function, not for a global logger

Import Prisma in the project using import prisma from "@/utils/prisma";

**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.

Files:

  • apps/web/utils/llms/model.test.ts
**/*.test.{ts,js}

📄 CodeRabbit Inference Engine (.cursor/rules/security.mdc)

Include security tests in your test suites to verify authentication, authorization, and error handling.

Files:

  • apps/web/utils/llms/model.test.ts
**/*.test.{ts,js,tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/testing.mdc)

**/*.test.{ts,js,tsx,jsx}: Tests are colocated next to the tested file (e.g., dir/format.ts and dir/format.test.ts)
Use vi.mock("server-only", () => ({})); to mock the server-only module in tests
Mock @/utils/prisma in tests using vi.mock("@/utils/prisma") and use the provided prisma mock
Mock external dependencies in tests
Clean up mocks between tests
Do not mock the Logger

Files:

  • apps/web/utils/llms/model.test.ts
apps/web/utils/**

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

Create utility functions in utils/ folder for reusable logic

Files:

  • apps/web/utils/llms/model.test.ts
apps/web/utils/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size

Files:

  • apps/web/utils/llms/model.test.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: Don't use elements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...

Files:

  • apps/web/utils/llms/model.test.ts
!pages/_document.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.

Files:

  • apps/web/utils/llms/model.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Don't use export or module.exports in test files.
Don't use focused tests.
Don't use disabled tests.
Make sure the assertion function, like expect, is placed inside an it() function call.
Don't nest describe() blocks too deeply in test files.
Don't use focused tests.
Don't use disabled tests.
Don't use export or module.exports in test files.

Files:

  • apps/web/utils/llms/model.test.ts
🧠 Learnings (12)
📚 Learning: applies to apps/web/utils/llms/model.ts : model definitions and configurations must be placed in uti...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/llms/model.ts : Model definitions and configurations must be placed in utils/llms/model.ts.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : test both ai and non-ai paths in llm-related tests...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths in LLM-related tests

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : document complex ai logic with clear comments in llm-r...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Document complex AI logic with clear comments in LLM-related code.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : do not mock the llm call in llm-related tests; call the...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Do not mock the LLM call in LLM-related tests; call the actual LLM

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : include standard test cases: happy path, error handling...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Include standard test cases: happy path, error handling, edge cases (empty input, null values), different user configurations, and various input formats in LLM-related tests

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : implement fallbacks for ai failures in llm-related fun...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Implement fallbacks for AI failures in LLM-related functions.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : always create helper functions for common test data in ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Always create helper functions for common test data in LLM-related tests

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/__tests__/**/*.test.ts : use descriptive console.debug statements for generated ...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-07-18T15:06:10.570Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use descriptive console.debug statements for generated content in LLM-related tests

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : use typescript types for all parameters and return val...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Use TypeScript types for all parameters and return values in LLM-related code.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : define clear interfaces for complex input/output struc...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Define clear interfaces for complex input/output structures in LLM-related code.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : system prompt should define the llm's role and task sp...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : System prompt should define the LLM's role and task specifications.

Applied to files:

  • apps/web/utils/llms/model.test.ts
📚 Learning: applies to apps/web/utils/{ai,llms}/**/*.ts : user prompt should contain the actual data and context...
Learnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-07-18T15:06:40.272Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : User prompt should contain the actual data and context.

Applied to files:

  • apps/web/utils/llms/model.test.ts
⏰ 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). (3)
  • GitHub Check: Static Code Analysis Js
  • GitHub Check: Jit Security
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/web/utils/llms/model.test.ts (1)

72-356: Excellent test coverage and structure.

The test suite demonstrates comprehensive coverage of the LLM model configuration functionality:

  • Tests all supported providers (OpenAI, Google, Groq, Anthropic, OpenRouter)
  • Covers different model types (default, chat, economy)
  • Tests both user-configured and default scenarios
  • Proper error handling verification
  • Clear test organization and descriptive names

The implementation follows LLM testing best practices with proper mocking, comprehensive scenarios, and clean structure.

Comment on lines +167 to +178
// it("should configure Ollama model correctly", () => {
// const userAi: UserAIFields = {
// aiApiKey: "user-api-key",
// aiProvider: Provider.OLLAMA!,
// aiModel: "llama3",
// };

// const result = getModel(userAi);
// expect(result.provider).toBe(Provider.OLLAMA);
// expect(result.model).toBe("llama3");
// expect(result.llmModel).toBeDefined();
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove commented-out test code.

The commented-out Ollama test should be deleted rather than kept as comments. Since Ollama support has been removed from the main implementation, keeping this commented code adds maintenance overhead and potential confusion.

Apply this diff to remove the commented-out test:

-    // it("should configure Ollama model correctly", () => {
-    //   const userAi: UserAIFields = {
-    //     aiApiKey: "user-api-key",
-    //     aiProvider: Provider.OLLAMA!,
-    //     aiModel: "llama3",
-    //   };
-
-    //   const result = getModel(userAi);
-    //   expect(result.provider).toBe(Provider.OLLAMA);
-    //   expect(result.model).toBe("llama3");
-    //   expect(result.llmModel).toBeDefined();
-    // });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// it("should configure Ollama model correctly", () => {
// const userAi: UserAIFields = {
// aiApiKey: "user-api-key",
// aiProvider: Provider.OLLAMA!,
// aiModel: "llama3",
// };
// const result = getModel(userAi);
// expect(result.provider).toBe(Provider.OLLAMA);
// expect(result.model).toBe("llama3");
// expect(result.llmModel).toBeDefined();
// });
🤖 Prompt for AI Agents
In apps/web/utils/llms/model.test.ts around lines 167 to 178, remove the entire
block of commented-out code for the Ollama model test. Since Ollama support has
been removed, delete these commented lines to avoid confusion and reduce
maintenance overhead.

@elie222 elie222 merged commit 07434e2 into main Aug 6, 2025
@elie222 elie222 deleted the feat/ai-sdk-v5 branch August 6, 2025 10:45
@claude
Copy link

claude bot commented Aug 6, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

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

Comments