Skip to content

Comments

tests: add tests for mail, url, and rule validation utilities#1235

Merged
elie222 merged 4 commits intomainfrom
feat/add-utility-tests
Jan 8, 2026
Merged

tests: add tests for mail, url, and rule validation utilities#1235
elie222 merged 4 commits intomainfrom
feat/add-utility-tests

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jan 8, 2026

User description

Summary

Add 83 new tests covering critical utility functions that previously lacked test coverage.

  • mail.test.ts (26 tests): Email parsing, content extraction, HTML-to-text conversion
  • url.test.ts (22 tests): Provider-specific URL building for Gmail/Outlook
  • rule.validation.test.ts (35 tests): Zod schema validation for rule creation

Bug Fixes

  • Fix whitespace-only name validation in rule schema (added .trim())
  • Remove ineffective .default() from conditionalOperator field

Test plan

  • All 1094 tests pass
  • New tests cover edge cases and document existing behavior

🤖 Generated with Claude Code


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Adds comprehensive test coverage for core utility functions, including email parsing, URL generation, and rule validation schemas. Refines rule validation logic and action sorting behavior.

TopicDetails
Rule Validation Adds extensive tests for the createRuleBody and delayInMinutesSchema Zod schemas, ensuring robust validation for rule creation data. Fixes a bug in createRuleBody where rule names with only whitespace were considered valid by adding .trim(), and removes an ineffective .default() value from the conditionalOperator field.
Modified files (2)
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
Latest Contributors(2)
UserCommitDate
elie222Add-cold-email-notifierDecember 19, 2025
joshwerner001@gmail.comCleaning-up-the-user-e...December 01, 2025
General Utilities Adds new tests for various other utility functions, including action item field handling (getActionFields, sanitizeActionFields), action sorting logic (sortActionsByPriority), ignored sender filtering (isIgnoredSender), CTA and unsubscribe keyword detection (containsCtaKeyword, containsUnsubscribeKeyword), template variable parsing (hasVariables), and text slugification (slugify). Also updates the ACTION_PRIORITY_ORDER to include ActionType.NOTIFY_SENDER and modifies containsUnsubscribeKeyword for case-insensitive matching.
Modified files (9)
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/action-sort.ts
  • apps/web/utils/filter-ignored-senders.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/unsubscribe.ts
  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
Latest Contributors(1)
UserCommitDate
elie222fix-up-imports-forNovember 22, 2025
Email & URL Utilities Introduces new tests for email-related utilities, covering content extraction (emailToContent), HTML-to-text conversion (convertEmailHtmlToText), reply parsing (parseReply), and email client identification (getEmailClient). Also adds tests for URL generation functions, ensuring correct construction of Gmail and Outlook links, search queries, and filter settings URLs.
Modified files (2)
  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
Latest Contributors(0)
UserCommitDate
This pull request is reviewed by Baz. Review like a pro on (Baz).

Summary by CodeRabbit

  • Bug Fixes

    • Unsubscribe keyword detection now works case-insensitively for improved matching
    • Rule name validation now properly trims leading and trailing whitespace
  • New Features

    • Added NOTIFY_SENDER action type to action priority ordering

✏️ Tip: You can customize this high-level summary in your review settings.

Add 83 new tests covering critical utility functions:
- mail.test.ts: email parsing, content extraction, HTML conversion
- url.test.ts: provider-specific URL building for Gmail/Outlook
- rule.validation.test.ts: Zod schema validation for rules

Also fixes whitespace-only name validation in rule schema and removes
ineffective default from conditionalOperator field.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
inbox-zero Ready Ready Preview Jan 8, 2026 1:00pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Adds many new unit tests for web utilities (rules, mail, URLs, templates, text, action items, action sorting, parsing). Also a minor rule validation schema change: name now trims whitespace and conditionalOperator default was removed (now optional).

Changes

Cohort / File(s) Summary
Rule Validation Tests
apps/web/utils/actions/rule.validation.test.ts
New comprehensive tests for delayInMinutesSchema and createRuleBody: name trimming, actions, conditions (AI/STATIC, duplicates), per-action required fields, delay bounds, optional fields, and error-message assertions.
Rule Validation Schema
apps/web/utils/actions/rule.validation.ts
Small schema changes: .trim() added to name validation; conditionalOperator no longer has a default (kept optional).
Mail Utility Tests
apps/web/utils/mail.test.ts
New tests for emailToContent, convertEmailHtmlToText, parseReply, and getEmailClient covering fallbacks, truncation, remove-forwarded heuristics, link/image handling, reply extraction, and client/domain detection.
URL Utility Tests
apps/web/utils/url.test.ts
New tests for URL builders (getEmailUrl, getEmailUrlForMessage, getGmailUrl, search/filter URLs) across providers, encoding/edge cases, and unknown-provider behavior.
Template Utility Tests
apps/web/utils/template.test.ts
New tests for TEMPLATE_VARIABLE_PATTERN and hasVariables: matching (including multiline), negative cases, and null/undefined handling.
Text Utilities & Tests
apps/web/utils/text.test.ts, apps/web/utils/text.ts
Adds slugify and extractTextFromPortableTextBlock plus tests for punctuation, whitespace, and portable text extraction edge cases.
Filter Ignored Senders Tests
apps/web/utils/filter-ignored-senders.test.ts
New tests for isIgnoredSender: exact-match, non-matches, case sensitivity, and substring/partial cases.
Action Item & Sanitization Tests
apps/web/utils/action-item.test.ts
New tests covering actionInputs, getActionFields, and sanitizeActionFields across many ActionType cases and field-preservation/nullification rules.
Action Sorting
apps/web/utils/action-sort.ts, apps/web/utils/action-sort.test.ts
Adds NOTIFY_SENDER to priority order (placed before CALL_WEBHOOK) and tests verifying full ordering, stability, and edge cases.
Parse CTA & Unsubscribe Tests / Fix
apps/web/utils/parse/cta.test.ts, apps/web/utils/parse/unsubscribe.test.ts, apps/web/utils/parse/unsubscribe.ts
New CTA tests; new unsubscribe tests plus a small change: containsUnsubscribeKeyword now performs case-insensitive matching.

