Skip to content

Comments

meeting-briefing: Agentic approach with research tools#1162

Merged
elie222 merged 2 commits intomainfrom
feat/agentic-meeting-briefing
Jan 1, 2026
Merged

meeting-briefing: Agentic approach with research tools#1162
elie222 merged 2 commits intomainfrom
feat/agentic-meeting-briefing

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jan 1, 2026

User description

Meeting Briefing: Refactor to agentic approach with research tools

Refactored the meeting briefing system from a pipeline approach to an agentic one, where the AI writes the full briefing with context-aware tool access.

  • Converted aiGenerateMeetingBriefing to use generateText with researchGuest and finalizeBriefing tools.
  • Simplified gatherContextForEvent to remove parallel research calls.
  • Added comprehensive AI and unit tests in ai-meeting-briefing.test.ts.
  • Improved prompt coherence by giving the AI full context of all guests simultaneously.

Summary by CodeRabbit

  • Tests

    • Added comprehensive tests for AI meeting briefing flows covering formatting, per-guest bullets, past meetings, email history, edge cases, and end-to-end scenarios.
  • New Features

    • Meeting briefs now deliver structured per-guest bullet summaries.
    • Email briefings include an AI-generated accuracy disclaimer for names.
  • Refactor

    • Brief generation moved to a tool-driven agent flow and simplified context gathering (removed prior per-guest AI research).

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


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Refactors the meeting briefing system to an agentic, tool-driven approach, converting aiGenerateMeetingBriefing to utilize generateText with researchGuest and finalizeBriefing tools. Simplifies context gathering by removing parallel research calls and improves prompt coherence, alongside adding comprehensive AI and unit tests.

TopicDetails
Agentic Briefing Workflow Refactors the meeting briefing generation to an agentic, tool-driven workflow, converting aiGenerateMeetingBriefing to use generateText with researchGuest and finalizeBriefing tools, and updating the AGENTIC_SYSTEM_PROMPT for conditional tool usage and improved coherence.
Modified files (1)
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
Latest Contributors(1)
UserCommitDate
elie222adjust-how-we-do-resea...January 01, 2026
AI Briefing Tests Adds comprehensive AI and unit tests for the aiGenerateMeetingBriefing function, covering various scenarios including single guests with no prior context and ensuring proper mock clearing before each test.
Modified files (1)
  • apps/web/__tests__/ai-meeting-briefing.test.ts
Latest Contributors(1)
UserCommitDate
elie222fixesJanuary 01, 2026
This pull request is reviewed by Baz. Review like a pro on (Baz).

@vercel
Copy link

vercel bot commented Jan 1, 2026

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Refactors meeting-briefing generation to an agentic, tool-driven flow (with finalize tool and web-search/perplexity tooling), removes per-guest AI research from context gathering, renames/expands research cache APIs, threads a logger into generation, adds many tests, and early-exits when no external guests.

Changes

