Skip to content

Comments

Structured briefing output#1096

Merged
elie222 merged 2 commits intomainfrom
feat/brief-format
Dec 16, 2025
Merged

Structured briefing output#1096
elie222 merged 2 commits intomainfrom
feat/brief-format

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Dec 16, 2025

Switch meeting briefings to structured per-guest JSON and update email rendering to list guests with bullets (max 10 words each)

Introduce Zod schemas and TypeScript types for structured guest briefings, update aiGenerateMeetingBriefing to return BriefingContent, and modify the meeting briefing email to render per-guest bullets with a new "Calendar link" label.

📍Where to Start

Start with the generator aiGenerateMeetingBriefing and its schema in generate-briefing.ts, then review the email component in meeting-briefing.tsx.


Macroscope summarized 8ba7ca2.

Summary by CodeRabbit

  • New Features

    • Meeting briefings now use a structured format showing each guest with name, email, and bullet points.
  • Improvements

    • Email template updated to render guest-specific briefing sections for clearer readability.
    • Event label changed from “Event link” to “Calendar link” for clarity.
  • Chores

    • Release version updated to v2.23.2.

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

@vercel
Copy link

vercel bot commented Dec 16, 2025

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

Project Deployment Review Updated (UTC)
inbox-zero Ready Ready Preview Dec 16, 2025 2:19pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Walkthrough

The changes convert meeting briefings from a freeform string into a typed BriefingContent with GuestBriefing entries, updating generation, sending, and email rendering to produce and consume a structured guests array; version updated to v2.23.2.

Changes

Cohort / File(s) Summary
AI Briefing Generation
apps/web/utils/ai/meeting-briefs/generate-briefing.ts
Added guestBriefingSchema and top-level briefingSchema; introduced BriefingContent type; changed aiGenerateMeetingBriefing to return Promise<BriefingContent>; updated system prompt and buildPrompt to require JSON with a guests array; adjusted return path to result.object.
Email Delivery Pipeline
apps/web/utils/meeting-briefs/send-briefing.ts , packages/resend/emails/meeting-briefing.tsx
sendBriefingEmail parameter type changed from string to BriefingContent; imported BriefingContent type; email component props updated to accept BriefingContent; replaced markdown-parsing/rendering with renderGuestBriefings to render guest name, email, and bullets; UI label changed from “Event link” to “Calendar link”; preview data updated to structured guests.
Release Versioning
version.txt
Bumped version from v2.23.1 to v2.23.2.

Sequence Diagram(s)

sequenceDiagram
  participant AI as AI Generator
  participant App as Web App / Sender
  participant Template as Email Template (Resend)
  participant SMTP as Email Service

  AI->>App: aiGenerateMeetingBriefing() → returns BriefingContent { guests: [...] }
  App->>Template: sendBriefingEmail(briefingContent: BriefingContent)
  Note right of Template: renderGuestBriefings iterates guests\nproduces HTML email body
  Template->>SMTP: send rendered email
  SMTP-->>App: delivery acknowledgement
  App-->>AI: (none) 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Specific areas requiring attention:
    • Verify schema/type parity for GuestBriefing and BriefingContent across generator and email component.
    • Confirm AI prompt and buildPrompt produce valid JSON matching the new schema (edge cases, validation).
    • Review renderGuestBriefings for correct HTML/email-safe escaping and layout.
    • Check all call sites for remaining assumptions that briefing is a string and update as needed.
    • Validate preview data and Story/preview components reflect the new structured prop.

Poem

🐰 I hop through lines of code and cheer,
Guests now have names, emails, and notes clear,
No more parsing chaos, just tidy arrays,
I nibble bugs and polish the ways,
A little version bump — hooray, let's steer! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Structured briefing output' clearly and concisely summarizes the main change: converting the briefing generation from plain text strings to a structured JSON object format with Zod validation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/brief-format

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

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/resend/emails/meeting-briefing.tsx (1)

13-21: Type duplication - see related comment.

These types are also defined in apps/web/utils/ai/meeting-briefs/generate-briefing.ts (lines 26-27). Please see the comment on that file for the recommendation to centralize these type definitions.