Sequence Diagram(s)

(omitted — changes are tests and small schema/utility tweaks; no new multi-component control flow to diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Add debug rules page #1102 — modifies apps/web/utils/actions/rule.validation.ts and adds related schema work (possible overlap with the name/conditionalOperator changes).
  • AI template responses #263 — related to template variable handling (hasVariables / TEMPLATE_VARIABLE_PATTERN) and test coverage alignment.
  • Move to folder action #668 — touches rule validation schemas; likely overlaps with createRuleBody/action validation logic.

Suggested reviewers

  • baz-reviewer
  • anakarentorosserrano-star

Poem

🐇
I thumped my paws and ran the tests,
From rules to mail and URL quests.
Variables found and text made neat,
Sorting, parsing — all discrete.
A carrot nibble for code well-dressed! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main additions: comprehensive test coverage for mail, url, and rule validation utilities, plus related test files for action handling, parsing, and text utilities.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/web/utils/mail.test.ts">

<violation number="1" location="apps/web/utils/mail.test.ts:230">
P2: Test asserts that result contains the new message but doesn't verify that quoted content is actually stripped, as the comment claims. Add an assertion like `expect(result).not.toContain("Old quoted content")` to verify the core functionality.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @apps/web/utils/url.test.ts:
- Around line 60-68: getProviderConfig currently only falls back when provider
is undefined, so PROVIDER_CONFIG[unknownKey] becomes undefined and later calls
like config.buildUrl in getEmailUrl throw; update getProviderConfig to guard
against missing keys by resolving the provider key then defaulting to
PROVIDER_CONFIG["default"] when the lookup returns undefined (e.g., compute a
resolvedKey = provider ?? "default" then return PROVIDER_CONFIG[resolvedKey] ??
PROVIDER_CONFIG["default"]) so unknown provider strings fall back to the default
config.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e6d0c8 and 82e0ac6.

📒 Files selected for processing (4)
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)