Cohort / File(s) Summary
Tests
apps/web/__tests__/ai-meeting-briefing.test.ts
New comprehensive tests for buildPrompt, formatMeetingForContext, and aiGenerateMeetingBriefing across many scenarios; includes mocks, helpers, verbose timeouts, and pretty-printing.
Agentic generation
apps/web/utils/ai/meeting-briefs/generate-briefing.ts
Introduces agentic flow (AGENTIC_SYSTEM_PROMPT), finalizeBriefing tool, MAX_* limits, toolsNote, web-search & Perplexity tooling with caching, generateFallbackBriefing, exports BriefingContent, and changes aiGenerateMeetingBriefing to accept a logger.
Context gathering
apps/web/utils/meeting-briefs/gather-context.ts
Removes per-guest AI research flow and ExternalGuest.aiResearch; now gathers attendees, recent emails, and past meetings only.
Process plumbing
apps/web/utils/meeting-briefs/process.ts
Passes event-scoped logger into aiGenerateMeetingBriefing; no other behavior changes.
Research module removed
apps/web/utils/ai/meeting-briefs/research-guest.ts
Deleted: previously provided researchGuestWithPerplexity, model selection, prompt assembly, caching & error handling.
Redis research cache
apps/web/utils/redis/research-cache.ts
Renamed from perplexity-specific API to generic research cache: new ResearchSource type, key prefix research, function renames (getCachedResearch/setCachedResearch/clearCachedResearchForUser), and source-scoped keys/logging.
User deletion usage
apps/web/utils/user/delete.ts
Updated import and call to use clearCachedResearchForUser; updated log text.
Email utils
apps/web/utils/email.ts
Added "mail.com" to PUBLIC_EMAIL_DOMAINS.
Email template
packages/resend/emails/meeting-briefing.tsx
Adds AI-generated accuracy disclaimer and tweaks guest section padding.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Generator as aiGenerateMeetingBriefing
    participant Agent as Agentic AI Flow
    participant Cache as Research Cache
    participant WebSearch as WebSearch Tool

    Client->>Generator: aiGenerateMeetingBriefing(briefingData, emailAccount, logger)
    Generator->>Cache: getCachedResearch(source?, user, guest)
    alt cache hit
        Cache-->>Generator: cached research
        Generator->>Agent: start agent with cached context & toolsNote
    else cache miss
        Generator->>Agent: start agent with AGENTIC_SYSTEM_PROMPT & tools
        loop Agentic steps (<= MAX_AGENT_STEPS)
            Agent->>WebSearch: optional web search request
            WebSearch-->>Agent: search results
            Agent->>Cache: setCachedResearch(source, user, guest, content)
        end
        Agent->>Agent: call finalizeBriefing tool
        Agent-->>Generator: finalized BriefingContent
    end
    Generator-->>Client: BriefingContent (guests with per-guest bullets)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Structured briefing output #1096: Converts meeting briefings to structured BriefingContent and updates consumers—closely related to the briefing schema change.
  • fix timezone issue #1147: Modifies buildPrompt / formatMeetingForContext—overlaps with prompt/formatting & tooling changes in this PR.

Suggested reviewers

  • anakarentorosserrano-star
  • baz-reviewer

Poem

🐰 I nibbled prompts and cached a clue,
Tools at my paws and web-search too.
Bullets for guests, each tidy and bright,
Logger in tow — briefings take flight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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
Title check ✅ Passed The title accurately reflects the main architectural change: transitioning the meeting briefing system from a pipeline model to an agentic AI approach with research tools.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

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

❤️ Share

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

@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Jan 1, 2026

Update meeting briefing agent to attempt agentic generation without search tools in generate-briefing.ts

Adjust AGENTIC_SYSTEM_PROMPT to conditionally reference search tools and change aiGenerateMeetingBriefing to run with available searchTools and finalizeBriefing instead of immediate fallback when no tools are configured; add test suite beforeEach to clear mocks.

📍Where to Start

Start with aiGenerateMeetingBriefing in generate-briefing.ts; then review the prompt changes to AGENTIC_SYSTEM_PROMPT in the same file.


Macroscope summarized 81613e1.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all issues)

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


<file name="apps/web/__tests__/ai-meeting-briefing.test.ts">

<violation number="1" location="apps/web/__tests__/ai-meeting-briefing.test.ts:80">
P2: Test assertion `expect(prompt).toContain(&quot;new contact&quot;)` passes for the wrong reason - it matches template text, not the guest&#39;s name &quot;New Contact&quot;. Consider changing to `&quot;New Contact&quot;` to actually verify the guest&#39;s name is included in the prompt.</violation>
</file>

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

86-106: Add error handling to the research tool.

The researchGuest tool calls researchGuestWithPerplexity without error handling. If the research call throws an exception, it could break the entire briefing generation flow.

🔎 Proposed enhancement
         execute: async ({ email, name }) => {
           logger.info("Researching guest", { email, name });
-          const research = await researchGuestWithPerplexity({
-            email,
-            name,
-            event: briefingData.event,
-            emailAccount,
-            logger,
-          });
-          if (!research) {
-            return { found: false, message: "No research results available" };
-          }
-          return { found: true, research };
+          try {
+            const research = await researchGuestWithPerplexity({
+              email,
+              name,
+              event: briefingData.event,
+              emailAccount,
+              logger,
+            });
+            if (!research) {
+              return { found: false, message: "No research results available" };
+            }
+            return { found: true, research };
+          } catch (error) {
+            logger.error("Research failed for guest", { email, name, error });
+            return { found: false, message: "Research failed" };
+          }
         },