🧹 Nitpick comments (1)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (1)

29-76: Add logging for LLM inputs and outputs.

As per coding guidelines for apps/web/utils/ai/**/*.ts, LLM feature functions should use createScopedLogger to log inputs and outputs with appropriate log levels. This helps with debugging and monitoring LLM behavior.

Based on coding guidelines for LLM functions.

Consider adding:

+import { createScopedLogger } from "@/utils/logger";
+
+const logger = createScopedLogger("meeting-briefing-generation");
+
 export async function aiGenerateMeetingBriefing({
   briefingData,
   emailAccount,
 }: {
   briefingData: MeetingBriefingData;
   emailAccount: EmailAccountWithAI;
 }): Promise<BriefingContent> {
+  const log = logger.with({ 
+    eventId: briefingData.event.id,
+    guestCount: briefingData.externalGuests.length 
+  });
+  
+  log.info("Generating meeting briefing");
+
   const system = `...`;
   const prompt = buildPrompt(briefingData);
   
   // ... existing code ...
   
   const result = await generateObject({
     ...modelOptions,
     system,
     prompt,
     schema: briefingSchema,
   });
 
+  log.info("Meeting briefing generated", { 
+    guestCount: result.object.guests.length 
+  });
+
   return result.object;
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a0dca3 and d954412.

📒 Files selected for processing (4)
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts (4 hunks)
  • apps/web/utils/meeting-briefs/send-briefing.ts (2 hunks)
  • packages/resend/emails/meeting-briefing.tsx (4 hunks)
  • version.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
!(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:

  • version.txt
  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.tsx
apps/web/**/*.{ts,tsx}

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

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Use @/ path aliases for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Follow consistent naming conventions using PascalCase for components
Centralize shared types in dedicated type files

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

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{ts,tsx}

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

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

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

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

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

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.tsx
**/{server,api,actions,utils}/**/*.ts

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

**/{server,api,actions,utils}/**/*.ts: Use createScopedLogger from "@/utils/logger" for logging in backend code
Add the createScopedLogger instantiation at the top of the file with an appropriate scope name
Use .with() method to attach context variables only within specific functions, not on global loggers
For large functions with reused variables, use createScopedLogger().with() to attach context once and reuse the logger without passing variables repeatedly

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{ts,tsx,js,jsx}

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

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

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

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.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's select option. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. All findUnique/findFirst calls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
All findMany queries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g., emailAccount: { id: emailAccountId }) to validate ownership

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{tsx,ts}

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

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

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.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/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.tsx
**/*.{js,jsx,ts,tsx}

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

**/*.{js,jsx,ts,tsx}: Don't use accessKey attribute on any HTML element
Don't set aria-hidden="true" on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like <marquee> or <blink>
Only use the scope prop on <th> elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assign tabIndex to non-interactive HTML elements
Don't use positive integers for tabIndex property
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include a title element for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
Assign tabIndex to non-interactive HTML elements with aria-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include a type attribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden)
Always include a lang attribute on the html element
Always include a title attribute for iframe elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.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')

Files:

  • apps/web/utils/meeting-briefs/send-briefing.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • packages/resend/emails/meeting-briefing.tsx
apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts

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

LLM-related code must be organized in specific directories: apps/web/utils/ai/ for main implementations, apps/web/utils/llms/ for core utilities and configurations, and apps/web/__tests__/ for LLM-specific tests

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/utils/ai/**/*.ts

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

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
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
System prompts must define the LLM's role and task specifications
User prompts must contain the actual data and context, and should be kept separate from system prompts
Always define a Zod schema for LLM response validation and make schemas as specific as possible to guide the LLM output
Use descriptive scoped loggers for each LLM feature, log inputs and outputs with appropriate log levels, and include relevant context in log messages
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
Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions
Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures
Keep related AI functions in the same file or directory, extract common patterns into utility functions, and document complex AI logic with clear comments

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.tsx

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