**/*.{ts,tsx}: For API GET requests to server, use the swr package
Use result?.serverError with toastError from @/components/Toast for error handling in async operations

**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls

**/*.{ts,tsx}: For early access feature flags, create hooks using the naming convention use[FeatureName]Enabled that return a boolean from useFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming convention use[FeatureName]Variant that define variant types, use useFeatureFlagVariantKey() with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g., inbox-cleaner, pricing-options-2)
Always define types for A/B test variant flags (e.g., type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting

**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
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 TypeScript namespaces
Don't use non-null assertions with the ! postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Use as const instead of literal types and type annotations
Use either T[] or Array<T> consistently
Initialize each enum member value explicitly
Use export type for types
Use `impo...

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)

Always import Prisma enums from @/generated/prisma/enums instead of @/generated/prisma/client to avoid Next.js bundling errors in client components

Import Prisma using the project's centralized utility: import prisma from '@/utils/prisma'

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/security.mdc)

**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma's select option. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. All findUnique/findFirst calls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
All findMany queries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g., emailAccount: { id: emailAccountId }) to validate ownership

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Use next/image package for images
For API GET requests to server, use the swr package with hooks like useSWR to fetch data
For text inputs, use the Input component with registerProps for form integration and error handling

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{tsx,ts,css}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

Implement responsive design with Tailwind CSS using a mobile-first approach

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: 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
Don't use distracting elements like <marquee> or <blink>
Only use the scope prop on <th> 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
Use semantic elements instead of role attributes in JSX
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 AR...

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
!(pages/_document).{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

Don't use the next/head module in pages/_document.js on Next.js projects

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)

**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)

Logger should be passed as a parameter to helper functions instead of creating their own logger instances

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx,js,jsx}: Use @/ path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Format code with Prettier

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
apps/web/**/*.{example,ts,json}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Add environment variables to .env.example, env.ts, and turbo.json

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

**/*.test.{ts,tsx}: Use vitest as the testing framework
Colocate test files next to the tested file with .test.ts or .test.tsx naming convention (e.g., dir/format.ts and dir/format.test.ts)
Mock server-only using vi.mock("server-only", () => ({}))
Mock Prisma using vi.mock("@/utils/prisma") and the provided mock from @/utils/__mocks__/prisma
Use test helper functions getEmail, getEmailAccount, and getRule from @/__tests__/helpers for creating mock data
Clear all mocks between tests using beforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
**/*.test.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
apps/web/utils/actions/*.ts

📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)

apps/web/utils/actions/*.ts: Use next-safe-action with Zod schemas for all server actions (create/update/delete mutations), storing validation schemas in apps/web/utils/actions/*.validation.ts
Server actions should use 'use server' directive and automatically receive authentication context (emailAccountId) from the actionClient

apps/web/utils/actions/*.ts: Create corresponding server action implementation files using the naming convention apps/web/utils/actions/NAME.ts with 'use server' directive
Use 'use server' directive at the top of server action implementation files
Implement all server actions using the next-safe-action library with actionClient, actionClientUser, or adminActionClient for type safety and validation
Use actionClientUser when only authenticated user context (userId) is needed
Use actionClient when both authenticated user context and a specific emailAccountId are needed, with emailAccountId bound when calling from the client
Use adminActionClient for actions restricted to admin users
Add metadata with a meaningful action name using .metadata({ name: "actionName" }) for Sentry instrumentation and monitoring
Use .schema() method with Zod validation schemas from corresponding .validation.ts files in next-safe-action configuration
Access context (userId, emailAccountId, etc.) via the ctx object parameter in the .action() handler
Use revalidatePath or revalidateTag from 'next/cache' within server action handlers when mutations modify data displayed elsewhere

Files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

apps/web/utils/actions/**/*.ts: Server actions must be located in apps/web/utils/actions folder
Server action files must start with use server directive

apps/web/utils/actions/**/*.ts: Use proper error handling with try/catch blocks
Use next-safe-action with Zod schemas for server actions to handle mutations
Use revalidatePath in server actions for cache invalidation after mutations

Files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Infer types from Zod schemas using z.infer<typeof schema> instead of duplicating as separate interfaces

Files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
**/*.validation.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)

**/*.validation.{ts,tsx}: Define validation schemas using Zod
Use descriptive error messages in validation schemas

Files:

  • apps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/*.validation.ts

📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)

apps/web/utils/actions/*.validation.ts: Define Zod validation schemas in separate *.validation.ts files and export both the schema and inferred type (e.g., CreateExampleBody)
Export types from Zod schemas using z.infer<> to maintain type safety between validation and client usage

apps/web/utils/actions/*.validation.ts: Create separate validation files for server actions using the naming convention apps/web/utils/actions/NAME.validation.ts containing Zod schemas and inferred types
Define input validation schemas using Zod in .validation.ts files and export both the schema and its inferred TypeScript type

Files:

  • apps/web/utils/actions/rule.validation.ts
🧠 Learnings (26)
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`

Applied to files:

  • apps/web/utils/mail.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Keep Gmail provider-specific implementation details isolated within the apps/web/utils/gmail/ directory

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Design Gmail wrapper functions to be provider-agnostic to support future email providers like Outlook and ProtonMail

Applied to files:

  • apps/web/utils/mail.test.ts
  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information

Applied to files:

  • apps/web/utils/url.test.ts
  • apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests

Applied to files:

  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Always use wrapper functions from @/utils/gmail/ for Gmail API operations instead of direct provider API calls

Applied to files:

  • apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Create separate validation files for server actions using the naming convention `apps/web/utils/actions/NAME.validation.ts` containing Zod schemas and inferred types

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod validation schemas in separate `*.validation.ts` files and export both the schema and inferred type (e.g., `CreateExampleBody`)

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `.schema()` method with Zod validation schemas from corresponding `.validation.ts` files in next-safe-action configuration

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `next-safe-action` with Zod schemas for all server actions (create/update/delete mutations), storing validation schemas in `apps/web/utils/actions/*.validation.ts`

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in `.validation.ts` files and export both the schema and its inferred TypeScript type

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:36:51.389Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-11-25T14:36:51.389Z
Learning: Applies to **/*.validation.ts : Define validation schemas using Zod

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Set timeout constant `const TIMEOUT = 15_000;` for LLM tests

Applied to files:

  • apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:36:51.389Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-11-25T14:36:51.389Z
Learning: Applies to **/*.validation.ts : Use descriptive error messages in Zod validation schemas

Applied to files:

  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to app/api/**/*.ts : All input parameters must be validated - check for presence, type, and format before use; use Zod schemas to validate request bodies with type guards and constraints

Applied to files:

  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions

Applied to files:

  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Remove redundant terms from logical expressions

Applied to files:

  • apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use `String.trimStart()` and `String.trimEnd()` over `String.trimLeft()` and `String.trimRight()`

Applied to files:

  • apps/web/utils/actions/rule.validation.ts
🧬 Code graph analysis (2)
apps/web/utils/mail.test.ts (1)
apps/web/utils/mail.ts (4)
  • emailToContent (74-103)
  • convertEmailHtmlToText (105-126)
  • parseReply (9-13)
  • getEmailClient (33-41)
apps/web/utils/actions/rule.validation.test.ts (2)
apps/web/utils/actions/rule.validation.ts (3)
  • delayInMinutesSchema (11-15)
  • CreateRuleBody (205-205)
  • createRuleBody (141-204)
apps/web/utils/date.ts (1)
  • NINETY_DAYS_MINUTES (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). (3)
  • GitHub Check: Baz Reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
🔇 Additional comments (5)
apps/web/utils/url.test.ts (1)

1-190: Excellent test coverage for URL utilities!

The test suite comprehensively covers all URL building functions across multiple providers with edge cases including:

  • Email address presence/absence
  • Special character encoding
  • Provider-specific behavior
  • Search and filter URL construction
apps/web/utils/mail.test.ts (1)

1-264: Comprehensive test coverage for mail utilities!

The test suite thoroughly validates all mail utility functions with excellent edge case coverage including:

  • Content source fallback hierarchy
  • Truncation behavior with various maxLength values
  • Forward content removal for multiple email clients
  • HTML-to-text conversion with link handling
  • Email client identification

The server-only mock on line 9 is appropriately used for unit testing.

apps/web/utils/actions/rule.validation.ts (2)

143-143: Good fix: Whitespace-only names now properly rejected.

Adding .trim() before .min(1) ensures that names consisting only of whitespace are correctly rejected. This is validated by the test at line 97-103 in the test file.


200-202: Good fix: Removed ineffective default value.

Removing .default(LogicalOperator.AND) makes the field truly optional. The previous .default() after .optional() was ineffective since .optional() already allows undefined values. This change is validated by the test at lines 384-390 in the test file.

apps/web/utils/actions/rule.validation.test.ts (1)

1-392: Excellent comprehensive validation test suite!

The test suite thoroughly validates all aspects of rule creation including:

  • Delay boundaries (1 minute to 90 days)
  • Name validation (non-empty, non-whitespace)
  • Actions and conditions requirements
  • Action-specific field requirements (LABEL, FORWARD, CALL_WEBHOOK, MOVE_FOLDER)
  • Duplicate condition detection
  • Optional field handling

The tests properly validate both success and failure paths with appropriate error message assertions.

Add 54 more tests for additional utility functions:
- template.test.ts: hasVariables and TEMPLATE_VARIABLE_PATTERN (22 tests)
- text.test.ts: slugify and extractTextFromPortableTextBlock (22 tests)
- filter-ignored-senders.test.ts: isIgnoredSender (10 tests)

Also improved parseReply test to verify quoted content is actually
stripped per PR feedback.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/web/utils/template.test.ts">

<violation number="1" location="apps/web/utils/template.test.ts:44">
P3: Duplicate test case - this test uses the identical string `"Hello {{name}}"` as the "detects simple variable" test above. Consider using a different input like `"said hello {{name}}"` to genuinely test a variable-at-end scenario.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +44 to +46
it("detects variable at end", () => {
expect(hasVariables("Hello {{name}}")).toBe(true);
});
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P3: Duplicate test case - this test uses the identical string "Hello {{name}}" as the "detects simple variable" test above. Consider using a different input like "said hello {{name}}" to genuinely test a variable-at-end scenario.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/template.test.ts, line 44:

<comment>Duplicate test case - this test uses the identical string `"Hello {{name}}"` as the "detects simple variable" test above. Consider using a different input like `"said hello {{name}}"` to genuinely test a variable-at-end scenario.</comment>

<file context>
@@ -0,0 +1,104 @@
+      expect(hasVariables("{{name}} said hello")).toBe(true);
+    });
+
+    it("detects variable at end", () => {
+      expect(hasVariables("Hello {{name}}")).toBe(true);
+    });
</file context>
Suggested change
it("detects variable at end", () => {
expect(hasVariables("Hello {{name}}")).toBe(true);
});
it("detects variable at end", () => {
expect(hasVariables("said hello {{name}}")).toBe(true);
});
Fix with Cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/utils/text.test.ts (1)

