Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces a public env flag (NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE) to disable referral-signature behavior. Applies it to hide the ReferralSignatureSetting UI and to bypass DB reads in draft generation. Updates env schema/mapping accordingly. Changes EmailAccount.includeReferralSignature default to true via Prisma schema and migration. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant W as Web App (UI)
participant E as Env Flag
participant D as DB
participant G as Draft Generator
rect rgba(230,240,255,0.4)
U->>W: Open Settings
W->>E: Read NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE
alt Flag enabled
W-->>U: ReferralSignatureSetting hidden
else Flag disabled
W-->>U: Show ReferralSignatureSetting UI
end
end
rect rgba(240,255,240,0.4)
U->>G: Generate draft
G->>E: Read NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE
alt Flag enabled
Note over G: Skip fetching includeReferralSignature
G-->>U: Draft without referral signature
else Flag disabled
G->>D: Fetch includeReferralSignature
D-->>G: { includeReferralSignature }
opt includeReferralSignature = true
G-->>U: Draft with referral signature appended
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/utils/reply-tracker/generate-draft.ts (1)
48-49: Don’t log full draft content (PII risk).Log metadata (length or hash) instead of the generated text.
Apply:
- logger.info("Draft generated", { result }); + logger.info("Draft generated", { length: typeof result === "string" ? result.length : null });
🧹 Nitpick comments (2)
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx (1)
47-49: Avoid unnecessary hooks/data fetching when feature is disabled.Short‑circuit before invoking hooks to prevent network calls and state setup.
Apply:
export function ReferralSignatureSetting() { - const { data, isLoading, error, mutate } = useEmailAccountFull(); + if (env.NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE) { + return null; + } + const { data, isLoading, error, mutate } = useEmailAccountFull(); const { emailAccountId } = useAccount(); @@ - if (env.NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE) { - return null; - }apps/web/utils/reply-tracker/generate-draft.ts (1)
82-88: Nice: guard avoids an extra DB read when disabled.This reduces load when the flag is on.
Consider selecting includeReferralSignature in getEmailAccountWithAi to avoid a second query when the flag is off.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx(2 hunks)apps/web/env.ts(2 hunks)apps/web/prisma/migrations/20250916133642_default_signature_enabled/migration.sql(1 hunks)apps/web/prisma/schema.prisma(1 hunks)apps/web/utils/reply-tracker/generate-draft.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (21)
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/env.tsapps/web/utils/reply-tracker/generate-draft.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/**/{.env.example,env.ts,turbo.json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/env.ts
apps/web/**/{.env.example,env.ts}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Client-side environment variables: Prefix with
NEXT_PUBLIC_
Files:
apps/web/env.ts
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/env.tsapps/web/prisma/schema.prismaapps/web/utils/reply-tracker/generate-draft.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsxapps/web/prisma/migrations/20250916133642_default_signature_enabled/migration.sql
apps/web/env.ts
📄 CodeRabbit inference engine (.cursor/rules/environment-variables.mdc)
apps/web/env.ts: When adding a new environment variable, add it toapps/web/env.tsin the appropriate section: useserverfor server-only variables, and for client-side variables, use theclientsection and also add toexperimental__runtimeEnv.
Client-side environment variables must be prefixed withNEXT_PUBLIC_and added to both theclientandexperimental__runtimeEnvsections inapps/web/env.ts.
Files:
apps/web/env.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/env.tsapps/web/utils/reply-tracker/generate-draft.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/env.tsapps/web/utils/reply-tracker/generate-draft.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.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/env.tsapps/web/utils/reply-tracker/generate-draft.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.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/env.tsapps/web/prisma/schema.prismaapps/web/utils/reply-tracker/generate-draft.tsapps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsxapps/web/prisma/migrations/20250916133642_default_signature_enabled/migration.sql
apps/web/prisma/schema.prisma
📄 CodeRabbit inference engine (.cursor/rules/prisma.mdc)
The Prisma schema file must be located at
apps/web/prisma/schema.prisma
Files:
apps/web/prisma/schema.prisma
apps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logic
Files:
apps/web/utils/reply-tracker/generate-draft.ts
apps/web/utils/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size
Files:
apps/web/utils/reply-tracker/generate-draft.ts
apps/web/app/**
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
NextJS app router structure with (app) directory
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/app/(app)/*/**
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/app/(app)/*/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If you need to use onClick in a component, that component is a client component and file must start with 'use client'
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/app/(app)/*/**/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/page-structure.mdc)
If we're in a deeply nested component we will use swr to fetch via API
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
apps/web/app/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Components with
onClickmust be client components withuse clientdirective
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.
Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx
**/*.{html,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...Files:
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx🧠 Learnings (3)
📚 Learning: 2025-07-18T15:04:50.520Z
Learnt from: CR PR: elie222/inbox-zero#0 File: .cursor/rules/environment-variables.mdc:0-0 Timestamp: 2025-07-18T15:04:50.520Z Learning: Applies to apps/web/env.ts : Client-side environment variables must be prefixed with `NEXT_PUBLIC_` and added to both the `client` and `experimental__runtimeEnv` sections in `apps/web/env.ts`.Applied to files:
apps/web/env.ts📚 Learning: 2025-07-18T15:04:30.467Z
Learnt from: CR PR: elie222/inbox-zero#0 File: apps/web/CLAUDE.md:0-0 Timestamp: 2025-07-18T15:04:30.467Z Learning: Applies to apps/web/**/{.env.example,env.ts} : Client-side environment variables: Prefix with `NEXT_PUBLIC_`Applied to files:
apps/web/env.ts📚 Learning: 2025-07-18T15:04:50.520Z
Learnt from: CR PR: elie222/inbox-zero#0 File: .cursor/rules/environment-variables.mdc:0-0 Timestamp: 2025-07-18T15:04:50.520Z Learning: Applies to apps/web/env.ts : When adding a new environment variable, add it to `apps/web/env.ts` in the appropriate section: use `server` for server-only variables, and for client-side variables, use the `client` section and also add to `experimental__runtimeEnv`.Applied to files:
apps/web/env.ts🧬 Code graph analysis (2)
apps/web/utils/reply-tracker/generate-draft.ts (1)
apps/web/env.ts (1)
env(16-242)apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx (1)
apps/web/env.ts (1)
env(16-242)⏰ 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 (7)
apps/web/prisma/schema.prisma (1)
118-118: Default switched to true — confirm data migration intent.Changing the default to true only affects new rows; existing EmailAccount rows keep their current value. If the intent is to enable this for all users, add a data backfill; if not, this is fine as-is.
apps/web/env.ts (3)
181-185: Env var definition looks correct and client-safe.Public flag is properly coerced to boolean with a default.
239-241: Runtime mapping wired correctly.The variable is exposed via experimental__runtimeEnv as required.
181-185: Add NEXT_PUBLIC_DISABLE_REFERRAL_SIGNATURE to apps/web/.env.example and apps/web/turbo.jsonFound in apps/web/env.ts but missing from apps/web/.env.example and the env passthrough in apps/web/turbo.json — add an example/default to .env.example and add the passthrough entry to turbo.json.
apps/web/prisma/migrations/20250916133642_default_signature_enabled/migration.sql (1)
1-2: Schema default migration is correct; clarify whether a data backfill is needed.This alters only the default. Confirm whether existing rows should remain unchanged.
apps/web/app/(app)/[emailAccountId]/assistant/settings/ReferralSignatureSetting.tsx (1)
13-13: Correct client-side env usage.Importing env from "@/env" in a client component is appropriate since it’s declared in the client schema.
apps/web/utils/reply-tracker/generate-draft.ts (1)
17-17: Env import LGTM.Consistent alias and shared public flag across client/server.
Summary by CodeRabbit