As per coding guidelines, implement proper error handling and fallbacks for AI failures.

📜 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 45e6da3 and 2be0caf.

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

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

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

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/__tests__/**/*.test.ts

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

apps/web/__tests__/**/*.test.ts: Place all LLM-related tests in apps/web/__tests__/ directory
Use vitest imports (describe, expect, test, vi, beforeEach) in LLM test files
Mock 'server-only' module with empty object in LLM test files: vi.mock("server-only", () => ({}))
Set timeout constant const TIMEOUT = 15_000; for LLM tests
Use describe.runIf(isAiTest) with environment variable RUN_AI_TESTS === "true" to conditionally run LLM tests
Use console.debug() for outputting generated LLM content in tests, e.g., console.debug("Generated content:\n", result.content);
Prefer using existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) instead of creating custom test data helpers

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.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/__tests__/ai-meeting-briefing.test.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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/**/*.{ts,tsx}

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • 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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • 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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • 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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

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

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

Files:

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • 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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
**/{scripts,tests,__tests__}/**/*.{ts,tsx}

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

Use createScopedLogger only for code that doesn't run within a middleware chain, such as standalone scripts or tests

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{ts,tsx,js,jsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

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

Format code with Prettier

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
apps/web/**/*.test.{ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{example,ts,json}

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

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

Files:

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.test.{ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/__tests__/**/*.{ts,tsx}

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

Place AI tests in the __tests__ directory and do not run them by default as they use a real LLM

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}

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

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

Files:

  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • 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
🧠 Learnings (17)
📚 Learning: 2026-01-01T10:42:29.767Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.767Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place AI tests in the `__tests__` directory and do not run them by default as they use a real LLM

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.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 : Implement early returns for invalid LLM inputs, use proper error types and logging, implement fallbacks for AI failures, and add retry logic for transient failures using `withRetry`

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
  • 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/__tests__/ai-meeting-briefing.test.ts
  • apps/web/utils/meeting-briefs/gather-context.ts
  • apps/web/utils/meeting-briefs/process.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/utils/meeting-briefs/gather-context.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 descriptive scoped loggers for each LLM feature, log inputs and outputs with appropriate log levels, and include relevant context in log messages

Applied to files:

  • apps/web/utils/meeting-briefs/process.ts
📚 Learning: 2025-12-18T16:37:47.972Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/logging.mdc:0-0
Timestamp: 2025-12-18T16:37:47.972Z
Learning: Applies to **/{utils,helpers,lib}/**/*.{ts,tsx} : Logger should be passed as a parameter to helper functions instead of creating their own logger instances

Applied to files:

  • apps/web/utils/meeting-briefs/process.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 : System prompts must define the LLM's role and task specifications

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 : Always define a Zod schema for LLM response validation and make schemas as specific as possible to guide the LLM output

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/__tests__/ai-meeting-briefing.test.ts (4)
apps/web/utils/logger.ts (1)
  • createScopedLogger (18-82)
apps/web/utils/meeting-briefs/gather-context.ts (2)
  • CalendarEvent (19-19)
  • MeetingBriefingData (26-31)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (4)
  • buildPrompt (132-167)
  • formatMeetingForContext (271-282)
  • aiGenerateMeetingBriefing (53-129)
  • BriefingContent (28-28)
apps/web/__tests__/helpers.ts (2)
  • getMockMessage (139-179)
  • getEmailAccount (26-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Baz Reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
🔇 Additional comments (7)
apps/web/utils/meeting-briefs/process.ts (1)

203-207: LGTM! Logger parameter correctly passed.

The addition of the logger parameter to aiGenerateMeetingBriefing correctly follows the guideline that helper functions should receive the logger as a parameter rather than creating their own instances.

Based on learnings, logger should be passed as a parameter to helper functions.

apps/web/utils/meeting-briefs/gather-context.ts (1)

88-96: LGTM! Clean simplification of data structure.

The removal of the aiResearch field from the external guests mapping aligns with the PR's refactoring goal to move guest research into the AI generation phase as a tool-based workflow.

apps/web/__tests__/ai-meeting-briefing.test.ts (1)

1-21: Well-structured LLM test file.

The test setup correctly follows LLM testing guidelines:

  • Uses describe.runIf(isAiTest) with environment variable check
  • Mocks server-only module
  • Uses proper vitest imports
  • Creates a scoped logger for tests
  • Sets appropriate timeout for agentic flow (60 seconds)

As per coding guidelines, LLM tests should be conditionally run and properly configured.

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

53-64: LGTM! Proper function signature and early return.

The function correctly:

  • Accepts logger as a parameter (following the guideline that helpers should receive logger rather than create their own)
  • Implements early return when there are no external guests
  • Accepts briefingData and emailAccount parameters as per LLM function structure

Based on learnings, logger should be passed as a parameter to helper functions.


30-51: Well-structured system prompt with clear workflow.

The AGENTIC_SYSTEM_PROMPT properly:

  • Defines the AI's role and task specifications
  • Provides clear workflow steps
  • Documents available tools
  • Sets concise briefing guidelines
  • Emphasizes the requirement to call finalizeBriefing

This follows LLM guidelines for separating system prompts (role/task) from user prompts (data/context).

As per coding guidelines, system prompts must define the LLM's role and task specifications.


123-128: Good fallback handling for missing result.

The code properly handles the edge case where finalizeBriefing is never called by:

  • Checking if result is null
  • Logging a warning
  • Returning an empty briefing structure

This prevents the function from returning null or throwing an error.

As per coding guidelines, implement fallbacks for AI failures.


150-167: Clean prompt construction with XML tags.

The buildPrompt function properly:

  • Uses XML-like tags to structure data (<upcoming_meeting>, <guest_context>)
  • Separates meeting details from guest context
  • Provides clear instructions for the AI workflow
  • Keeps the user prompt focused on data and context

This follows the guideline to use XML-like tags for structuring data in prompts and to keep user prompts separate from system prompts.

As per coding guidelines, use XML-like tags to structure data in prompts.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/__tests__/ai-meeting-briefing.test.ts (1)

23-50: Consider moving helper functions to the bottom of the file.

For consistency with project guidelines, helper functions should be placed at the bottom of files. While test data builders are commonly placed at the top in test files, the prettyPrintBriefing helper at line 474 follows the guideline. Consider moving getCalendarEvent and getMeetingBriefingData to the bottom as well for consistency.

As per coding guidelines, helper functions should be at the bottom of files.

📜 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 2be0caf and 2de7d01.

📒 Files selected for processing (1)
  • apps/web/__tests__/ai-meeting-briefing.test.ts
🧰 Additional context used
📓 Path-based instructions (20)
**/*.{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/__tests__/ai-meeting-briefing.test.ts
apps/web/__tests__/**/*.test.ts

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

apps/web/__tests__/**/*.test.ts: Place all LLM-related tests in apps/web/__tests__/ directory
Use vitest imports (describe, expect, test, vi, beforeEach) in LLM test files
Mock 'server-only' module with empty object in LLM test files: vi.mock("server-only", () => ({}))
Set timeout constant const TIMEOUT = 15_000; for LLM tests
Use describe.runIf(isAiTest) with environment variable RUN_AI_TESTS === "true" to conditionally run LLM tests
Use console.debug() for outputting generated LLM content in tests, e.g., console.debug("Generated content:\n", result.content);
Prefer using existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) instead of creating custom test data helpers

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.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/__tests__/ai-meeting-briefing.test.ts
**/*.{ts,tsx,js,jsx}

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{ts,tsx}

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.ts

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.{tsx,ts}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.{tsx,ts,css}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.{js,jsx,ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

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

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

Files:

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

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.{js,ts,jsx,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/{scripts,tests,__tests__}/**/*.{ts,tsx}

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

Use createScopedLogger only for code that doesn't run within a middleware chain, such as standalone scripts or tests

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{ts,tsx,js,jsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

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

Format code with Prettier

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.test.{ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
apps/web/**/*.{example,ts,json}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.test.{js,jsx,ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/*.test.{ts,tsx}

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

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

Files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
**/__tests__/**/*.{ts,tsx}

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

Place AI tests in the __tests__ directory and do not run them by default as they use a real LLM

Files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Implement early returns for invalid LLM inputs, use proper error types and logging, implement fallbacks for AI failures, and add retry logic for transient failures using `withRetry`

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : System prompts must define the LLM's role and task specifications

Applied to files:

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

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use descriptive scoped loggers for each LLM feature, log inputs and outputs with appropriate log levels, and include relevant context in log messages

Applied to files:

  • apps/web/__tests__/ai-meeting-briefing.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : 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/__tests__/ai-meeting-briefing.test.ts
🧬 Code graph analysis (1)
apps/web/__tests__/ai-meeting-briefing.test.ts (3)
apps/web/utils/meeting-briefs/gather-context.ts (2)
  • CalendarEvent (19-19)
  • MeetingBriefingData (26-31)
apps/web/utils/ai/meeting-briefs/generate-briefing.ts (4)
  • buildPrompt (132-167)
  • formatMeetingForContext (271-282)
  • aiGenerateMeetingBriefing (53-129)
  • BriefingContent (28-28)
apps/web/__tests__/helpers.ts (2)
  • getMockMessage (139-179)
  • getEmailAccount (26-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Baz Reviewer
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Macroscope - Correctness Check
🔇 Additional comments (2)
apps/web/__tests__/ai-meeting-briefing.test.ts (2)

21-21: Verify that 60-second timeout is necessary for agentic tests.

The coding guideline specifies const TIMEOUT = 15_000; for LLM tests, but this test uses 60 seconds (4x longer). While the comment mentions "agentic flow with research," confirm that this extended timeout is necessary and not masking performance issues.

As per coding guidelines, the standard timeout for LLM tests is 15 seconds.


52-472: Excellent test coverage and implementation!

The test suite comprehensively covers the meeting briefing functionality with well-structured unit tests and AI integration tests:

  • Unit tests validate buildPrompt and formatMeetingForContext with various scenarios (guest context, email history, past meetings, multiple guests)
  • AI tests are properly gated with describe.runIf(isAiTest) and exercise realistic end-to-end scenarios
  • Test names are clear and descriptive
  • Proper use of existing helpers from @/__tests__/helpers
  • Logger correctly passed to aiGenerateMeetingBriefing
  • Assertions are appropriate for both deterministic unit tests and non-deterministic AI outputs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

248-272: Consider adding Anthropic provider support.

getWebSearchConfig handles OpenAI, Google, and OpenRouter but returns null for Anthropic (DEFAULT_LLM_PROVIDER's default). If Anthropic is commonly used, users may lose web search capability. This may be intentional if Anthropic lacks a native search tool, but worth noting.


363-377: Tool availability check duplicates provider logic.

The buildPrompt function re-checks provider configuration to list available tools, duplicating the logic in buildSearchTools and getWebSearchConfig. Consider extracting a shared helper or passing the actual tool names from buildSearchTools.

Example approach
// In aiGenerateMeetingBriefing, pass tool names to buildPrompt:
const toolNames = Object.keys(tools);
const prompt = buildPrompt(briefingData, emailAccount.timezone, toolNames);

// In buildPrompt:
export function buildPrompt(
  briefingData: MeetingBriefingData,
  timezone: string | null,
  availableTools: string[] = [],
): string {
  // ...
  const toolsNote =
    availableTools.length > 0
      ? `\nAvailable search tools: ${availableTools.join(", ")}`
      : "";
  // ...
}
apps/web/utils/redis/research-cache.ts (1)

48-61: Consider cursor type consistency.

The cursor variable is initialized as number (line 49), but redis.scan returns nextCursor which is then converted via Number(nextCursor). This works, but let cursor: string | number = 0 might be cleaner if the SDK returns strings.

📜 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 2de7d01 and 6ff89ca.

📒 Files selected for processing (6)
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/ai/meeting-briefs/research-guest.ts
  • apps/web/utils/email.ts
  • apps/web/utils/redis/research-cache.ts
  • apps/web/utils/user/delete.ts
  • packages/resend/emails/meeting-briefing.tsx
💤 Files with no reviewable changes (1)
  • apps/web/utils/ai/meeting-briefs/research-guest.ts
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{ts,tsx}

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

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

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

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
  • packages/resend/emails/meeting-briefing.tsx
**/*.{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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
  • packages/resend/emails/meeting-briefing.tsx
apps/web/**/*.{ts,tsx}

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

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
  • packages/resend/emails/meeting-briefing.tsx
!(pages/_document).{jsx,tsx}

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
  • packages/resend/emails/meeting-briefing.tsx
**/{utils,helpers,lib}/**/*.{ts,tsx}

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
apps/web/**/*.{ts,tsx,js,jsx}

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}

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

Format code with Prettier

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.ts
apps/web/**/*.{example,ts,json}

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

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

Files:

  • apps/web/utils/user/delete.ts
  • apps/web/utils/email.ts
  • apps/web/utils/ai/meeting-briefs/generate-briefing.ts
  • apps/web/utils/redis/research-cache.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
**/*.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 (9)
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Keep Gmail provider-specific implementation details isolated within the apps/web/utils/gmail/ directory

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/web/utils/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 : 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 : Implement early returns for invalid LLM inputs, use proper error types and logging, implement fallbacks for AI failures, and add retry logic for transient failures using `withRetry`

Applied to files:

  • apps/web/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 (3)
apps/web/utils/user/delete.ts (1)
apps/web/utils/redis/research-cache.ts (1)
  • clearCachedResearchForUser (39-80)
apps/web/utils/redis/research-cache.ts (3)
apps/web/utils/logger.ts (1)
  • createScopedLogger (18-82)
apps/web/env.ts (1)
  • env (17-258)
apps/web/utils/hash.ts (1)
  • hash (10-20)
packages/resend/emails/meeting-briefing.tsx (1)
apps/web/components/new-landing/common/Section.tsx (1)
  • Section (9-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Baz Reviewer
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
  • GitHub Check: Macroscope - Correctness Check
🔇 Additional comments (9)
apps/web/utils/email.ts (1)

145-145: LGTM!

Adding "mail.com" to the public email domains set is appropriate — it's a well-known free email provider that should be treated the same as gmail.com, yahoo.com, etc.

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

100-109: LGTM!

Good addition of the AI accuracy disclaimer. This sets appropriate expectations for users, especially regarding common name ambiguity. The styling is consistent with the email template.

apps/web/utils/user/delete.ts (1)

12-12: LGTM!

The import and function call correctly reflect the renamed/generalized research cache module. Not passing a source parameter to clearCachedResearchForUser will clear all sources (perplexity + websearch), which is the correct behavior for user deletion.

Also applies to: 71-74

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

84-86: LGTM!

Good early exit when there are no external guests — avoids unnecessary tool initialization and LLM calls.


135-143: LGTM!

Good defensive fallback if the agent fails to call finalizeBriefing. The warning log provides visibility into these edge cases.


208-216: Fire-and-forget cache writes are acceptable here.

The .catch() pattern for setCachedResearch is fine since caching is an optimization — search results will still be returned even if caching fails. The error is logged appropriately.

Also applies to: 325-333


114-117: No changes needed — the behavior is correct as implemented.

The stopWhen callback receives steps as an accumulated array of all executed steps, not just the current step. The condition stepResult.steps.length > MAX_AGENT_STEPS correctly checks the total accumulated step count to prevent infinite loops.

apps/web/utils/redis/research-cache.ts (2)

12-13: LGTM!

Good generalization of the cache module to support multiple research sources. The ResearchSource type provides type safety, and including the source in the cache key ensures proper isolation between Perplexity and web search results.

Also applies to: 18-29


31-37: LGTM!

The pattern logic correctly handles both source-specific (research:{source}:{userId}:*) and all-sources (research:*:{userId}:*) deletion. The wildcard positioning is correct for Redis SCAN.

@elie222 elie222 merged commit 2088bc2 into main Jan 1, 2026
14 of 16 checks passed
@elie222 elie222 deleted the feat/agentic-meeting-briefing branch January 1, 2026 15:52
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