5-79: Consolidate duplicate slugify implementations.

The codebase has two separate slugify functions with different implementations:

  1. apps/web/utils/string.ts - actively used in sso.ts and organization/create/page.tsx, includes trim, Unicode-aware regex, and removes leading/trailing hyphens
  2. apps/web/utils/text.ts - only used in its own test file, simpler regex without trim or edge case handling

The text.ts implementation has no production usage. Consolidating to a single, well-tested implementation in string.ts will eliminate duplication and reduce maintenance overhead. If text.ts requires Portable Text-specific logic, consider either: (a) extending the unified implementation with an optional parameter, or (b) clearly documenting the purpose of the text.ts version.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82e0ac6 and c2dc0b4.

📒 Files selected for processing (4)
  • apps/web/utils/filter-ignored-senders.test.ts
  • apps/web/utils/mail.test.ts
  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/utils/mail.test.ts
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)

**/*.{ts,tsx}: For API GET requests to server, use the swr package
Use result?.serverError with toastError from @/components/Toast for error handling in async operations

**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls

**/*.{ts,tsx}: For early access feature flags, create hooks using the naming convention use[FeatureName]Enabled that return a boolean from useFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming convention use[FeatureName]Variant that define variant types, use useFeatureFlagVariantKey() with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g., inbox-cleaner, pricing-options-2)
Always define types for A/B test variant flags (e.g., type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting

**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
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 TypeScript namespaces
Don't use non-null assertions with the ! postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Use as const instead of literal types and type annotations
Use either T[] or Array<T> consistently
Initialize each enum member value explicitly
Use export type for types
Use `impo...

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)

Always import Prisma enums from @/generated/prisma/enums instead of @/generated/prisma/client to avoid Next.js bundling errors in client components

Import Prisma using the project's centralized utility: import prisma from '@/utils/prisma'

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/security.mdc)

**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma's select option. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. All findUnique/findFirst calls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
All findMany queries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g., emailAccount: { id: emailAccountId }) to validate ownership

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Use next/image package for images
For API GET requests to server, use the swr package with hooks like useSWR to fetch data
For text inputs, use the Input component with registerProps for form integration and error handling

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{tsx,ts,css}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

Implement responsive design with Tailwind CSS using a mobile-first approach

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: 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
Don't use distracting elements like <marquee> or <blink>
Only use the scope prop on <th> 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
Use semantic elements instead of role attributes in JSX
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 AR...

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
!(pages/_document).{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

Don't use the next/head module in pages/_document.js on Next.js projects

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)

**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)

Logger should be passed as a parameter to helper functions instead of creating their own logger instances

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx,js,jsx}: Use @/ path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Format code with Prettier

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{example,ts,json}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Add environment variables to .env.example, env.ts, and turbo.json

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

**/*.test.{ts,tsx}: Use vitest as the testing framework
Colocate test files next to the tested file with .test.ts or .test.tsx naming convention (e.g., dir/format.ts and dir/format.test.ts)
Mock server-only using vi.mock("server-only", () => ({}))
Mock Prisma using vi.mock("@/utils/prisma") and the provided mock from @/utils/__mocks__/prisma
Use test helper functions getEmail, getEmailAccount, and getRule from @/__tests__/helpers for creating mock data
Clear all mocks between tests using beforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
**/*.test.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
🧠 Learnings (16)
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `describe.runIf(isAiTest)` with environment variable `RUN_AI_TESTS === "true"` to conditionally run LLM tests

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/text.test.ts
📚 Learning: 2026-01-04T00:25:22.311Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/notes.mdc:0-0
Timestamp: 2026-01-04T00:25:22.311Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`

Applied to files:

  • apps/web/utils/template.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers

Applied to files:

  • apps/web/utils/template.test.ts
  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.{example,ts,json} : Add environment variables to `.env.example`, `env.ts`, and `turbo.json`

Applied to files:

  • apps/web/utils/template.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions

Applied to files:

  • apps/web/utils/text.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests

Applied to files:

  • apps/web/utils/text.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data

Applied to files:

  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Keep Gmail provider-specific implementation details isolated within the apps/web/utils/gmail/ directory

Applied to files:

  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place AI tests in the `__tests__` directory and do not run them by default as they use a real LLM

Applied to files:

  • apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Make sure the assertion function, like expect, is placed inside an it() function call

Applied to files:

  • apps/web/utils/filter-ignored-senders.test.ts
🧬 Code graph analysis (1)
apps/web/utils/text.test.ts (1)
apps/web/utils/string.ts (1)
  • slugify (52-59)
🪛 ast-grep (0.40.4)
apps/web/utils/template.test.ts

[warning] 5-5: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)


