Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a new onboarding step for selecting company size, introduces a reusable OnboardingButton component, wires the step into the onboarding flow, persists the selection to the User model via actions and a Prisma migration, and adjusts schedule calculation in settings to pass a null lastOccurrenceAt. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as StepCompanySize
participant Actions as saveOnboardingAnswersAction
participant DB as Prisma/User
participant Toast as toastError
User->>UI: Click company size option
rect rgba(200,230,255,0.3)
UI->>Actions: save({ surveyId:"onboarding", answers:{ company_size } })
Actions->>DB: user.update({ surveyCompanySize: Number(company_size) })
DB-->>Actions: OK / Error
alt Save succeeded
Actions-->>UI: success
UI-->>User: onNext()
else Save failed
Actions-->>UI: error
UI->>Toast: Show error message
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (10)
apps/web/app/(landing)/welcome/survey.ts (1)
35-47: Remove stale commented block or align with new numeric mapping.The company_size question is commented out; either delete it or update it to reflect the new numeric value approach used in onboarding to avoid drift.
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx (2)
95-99: Remove console usage in client code.Console is disallowed by guidelines. Keep this silent as intended.
- .catch((error) => { - // Fail silently - persona analysis is optional enhancement - console.error("Failed to analyze persona:", error); - }); + .catch(() => { + // Fail silently - persona analysis is optional enhancement + });
53-58: Drop unused provider prop when calling StepDraft.The provider prop isn’t used by StepDraft; remove to avoid confusion.
- () => ( - <StepDraft - provider={provider} - emailAccountId={emailAccountId} - onNext={onNext} - /> - ), + () => <StepDraft emailAccountId={emailAccountId} onNext={onNext} />,apps/web/prisma/schema.prisma (1)
72-73: Enforce allowed values at the application layer.Since surveyCompanySize is free-form Int?, validate to an allowed set (e.g., [1, 5, 50, 500, 1000]) in the action/schema to prevent arbitrary values.
apps/web/utils/actions/onboarding.ts (2)
87-93: Validate company_size to an allowed set before persisting.Prevents noisy data and keeps the numeric mapping stable.
- const companySizeAnswer = getAnswerByKey("company_size"); - if (companySizeAnswer && companySizeAnswer !== "undefined") { - const numericValue = Number(companySizeAnswer); - if (!Number.isNaN(numericValue)) { - result.surveyCompanySize = numericValue; - } - } + const companySizeAnswer = getAnswerByKey("company_size"); + if (companySizeAnswer && companySizeAnswer !== "undefined") { + const numericValue = Number(companySizeAnswer); + const allowed = [1, 5, 50, 500, 1000] as const; + if (!Number.isNaN(numericValue) && allowed.includes(numericValue)) { + result.surveyCompanySize = numericValue; + } + }
29-36: Avoid any; tighten local types.Define a minimal Question/Answers shape to improve safety without over‑typing.
- function extractSurveyAnswers(questions: any[], answers: any) { + function extractSurveyAnswers( + questions: Array<{ key: string }>, + answers: Record<string, unknown>, + ) {apps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx (1)
13-20: Remove unused provider prop.It’s declared but not used; drop it here and at the call site.
-export function StepDraft({ - emailAccountId, - onNext, -}: { - emailAccountId: string; - provider: string; - onNext: () => void; -}) { +export function StepDraft({ + emailAccountId, + onNext, +}: { + emailAccountId: string; + onNext: () => void; +}) {apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx (3)
14-14: Import useState to manage a pending guard.Needed for the submission de‑dup guard below.
-import { useCallback } from "react"; +import { useCallback, useState } from "react";
82-91: Optional: improve layout on wider screens.Two columns reduce scrolling for larger viewports without hurting mobile.
- <div className="mt-6 grid gap-3"> + <div className="mt-6 grid gap-3 sm:grid-cols-2">
19-45: Type COMPANY_SIZES and confirm bucket mapping (verified).Prisma schema (apps/web/prisma/schema.prisma:72) documents buckets 1, 5, 50, 500, 1000 — the values in apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx match. Apply the satisfies lock to prevent accidental refactors:
-const COMPANY_SIZES = [ +const COMPANY_SIZES = [ { value: 1, label: "Only me", icon: <User className="size-4" />, }, { value: 5, label: "2-10 people", icon: <Users className="size-4" />, }, { value: 50, label: "11-100 people", icon: <Building className="size-4" />, }, { value: 500, label: "101-1000 people", icon: <Factory className="size-4" />, }, { value: 1000, label: "1000+ people", icon: <Landmark className="size-4" />, }, -]; +] satisfies ReadonlyArray<{ value: number; label: string; icon: JSX.Element }>;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx(2 hunks)apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx(1 hunks)apps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx(1 hunks)apps/web/app/(landing)/welcome/survey.ts(1 hunks)apps/web/prisma/migrations/20250916180645_company_size/migration.sql(1 hunks)apps/web/prisma/schema.prisma(1 hunks)apps/web/utils/actions/onboarding.ts(3 hunks)apps/web/utils/actions/settings.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (20)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use@/for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/app/**
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
NextJS app router structure with (app) directory
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/utils/actions/settings.tsapps/web/prisma/migrations/20250916180645_company_size/migration.sqlapps/web/prisma/schema.prismaapps/web/utils/actions/onboarding.tsapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport Prisma in the project using
import prisma from "@/utils/prisma";
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
!pages/_document.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.
Files:
apps/web/app/(landing)/welcome/survey.tsapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/utils/actions/settings.tsapps/web/prisma/migrations/20250916180645_company_size/migration.sqlapps/web/prisma/schema.prismaapps/web/utils/actions/onboarding.tsapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/app/(app)/*/**
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/app/(app)/*/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If you need to use onClick in a component, that component is a client component and file must start with 'use client'
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/app/(app)/*/**/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If we're in a deeply nested component we will use swr to fetch via API
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
apps/web/app/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Components with
onClickmust be client components withuse clientdirective
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.
Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx
**/*.{html,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...Files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsxapps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsxapps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsxapps/web/utils/actions/**/*.ts
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/utils/actions/**/*.ts: Use server actions for all mutations (create/update/delete operations)
next-safe-actionprovides centralized error handling
Use Zod schemas for validation on both client and server
UserevalidatePathin server actions for cache invalidation
apps/web/utils/actions/**/*.ts: Use server actions (withnext-safe-action) for all mutations (create/update/delete operations); do NOT use POST API routes for mutations.
UserevalidatePathin server actions to invalidate cache after mutations.Files:
apps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/utils/actions/*.ts
📄 CodeRabbit inference engine (.cursor/rules/server-actions.mdc)
apps/web/utils/actions/*.ts: Implement all server actions using thenext-safe-actionlibrary for type safety, input validation, context management, and error handling. Refer toapps/web/utils/actions/safe-action.tsfor client definitions (actionClient,actionClientUser,adminActionClient).
UseactionClientUserwhen only authenticated user context (userId) is needed.
UseactionClientwhen both authenticated user context and a specificemailAccountIdare needed. TheemailAccountIdmust be bound when calling the action from the client.
UseadminActionClientfor actions restricted to admin users.
Access necessary context (likeuserId,emailAccountId, etc.) provided by the safe action client via thectxobject in the.action()handler.
Server Actions are strictly for mutations (operations that change data, e.g., creating, updating, deleting). Do NOT use Server Actions for data fetching (GET operations). For data fetching, use dedicated GET API Routes combined with SWR Hooks.
UseSafeErrorfor expected/handled errors within actions if needed.next-safe-actionprovides centralized error handling.
Use the.metadata({ name: "actionName" })method to provide a meaningful name for monitoring. Sentry instrumentation is automatically applied viawithServerActionInstrumentationwithin the safe action clients.
If an action modifies data displayed elsewhere, userevalidatePathorrevalidateTagfromnext/cachewithin the action handler as needed.Server action files must start with
use serverFiles:
apps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logicFiles:
apps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/utils/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle sizeFiles:
apps/web/utils/actions/settings.tsapps/web/utils/actions/onboarding.tsapps/web/prisma/schema.prisma
📄 CodeRabbit inference engine (.cursor/rules/prisma.mdc)
The Prisma schema file must be located at
apps/web/prisma/schema.prismaFiles:
apps/web/prisma/schema.prisma🧠 Learnings (2)
📚 Learning: 2025-07-20T09:00:16.505Z
Learnt from: CR PR: elie222/inbox-zero#0 File: .cursor/rules/project-structure.mdc:0-0 Timestamp: 2025-07-20T09:00:16.505Z Learning: Applies to apps/web/components/**/*.tsx : Use PascalCase for components (e.g. `components/Button.tsx`)Applied to files:
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsx📚 Learning: 2025-07-08T13:14:07.449Z
Learnt from: elie222 PR: elie222/inbox-zero#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]/onboarding/OnboardingContent.tsx🧬 Code graph analysis (4)
apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsx (1)
apps/web/app/(app)/[emailAccountId]/onboarding/IconCircle.tsx (1)
IconCircle(82-99)apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx (4)
apps/web/utils/actions/onboarding.ts (1)
saveOnboardingAnswersAction(19-124)apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingWrapper.tsx (1)
OnboardingWrapper(3-22)apps/web/app/(app)/[emailAccountId]/onboarding/IconCircle.tsx (1)
IconCircle(82-99)apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsx (1)
OnboardingButton(3-25)apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx (1)
apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx (1)
StepCompanySize(47-94)apps/web/utils/actions/settings.ts (1)
apps/web/utils/schedule.ts (1)
calculateNextScheduleDate(124-230)⏰ 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: cubic · AI code reviewer
🔇 Additional comments (6)
apps/web/utils/actions/settings.ts (1)
68-71: Confirm intent: ignore lastOccurrenceAt when computing nextOccurrenceAt.Passing lastOccurrenceAt: null changes semantics to calculate from “now,” even if a client supplied lastOccurrenceAt. If intentional, add a brief comment for future readers.
- nextOccurrenceAt: calculateNextScheduleDate({ - ...parsedInput, - lastOccurrenceAt: null, - }), + // Compute next occurrence from now (ignore any client-provided lastOccurrenceAt) + nextOccurrenceAt: calculateNextScheduleDate({ + ...parsedInput, + lastOccurrenceAt: null, + }),apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx (1)
23-24: LGTM: StepCompanySize integrated correctly.Import and step insertion look consistent with the flow.
Also applies to: 44-44
apps/web/prisma/migrations/20250916180645_company_size/migration.sql (1)
2-2: LGTM: adds nullable integer column.apps/web/app/(app)/[emailAccountId]/onboarding/StepDraft.tsx (1)
11-11: LGTM: using shared OnboardingButton.apps/web/utils/actions/onboarding.ts (1)
111-121: Approve — new field persisted and validation allows company_size.
saveOnboardingAnswersBody uses z.any() for questions/answers; Prisma schema defines surveyCompanySize Int? (apps/web/prisma/schema.prisma) and the migration exists (apps/web/prisma/migrations/20250916180645_company_size/migration.sql); apps/web/utils/actions/onboarding.ts persists surveyCompanySize.apps/web/app/(app)/[emailAccountId]/onboarding/StepCompanySize.tsx (1)
1-2: Client component boundary is correct."use client" is present, which is required since this component handles onClick.
| import { IconCircle } from "@/app/(app)/[emailAccountId]/onboarding/IconCircle"; | ||
|
|
||
| export function OnboardingButton({ | ||
| text, | ||
| icon, | ||
| onClick, | ||
| }: { | ||
| text: string; | ||
| icon: React.ReactNode; | ||
| onClick: () => void; | ||
| }) { | ||
| return ( | ||
| <button | ||
| type="button" | ||
| className="rounded-xl border bg-card p-4 text-card-foreground shadow-sm text-left flex items-center gap-4 transition-all hover:border-blue-600 hover:ring-2 hover:ring-blue-100" | ||
| onClick={onClick} | ||
| > | ||
| <IconCircle size="sm">{icon}</IconCircle> | ||
|
|
||
| <div className="flex-1"> | ||
| <div className="font-medium">{text}</div> | ||
| </div> | ||
| </button> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Make this a Client Component and fix React type import.
Without "use client", onClick isn’t allowed; also React.ReactNode requires importing React types. This will otherwise fail at build/runtime.
+ "use client";
+
import { IconCircle } from "@/app/(app)/[emailAccountId]/onboarding/IconCircle";
+import type { ReactNode } from "react";
export function OnboardingButton({
text,
icon,
onClick,
}: {
text: string;
- icon: React.ReactNode;
+ icon: ReactNode;
onClick: () => void;
}) {
return (
<button
type="button"
className="rounded-xl border bg-card p-4 text-card-foreground shadow-sm text-left flex items-center gap-4 transition-all hover:border-blue-600 hover:ring-2 hover:ring-blue-100"
onClick={onClick}
>
<IconCircle size="sm">{icon}</IconCircle>
<div className="flex-1">
<div className="font-medium">{text}</div>
</div>
</button>
);
}📝 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.
| import { IconCircle } from "@/app/(app)/[emailAccountId]/onboarding/IconCircle"; | |
| export function OnboardingButton({ | |
| text, | |
| icon, | |
| onClick, | |
| }: { | |
| text: string; | |
| icon: React.ReactNode; | |
| onClick: () => void; | |
| }) { | |
| return ( | |
| <button | |
| type="button" | |
| className="rounded-xl border bg-card p-4 text-card-foreground shadow-sm text-left flex items-center gap-4 transition-all hover:border-blue-600 hover:ring-2 hover:ring-blue-100" | |
| onClick={onClick} | |
| > | |
| <IconCircle size="sm">{icon}</IconCircle> | |
| <div className="flex-1"> | |
| <div className="font-medium">{text}</div> | |
| </div> | |
| </button> | |
| ); | |
| } | |
| "use client"; | |
| import { IconCircle } from "@/app/(app)/[emailAccountId]/onboarding/IconCircle"; | |
| import type { ReactNode } from "react"; | |
| export function OnboardingButton({ | |
| text, | |
| icon, | |
| onClick, | |
| }: { | |
| text: string; | |
| icon: ReactNode; | |
| onClick: () => void; | |
| }) { | |
| return ( | |
| <button | |
| type="button" | |
| className="rounded-xl border bg-card p-4 text-card-foreground shadow-sm text-left flex items-center gap-4 transition-all hover:border-blue-600 hover:ring-2 hover:ring-blue-100" | |
| onClick={onClick} | |
| > | |
| <IconCircle size="sm">{icon}</IconCircle> | |
| <div className="flex-1"> | |
| <div className="font-medium">{text}</div> | |
| </div> | |
| </button> | |
| ); | |
| } |
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingButton.tsx lines
1-25, this component must be a React client component and needs proper React
type imports: add "use client" as the first line of the file and import React
types (either `import React from "react"` or `import type { ReactNode } from
"react"` and update prop types to use ReactNode) so onClick is allowed and the
React types resolve correctly.
| export function StepCompanySize({ onNext }: { onNext: () => void }) { | ||
| const onSelectCompanySize = useCallback( | ||
| async (companySize: number) => { | ||
| try { | ||
| // Save the company size to onboarding answers | ||
| await saveOnboardingAnswersAction({ | ||
| surveyId: "onboarding", | ||
| questions: [{ key: "company_size", type: "single_choice" }], | ||
| answers: { $survey_response: companySize }, | ||
| }); | ||
|
|
||
| onNext(); | ||
| } catch (error) { | ||
| toastError({ | ||
| description: | ||
| "There was an error saving your selection. Please try again.", | ||
| }); | ||
| } | ||
| }, | ||
| [onNext], | ||
| ); |
There was a problem hiding this comment.
Handle server action result (result?.serverError) and prevent double‑submission.
With next-safe-action style APIs, errors surface via result?.serverError and won’t throw; current code would advance the step on server errors. Also, rapid clicks can fire multiple updates.
export function StepCompanySize({ onNext }: { onNext: () => void }) {
- const onSelectCompanySize = useCallback(
+ const [saving, setSaving] = useState(false);
+ const onSelectCompanySize = useCallback(
async (companySize: number) => {
- try {
+ if (saving) return;
+ setSaving(true);
+ try {
// Save the company size to onboarding answers
- await saveOnboardingAnswersAction({
+ const result = await saveOnboardingAnswersAction({
surveyId: "onboarding",
questions: [{ key: "company_size", type: "single_choice" }],
answers: { $survey_response: companySize },
});
- onNext();
+ if (result?.serverError) {
+ toastError({ description: result.serverError });
+ return;
+ }
+ onNext();
} catch (error) {
toastError({
description:
"There was an error saving your selection. Please try again.",
});
- }
+ } finally {
+ setSaving(false);
+ }
},
- [onNext],
+ [onNext, saving],
);Optional follow‑up: if you want visual feedback, I can add disabled/aria‑busy support to OnboardingButton.
📝 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.
| export function StepCompanySize({ onNext }: { onNext: () => void }) { | |
| const onSelectCompanySize = useCallback( | |
| async (companySize: number) => { | |
| try { | |
| // Save the company size to onboarding answers | |
| await saveOnboardingAnswersAction({ | |
| surveyId: "onboarding", | |
| questions: [{ key: "company_size", type: "single_choice" }], | |
| answers: { $survey_response: companySize }, | |
| }); | |
| onNext(); | |
| } catch (error) { | |
| toastError({ | |
| description: | |
| "There was an error saving your selection. Please try again.", | |
| }); | |
| } | |
| }, | |
| [onNext], | |
| ); | |
| export function StepCompanySize({ onNext }: { onNext: () => void }) { | |
| const [saving, setSaving] = useState(false); | |
| const onSelectCompanySize = useCallback( | |
| async (companySize: number) => { | |
| if (saving) return; | |
| setSaving(true); | |
| try { | |
| // Save the company size to onboarding answers | |
| const result = await saveOnboardingAnswersAction({ | |
| surveyId: "onboarding", | |
| questions: [{ key: "company_size", type: "single_choice" }], | |
| answers: { $survey_response: companySize }, | |
| }); | |
| if (result?.serverError) { | |
| toastError({ description: result.serverError }); | |
| return; | |
| } | |
| onNext(); | |
| } catch (error) { | |
| toastError({ | |
| description: | |
| "There was an error saving your selection. Please try again.", | |
| }); | |
| } finally { | |
| setSaving(false); | |
| } | |
| }, | |
| [onNext, saving], | |
| ); |
There was a problem hiding this comment.
3 issues found across 9 files
Prompt for AI agents (all 3 issues)
Understand the root cause of the following 3 issues and fix them.
<file name="apps/web/app/(landing)/welcome/survey.ts">
<violation number="1" location="apps/web/app/(landing)/welcome/survey.ts:46">
Added commented-out code; has no effect and suggests incomplete implementation. Remove dead code or implement by uncommenting the question block.</violation>
</file>
<file name="apps/web/prisma/schema.prisma">
<violation number="1" location="apps/web/prisma/schema.prisma:72">
Clarify the company size ranges in the comment to avoid overlap at 1000.</violation>
</file>
<file name="apps/web/prisma/migrations/20250916180645_company_size/migration.sql">
<violation number="1" location="apps/web/prisma/migrations/20250916180645_company_size/migration.sql:2">
No validation on enumerated company size; add a CHECK to restrict values to 1, 5, 50, 500, or 1000.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| // "101-1000 people", | ||
| // "1000+ people", | ||
| // ], | ||
| // skippable: false, |
There was a problem hiding this comment.
Added commented-out code; has no effect and suggests incomplete implementation. Remove dead code or implement by uncommenting the question block.
Prompt for AI agents
Address the following comment on apps/web/app/(landing)/welcome/survey.ts at line 46:
<comment>Added commented-out code; has no effect and suggests incomplete implementation. Remove dead code or implement by uncommenting the question block.</comment>
<file context>
@@ -43,6 +43,7 @@ export const survey = {
// "101-1000 people",
// "1000+ people",
// ],
+ // skippable: false,
// },
{
</file context>
| surveyFeatures String[] // multiple choice: features user is interested in | ||
| surveyRole String? // single choice: user's role. Now using `EmailAccount.role` instead | ||
| surveyGoal String? // single choice: what user wants to achieve | ||
| surveyCompanySize Int? // numeric company size: 1 (solo), 5 (2-10), 50 (11-100), 500 (101-1000), 1000 (1000+) |
There was a problem hiding this comment.
Clarify the company size ranges in the comment to avoid overlap at 1000.
Prompt for AI agents
Address the following comment on apps/web/prisma/schema.prisma at line 72:
<comment>Clarify the company size ranges in the comment to avoid overlap at 1000.</comment>
<file context>
@@ -69,6 +69,7 @@ model User {
surveyFeatures String[] // multiple choice: features user is interested in
surveyRole String? // single choice: user's role. Now using `EmailAccount.role` instead
surveyGoal String? // single choice: what user wants to achieve
+ surveyCompanySize Int? // numeric company size: 1 (solo), 5 (2-10), 50 (11-100), 500 (101-1000), 1000 (1000+)
surveySource String? // single choice: how user heard about Inbox Zero
surveyImprovements String? // open text: what user wants to improve
</file context>
| surveyCompanySize Int? // numeric company size: 1 (solo), 5 (2-10), 50 (11-100), 500 (101-1000), 1000 (1000+) | |
| surveyCompanySize Int? // numeric company size: 1 (solo), 5 (2-10), 50 (11-100), 500 (101-999), 1000 (>=1000) |
| @@ -0,0 +1,2 @@ | |||
| -- AlterTable | |||
| ALTER TABLE "public"."User" ADD COLUMN "surveyCompanySize" INTEGER; | |||
There was a problem hiding this comment.
No validation on enumerated company size; add a CHECK to restrict values to 1, 5, 50, 500, or 1000.
Prompt for AI agents
Address the following comment on apps/web/prisma/migrations/20250916180645_company_size/migration.sql at line 2:
<comment>No validation on enumerated company size; add a CHECK to restrict values to 1, 5, 50, 500, or 1000.</comment>
<file context>
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "public"."User" ADD COLUMN "surveyCompanySize" INTEGER;
</file context>
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores