Conversation
WalkthroughAdds a read-only "Prompt" view for Rules with a new RulesPromptFormat component, integrates it into a tabbed Rules UI, extends SimpleRichTextEditor with an editable flag for read-only rendering, adds rule-to-text Markdown conversion, and bumps the version to v2.6.12. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as RulesTabNew (Tabs)
participant List as Rules (list)
participant Prompt as RulesPromptFormat
participant Data as useRules/useLabels
participant Util as ruleToText
participant Editor as SimpleRichTextEditor (editable=false)
User->>UI: Open Rules page (format=list|prompt)
alt format=list
UI->>List: Render rules list
else format=prompt
UI->>Prompt: Render Prompt view
Prompt->>Data: fetch rules & labels
Data-->>Prompt: rules, labels
Prompt->>Util: ruleToText(rule) for each rule
Util-->>Prompt: markdown snippet
Prompt->>Editor: load combined markdown (editable=false)
end
sequenceDiagram
autonumber
participant Prompt as RulesPromptFormat
participant Util as ruleToText
participant Action as Rule.actions
Prompt->>Util: ruleToText(rule)
loop each rule
Util->>Action: inspect actions & types
Action-->>Util: action details
end
Util-->>Prompt: "**When:** ...\n**Then:** ..."
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (7)
apps/web/components/editor/SimpleRichTextEditor.tsx (3)
20-21: Keep editor’s read-only state in sync when theeditableprop changes.
useEditor({ editable })only uses the initial value. Ifeditableever toggles, TipTap won’t update unless you calleditor.setEditable(...).Apply:
- import { useImperativeHandle, forwardRef } from "react"; + import { useImperativeHandle, forwardRef, useEffect } from "react"; @@ const editor = useEditor({ editable, @@ }); + + useEffect(() => { + if (editor) editor.setEditable(editable); + }, [editor, editable]);Also applies to: 40-46
147-150: Improve UX for read-only: allow text selection and avoid “not-allowed” cursor.Users may want to select/copy text in read-only mode.
Apply:
- !editable && "bg-muted/30 cursor-not-allowed", + !editable && "bg-muted/30 cursor-default select-text",
91-95: Tiny cleanup: duplicate class.
max-w-noneappears twice.Apply:
- "p-3 max-w-none focus:outline-none max-w-none simple-rich-editor", + "p-3 max-w-none focus:outline-none simple-rich-editor",apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsx (3)
55-58: Surface errors in LoadingContent.Pass
errorfrom both hooks for consistent UX.Apply:
- <LoadingContent - loading={isLoadingLabels || isLoadingRules} - loadingComponent={<Skeleton className="min-h-[220px] w-full" />} - > + <LoadingContent + loading={isLoadingLabels || isLoadingRules} + error={labelsError || rulesError} + loadingComponent={<Skeleton className="min-h-[220px] w-full" />} + >And update the labels hook destructure:
- const { userLabels, isLoading: isLoadingLabels } = useLabels(); + const { userLabels, isLoading: isLoadingLabels, error: labelsError } = useLabels();
48-55: Form submits are redundant while Save is disabled.Either remove the
<form>wrapper or make the buttontype="button"to avoid accidental submits.Apply one of:
- return ( - <form - onSubmit={(e) => { - e.preventDefault(); - onSubmit(); - }} - > + return ( + <div> @@ - <Button type="submit" size="sm" disabled> + <Button type="button" size="sm" disabled>Also applies to: 73-76
59-63: Avoid duplicating the “editing disabled” notice.Keep one notice (preferably above the editor).
Also applies to: 78-81
apps/web/utils/rule/rule-to-text.ts (1)
88-91: Redact webhook secrets when rendering.Avoid leaking tokens/keys in URLs.
Apply:
- if (action.url) { - actions.push(`Call webhook: ${action.url}`); - } + if (action.url) { + try { + const u = new URL(action.url); + u.search = u.search ? "?…" : ""; + actions.push(`Call webhook: ${u.toString()}`); + } catch { + actions.push("Call webhook"); + } + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx(1 hunks)apps/web/components/editor/SimpleRichTextEditor.tsx(3 hunks)apps/web/utils/rule/rule-to-text.ts(1 hunks)version.txt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (19)
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/RulesPromptFormat.tsxapps/web/utils/rule/rule-to-text.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/utils/rule/rule-to-text.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.tsxversion.txt
**/*.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/utils/rule/rule-to-text.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.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/RulesPromptFormat.tsxapps/web/utils/rule/rule-to-text.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/utils/rule/rule-to-text.tsapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.tsxversion.txt
**/*.{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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsxapps/web/components/editor/SimpleRichTextEditor.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/rule/rule-to-text.tsapps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logicFiles:
apps/web/utils/rule/rule-to-text.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/rule/rule-to-text.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/SimpleRichTextEditor.tsxapps/web/components/!(ui)/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
All other components are in
components/Files:
apps/web/components/editor/SimpleRichTextEditor.tsx🧠 Learnings (1)
📚 Learning: 2025-08-17T16:57:25.834Z
Learnt from: CR PR: elie222/inbox-zero#0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-08-17T16:57:25.834Z Learning: Applies to apps/web/utils/{ai,llms}/**/*.ts : Format prompts with XML-like tags; remove excessive whitespace; truncate overly long inputs; keep formatting consistentApplied to files:
apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsxapps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx🧬 Code graph analysis (2)
apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsx (6)
apps/web/hooks/useRules.tsx (1)
useRules(4-8)apps/web/hooks/useLabels.ts (1)
useLabels(62-88)apps/web/components/editor/SimpleRichTextEditor.tsx (2)
SimpleRichTextEditorRef(23-26)SimpleRichTextEditor(28-158)apps/web/utils/rule/rule-to-text.ts (1)
ruleToText(14-121)apps/web/components/LoadingContent.tsx (1)
LoadingContent(13-27)apps/web/components/Notice.tsx (1)
Notice(16-28)apps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx (4)
apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptNew.tsx (1)
RulesPrompt(31-63)apps/web/app/(app)/[emailAccountId]/assistant/RulesPrompt.tsx (1)
RulesPrompt(39-93)apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx (1)
Rules(70-501)apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsx (1)
RulesPromptFormat(18-85)🔇 Additional comments (4)
version.txt (1)
1-1: Version bump looks good.No issues.
apps/web/app/(app)/[emailAccountId]/assistant/RulesTabNew.tsx (2)
11-28: Tabbed integration is clear and sensible.List/Prompt split with URL
searchParam="format"is solid.
1-4: No action needed—imports correctly reference intendedRulesPrompt. Confirmed thatRulesPrompt.tsxandRulesPromptNew.tsxeach exportRulesPrompt, and all import sites (RulesTab.tsx,RulesTabNew.tsx,AssistantTabs.tsx) point to the correct file.apps/web/app/(app)/[emailAccountId]/assistant/RulesPromptFormat.tsx (1)
19-21: Incorrect:useRules()returns an array, not{ rules: … }. The hook is typed asuseSWRWithEmailAccount<RulesResponse>whereRulesResponse = Awaited<ReturnType<typeof getRules>>andgetRulesreturns the array fromprisma.rule.findMany, sodatais alreadyRuleWithActions[]. Mapping overrulesis correct.Likely an incorrect or invalid review comment.
| import { | ||
| ActionType, | ||
| CategoryFilterType, | ||
| LogicalOperator, | ||
| } from "@prisma/client"; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Do not import Prisma enums in the web bundle; compare to string literals instead.
Importing @prisma/client values on the client drags server-only code into the browser and violates guidelines.
Apply:
-import type { Rule, Action } from "@prisma/client";
-import {
- ActionType,
- CategoryFilterType,
- LogicalOperator,
-} from "@prisma/client";
+import type { Rule, Action } from "@prisma/client";
@@
- if (rule.categoryFilterType && rule.categoryFilters?.length) {
+ if (rule.categoryFilterType && rule.categoryFilters?.length) {
const categoryNames = rule.categoryFilters.map((c) => c.name).join(", ");
- if (rule.categoryFilterType === CategoryFilterType.INCLUDE) {
+ if (rule.categoryFilterType === "INCLUDE") {
conditions.push(`Sender is in categories: ${categoryNames}`);
} else {
conditions.push(`Sender is NOT in categories: ${categoryNames}`);
}
}
@@
- rule.actions.forEach((action) => {
+ rule.actions.forEach((action) => {
switch (action.type) {
- case ActionType.ARCHIVE:
+ case "ARCHIVE":
actions.push("Archive");
break;
- case ActionType.LABEL:
+ case "LABEL":
if (action.label) {
actions.push(`Label as @[${action.label}]`);
}
break;
- case ActionType.REPLY:
+ case "REPLY":
if (action.content) {
actions.push(`Reply with: "${action.content}"`);
} else {
actions.push("Send reply");
}
break;
- case ActionType.FORWARD:
+ case "FORWARD":
if (action.to) {
actions.push(`Forward to ${action.to}`);
}
break;
- case ActionType.SEND_EMAIL:
+ case "SEND_EMAIL":
actions.push(`Send email${action.to ? ` to ${action.to}` : ""}`);
break;
- case ActionType.DRAFT_EMAIL:
+ case "DRAFT_EMAIL":
actions.push("Draft a reply");
break;
- case ActionType.MARK_SPAM:
+ case "MARK_SPAM":
actions.push("Mark as spam");
break;
- case ActionType.MARK_READ:
+ case "MARK_READ":
actions.push("Mark as read");
break;
- case ActionType.CALL_WEBHOOK:
+ case "CALL_WEBHOOK":
if (action.url) {
actions.push(`Call webhook: ${action.url}`);
}
break;
- case ActionType.DIGEST:
+ case "DIGEST":
actions.push("Add to digest");
break;
- case ActionType.MOVE_FOLDER:
+ case "MOVE_FOLDER":
if (action.folderName) {
actions.push(`Move to folder "${action.folderName}"`);
}
break;
- case ActionType.TRACK_THREAD:
+ case "TRACK_THREAD":
// Skip this action as it's typically internal
break;
}
});
@@
- const operator =
- rule.conditionalOperator === LogicalOperator.OR ? " OR " : " AND ";
+ const operator = rule.conditionalOperator === "OR" ? " OR " : " AND ";Check for any other client-side imports of @prisma/client values:
Also applies to: 43-50, 55-103, 107-109
🏁 Script executed:
#!/bin/bash
rg -nP --glob 'apps/web/**' -C2 'from\s+"@prisma/client";'Length of output: 80559
Remove all runtime imports of @prisma/client from the web bundle
Replace every non-type import of enums or models from @prisma/client in apps/web with string literals (for enum comparisons) or move that logic into server-only modules. Client code may only use import type { … } from "@prisma/client". Run the provided ripgrep command to locate and fix all occurrences.
🤖 Prompt for AI Agents
In apps/web/utils/rule/rule-to-text.ts around lines 2 to 6, runtime-imports from
"@prisma/client" are included which will pull Prisma into the web bundle;
replace the non-type imports with type-only imports and convert any enum usages
to string literals (or move the logic into a server-only module). Specifically:
change imports to "import type { ActionType, CategoryFilterType, LogicalOperator
} from '@prisma/client'" and replace any runtime comparisons like ActionType.FOO
or LogicalOperator.AND with the equivalent string values ("FOO", "AND"); if this
file must evaluate Prisma enums at runtime, move that logic to a server-only
helper and call it via API/SSR. Run the ripgrep provided in the review to locate
and fix any other non-type imports in apps/web.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/app/(app)/[emailAccountId]/assistant/constants.ts (1)
84-86: Broaden “label” detection and centralize keyword logicIn both apps/web/app/(app)/[emailAccountId]/assistant/constants.ts (line 84) and ExamplesList.tsx (line 74), replace:
- if (lowerExample.includes("label") || lowerExample.includes("categorize")) { + if (/\b(label|tag|tagging|categorize|categorise|categorization|categorisation)\b/.test(lowerExample)) { return ACTION_TYPE_COLORS[ActionType.LABEL]; }Optional: export a
LABEL_KEYWORDSarray and anisLabelLike(s: string)helper near your other utilities, then callif (isLabelLike(example))in both places to keep this logic DRY.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/assistant/constants.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.tsx
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/app/(app)/[emailAccountId]/assistant/constants.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/app/(app)/[emailAccountId]/assistant/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/constants.tsapps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.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/ExamplesList.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/ExamplesList.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/ExamplesList.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/ExamplesList.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/ExamplesList.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/ExamplesList.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/ExamplesList.tsx
| if (lowerExample.includes("label") || lowerExample.includes("categorize")) { | ||
| return { type: "label", color }; | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Match constants.ts: add “categorise”, “categorization”, and “tag” variants.
Prevents user prompts like “tag this” or “categorise as” from falling into “other”.
Minimal change:
- if (lowerExample.includes("label") || lowerExample.includes("categorize")) {
+ if (/\b(label|tag|tagging|categorize|categorise|categorization|categorisation)\b/.test(lowerExample)) {
return { type: "label", color };
}If you adopt the shared helper suggested in constants.ts, this becomes:
import { getActionTypeColor, isLabelLike } from "@/app/(app)/[emailAccountId]/assistant/constants";
// ...
if (isLabelLike(example)) {
return { type: "label", color };
}Quick check for other spots needing the same update:
🏁 Script executed:
#!/bin/bash
rg -n --type=ts --type=tsx -C2 "(includes\(['\"]label['\"]\)|categoriz(e|ation)|categoris(e|ation)|\btag(ging)?\b)" apps/webLength of output: 158
🏁 Script executed:
#!/bin/bash
# Search for “label”, “categorize”/“categorise”, “tag”/“tagging”, and “categorization” variants in .ts/.tsx files without relying on type aliases
rg -n -C2 "(includes\(['\"]label['\"]\)|includes\(['\"]categorize['\"]\)|includes\(['\"]categorise['\"]\)|includes\(['\"]tag['\"]\)|includes\(['\"]tagging['\"]\)|categorization|categorisation)" -g "*.ts" -g "*.tsx" apps/webLength of output: 14224
🏁 Script executed:
#!/bin/bash
# Search for isLabelLike helper definition
rg -n "isLabelLike" -C2 -g "*.ts" -g "*.tsx" apps/webLength of output: 53
Cover all label-like variants and DRY the logic
- In apps/web/app/(app)/[emailAccountId]/assistant/constants.ts, add:
export function isLabelLike(example: string): boolean { return /\b(label|tag|tagging|categorize|categorise|categorization|categorisation)\b/.test( example.toLowerCase() ); }
- Replace both occurrences
• ExamplesList.tsx (lines 74–76)
• constants.ts (lines 84–86)
with:if (isLabelLike(lowerExample)) { return { type: "label", color }; }
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/assistant/ExamplesList.tsx (around lines
74–76) and apps/web/app/(app)/[emailAccountId]/assistant/constants.ts (around
lines 84–86), replace the ad-hoc checks for "label" and "categorize" with a
single DRY helper: add the provided isLabelLike function to constants.ts, export
it, then import isLabelLike into ExamplesList.tsx and any other file using the
old logic and change the if to call isLabelLike(lowerExample) returning { type:
"label", color } as before; remove the original inline string checks so all
label-like variants are covered consistently.
Summary by CodeRabbit
New Features
Enhancements
Chores