[warning] 10-10: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)


[warning] 15-15: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)


[warning] 20-20: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)

⏰ 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). (4)
  • GitHub Check: Baz Reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
apps/web/utils/filter-ignored-senders.test.ts (1)

1-52: LGTM! Comprehensive test coverage for isIgnoredSender.

The test suite thoroughly covers the expected behavior:

  • Exact match validation
  • Case sensitivity requirements
  • Edge cases (empty strings, partial matches, substrings)
  • Different email formats

The tests are well-organized and follow project conventions.

apps/web/utils/template.test.ts (1)

1-104: LGTM! Thorough test coverage for template variable detection.

The tests comprehensively validate both TEMPLATE_VARIABLE_PATTERN and hasVariables:

  • Various variable formats (simple, spaces, multiline, special characters)
  • Edge cases (empty variables, unmatched braces)
  • Null/undefined handling

Note: The static analysis warnings about ReDoS for new RegExp(TEMPLATE_VARIABLE_PATTERN) are false positives in this context—TEMPLATE_VARIABLE_PATTERN is an imported constant, not user input, and the tests are specifically validating the pattern's behavior.

apps/web/utils/text.test.ts (1)

81-136: LGTM! Comprehensive test coverage for extractTextFromPortableTextBlock.

The tests thoroughly validate text extraction from PortableText blocks:

  • Single and multiple spans
  • Empty children arrays
  • Non-span children filtering
  • Empty text handling

Add 81 more tests:
- action-sort.test.ts (12 tests): action priority sorting
- action-item.test.ts (27 tests): field extraction and sanitization
- parse/unsubscribe.test.ts (16 tests): unsubscribe keyword detection
- parse/cta.test.ts (26 tests): CTA keyword detection with length constraints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/web/utils/parse/cta.test.ts">

