Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update delivers a major refactor and modernization of the chat assistant architecture and UI. It introduces a new context-based Changes
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)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
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-errorcomment indicates a type mismatch withsetMessages. This should be properly resolved rather than suppressed with a comment.The issue might be that
setMessagesexpects 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 UUIDThe AI SDK v5 already provides
generateId()(andcreateIdGenerator()) for message/chat IDs. Please replace your customgenerateUUID()with the SDK utility to ensure consistency across hooks and streaming methods.• File:
apps/web/components/assistant-chat/chat.tsx
Lines: 327–334Proposed 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
useChatandstreamTextproduce 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-ignorecomment 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
convertToUIMessageshelper is imported from the components directory into an API route. Consider moving shared utilities to a common location likeutils/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 dialogWhile 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 codeThis 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 messagesThe "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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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.tsxapps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/utils/redis/usage.tsapps/web/components/assistant-chat/overview.tsxapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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.tsxapps/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
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(app)/[emailAccountId]/simple/Summary.tsxapps/web/components/assistant-chat/ChatContext.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/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.tsxapps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/utils/redis/usage.tsapps/web/components/assistant-chat/overview.tsxapps/web/package.jsonapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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.tsxapps/web/components/assistant-chat/ChatContext.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport 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.tsxapps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/utils/redis/usage.tsapps/web/components/assistant-chat/overview.tsxapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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
onClickmust be client components withuse clientdirective
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 useelements 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.tsxapps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/utils/redis/usage.tsapps/web/components/assistant-chat/overview.tsxapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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.tsxapps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/utils/redis/usage.tsapps/web/components/assistant-chat/overview.tsxapps/web/package.jsonapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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.tsxapps/web/components/assistant-chat/ChatContext.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/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.tsxapps/web/components/assistant-chat/ChatContext.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/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 ZodFiles:
apps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/components/assistant-chat/helpers.tsapps/web/utils/redis/usage.tsapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/components/assistant-chat/types.tsapps/web/app/api/chat/route.tsapps/web/utils/llms/index.tsapps/web/utils/ai/assistant/chat.tsapps/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.tsapps/web/utils/llms/model.tsapps/web/utils/llms/index.tsapps/web/utils/ai/assistant/chat.tsapps/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.tsapps/web/utils/llms/model.tsapps/web/utils/llms/index.tsapps/web/utils/ai/assistant/chat.tsapps/web/utils/**
📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logicFiles:
apps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/utils/redis/usage.tsapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/utils/llms/index.tsapps/web/utils/ai/assistant/chat.tsapps/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 sizeFiles:
apps/web/utils/ai/choose-rule/ai-choose-args.tsapps/web/utils/redis/usage.tsapps/web/utils/llms/model.tsapps/web/utils/usage.tsapps/web/utils/llms/index.tsapps/web/utils/ai/assistant/chat.tsapps/web/components/!(ui)/**
📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
All other components are in
components/Files:
apps/web/components/assistant-chat/helpers.tsapps/web/components/assistant-chat/ChatContext.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/types.tsapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/web/components/**/*.tsx
📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)
Use React Hook Form with Zod validation for form handling
Use the
LoadingContentcomponent 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.tsxapps/web/components/assistant-chat/overview.tsxapps/web/components/assistant-chat/message-editor.tsxapps/web/components/assistant-chat/message.tsxapps/web/components/assistant-chat/messages.tsxapps/web/components/assistant-chat/tools.tsxapps/web/components/assistant-chat/multimodal-input.tsxapps/web/components/assistant-chat/chat.tsxapps/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.tsapps/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.tsapps/web/app/api/**/route.ts
📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)
apps/web/app/api/**/route.ts: UsewithAuthfor user-level operations
UsewithEmailAccountfor 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 withwithAuthorwithEmailAccountmiddleware 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).
UsewithEmailAccountmiddleware for API routes that operate on a specific email account (i.e., use or requireemailAccountId).
UsewithAuthmiddleware for API routes that operate at the user level (i.e., use or require onlyuserId).
UsewithErrormiddleware (with proper validation) for public endpoints, custom authentication, or cron endpoints.
Cron endpoints MUST usewithErrormiddleware and validate the cron secret usinghasCronSecret(request)orhasPostCronSecret(request).
Cron endpoints MUST capture unauthorized attempts withcaptureExceptionand 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.
AllfindUniqueandfindFirstPrisma calls in API routes MUST include ownership filters (e.g., userId or emailAccountId).
AllfindManyPrisma 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.tsapps/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.tsapps/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 hooksLearnt 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 theuseprefix (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:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 availableLearnt 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 usinguseSWR.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 withonClickmust be client components withuse clientdirectiveLearnt 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 dataLearnt 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 theLoadingContentcomponent to handle loading statesLearnt 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 theLoadingContentcomponent 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 : UseLoadingContentcomponent to handle loading and error states consistentlyapps/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 testsLearnt 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.tsfile. These schemas are used bynext-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 serverLearnt 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 ZodLearnt 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 : UsewithEmailAccountfor email-account-level operationsapps/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 theuseprefix (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 hooksLearnt 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.tsLearnt 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 theuseSearchParamshook 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 (likeuserId,emailAccountId, etc.) provided by the safe action client via thectxobject 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 theInputcomponent for text inputs, passingregisterPropsanderrorprops for form handlingLearnt 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 usinguseSWR.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 hooksapps/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 serverLearnt 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 withuse serverapps/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 theInputcomponent withautosizeTextareaand appropriate props for text areasLearnt 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 theInputcomponent for text inputs, passingregisterPropsanderrorprops for form handlingLearnt 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 availableLearnt from: aryanprince
PR: #210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 stylingLearnt 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 hooksLearnt 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 theLoadingContentcomponent to handle loading statesLearnt 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 submissionapps/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 PrismaLearnt 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 : Usenext/imagepackage for imagesLearnt 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 theswrpackageLearnt 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 stylingLearnt 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 theswrpackageLearnt 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-featureLearnt 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 testsapps/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 testsLearnt 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 | undefinedinstead 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 theInputcomponent withautosizeTextareaand appropriate props for text areasLearnt 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 : UseadminActionClientfor 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 : UseactionClientUserwhen 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 (likeuserId,emailAccountId, etc.) provided by the safe action client via thectxobject 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 : UseactionClientwhen both authenticated user context and a specificemailAccountIdare needed. TheemailAccountIdmust 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 withonClickmust be client components withuse clientdirectiveLearnt from: aryanprince
PR: #210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 theInputcomponent withautosizeTextareaand appropriate props for text areasLearnt 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 availableLearnt 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 withonClickmust be client components withuse clientdirectiveLearnt 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 hooksLearnt 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:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 stylingLearnt 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 theuseprefix (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} : Useresult?.serverErrorwithtoastErrorandtoastSuccessfor error handling; success toast is optionalLearnt 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 : UseLoadingContentcomponent to handle loading and error states consistentlyLearnt 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 theLoadingContentcomponent 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 : Useresult?.serverErrorwithtoastErrorandtoastSuccessfor 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 fieldsLearnt 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 : Useresult?.serverErrorwithtoastErrorandtoastSuccessLearnt 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 theInputcomponent for text inputs, passingregisterPropsanderrorprops for form handlingLearnt 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 : UseSafeErrorfor expected/handled errors within actions if needed.next-safe-actionprovides 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 : Passloading,error, and children props toLoadingContentapps/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:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 hooksapps/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 (withnext-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: Theutilsfolder 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.tsfile. These schemas are used bynext-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 ZodLearnt 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 Prismaapps/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 serverLearnt 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 availableLearnt 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 stylingLearnt 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 actionsLearnt 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 hooksLearnt 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 thenext-safe-actionlibrary for type safety, input validation, context management, and error handling. Refer toapps/web/utils/actions/safe-action.tsfor 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 theInputcomponent withautosizeTextareaand appropriate props for text areasLearnt 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 theInputcomponent for text inputs, passingregisterPropsanderrorprops for form handlingLearnt 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 availableLearnt 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 submissionLearnt 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 : Callmutate()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 cachingLearnt 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 APILearnt 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 theswrpackageLearnt 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 usinguseSWR.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 theInputcomponent withautosizeTextareaand appropriate props for text areasLearnt 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 theswrpackageLearnt from: CR
PR: elie222/inbox-zero#0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-07-20T09:00:16.480Z
Learning: Useswrfor data fetching in deeply nested componentsLearnt 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 SWRLearnt from: aryanprince
PR: #210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning:MoreDropdownis a React component anduseUnsubscribeButtonis a custom React hook, and they should not be imported usingimport 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 availableLearnt 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 stylingLearnt 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 approachLearnt 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 hooksLearnt 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 theLoadingContentcomponent 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 : UseLoadingContentcomponent to handle loading and error states consistentlyLearnt 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 dataLearnt 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 theLoadingContentcomponent to handle loading statesLearnt 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} : Callmutate()after successful mutations to refresh dataLearnt 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 theInputcomponent for text inputs, passingregisterPropsanderrorprops for form handlingapps/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 testsLearnt 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.tsfile. These schemas are used bynext-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 serverLearnt 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 sameuseCompletionhook 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
useChathook within aChatProvider. 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
InvalidToolArgumentsErrortoInvalidArgumentErroraligns with the AI SDK v5 error naming conventions.
83-83: Updated tool schema property name.The change from
parameterstoinputSchemafollows the new AI SDK v5 tool configuration API.
97-97: Updated retry condition for new error type.The retry condition correctly uses the new
InvalidArgumentErrorclass with itsisInstancemethod, maintaining proper error handling logic.
107-107: Updated tool call property access.The change from
argstoinputreflects 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) => voidis clearer and removes the dependency onUseChatHelpers, 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-baseclass 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
GetChatResponsetoChatMessage[]. 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 vulnerabilitiesAfter 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 UpgradePlease ensure that upgrading to
@openrouter/ai-sdk-provider@1.0.0-beta.5aligns with the new AI SDK v5 requirements:• Convert UIMessage → ModelMessage before sending to the model
• Update tool‐call handling to usetool-${toolName}naming conventions
• ConfigureuseChatwith 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 v5Refer to the official v5 migration guide for detailed steps:
https://v5.ai-sdk.dev/docs/migration-guides/migration-guide-5-0?utm_source=openaiapps/web/utils/usage.ts (2)
1-1: LGTM! Consistent migration to AI SDK v5 types.The migration to
LanguageModelUsagetype 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
aiApiKeyinitialization with the provider and model logic.
1-1: No remaining LanguageModelV1 references detected
Searches forLanguageModelV1acrossapps/web/and forllmModel.inapps/web/utils/&apps/web/components/returned no matches. All consuming code now targetsLanguageModelV2. 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
ChatMessageas the generic parameter forUseChatHelpersprovides better type safety and IntelliSense support. This ensures all chat-related props are properly typed according to theChatMessageinterface defined intypes.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 typesyntax 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
UseChatHelperswithChatMessageand the rename fromreloadtoregenerateare consistent with the broader refactoring across the assistant chat components.
28-34: Proper handling of the new message structure.Good use of the
getTextFromMessagehelper to extract text content from the new part-based message structure.
115-120: Well-implemented text extraction helper.The
getTextFromMessagefunction 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
UseChatHelperswithChatMessageand the simplifiedsetInputtype improve type clarity and consistency.Also applies to: 11-16
23-23: Consistent prop renaming throughout the component.The
reloadtoregeneraterename 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 typefor all type imports and clear definition ofSetInputFunction.
21-30: Well-structured tool type aggregation.The
ChatToolstype 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
ChatMessagetype andregeneratemethod.Also applies to: 27-32
27-27: Consistent prop renaming.The
reloadtoregeneraterename is properly propagated.Also applies to: 104-104
347-349: Simple and effective error display component.The
ErrorToolCardprovides clear error visibility with appropriate styling.apps/web/components/assistant-chat/tools.tsx (6)
4-11: LGTM! Clean type importsThe 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 componentThe component properly handles conditional rendering, null checking, and displays rule information in a clear hierarchical structure. Good use of the
filterNullPropertiespattern for clean data display.
104-191: Excellent diff visualization implementationThe 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 constraintsThe generic type parameter
Tis properly constrained to ensure type safety while maintaining flexibility for different action formats.
281-335: Clean pattern visualizationThe component effectively displays learned patterns with clear separation between include and exclude rules. Good defensive programming with null checks.
337-369: Well-integrated navigation componentsBoth components follow consistent patterns. The
AddToKnowledgeBasecomponent'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 goodThe migration from
CoreMessagetoModelMessagealigns with the AI SDK v5 update.
136-136: Correct SDK v5 syntaxAdding
output: "object"is the correct way to specify object generation in the new SDK version.
194-194: Updated step limiting patternThe migration to
stopWhenwithstepCountIsis the correct approach for the new SDK version.
200-210: Efficient concurrent executionGood use of
Promise.allto avoid blocking the callback on usage saving. SincesaveAiUsagehandles errors internally, this pattern is safe and performant.apps/web/components/assistant-chat/chat.tsx (4)
73-79: Clean removal of SWR wrapperGood simplification by removing the unnecessary SWR config wrapper and using the helper function for message conversion.
97-143: Well-structured state managementThe 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 interfaceThe explicit prop interface makes the component's dependencies clear and improves testability.
192-196: Good UX considerationThe 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 v5The migration to
InferUITool,tool, andModelMessagefrom the "ai" package aligns perfectly with the SDK upgrade.
25-119: Well-structured tool factory patternThe
getUserRulesAndSettingsToolfactory encapsulates all logic nicely. Good use offilterNullPropertiesto clean up the response data.
183-237: Robust error handling in createRuleToolGood 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 logicThe 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 functionThe simplified
aiProcessAssistantChatfunction with tool initialization is much cleaner than inline tool definitions. The system prompt is comprehensive with good examples.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
apps/web/public/images/testimonials/joel.jpegis excluded by!**/*.jpegapps/web/public/images/testimonials/slim.pngis excluded by!**/*.pngapps/web/public/images/testimonials/valentine.pngis excluded by!**/*.pngapps/web/public/images/testimonials/will.jpegis excluded by!**/*.jpegapps/web/public/images/testimonials/yoni.jpegis 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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/utils/outlook/message.tsapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/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
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/utils/outlook/message.tsapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/components/editor/extensions/MentionList.tsxapps/web/components/editor/extensions/LabelMention.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport 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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/utils/outlook/message.tsapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsx
apps/web/app/**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
Components with
onClickmust be client components withuse clientdirective
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/SettingsTab.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements 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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/utils/outlook/message.tsapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/utils/outlook/message.tsapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftKnowledgeSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/web/app/(landing)/home/Testimonials.tsxapps/web/components/editor/extensions/MentionList.tsxapps/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 ZodFiles:
apps/web/utils/gmail/message.tsapps/web/utils/outlook/message.tsapps/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.tsapps/web/utils/**
📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logicFiles:
apps/web/utils/gmail/message.tsapps/web/utils/outlook/message.tsapps/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 sizeFiles:
apps/web/utils/gmail/message.tsapps/web/utils/outlook/message.tsapps/web/components/**/*.tsx
📄 CodeRabbit Inference Engine (apps/web/CLAUDE.md)
Use React Hook Form with Zod validation for form handling
Use the
LoadingContentcomponent 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.tsxapps/web/components/editor/extensions/LabelMention.tsxapps/web/components/!(ui)/**
📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
All other components are in
components/Files:
apps/web/components/editor/extensions/MentionList.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/web/utils/gmail/message.tsapps/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 rootApplied 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` folderApplied 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.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/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 folderApplied 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 namesApplied to files:
apps/web/app/(app)/[emailAccountId]/assistant/knowledge/KnowledgeDialog.tsxapps/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 hooksApplied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/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 availableApplied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/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.tsApplied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DraftReplies.tsxapps/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.tsxapps/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 optionalApplied 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.tsxapps/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.tsxapps/web/app/(app)/[emailAccountId]/assistant/RuleForm.tsxapps/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 hooksApplied 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` directiveApplied 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 APIApplied 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.tsApplied 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 flagsApplied 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.tsxapps/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 handlingApplied 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 stylingApplied 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 operationsApplied 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 ZodApplied 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 validationApplied 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 dataApplied 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 testsApplied 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 testsApplied 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.tsxapps/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 availableThe addition of the Digest action type to the typeOptions array is correct and aligns with the removal of the
useDigestEnabledfeature flag.
335-335: LGTM: Dependency array correctly updatedThe empty dependency array is appropriate since
typeOptionsno longer depends on any reactive values after removing thedigestEnabledfeature flag.apps/web/components/editor/extensions/MentionList.tsx (1)
6-7: LGTM! Clean implementation of the create new label feature.The extension of
UserLabelwith an optionalisCreateNewproperty 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
settingssubdirectory, and the newDraftKnowledgeSettingcomponent is properly imported.
10-10: Good component placement for logical grouping.The
DraftKnowledgeSettingcomponent is well-positioned betweenDraftRepliesandAboutSetting, 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
enabledboolean 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
enabledis 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
useDraftRepliesallows other components likeDraftKnowledgeSettingto 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
useDraftReplieshook and derives theisEnabledstate 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.
| 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, | ||
| }, | ||
| ); | ||
| } |
There was a problem hiding this comment.
💡 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/messagesendpoint, 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 thedependsOnproperty 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
$selectto retrieve only the necessary fields and$filterto 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 Requestsresponse, implement a retry strategy that waits for the duration specified in theRetry-Afterheader 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:
- 1: https://learn.microsoft.com/en-us/graph/throttling-limits?utm_source=openai
- 2: https://learn.microsoft.com/en-us/graph/throttling-limits?utm_source=openai
- 3: https://learn.microsoft.com/en-us/graph/throttling-limits?utm_source=openai
- 4: https://gsexdev.blogspot.com/2020/09/the-mailboxconcurrency-limit-and-using.html?utm_source=openai
- 5: https://mrmicrosoft.com/how-to-avoid-microsoft-graph-api-throttling/?utm_source=openai
- 6: https://mrmicrosoft.com/how-to-avoid-microsoft-graph-api-throttling/?utm_source=openai
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_RESULTSis meant to limit • page size (GET/me/messagesvia$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-Afterfor 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.
johnlowe399-blip
left a comment
There was a problem hiding this comment.
apps/web/app/(app)/[emailAccountId]/usage/usage.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
apps/web/components/email-list/EmailMessage.tsx (2)
176-179: Fix misplaced onClick handler.The
onClickhandler is incorrectly placed on theForwardIconinstead of theButtonelement.- <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,
consoleusage should be avoided in production code.- console.error(result); + // Handle error appropriately - consider using a proper error logging service + // or displaying user-friendly error messageConsider using a proper logging service or displaying a user-friendly error message instead.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/web/utils/ai/rule/prompt-to-rules.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport 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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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 useelements 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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/components/PlanBadge.tsxapps/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
LoadingContentcomponent 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.tsxapps/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.tsxapps/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.tsxapps/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.tsxapps/web/components/email-list/EmailMessage.tsxapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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 testsApplied to files:
apps/web/utils/ai/example-matches/find-example-matches.tsapps/web/utils/ai/group/create-group.tsapps/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.tsapps/web/components/PlanBadge.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/components/PlanBadge.tsxapps/web/components/email-list/EmailMessage.tsxapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/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.tsapps/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.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsapps/web/utils/ai/group/create-group.tsapps/web/utils/ai/rule/generate-rules-prompt.tsapps/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.tsxapps/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.tsxapps/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.tsxapps/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` directiveApplied 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.tsapps/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.tsapps/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.tsapps/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.tsapps/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 operationsApplied 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 serverApplied 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>toignoreis cleaner and more direct for the intentional fallthrough case.
170-170: LGTM: Lint comment simplification.The simplification from
<explanation>toignoreis 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
toolfrom "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 withinputSchemacorrectly 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
toolNamerather than assuming it's the first element is more robust. Usinginputinstead ofargsand 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 withinputSchemais correctly implemented. Using the computed property name with theFIND_EXAMPLE_MATCHESconstant is good practice for maintainability.
116-118: LGTM - Tool call result extraction updated correctly.The change from
argstoinputin 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
hasSnippetsflag, and both branches properly use the newtool()function withinputSchema.
131-135: LGTM - Robust tool call result extraction.Using
find()to locate the specific tool call by name and accessinginputinstead ofargsfollows 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_ITEMStool definition correctly uses thetool()function withinputSchemaand maintains the computed property name pattern.
117-118: LGTM - Tool call extraction in reduce function updated correctly.The change from
argstoinputin 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_ITEMStool 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
inputinstead ofargsand maintains the logic of using the last tool call result.
|
|
||
| return ( | ||
| // biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> | ||
| // biome-ignore lint/a11y/useKeyWithClickEvents: ignore |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
📒 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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/web/utils/llms/index.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport 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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/web/utils/llms/index.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements 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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/assistant/process-assistant-email.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/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.tsapps/web/utils/ai/rule/find-existing-rules.tsapps/web/utils/ai/rule/create-rule.tsapps/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.tsapps/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.tsapps/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.tsapps/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.contenttolastToolCall.input.contentaligns with the AI SDK v5 migration where tool call inputs are now accessed via theinputproperty. 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
chatCompletionObjectfunction.
47-58: LGTM! Simplified API call with schema-driven approach.The migration from
chatCompletionToolstochatCompletionObjectwith direct schema parameters is cleaner and more consistent. The parameter rename fromlabeltousageLabelaligns 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
chatCompletionObjectand scoped logger imports to support the AI SDK v5 migration.
60-72: LGTM! Excellent migration to chatCompletionObject with logging.The update to use
chatCompletionObjectwith 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
chatCompletionObjectand 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
ModelMessagereplacing older message types, and new streaming utilities likestepCountIsfor more flexible step control.
94-96: LGTM! Enhanced schema support for chatCompletionObject.The addition of optional
schemaNameandschemaDescriptionparameters 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:
stepCountIs(maxSteps)provides more flexible step control- Concurrent promise handling with
Promise.all()improves performance- Comprehensive error handling with proper logging and exception capture
- 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 defaultToolSet.
304-304: LGTM! Consistent use of stepCountIs pattern.The migration from
maxStepsparameter tostepCountIs(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; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add missing LLM function structure compliance.
This LLM-related function should follow the standard structure outlined in the coding guidelines. Consider adding:
- Scoped logger with input/output logging
- Error handling with fallbacks
- 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.
| 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.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
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
📒 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}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport 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.tsanddir/format.test.ts)
Usevi.mock("server-only", () => ({}));to mock theserver-onlymodule in tests
Mock@/utils/prismain tests usingvi.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 useelements 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.
| // 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(); | ||
| // }); |
There was a problem hiding this comment.
🛠️ 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.
| // 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.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Refactor
Chores
Style