**/*.tsx: Use the LoadingContent component to handle loading states instead of manual loading state management
For text areas, use the Input component with type='text', autosizeTextarea prop set to true, and registerProps for form integration

Files:

  • packages/resend/emails/meeting-briefing.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 both children and dangerouslySetInnerHTML props 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 use target="_blank" without rel="noopener"
Don't use <img> elements in Next.js projects
Don't use <head> elements in Next.js projects

Files:

  • packages/resend/emails/meeting-briefing.tsx
🧠 Learnings (5)
📚 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/meeting-briefs/send-briefing.ts
  • packages/resend/emails/meeting-briefing.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 : Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : 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/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : 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/utils/ai/meeting-briefs/generate-briefing.ts
🧬 Code graph analysis (2)
apps/web/utils/meeting-briefs/send-briefing.ts (2)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (1)
  • BriefingContent (27-27)
packages/resend/emails/meeting-briefing.tsx (1)
  • BriefingContent (19-21)
packages/resend/emails/meeting-briefing.tsx (1)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (2)
  • GuestBriefing (26-26)
  • BriefingContent (27-27)
⏰ 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). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
🔇 Additional comments (4)
apps/web/utils/meeting-briefs/send-briefing.ts (1)

9-9: LGTM - Type update is consistent.

The parameter type change from string to BriefingContent aligns well with the structured briefing refactor. The import is correct and usage throughout the function is consistent.

Also applies to: 24-24

apps/web/utils/ai/meeting-briefs/generate-briefing.ts (1)

12-24: LGTM - Schema structure is well-designed.

The Zod schemas are specific and descriptive, with clear guidance for the LLM output. The structured approach with guest-specific information is a good improvement over unstructured text.

packages/resend/emails/meeting-briefing.tsx (2)

34-52: LGTM - Guest rendering logic is well-structured.

The renderGuestBriefings function properly handles the structured data with appropriate React keys, semantic HTML, and good visual hierarchy. The spacing and styling choices create a clear, readable briefing format.


135-158: LGTM - Preview data effectively demonstrates the feature.

The preview data provides comprehensive examples with realistic guest information, helping developers and designers understand how the structured briefing will render.

Comment on lines 26 to 27
export type GuestBriefing = z.infer<typeof guestBriefingSchema>;
export type BriefingContent = z.infer<typeof briefingSchema>;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Centralize type definitions to avoid duplication.

Both GuestBriefing and BriefingContent types are defined here and also in packages/resend/emails/meeting-briefing.tsx (lines 13-21). This violates the DRY principle and could lead to type drift if one definition is updated without the other.

Consider creating a shared types file (e.g., @/utils/meeting-briefs/types.ts) and exporting these types from a single location, or consistently import from one canonical source.

🤖 Prompt for AI Agents
In apps/web/utils/ai/meeting-briefs/generate-briefing.ts around lines 26-27, the
GuestBriefing and BriefingContent types are duplicated elsewhere
(packages/resend/emails/meeting-briefing.tsx lines 13-21); extract these z.infer
types into a single shared file (for example
apps/web/utils/ai/meeting-briefs/types.ts or a top-level package path like
@/utils/meeting-briefs/types.ts), export the types from that file, then replace
the local type definitions in both generate-briefing.ts and
packages/resend/emails/meeting-briefing.tsx with imports from the new shared
module so both files consume the canonical type definitions.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 4 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (1)

25-25: Centralize type definitions to avoid duplication.

The BriefingContent type is inferred here and also defined in packages/resend/emails/meeting-briefing.tsx (lines 18-20). This duplication violates the DRY principle and the coding guideline to centralize shared types in dedicated type files. If one definition is updated without the other, type drift could occur.

As per coding guidelines, consider extracting these types to a shared location (e.g., @/utils/meeting-briefs/types.ts) and importing from that single source in both files.

🧹 Nitpick comments (1)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (1)

27-74: Add logging and consider retry logic for LLM resilience.

Per coding guidelines for LLM feature functions, this function should use createScopedLogger to log inputs and outputs for observability. Additionally, consider adding withRetry for transient failure handling to improve resilience.

Apply this pattern:

+import { createScopedLogger } from "@/utils/logger";
+import { withRetry } from "@/utils/llms";
+
+const logger = createScopedLogger("meeting-briefing");
+
 export async function aiGenerateMeetingBriefing({
   briefingData,
   emailAccount,
 }: {
   briefingData: MeetingBriefingData;
   emailAccount: EmailAccountWithAI;
 }): Promise<BriefingContent> {
+  logger.info("Generating meeting briefing", {
+    eventId: briefingData.event.id,
+    guestCount: briefingData.externalGuests.length,
+  });
+
   const system = `You are an AI assistant that prepares concise meeting briefings.
   ...

Based on coding guidelines for apps/web/utils/ai/**/*.ts.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d954412 and 8ba7ca2.