<violation number="1" location="apps/web/utils/parse/cta.test.ts:60">
P2: Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +60 to +62
it("returns true for text exactly 29 characters with keyword", () => {
// "view it on GitHub" is 17 chars, add 12 more to get 29
const text = "view it on GitHub123456";
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P2: Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/parse/cta.test.ts, line 60:

<comment>Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.</comment>

<file context>
@@ -0,0 +1,129 @@
+  });
+
+  describe("length constraint (max 30 characters)", () => {
+    it("returns true for text exactly 29 characters with keyword", () => {
+      // "view it on GitHub" is 17 chars, add 12 more to get 29
+      const text = "view it on GitHub123456";
</file context>
Suggested change
it("returns true for text exactly 29 characters with keyword", () => {
// "view it on GitHub" is 17 chars, add 12 more to get 29
const text = "view it on GitHub123456";
it("returns true for text within the 30 character limit", () => {
// "view it on GitHub" is 17 chars, add 6 more to get 23
const text = "view it on GitHub123456";
Fix with Cubic

…DER to action priority

- Make containsUnsubscribeKeyword case-insensitive by lowercasing input text
- Add NOTIFY_SENDER to ACTION_TYPE_PRIORITY_ORDER (before CALL_WEBHOOK)
- Update tests to reflect both fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @apps/web/utils/action-sort.test.ts:
- Around line 55-84: The test "maintains correct priority order for all action
types" is missing ActionType.NOTIFY_SENDER; add { type: ActionType.NOTIFY_SENDER
} to the input actions array and include ActionType.NOTIFY_SENDER in the
expected sorted array returned from sortActionsByPriority, placing it at the
correct position according to the priority defined in action-sort.ts; update the
assertions in apps/web/utils/action-sort.test.ts so the input, call to
sortActionsByPriority, and expected arrays both contain NOTIFY_SENDER using the
same ActionType symbol.

In @apps/web/utils/parse/cta.test.ts:
- Around line 60-65: The test "returns true for text exactly 29 characters with
keyword" is inconsistent: the text variable ("view it on GitHub123456") and its
length assertion use 23, not 29; update the test to be consistent by either (A)
renaming the test description and comment to say 23 characters (and keep
expect(text.length).toBe(23)) or (B) change the text string so it is actually 29
characters and update the expect(text.length) to 29; adjust the inline comment
accordingly and leave the containsCtaKeyword(text) assertion as-is.
- Around line 107-113: The containsCtaKeyword function is case-sensitive and
misses common CTA casing; update it to normalize case like
containsUnsubscribeKeyword by comparing text.toLowerCase() (and keywords
lowercased) when checking includes, and then update the related tests ("is case
sensitive - does not match uppercase"/"title case") to expect true (or remove
those negative tests) so CTA strings like "VIEW IT" and "View It" are
recognized.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2dc0b4 and c6d096d.

📒 Files selected for processing (6)
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/unsubscribe.ts
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)

**/*.{ts,tsx}: For API GET requests to server, use the swr package
Use result?.serverError with toastError from @/components/Toast for error handling in async operations

**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls

**/*.{ts,tsx}: For early access feature flags, create hooks using the naming convention use[FeatureName]Enabled that return a boolean from useFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming convention use[FeatureName]Variant that define variant types, use useFeatureFlagVariantKey() with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g., inbox-cleaner, pricing-options-2)
Always define types for A/B test variant flags (e.g., type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting

**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
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 TypeScript namespaces
Don't use non-null assertions with the ! postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Use as const instead of literal types and type annotations
Use either T[] or Array<T> consistently
Initialize each enum member value explicitly
Use export type for types
Use `impo...

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)

Always import Prisma enums from @/generated/prisma/enums instead of @/generated/prisma/client to avoid Next.js bundling errors in client components

Import Prisma using the project's centralized utility: import prisma from '@/utils/prisma'

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/security.mdc)

**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma's select option. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. All findUnique/findFirst calls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
All findMany queries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g., emailAccount: { id: emailAccountId }) to validate ownership

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Use next/image package for images
For API GET requests to server, use the swr package with hooks like useSWR to fetch data
For text inputs, use the Input component with registerProps for form integration and error handling

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{tsx,ts,css}

📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)

Implement responsive design with Tailwind CSS using a mobile-first approach

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{js,jsx,ts,tsx}: 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
Don't use distracting elements like <marquee> or <blink>
Only use the scope prop on <th> 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
Use semantic elements instead of role attributes in JSX
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 AR...

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
!(pages/_document).{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

Don't use the next/head module in pages/_document.js on Next.js projects

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)

**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g., import groupBy from 'lodash/groupBy')

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)

Logger should be passed as a parameter to helper functions instead of creating their own logger instances

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

apps/web/**/*.{ts,tsx,js,jsx}: Use @/ path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Format code with Prettier

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{example,ts,json}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Add environment variables to .env.example, env.ts, and turbo.json

Files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
  • apps/web/utils/parse/unsubscribe.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests

Files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
apps/web/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (apps/web/CLAUDE.md)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

**/*.test.{ts,tsx}: Use vitest as the testing framework
Colocate test files next to the tested file with .test.ts or .test.tsx naming convention (e.g., dir/format.ts and dir/format.test.ts)
Mock server-only using vi.mock("server-only", () => ({}))
Mock Prisma using vi.mock("@/utils/prisma") and the provided mock from @/utils/__mocks__/prisma
Use test helper functions getEmail, getEmailAccount, and getRule from @/__tests__/helpers for creating mock data
Clear all mocks between tests using beforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests

Files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
**/*.test.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)

Co-locate test files next to source files (e.g., utils/example.test.ts). Only E2E and AI tests go in __tests__/

Files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
🧠 Learnings (23)
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Add metadata with a meaningful action name using `.metadata({ name: "actionName" })` for Sentry instrumentation and monitoring

Applied to files:

  • apps/web/utils/action-sort.ts
  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place AI tests in the `__tests__` directory and do not run them by default as they use a real LLM

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Make sure the assertion function, like expect, is placed inside an it() function call

Applied to files:

  • apps/web/utils/parse/unsubscribe.test.ts
  • apps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `describe.runIf(isAiTest)` with environment variable `RUN_AI_TESTS === "true"` to conditionally run LLM tests

Applied to files:

  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Keep related AI functions in the same file or directory, extract common patterns into utility functions, and document complex AI logic with clear comments

Applied to files:

  • apps/web/utils/parse/cta.test.ts
📚 Learning: 2026-01-04T00:25:22.311Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/notes.mdc:0-0
Timestamp: 2026-01-04T00:25:22.311Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`

Applied to files:

  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests

Applied to files:

  • apps/web/utils/parse/cta.test.ts
  • apps/web/utils/action-item.test.ts
  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : User prompts must contain the actual data and context, and should be kept separate from system prompts

Applied to files:

  • apps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information

Applied to files:

  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Implement all server actions using the `next-safe-action` library with actionClient, actionClientUser, or adminActionClient for type safety and validation

Applied to files:

  • apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Create separate validation files for server actions using the naming convention `apps/web/utils/actions/NAME.validation.ts` containing Zod schemas and inferred types

Applied to files:

  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `next-safe-action` with Zod schemas for all server actions (create/update/delete mutations), storing validation schemas in `apps/web/utils/actions/*.validation.ts`

Applied to files:

  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Server actions must be located in `apps/web/utils/actions` folder

Applied to files:

  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use `next-safe-action` with Zod schemas for server actions to handle mutations

Applied to files:

  • apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:27.988Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-11-25T14:38:27.988Z
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/utils/parse/unsubscribe.ts
📚 Learning: 2025-11-25T14:38:32.328Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-11-25T14:38:32.328Z
Learning: Applies to **/*.{ts,tsx} : Use kebab-case for PostHog feature flag keys (e.g., `inbox-cleaner`, `pricing-options-2`)

Applied to files:

  • apps/web/utils/parse/unsubscribe.ts
🧬 Code graph analysis (3)
apps/web/utils/parse/unsubscribe.test.ts (1)
apps/web/utils/parse/unsubscribe.ts (1)
  • containsUnsubscribeKeyword (9-12)
apps/web/utils/action-item.test.ts (1)
apps/web/utils/action-item.ts (3)
  • actionInputs (4-155)
  • getActionFields (157-182)
  • sanitizeActionFields (200-289)
apps/web/utils/action-sort.test.ts (1)
apps/web/utils/action-sort.ts (1)
  • sortActionsByPriority (41-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). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Baz Reviewer
  • GitHub Check: test
🔇 Additional comments (13)
apps/web/utils/parse/unsubscribe.ts (1)

9-12: LGTM! Case-insensitive matching implemented correctly.

The implementation efficiently converts the input text to lowercase once and compares against the already-lowercase keywords. This ensures consistent keyword detection regardless of text casing.

apps/web/utils/parse/unsubscribe.test.ts (1)

1-91: LGTM! Excellent test coverage and organization.

The test suite is comprehensive and well-structured:

  • All five keywords are individually tested
  • Matching behavior is verified at different text positions
  • Case insensitivity is thoroughly validated with multiple test cases
  • Negative cases ensure no false positives
  • Test names are descriptive and clearly indicate what's being tested
  • Follows coding guidelines (vitest, co-location, proper naming convention)
apps/web/utils/action-sort.ts (1)

23-23: LGTM! NOTIFY_SENDER positioned appropriately.

The placement of NOTIFY_SENDER between MARK_SPAM and CALL_WEBHOOK is logical and matches the test expectations.

apps/web/utils/action-sort.test.ts (3)

6-52: LGTM! Basic sorting tests are comprehensive.

The tests cover key sorting relationships and action grouping correctly.


87-153: LGTM! Edge case coverage is thorough.

Tests properly verify empty arrays, single actions, duplicates, property preservation, and non-mutation of the original array.


155-169: LGTM! NOTIFY_SENDER placement test is correct.

The test correctly verifies that NOTIFY_SENDER appears after LABEL and before CALL_WEBHOOK.

apps/web/utils/action-item.test.ts (3)

9-44: LGTM! ActionInputs tests are comprehensive.

Tests verify all action types have configuration and validate specific field requirements for different action types.


46-103: LGTM! Field extraction tests are thorough.

Tests correctly verify that only truthy values are returned, empty strings and nulls are excluded, and all populated fields are preserved.


105-295: LGTM! Sanitization tests comprehensively cover all action types.

Tests verify correct field preservation and nullification for each action type, including the new NOTIFY_SENDER type and delayInMinutes handling.

apps/web/utils/parse/cta.test.ts (4)

1-2: LGTM!

Imports follow the project's testing conventions with proper vitest usage and co-located test file structure.


5-57: LGTM!

Comprehensive coverage of CTA keyword detection with clear, descriptive test cases.


67-92: LGTM!

Length constraint boundary tests are accurate and comprehensive, properly testing the 30-character limit.


116-128: LGTM!

Position-based matching tests provide good coverage to ensure keywords are detected regardless of their location in the text.

Comment on lines +55 to +84
it("maintains correct priority order for all action types", () => {
const actions = [
{ type: ActionType.CALL_WEBHOOK },
{ type: ActionType.MARK_SPAM },
{ type: ActionType.DIGEST },
{ type: ActionType.FORWARD },
{ type: ActionType.SEND_EMAIL },
{ type: ActionType.REPLY },
{ type: ActionType.DRAFT_EMAIL },
{ type: ActionType.MARK_READ },
{ type: ActionType.ARCHIVE },
{ type: ActionType.MOVE_FOLDER },
{ type: ActionType.LABEL },
];

const sorted = sortActionsByPriority(actions);
expect(sorted.map((a) => a.type)).toEqual([
ActionType.LABEL,
ActionType.MOVE_FOLDER,
ActionType.ARCHIVE,
ActionType.MARK_READ,
ActionType.DRAFT_EMAIL,
ActionType.REPLY,
ActionType.SEND_EMAIL,
ActionType.FORWARD,
ActionType.DIGEST,
ActionType.MARK_SPAM,
ActionType.CALL_WEBHOOK,
]);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Test is incomplete – missing NOTIFY_SENDER.

The test claims to "maintain correct priority order for all action types" but doesn't include NOTIFY_SENDER in either the input or expected arrays. Since NOTIFY_SENDER was added to the priority order in action-sort.ts, this test should include it.

🔧 Proposed fix
 it("maintains correct priority order for all action types", () => {
   const actions = [
     { type: ActionType.CALL_WEBHOOK },
+    { type: ActionType.NOTIFY_SENDER },
     { type: ActionType.MARK_SPAM },
     { type: ActionType.DIGEST },
     { type: ActionType.FORWARD },
     { type: ActionType.SEND_EMAIL },
     { type: ActionType.REPLY },
     { type: ActionType.DRAFT_EMAIL },
     { type: ActionType.MARK_READ },
     { type: ActionType.ARCHIVE },
     { type: ActionType.MOVE_FOLDER },
     { type: ActionType.LABEL },
   ];

   const sorted = sortActionsByPriority(actions);
   expect(sorted.map((a) => a.type)).toEqual([
     ActionType.LABEL,
     ActionType.MOVE_FOLDER,
     ActionType.ARCHIVE,
     ActionType.MARK_READ,
     ActionType.DRAFT_EMAIL,
     ActionType.REPLY,
     ActionType.SEND_EMAIL,
     ActionType.FORWARD,
     ActionType.DIGEST,
     ActionType.MARK_SPAM,
+    ActionType.NOTIFY_SENDER,
     ActionType.CALL_WEBHOOK,
   ]);
 });
🤖 Prompt for AI Agents
In @apps/web/utils/action-sort.test.ts around lines 55 - 84, The test "maintains
correct priority order for all action types" is missing
ActionType.NOTIFY_SENDER; add { type: ActionType.NOTIFY_SENDER } to the input
actions array and include ActionType.NOTIFY_SENDER in the expected sorted array
returned from sortActionsByPriority, placing it at the correct position
according to the priority defined in action-sort.ts; update the assertions in
apps/web/utils/action-sort.test.ts so the input, call to sortActionsByPriority,
and expected arrays both contain NOTIFY_SENDER using the same ActionType symbol.

Comment on lines +60 to +65
it("returns true for text exactly 29 characters with keyword", () => {
// "view it on GitHub" is 17 chars, add 12 more to get 29
const text = "view it on GitHub123456";
expect(text.length).toBe(23);
expect(containsCtaKeyword(text)).toBe(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix test name or text length - inconsistency detected.

The test name claims "text exactly 29 characters" but the assertion on line 63 verifies the text is 23 characters. The comment on line 61 also incorrectly states the math. Either update the test name to reflect 23 characters or adjust the text to actually be 29 characters.

🔧 Suggested fix

Option 1: Update the test name to match the actual length:

-    it("returns true for text exactly 29 characters with keyword", () => {
-      // "view it on GitHub" is 17 chars, add 12 more to get 29
+    it("returns true for text with keyword (23 characters)", () => {
+      // "view it on GitHub123456" is 23 chars
       const text = "view it on GitHub123456";
       expect(text.length).toBe(23);
       expect(containsCtaKeyword(text)).toBe(true);
     });

Option 2: Adjust the text to be 29 characters:

     it("returns true for text exactly 29 characters with keyword", () => {
-      // "view it on GitHub" is 17 chars, add 12 more to get 29
-      const text = "view it on GitHub123456";
-      expect(text.length).toBe(23);
+      // Exactly 29 characters with keyword
+      const text = "view it on GitHub12345678901"; // 29 chars
+      expect(text.length).toBe(29);
       expect(containsCtaKeyword(text)).toBe(true);
     });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("returns true for text exactly 29 characters with keyword", () => {
// "view it on GitHub" is 17 chars, add 12 more to get 29
const text = "view it on GitHub123456";
expect(text.length).toBe(23);
expect(containsCtaKeyword(text)).toBe(true);
});
it("returns true for text with keyword (23 characters)", () => {
// "view it on GitHub123456" is 23 chars
const text = "view it on GitHub123456";
expect(text.length).toBe(23);
expect(containsCtaKeyword(text)).toBe(true);
});
🤖 Prompt for AI Agents
In @apps/web/utils/parse/cta.test.ts around lines 60 - 65, The test "returns
true for text exactly 29 characters with keyword" is inconsistent: the text
variable ("view it on GitHub123456") and its length assertion use 23, not 29;
update the test to be consistent by either (A) renaming the test description and
comment to say 23 characters (and keep expect(text.length).toBe(23)) or (B)
change the text string so it is actually 29 characters and update the
expect(text.length) to 29; adjust the inline comment accordingly and leave the
containsCtaKeyword(text) assertion as-is.

Comment on lines +107 to +113
it("is case sensitive - does not match uppercase", () => {
expect(containsCtaKeyword("VIEW IT")).toBe(false);
});

it("is case sensitive - does not match title case", () => {
expect(containsCtaKeyword("View It")).toBe(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat apps/web/utils/parse/cta.ts

Repository: elie222/inbox-zero

Length of output: 667


🏁 Script executed:

cat apps/web/utils/parse/unsubscribe.ts

Repository: elie222/inbox-zero

Length of output: 382


Make containsCtaKeyword case-insensitive to match common email button formatting.

The function is case-sensitive and will miss CTA buttons using uppercase or title case. Compare the implementations:

  • containsCtaKeyword: Checks text.includes(keyword) without lowercasing → rejects "VIEW IT" and "View It"
  • containsUnsubscribeKeyword: Uses text.toLowerCase() before checking → handles all case variations

CTA buttons commonly use uppercase or title case for visual emphasis (e.g., "VIEW DETAILS", "CONFIRM", "Reply Now"). Apply the same case-insensitive pattern used in containsUnsubscribeKeyword to avoid missing valid CTAs.

🤖 Prompt for AI Agents
In @apps/web/utils/parse/cta.test.ts around lines 107 - 113, The
containsCtaKeyword function is case-sensitive and misses common CTA casing;
update it to normalize case like containsUnsubscribeKeyword by comparing
text.toLowerCase() (and keywords lowercased) when checking includes, and then
update the related tests ("is case sensitive - does not match uppercase"/"title
case") to expect true (or remove those negative tests) so CTA strings like "VIEW
IT" and "View It" are recognized.

@elie222 elie222 merged commit ecc7fc6 into main Jan 8, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant