Conversation
- Add toggle + Configure button UI to Digest setting - Create toggleDigestAction to enable/disable digest - When enabled: creates daily 9am schedule, adds DIGEST action to Newsletter rule - When disabled: deletes schedule - Add loading skeleton to prevent flash on both Digest and Follow-up settings - Extract buildScheduleCreateData helper and DEFAULT_DIGEST_SCHEDULE constant Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds loading states to digest and follow-up reminder settings, introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as DigestSetting UI
participant Action as toggleDigestAction
participant DB as Database
participant Hook as useEmailAccountFull
User->>UI: Click Toggle
UI->>UI: Set optimistic state
UI->>Action: Call toggleDigestAction({ enabled })
alt Enable Digest
Action->>DB: Upsert digest schedule
Action->>DB: Create/ensure DIGEST action
Action->>DB: Calculate nextOccurrenceAt
else Disable Digest
Action->>DB: Delete all digest schedules
end
alt Success
DB-->>Action: Success response
Action-->>UI: { success: true }
UI->>Hook: mutate() refresh data
Hook-->>UI: Updated data
else Error
DB-->>Action: Error
Action-->>UI: Error thrown
UI->>UI: Show error toast
UI->>Hook: mutate() refresh data
Hook-->>UI: Restore previous state
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
2 issues 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/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx">
<violation number="1" location="apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx:26">
P2: `enabled` defaults to true while account data is still loading (or failed), so the Digest toggle and Configure button incorrectly render as enabled even though the real state is unknown and interactions are ignored. Default to false until `digestSchedule` is actually present.</violation>
</file>
<file name="apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx">
<violation number="1" location="apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx:114">
P2: Disable the toggle when account data is unavailable so the control doesn’t appear clickable while `handleToggle` is a no-op.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
Show resolved
Hide resolved
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
Show resolved
Hide resolved
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
Show resolved
Hide resolved
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
Show resolved
Hide resolved
- Fix enabled state to use != null (handles undefined correctly) - Add disabled prop to follow-up reminders toggle when data unavailable Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @apps/web/utils/actions/settings.ts:
- Around line 155-201: toggleDigestAction and updateDigestScheduleAction perform
prisma.schedule mutations but don't call revalidatePath to invalidate the UI
cache; after each schedule-changing operation (the upsert and delete in
toggleDigestAction and the update in updateDigestScheduleAction) call
revalidatePath with your settings page route (e.g. revalidatePath("/settings"))
to revalidate the cache, and add the appropriate import for revalidatePath (from
next/cache or your routing util).
🧹 Nitpick comments (2)
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx (1)
59-90: Add disabled prop to the Toggle component.The Toggle component should have a
disabled={!data}prop to prevent interaction when data is unavailable, matching the pattern inFollowUpRemindersSetting.tsx(line 118).♻️ Suggested fix
<Toggle name="digest-enabled" enabled={enabled} onChange={handleToggle} + disabled={!data} />apps/web/utils/actions/settings.ts (1)
167-179: Consider whether the empty update object is intentional.The
upsertuses an emptyupdate: {}object (line 178), meaning if a schedule already exists, enabling digest won't modify it. This could preserve user customizations, but it might be unexpected if the user disabled and then re-enabled digest - they might expect it to reset to defaults.If the intent is to reset to defaults on re-enable:
♻️ Alternative approach
await prisma.schedule.upsert({ where: { emailAccountId }, create: { emailAccountId, ...defaultSchedule, lastOccurrenceAt: new Date(), nextOccurrenceAt: calculateNextScheduleDate({ ...defaultSchedule, lastOccurrenceAt: null, }), }, - update: {}, + update: { + ...defaultSchedule, + lastOccurrenceAt: new Date(), + nextOccurrenceAt: calculateNextScheduleDate({ + ...defaultSchedule, + lastOccurrenceAt: null, + }), + }, });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsxapps/web/utils/actions/settings.tsapps/web/utils/actions/settings.validation.ts
🧰 Additional context used
📓 Path-based instructions (25)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor 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}: 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
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Useimport typefor types
Make sure all enum members are literal values
Don't use TypeScript const enum
Don't declare empty interfaces
Don't let variables evolve into any type through reassignments
Don't use the any type
Don't misuse the non-null assertion operator (!) in TypeScript files
Don't use implicit any type on variable declarations
Don't merge interfaces and classes unsafely
Don't use overload signatures that aren't next to each other
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces
Use consistent accessibility modifiers on class properties and methods
Use function types instead of object types wit...
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.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/settings.validation.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/utils/actions/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/actions/**/*.ts: Server actions must be located inapps/web/utils/actionsfolder
Server action files must start withuse serverdirective
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.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
Infer types from Zod schemas usingz.infer<typeof schema>instead of duplicating as separate interfaces
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.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'sselectoption. 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. AllfindUnique/findFirstcalls 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
AllfindManyqueries 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/actions/settings.validation.tsapps/web/utils/actions/settings.ts
apps/web/utils/actions/*.validation.ts
📄 CodeRabbit inference engine (.cursor/rules/server-actions.mdc)
apps/web/utils/actions/*.validation.ts: Create separate validation files for server actions using the naming conventionapps/web/utils/actions/NAME.validation.tscontaining Zod schemas and inferred types
Define input validation schemas using Zod in.validation.tsfiles and export both the schema and its inferred TypeScript typeValidation schemas should be in separate files (e.g.,
utils/actions/example.validation.ts)
Files:
apps/web/utils/actions/settings.validation.ts
apps/web/utils/actions/*.ts
📄 CodeRabbit inference engine (.cursor/rules/server-actions.mdc)
apps/web/utils/actions/*.ts: Create corresponding server action implementation files using the naming conventionapps/web/utils/actions/NAME.tswith 'use server' directive
Use 'use server' directive at the top of server action implementation files
Implement all server actions using thenext-safe-actionlibrary with actionClient, actionClientUser, or adminActionClient for type safety and validation
UseactionClientUserwhen only authenticated user context (userId) is needed
UseactionClientwhen both authenticated user context and a specific emailAccountId are needed, with emailAccountId bound when calling from the client
UseadminActionClientfor 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.tsfiles in next-safe-action configuration
Access context (userId, emailAccountId, etc.) via thectxobject parameter in the.action()handler
UserevalidatePathorrevalidateTagfrom 'next/cache' within server action handlers when mutations modify data displayed elsewhere
apps/web/utils/actions/*.ts: Usenext-safe-actionwith proper Zod validation for server actions
Server actions should useactionClient.metadata({ name: 'actionName' }).schema(schema).action(...)pattern
CallrevalidatePathin server actions after successful mutations
UserevalidatePathin server actions for cache invalidation
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.{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/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-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 thescopeprop 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 assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
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 atitleelement 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
AssigntabIndexto non-interactive HTML elements witharia-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 atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/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/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
!(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/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.{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')
**/*.{js,ts,jsx,tsx}: 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/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/{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/actions/settings.validation.tsapps/web/utils/actions/settings.ts
apps/web/utils/actions/**/*.validation.ts
📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)
Create Zod validation schemas at
apps/web/utils/actions/{feature}.validation.tsfor all server action input validation
Files:
apps/web/utils/actions/settings.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
Use proper error handling with try/catch blocks
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments. Never add comments that just describe what the code does. Only add comments for 'why' not 'what'
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports
UsegetActionErrorMessage(error.error)from@/utils/errorto extract user-friendly error messages
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/**/*.{ts,tsx,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Follow tailwindcss patterns with prettier-plugin-tailwindcss
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Client-side environment variables must be prefixed with
NEXT_PUBLIC_
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,rs,kt,swift,m}
📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments. Never add comments that just describe what the code does - code should explain itself. Only add comments for 'why' not 'what'.
Files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/utils/actions/!(*.validation).ts
📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)
apps/web/utils/actions/!(*.validation).ts: Usenext-safe-actionfor all server actions withactionClient,.metadata(),.inputSchema(), and.action()chain pattern
Add'use server'directive at the top of all server action files
Files:
apps/web/utils/actions/settings.ts
apps/web/app/(app)/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
apps/web/app/(app)/**/*.{ts,tsx}: Components for the page are either put inpage.tsx, or in theapps/web/app/(app)/PAGE_NAMEfolder
If we're in a deeply nested component we will useswrto fetch via API
If you need to useonClickin a component, that component is a client component and file must start withuse client
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.tsx: Use theLoadingContentcomponent to handle loading states instead of manual loading state management
For text areas, use theInputcomponent withtype='text',autosizeTextareaprop set to true, andregisterPropsfor form integration
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't use unnecessary fragments
Don't pass children as props
Don't use the return value of React.render
Make sure all dependencies are correctly specified in React hooks
Make sure all React hooks are called from the top level of component functions
Don't forget key props in iterators and collection literals
Don't define React components inside other components
Don't use event handlers on non-interactive elements
Don't assign to React component props
Don't use bothchildrenanddangerouslySetInnerHTMLprops on the same element
Don't use dangerous JSX props
Don't use Array index in keys
Don't insert comments as text nodes
Don't assign JSX properties multiple times
Don't add extra closing tags for components without children
Use<>...</>instead of<Fragment>...</Fragment>
Watch out for possible "wrong" semicolons inside JSX elements
Make sure void (self-closing) elements don't have children
Don't usetarget="_blank"withoutrel="noopener"
Don't use<img>elements in Next.js projects
Don't use<head>elements in Next.js projects
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{tsx,jsx}: Prefer functional components with hooks
Use shadcn/ui components when available
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data with loading and error states
Use React Hook Form with Zod validation for form handling
UseuseActionhook fromnext-safe-action/hookswithonSuccessandonErrorcallbacks for form submission
Use LoadingContent component to handle loading and error states consistently
Callmutate()after successful mutations to refresh SWR data
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
apps/web/**/*.{tsx,jsx,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Ensure responsive design with mobile-first approach
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
🧠 Learnings (35)
📓 Common learnings
Learnt from: elie222
Repo: elie222/inbox-zero PR: 1234
File: apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx:65-83
Timestamp: 2026-01-09T17:27:31.556Z
Learning: In the elie222/inbox-zero repository, for React components using next-safe-action, optimistic updates combined with mutate on success/error is an accepted pattern for handling potential race conditions in toggle handlers. Select components use disabled={isExecuting}, but rapid toggle clicks without isExecuting guards are considered acceptable because the optimistic UI + mutate reconciliation handles state correctly.
📚 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/settings.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/*.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/settings.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/settings.validation.ts
📚 Learning: 2025-11-25T14:39:08.150Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-11-25T14:39:08.150Z
Learning: Applies to apps/web/app/api/**/*.{ts,tsx} : Request bodies should use Zod schemas for validation to ensure type safety and prevent injection attacks
Applied to files:
apps/web/utils/actions/settings.validation.ts
📚 Learning: 2026-01-08T15:09:06.736Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2026-01-08T15:09:06.736Z
Learning: Applies to apps/web/utils/actions/**/*.validation.ts : Create Zod validation schemas at `apps/web/utils/actions/{feature}.validation.ts` for all server action input validation
Applied to files:
apps/web/utils/actions/settings.validation.ts
📚 Learning: 2025-11-25T14:39:27.909Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:27.909Z
Learning: Applies to **/app/api/**/*.ts : Always validate request bodies using Zod schemas to ensure type safety and prevent invalid data from reaching database operations
Applied to files:
apps/web/utils/actions/settings.validation.ts
📚 Learning: 2025-11-25T14:36:53.147Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-11-25T14:36:53.147Z
Learning: Applies to **/*.validation.{ts,tsx} : Define validation schemas using Zod
Applied to files:
apps/web/utils/actions/settings.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/settings.validation.ts
📚 Learning: 2026-01-09T21:51:15.182Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2026-01-09T21:51:15.182Z
Learning: Applies to apps/web/**/*.{ts,tsx} : Infer types from Zod schemas using `z.infer<typeof schema>` instead of duplicating as separate interfaces
Applied to files:
apps/web/utils/actions/settings.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/settings.validation.ts
📚 Learning: 2025-07-17T04:19:57.099Z
Learnt from: edulelis
Repo: elie222/inbox-zero PR: 576
File: packages/resend/emails/digest.tsx:78-83
Timestamp: 2025-07-17T04:19:57.099Z
Learning: In packages/resend/emails/digest.tsx, the DigestEmailProps type uses `[key: string]: DigestItem[] | undefined | string | Date | undefined` instead of intersection types like `& Record<string, DigestItem[] | undefined>` due to implementation constraints. This was the initial implementation approach and cannot be changed to more restrictive typing.
Applied to files:
apps/web/utils/actions/settings.validation.tsapps/web/utils/actions/settings.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2026-01-09T17:27:31.556Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 1234
File: apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx:65-83
Timestamp: 2026-01-09T17:27:31.556Z
Learning: In the elie222/inbox-zero repository, for React components using next-safe-action, optimistic updates combined with mutate on success/error is an accepted pattern for handling potential race conditions in toggle handlers. Select components use disabled={isExecuting}, but rapid toggle clicks without isExecuting guards are considered acceptable because the optimistic UI + mutate reconciliation handles state correctly.
Applied to files:
apps/web/utils/actions/settings.ts
📚 Learning: 2026-01-09T17:27:19.225Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 1234
File: apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx:65-83
Timestamp: 2026-01-09T17:27:19.225Z
Learning: In the elie222/inbox-zero repo, for React components using next-safe-action, using optimistic updates with mutate on success/error is an accepted approach to address race conditions in toggle handlers. It is acceptable for components not to guard rapid toggles with isExecuting (disable) when the optimistic UI state is reconciled by mutate. Apply this guidance to similar TSX components in the web app where appropriate.
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2025-12-31T23:49:09.597Z
Learnt from: rsnodgrass
Repo: elie222/inbox-zero PR: 1154
File: apps/web/app/api/user/setup-progress/route.ts:0-0
Timestamp: 2025-12-31T23:49:09.597Z
Learning: In apps/web/app/api/user/setup-progress/route.ts, Reply Zero enabled status should be determined solely by checking if the TO_REPLY rule is enabled, as it is the critical/canonical rule that Reply Zero is based on. The other conversation status types (FYI, AWAITING_REPLY, ACTIONED) should not be checked for determining Reply Zero setup progress.
<!-- </add_learning>
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2025-07-08T13:14:07.449Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 537
File: apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx:30-34
Timestamp: 2025-07-08T13:14:07.449Z
Learning: The clean onboarding page in apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx is intentionally Gmail-specific and should show an error for non-Google email accounts rather than attempting to support multiple providers.
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 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 isNaN() when checking for NaN
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 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} : Don't use optional chaining where undefined values aren't allowed
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 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 `===` and `!==`
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 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: Components with `onClick` handlers must be client components marked with the `use client` directive
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2025-11-25T14:38:18.874Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:18.874Z
Learning: Applies to apps/web/app/(app)/**/*.tsx : If you need to use `onClick` in a component, that component must be a client component and file must start with `use client` directive
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2025-11-25T14:38:23.265Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:23.265Z
Learning: Applies to apps/web/app/(app)/**/*.{ts,tsx} : If you need to use `onClick` in a component, that component is a client component and file must start with `use client`
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2024-08-23T11:37:26.779Z
Learnt from: aryanprince
Repo: elie222/inbox-zero PR: 210
File: apps/web/app/(app)/stats/NewsletterModal.tsx:2-4
Timestamp: 2024-08-23T11:37:26.779Z
Learning: `MoreDropdown` is a React component and `useUnsubscribeButton` is a custom React hook, and they should not be imported using `import type`.
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2026-01-08T15:09:06.736Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2026-01-08T15:09:06.736Z
Learning: Applies to apps/web/components/**/*.tsx : Use `useAction` hook with `onSuccess` and `onError` callbacks for handling server action responses in forms
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx
📚 Learning: 2026-01-07T21:07:06.691Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 1230
File: apps/web/app/(app)/[emailAccountId]/drive/page.tsx:47-70
Timestamp: 2026-01-07T21:07:06.691Z
Learning: In TSX files across the codebase, prefer direct server action calls with manual error handling (e.g., check result?.serverError and handle errors explicitly). The useAction hook pattern is not required; you can call server actions directly and use try/finally to ensure cleanup (such as resetting loading states) regardless of the hook. Apply consistently for components that perform server interactions.
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsxapps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2026-01-09T21:51:15.182Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2026-01-09T21:51:15.182Z
Learning: Applies to apps/web/**/*.{tsx,jsx} : Use LoadingContent component to handle loading and error states consistently
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2026-01-09T21:51:15.182Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2026-01-09T21:51:15.182Z
Learning: Applies to apps/web/**/*.{tsx,jsx} : Use LoadingContent component for async data with loading and error states
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2026-01-08T15:09:06.736Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2026-01-08T15:09:06.736Z
Learning: Applies to apps/web/components/**/*.tsx : Use `LoadingContent` component to handle loading and error states, passing `loading`, `error`, and `children` props
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2025-11-25T14:40:15.063Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-11-25T14:40:15.063Z
Learning: Applies to **/*.tsx : Use the `LoadingContent` component to handle loading states instead of manual loading state management
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2025-11-25T14:40:13.649Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-11-25T14:40:13.649Z
Learning: Applies to **/*.{tsx,ts,jsx,js} : Use the `LoadingContent` component to handle loading states
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 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 : Implement early returns for invalid LLM inputs, use proper error types and logging, implement fallbacks for AI failures, and add retry logic for transient failures using `withRetry`
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 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/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 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 : LLM feature functions must follow a standard structure: accept options with `inputData` and `emailAccount` parameters, implement input validation with early returns, define separate system and user prompts, create a Zod schema for response validation, and use `createGenerateObject` to execute the LLM call
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 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 : LLM feature functions must import from `zod` for schema validation, use `createScopedLogger` from `@/utils/logger`, `chatCompletionObject` and `createGenerateObject` from `@/utils/llms`, and import `EmailAccountWithAI` type from `@/utils/llms/types`
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
📚 Learning: 2025-11-25T14:40:13.649Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ui-components.mdc:0-0
Timestamp: 2025-11-25T14:40:13.649Z
Learning: Applies to **/*.{tsx,ts,jsx,js} : For text inputs in forms, use the `Input` component with `type='email'`, `name`, `label`, `registerProps` from react-hook-form, and `error` props
Applied to files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx
🧬 Code graph analysis (2)
apps/web/utils/actions/settings.ts (3)
apps/web/utils/actions/safe-action.ts (1)
actionClient(84-138)apps/web/utils/actions/settings.validation.ts (1)
toggleDigestBody(55-57)apps/web/utils/schedule.ts (2)
createCanonicalTimeOfDay(12-14)calculateNextScheduleDate(124-227)
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx (2)
apps/web/components/ui/dialog.tsx (2)
Dialog(116-116)DialogTrigger(120-120)apps/web/components/Toggle.tsx (1)
Toggle(18-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (8)
apps/web/utils/actions/settings.validation.ts (1)
54-58: LGTM!The validation schema follows the established pattern and correctly uses Zod with type inference. As per coding guidelines, validation schemas are properly separated in
.validation.tsfiles.apps/web/app/(app)/[emailAccountId]/assistant/settings/DigestSetting.tsx (3)
3-20: LGTM!The imports are appropriate and follow the established patterns. The use of
useCallback,useAction, anduseEmailAccountFullaligns with the codebase conventions.
24-26: LGTM!Using
!= nullcorrectly handles bothnullandundefinedvalues for the enabled state, matching the approach described in the commit messages.
28-52: LGTM!The optimistic update pattern with
mutate(optimisticData, false)and error recovery usingmutate()follows the accepted approach for handling race conditions in toggle handlers. Based on learnings, this pattern is preferred in the codebase.apps/web/utils/actions/settings.ts (1)
9-18: LGTM!The imports are appropriate for the new toggle digest functionality, including schedule utilities and enum types.
apps/web/app/(app)/[emailAccountId]/assistant/settings/FollowUpRemindersSetting.tsx (3)
17-17: LGTM!The Skeleton import is appropriately added to support the loading state UI pattern.
50-50: LGTM!The
useEmailAccountFullhook now correctly exposesisLoadingfor proper loading state management.
88-121: LGTM!The conditional rendering with Skeleton during loading and the
disabled={!data}prop on the Toggle component follow best practices. This pattern prevents UI flash and ensures the toggle cannot be interacted with before data is available.
User description
Add toggle + Configure button UI to Digest setting, matching Follow-up reminders pattern.
buildScheduleCreateDatahelper for DRY schedule creation🤖 Generated with Claude Code
Generated description
Below is a concise technical summary of the changes proposed in this PR:
graph LR DigestSetting_("DigestSetting"):::modified NEXT_SAFE_ACTION_("NEXT_SAFE_ACTION"):::modified toggleDigestAction_("toggleDigestAction"):::added toggleDigestBody_("toggleDigestBody"):::added SCHEDULE_UTILS_("SCHEDULE_UTILS"):::modified PRISMA_("PRISMA"):::modified DigestSetting_ -- "Triggers toggleDigestAction sending emailAccountId and enabled flag." --> NEXT_SAFE_ACTION_ NEXT_SAFE_ACTION_ -- "Executes action with {enabled} payload for account." --> toggleDigestAction_ toggleDigestAction_ -- "Validates incoming payload's enabled boolean." --> toggleDigestBody_ toggleDigestAction_ -- "Creates default schedule timing (timeOfDay, nextOccurrence)." --> SCHEDULE_UTILS_ toggleDigestAction_ -- "Upserts schedule row with default interval, days, nextOccurrence." --> PRISMA_ toggleDigestAction_ -- "Ensures newsletter rule has DIGEST action, inserts if missing." --> PRISMA_ toggleDigestAction_ -- "Deletes existing schedule rows for the email account." --> PRISMA_ classDef added stroke:#15AA7A classDef removed stroke:#CD5270 classDef modified stroke:#EDAC4C linkStyle default stroke:#CBD5E1,font-size:13pxIntroduces a toggle and configure button to the
DigestSettingUI, aligning its user experience with theFollowUpRemindersSettingcomponent. Implements backend logic intoggleDigestActionto create a daily 9 am digest schedule and associate aDIGESTaction with the newsletter rule when enabled, or delete the schedule when disabled.DigestSettingcomponent, allowing users to enable/disable and customize their email digest schedule. Applies a loadingSkeletonto bothDigestSettingandFollowUpRemindersSettingto improve UI responsiveness during data fetching.Modified files (2)
Latest Contributors(2)
toggleDigestActionto manage the backend state of the digest feature. When enabled, it creates a daily 9 am schedule and ensures aDIGESTaction is added to theNEWSLETTERrule; when disabled, it deletes the associated schedule. Also adds validation for the new action viatoggleDigestBody.Modified files (2)
Latest Contributors(2)