📒 Files selected for processing (1)
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
apps/web/**/*.{ts,tsx}

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

apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Use @/ path aliases for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Follow consistent naming conventions using PascalCase for components
Centralize shared types in dedicated type files

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{ts,tsx}

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

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

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

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts

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

LLM-related code must be organized in specific directories: apps/web/utils/ai/ for main implementations, apps/web/utils/llms/ for core utilities and configurations, and apps/web/__tests__/ for LLM-specific tests

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/utils/ai/**/*.ts

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

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
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
System prompts must define the LLM's role and task specifications
User prompts must contain the actual data and context, and should be kept separate from system prompts
Always define a Zod schema for LLM response validation and make schemas as specific as possible to guide the LLM output
Use descriptive scoped loggers for each LLM feature, log inputs and outputs with appropriate log levels, and include relevant context in log messages
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
Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions
Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures
Keep related AI functions in the same file or directory, extract common patterns into utility functions, and document complex AI logic with clear comments

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/{server,api,actions,utils}/**/*.ts

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

**/{server,api,actions,utils}/**/*.ts: Use createScopedLogger from "@/utils/logger" for logging in backend code
Add the createScopedLogger instantiation at the top of the file with an appropriate scope name
Use .with() method to attach context variables only within specific functions, not on global loggers
For large functions with reused variables, use createScopedLogger().with() to attach context once and reuse the logger without passing variables repeatedly

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{ts,tsx,js,jsx}

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

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.ts

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{tsx,ts}

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{tsx,ts,css}

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{js,jsx,ts,tsx}

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

**/*.{js,jsx,ts,tsx}: Don't use accessKey attribute on any HTML element
Don't set aria-hidden="true" on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like <marquee> or <blink>
Only use the scope prop on <th> elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assign tabIndex to non-interactive HTML elements
Don't use positive integers for tabIndex property
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include a title element for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
Assign tabIndex to non-interactive HTML elements with aria-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include a type attribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden)
Always include a lang attribute on the html element
Always include a title attribute for iframe elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
!(pages/_document).{jsx,tsx}

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

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

Files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{js,ts,jsx,tsx}

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

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

Files:

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

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:36:18.416Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-11-25T14:36:18.416Z
Learning: Applies to apps/web/**/*.{ts,tsx} : Centralize shared types in dedicated type files

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : 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/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Keep related AI functions in the same file or directory, extract common patterns into utility functions, and document complex AI logic with clear comments

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.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/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : 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/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : User prompts must contain the actual data and context, and should be kept separate from system prompts

Applied to files:

  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
🧬 Code graph analysis (1)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (3)
packages/resend/emails/meeting-briefing.tsx (1)
  • BriefingContent (19-21)
apps/web/utils/meeting-briefs/gather-context.ts (1)
  • MeetingBriefingData (30-35)
apps/web/utils/llms/types.ts (1)
  • EmailAccountWithAI (10-32)
⏰ 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 (2)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (2)

12-24: LGTM! Well-structured schema definitions.

The Zod schemas are properly defined with descriptive fields that align with the JSON output format specified in the system prompt. The schema structure (guest with name, email, and bullets) is clear and appropriate for the meeting briefing use case.


34-54: LGTM! Clear prompt structure with proper JSON output specification.

The system prompt clearly defines the task and expected JSON structure, while the user prompt appropriately uses XML-like tags to structure the input data. The prompts align well with the Zod schema and provide specific guidelines (max 10 bullets, max 10 words each) that will help guide the LLM output.

Also applies to: 91-102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant