Skip to content

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Dec 9, 2025

Summary by CodeRabbit

  • New Features

    • Organization analytics dashboard with email volume, automation usage, active member metrics and date-range filtering
    • Tabbed organization navigation and an Analytics action next to the invite flow
    • Azure OpenAI added as a configurable LLM provider (UI, CLI setup, and runtime support)
  • UI

    • Smaller invite button trigger for modal
  • Documentation

    • Updated environment variable docs to include Azure settings
  • Chores

    • Version bumped to v2.21.60

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

@vercel
Copy link

vercel bot commented Dec 9, 2025

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

Project Deployment Preview Updated (UTC)
inbox-zero Ready Ready Preview Dec 10, 2025 2:12am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

Walkthrough

Adds Azure OpenAI as a new LLM provider (env, model selection, CLI, dependency) and introduces an Organization Analytics feature: tabbed org navigation, a stats page/component with date-range filters and charts, and a new API endpoint that computes bucketed org metrics.

Changes

Cohort / File(s) Summary
LLM Provider: Azure OpenAI
apps/web/.env.example, apps/web/env.ts, apps/web/package.json, apps/web/utils/llms/config.ts, apps/web/utils/llms/model.ts, docs/hosting/environment-variables.md, packages/cli/src/main.ts
Add "azure" as a supported LLM provider: new env vars AZURE_BASE_URL, AZURE_API_KEY (server-side), update provider enum and model selection to construct Azure models, add @ai-sdk/azure dependency, and update CLI setup flow to collect/store Azure credentials.
Organization Analytics Feature
apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx, apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx, apps/web/app/(app)/organization/[organizationId]/stats/page.tsx, apps/web/app/api/organizations/[organizationId]/stats/route.ts
Add organization analytics: tabbed navigation (Members / Analytics), OrgStats React component with date-range selection and bucketed charts, new stats page route, and a GET API route that validates auth/params and computes email volume, executed-rules buckets, and totals via SQL queries.
Organization Page Updates
apps/web/app/(app)/organization/[organizationId]/page.tsx, apps/web/app/(app)/organization/[organizationId]/Members.tsx
Replace previous page header with OrganizationTabs, fetch organization name via Prisma, add Analytics button next to Invite flow, and adjust layout spacing.
Minor UI Refinements
apps/web/components/InviteMemberModal.tsx
Make InviteMemberModal trigger button size small (size="sm").
Version Update
version.txt
Bump version from v2.21.58 to v2.21.60.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser as OrgStats UI (React)
    participant NextAPI as /api/organizations/[id]/stats (Next route)
    participant Auth as withAuth / Admin check
    participant DB as Database (Prisma/SQL)

    User->>Browser: Navigate to /organization/{id}/stats
    Browser->>Browser: Init date range (last 7 days)
    Browser->>NextAPI: GET /api/organizations/{id}/stats?fromDate=&toDate=
    NextAPI->>Auth: withAuth + fetchAndCheckIsAdmin
    Auth-->>NextAPI: auth ok / admin confirmed
    NextAPI->>DB: Query per-member email counts (date bounds)
    DB-->>NextAPI: email counts
    NextAPI->>DB: Query per-member executed rules (date bounds)
    DB-->>NextAPI: rule counts
    NextAPI->>DB: Query totals (emails, rules, active members)
    DB-->>NextAPI: totals
    NextAPI->>NextAPI: Bucket results & build response
    NextAPI-->>Browser: OrgStatsResponse (buckets + totals)
    Browser->>Browser: Render StatCards & BucketCharts
    Browser->>User: Display analytics UI and charts
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts — Verify raw SQL correctness, date filtering, SQL injection safety, performance of aggregation queries, and authorization enforcement.
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx — Check SWR usage, query param encoding, loading/error states, and chart rendering for edge/empty cases.
  • apps/web/utils/llms/model.ts & apps/web/env.ts & packages/cli/src/main.ts — Ensure Azure credential handling follows existing provider patterns, fallback behavior when creds are missing, and CLI storage/validation logic are correct.

Possibly related PRs

Poem

🐰 Tabs click, buckets hum with cheer,
Azure whispers models near,
Charts hop out in tidy rows,
Dates and counts in gentle glows,
A tiny rabbit sings: version up — hooray, my dear! 🥕📊

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Azure openai' is vague and lacks specificity about the actual changes; it does not clearly describe what was added or modified regarding Azure OpenAI support. Consider using a more descriptive title like 'Add Azure OpenAI provider support' or 'Integrate Azure OpenAI LLM provider' to clearly communicate the feature being added.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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/azure-support

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

macroscopeapp bot commented Dec 9, 2025

Add Azure OpenAI provider support across web app, CLI, and env configuration to enable Azure-backed models

Introduce azure to provider enums and selection flows, wire up AZURE_BASE_URL and AZURE_API_KEY in server env validation, integrate @ai-sdk/azure, and add a Provider.AZURE case in model.selectModel using defaults gpt-5.1 and gpt-5.1-mini. Update docs and example env, and extend the CLI to collect Azure credentials and set default/economy models.

📍Where to Start

Start with the Azure branch in model.selectModel in model.ts, then review env validation in env.ts and the CLI provider flow in main.ts.


Macroscope summarized eaec6b6.

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 15 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: 4

🧹 Nitpick comments (5)
apps/web/app/api/organizations/[organizationId]/stats/route.ts (3)

16-32: Consider consolidating duplicate bucket definitions.

EMAIL_BUCKETS and RULES_BUCKETS are identical. Consider using a single shared constant to reduce duplication and ensure consistency.

-// Bucket boundaries for email volume per user
-const EMAIL_BUCKETS = [
-  { min: 500, label: "500+" },
-  { min: 200, max: 500, label: "200-500" },
-  { min: 100, max: 200, label: "100-200" },
-  { min: 50, max: 100, label: "50-100" },
-  { min: 0, max: 50, label: "<50" },
-];
-
-// Bucket boundaries for executed rules per user
-const RULES_BUCKETS = [
-  { min: 500, label: "500+" },
-  { min: 200, max: 500, label: "200-500" },
-  { min: 100, max: 200, label: "100-200" },
-  { min: 50, max: 100, label: "50-100" },
-  { min: 0, max: 50, label: "<50" },
-];
+// Bucket boundaries for volume metrics per user
+const VOLUME_BUCKETS = [
+  { min: 500, label: "500+" },
+  { min: 200, max: 500, label: "200-500" },
+  { min: 100, max: 200, label: "100-200" },
+  { min: 50, max: 100, label: "50-100" },
+  { min: 0, max: 50, label: "<50" },
+];

130-180: Consider extracting shared bucketing logic.

The bucketing loop (lines 165-177) is identical to lines 113-125 in getEmailVolumeBuckets. Consider extracting a helper function to reduce duplication.

function bucketResults<T extends { count: bigint }>(
  results: T[],
  buckets: typeof VOLUME_BUCKETS,
  countKey: keyof T,
) {
  const bucketCounts = buckets.map((bucket) => ({
    label: bucket.label,
    userCount: 0,
  }));

  for (const item of results) {
    const count = Number(item[countKey]);
    for (let i = 0; i < buckets.length; i++) {
      const bucket = buckets[i];
      if (count >= bucket.min && (bucket.max === undefined || count < bucket.max)) {
        bucketCounts[i].userCount++;
        break;
      }
    }
  }
  return bucketCounts;
}

1-6: Consider adding scoped logger for observability.

As per coding guidelines, backend code should use createScopedLogger for logging. This would help with debugging and monitoring.

 import { NextResponse } from "next/server";
 import { z } from "zod";
 import prisma from "@/utils/prisma";
 import { withAuth } from "@/utils/middleware";
 import { fetchAndCheckIsAdmin } from "@/utils/organizations/access";
 import { Prisma } from "@/generated/prisma/client";
+import { createScopedLogger } from "@/utils/logger";
+
+const logger = createScopedLogger("organizations/stats");
apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1)

39-41: Consider adding dark mode support for border.

The border uses border-neutral-200 without a dark mode variant, which may not contrast well in dark theme.

-      <div className="border-b border-neutral-200">
+      <div className="border-b border-neutral-200 dark:border-neutral-700">
apps/web/.env.example (1)

88-95: Azure block is correct; consider clearer example placeholders.

The Azure OpenAI block matches the rest of the configuration and aligns with env.ts. To make it more self-explanatory for self-hosters, you could add explicit placeholder values:

-# AZURE_RESOURCE_NAME=
-# AZURE_API_KEY=
+# AZURE_RESOURCE_NAME=your-azure-openai-resource-name
+# AZURE_API_KEY=your-azure-openai-api-key
📜 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 b5f1239 and eaa470c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • apps/web/.env.example (1 hunks)
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx (2 hunks)
  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1 hunks)
  • apps/web/app/(app)/organization/[organizationId]/page.tsx (2 hunks)
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx (1 hunks)
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx (1 hunks)
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts (1 hunks)
  • apps/web/components/InviteMemberModal.tsx (1 hunks)
  • apps/web/env.ts (2 hunks)
  • apps/web/package.json (1 hunks)
  • apps/web/utils/llms/config.ts (2 hunks)
  • apps/web/utils/llms/model.ts (3 hunks)
  • docs/hosting/environment-variables.md (2 hunks)
  • version.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (30)
**/package.json

📄 CodeRabbit inference engine (.cursor/rules/installing-packages.mdc)

Use pnpm as the package manager

Files:

  • apps/web/package.json
apps/web/package.json

📄 CodeRabbit inference engine (.cursor/rules/installing-packages.mdc)

Don't install packages in root; install in apps/web workspace instead

Files:

  • apps/web/package.json
!(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/package.json
  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/.env.example
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • version.txt
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • docs/hosting/environment-variables.md
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/app/**/*.{ts,tsx}

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

Follow NextJS app router structure with (app) directory

Files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/**/*.tsx

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

apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss for class sorting
Prefer functional components with hooks over class components
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Use LoadingContent component for async data with loading and error states

Files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
**/*.{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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/app/(app)/**/*.{ts,tsx}

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

apps/web/app/(app)/**/*.{ts,tsx}: Components for the page are either put in page.tsx, or in the apps/web/app/(app)/PAGE_NAME folder
If we're in a deeply nested component we will use swr to fetch via API
If you need to use onClick in a component, that component is a client component and file must start with use client

Files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/Members.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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.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:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/app/(app)/organization/[organizationId]/Members.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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
**/*.{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:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/app/(app)/organization/[organizationId]/Members.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/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
  • apps/web/env.ts
  • apps/web/components/InviteMemberModal.tsx
  • apps/web/utils/llms/config.ts
  • apps/web/app/(app)/organization/[organizationId]/Members.tsx
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/**/{.env.example,env.ts,turbo.json}

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

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

Files:

  • apps/web/env.ts
  • apps/web/.env.example
apps/web/env.ts

📄 CodeRabbit inference engine (.cursor/rules/environment-variables.mdc)

apps/web/env.ts: Add server-only environment variables to apps/web/env.ts under the server object with Zod schema validation
Add client-side environment variables to apps/web/env.ts under the client object with NEXT_PUBLIC_ prefix and Zod schema validation
Add client-side environment variables to apps/web/env.ts under the experimental__runtimeEnv object to enable runtime access

Files:

  • apps/web/env.ts
{.env.example,apps/web/env.ts}

📄 CodeRabbit inference engine (.cursor/rules/environment-variables.mdc)

Client-side environment variables must be prefixed with NEXT_PUBLIC_

Files:

  • apps/web/env.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/env.ts
  • apps/web/utils/llms/config.ts
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/components/**/*.tsx

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

apps/web/components/**/*.tsx: Use React Hook Form with Zod validation for form components
Use result?.serverError with toastError and toastSuccess for error handling in form submissions

Use LoadingContent component to consistently handle loading and error states, passing loading, error, and children props

Use PascalCase for component file names (e.g., components/Button.tsx)

Files:

  • apps/web/components/InviteMemberModal.tsx
**/{pages,routes,components}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/gmail-api.mdc)

Never call Gmail API directly from routes or components - always use wrapper functions from the utils folder

Files:

  • apps/web/components/InviteMemberModal.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/llms/config.ts
  • apps/web/utils/llms/model.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/llms/config.ts
  • apps/web/utils/llms/model.ts
  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/utils/llms/{index,model}.ts

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

Core LLM functionality must be defined in utils/llms/index.ts, model definitions and configurations in utils/llms/model.ts, and usage tracking in utils/usage.ts

Files:

  • apps/web/utils/llms/model.ts
apps/web/app/api/**/*.ts

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

apps/web/app/api/**/*.ts: Wrap GET API routes with withAuth or withEmailAccount middleware for authentication
Export response types from GET API routes using Awaited<ReturnType<>> pattern for type-safe client usage

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/app/api/**/route.ts

📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)

apps/web/app/api/**/route.ts: Create GET API routes using withAuth or withEmailAccount middleware in apps/web/app/api/*/route.ts, export response types as GetExampleResponse type alias for client-side type safety
Always export response types from GET routes as Get[Feature]Response using type inference from the data fetching function for type-safe client consumption
Do NOT use POST API routes for mutations - always use server actions with next-safe-action instead

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
**/app/**/route.ts

📄 CodeRabbit inference engine (.cursor/rules/get-api-route.mdc)

**/app/**/route.ts: Always wrap GET API route handlers with withAuth or withEmailAccount middleware for consistent error handling and authentication in Next.js App Router
Infer and export response type for GET API routes using Awaited<ReturnType<typeof functionName>> pattern in Next.js
Use Prisma for database queries in GET API routes
Return responses using NextResponse.json() in GET API routes
Do not use try/catch blocks in GET API route handlers when using withAuth or withEmailAccount middleware, as the middleware handles error handling

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/app/**/[!.]*/route.{ts,tsx}

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

Use kebab-case for route directories in Next.js App Router (e.g., api/hello-world/route)

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
apps/web/app/api/**/*.{ts,tsx}

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

apps/web/app/api/**/*.{ts,tsx}: API routes must use withAuth, withEmailAccount, or withError middleware for authentication
All database queries must include user scoping with emailAccountId or userId filtering in WHERE clauses
Request parameters must be validated before use; avoid direct parameter usage without type checking
Use generic error messages instead of revealing internal details; throw SafeError instead of exposing user IDs, resource IDs, or system information
API routes should only return necessary fields using select in database queries to prevent unintended information disclosure
Cron endpoints must use hasCronSecret or hasPostCronSecret to validate cron requests and prevent unauthorized access
Request bodies should use Zod schemas for validation to ensure type safety and prevent injection attacks

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
**/app/api/**/*.ts

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

**/app/api/**/*.ts: ALL API routes that handle user data MUST use appropriate middleware: use withEmailAccount for email-scoped operations, use withAuth for user-scoped operations, or use withError with proper validation for public/custom auth endpoints
Use withEmailAccount middleware for operations scoped to a specific email account, including reading/writing emails, rules, schedules, or any operation using emailAccountId
Use withAuth middleware for user-level operations such as user settings, API keys, and referrals that use only userId
Use withError middleware only for public endpoints, custom authentication logic, or cron endpoints. For cron endpoints, MUST use hasCronSecret() or hasPostCronSecret() validation
Cron endpoints without proper authentication can be triggered by anyone. CRITICAL: All cron endpoints MUST validate cron secret using hasCronSecret(request) or hasPostCronSecret(request) and capture unauthorized attempts with captureException()
Always validate request bodies using Zod schemas to ensure type safety and prevent invalid data from reaching database operations
Maintain consistent error response format across all API routes to avoid information disclosure while providing meaningful error feedback

Files:

  • apps/web/app/api/organizations/[organizationId]/stats/route.ts
🧠 Learnings (24)
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Applies to apps/web/app/(app)/*/page.tsx : Create new pages at `apps/web/app/(app)/PAGE_NAME/page.tsx` with components either colocated in the same folder or in `page.tsx`

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
📚 Learning: 2025-11-25T14:38:23.265Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:23.265Z
Learning: Applies to apps/web/app/(app)/*/page.tsx : Create new pages at `apps/web/app/(app)/PAGE_NAME/page.tsx`

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
📚 Learning: 2025-11-25T14:38:23.265Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:23.265Z
Learning: Applies to apps/web/app/(app)/**/*.{ts,tsx} : Components for the page are either put in `page.tsx`, or in the `apps/web/app/(app)/PAGE_NAME` folder

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
📚 Learning: 2025-11-25T14:38:18.874Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:18.874Z
Learning: Applies to apps/web/app/(app)/**/page.tsx : Create new pages at `apps/web/app/(app)/PAGE_NAME/page.tsx`

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
📚 Learning: 2025-11-25T14:38:18.874Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:18.874Z
Learning: Applies to apps/web/app/(app)/**/*.tsx : Components for pages are either put in `page.tsx`, or in the `apps/web/app/(app)/PAGE_NAME` folder

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
  • apps/web/app/(app)/organization/[organizationId]/page.tsx
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Applies to apps/web/components/ui/**/*.tsx : Shadcn UI components are located in `components/ui` directory

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx
📚 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/app/**/*.{ts,tsx} : Follow NextJS app router structure with (app) directory

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
📚 Learning: 2025-11-25T14:38:23.265Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/page-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:23.265Z
Learning: Applies to apps/web/app/(app)/*/page.tsx : Pages are Server components so you can load data into them directly

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Main Next.js application is located in `apps/web`

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Applies to apps/web/app/*/page.tsx : Pages must be Server components that load data directly

Applied to files:

  • apps/web/app/(app)/organization/[organizationId]/stats/page.tsx
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add server-only environment variables to `apps/web/env.ts` under the `server` object with Zod schema validation

Applied to files:

  • apps/web/env.ts
📚 Learning: 2025-11-25T14:36:43.454Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:43.454Z
Learning: Applies to apps/web/env.ts : Define environment variables in `apps/web/env.ts` using Zod schema validation, organizing them into `server` and `client` sections

Applied to files:

  • apps/web/env.ts
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add client-side environment variables to `apps/web/env.ts` under the `client` object with `NEXT_PUBLIC_` prefix and Zod schema validation

Applied to files:

  • apps/web/env.ts
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to apps/web/env.ts : Add client-side environment variables to `apps/web/env.ts` under the `experimental__runtimeEnv` object to enable runtime access

Applied to files:

  • apps/web/env.ts
  • apps/web/.env.example
📚 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/**/{.env.example,env.ts,turbo.json} : Add environment variables to `.env.example`, `env.ts`, and `turbo.json`

Applied to files:

  • apps/web/env.ts
  • apps/web/.env.example
📚 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/env.ts
  • apps/web/utils/llms/config.ts
  • apps/web/utils/llms/model.ts
📚 Learning: 2025-11-25T14:36:43.454Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:43.454Z
Learning: Applies to apps/web/env.ts : For client-side environment variables in `apps/web/env.ts`, prefix them with `NEXT_PUBLIC_` and add them to both the `client` and `experimental__runtimeEnv` sections

Applied to files:

  • apps/web/env.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/env.ts
  • apps/web/utils/llms/model.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/env.ts
  • apps/web/utils/llms/model.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/env.ts
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to .env.example : Add new environment variables to `.env.example` with example values

Applied to files:

  • apps/web/.env.example
📚 Learning: 2025-11-25T14:36:43.454Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:43.454Z
Learning: Applies to .env.example : Add environment variables to `.env.example` with example values in the format `VARIABLE_NAME=value_example`

Applied to files:

  • apps/web/.env.example
📚 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/llms/{index,model}.ts : Core LLM functionality must be defined in `utils/llms/index.ts`, model definitions and configurations in `utils/llms/model.ts`, and usage tracking in `utils/usage.ts`

Applied to files:

  • apps/web/utils/llms/config.ts
  • apps/web/utils/llms/model.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,utils/llms,__tests__}/**/*.ts : 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

Applied to files:

  • apps/web/utils/llms/model.ts
🧬 Code graph analysis (7)
apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1)
apps/web/components/TabSelect.tsx (1)
  • TabSelect (44-103)
apps/web/app/(app)/organization/[organizationId]/stats/page.tsx (3)
apps/web/components/PageWrapper.tsx (1)
  • PageWrapper (3-20)
apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1)
  • OrganizationTabs (12-44)
apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx (1)
  • OrgStats (22-128)
apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx (3)
apps/web/app/api/organizations/[organizationId]/stats/route.ts (1)
  • OrgStatsResponse (14-14)
apps/web/components/DatePickerWithRange.tsx (1)
  • DatePickerWithRange (37-115)
apps/web/components/new-landing/common/Card.tsx (3)
  • Card (67-105)
  • CardHeader (22-54)
  • CardContent (10-12)
apps/web/app/(app)/organization/[organizationId]/page.tsx (2)
apps/web/components/PageWrapper.tsx (1)
  • PageWrapper (3-20)
apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1)
  • OrganizationTabs (12-44)
apps/web/app/(app)/organization/[organizationId]/Members.tsx (2)
apps/web/components/new-landing/icons/Link.tsx (1)
  • Link (1-18)
apps/web/components/InviteMemberModal.tsx (1)
  • InviteMemberModal (34-144)
apps/web/utils/llms/model.ts (2)
apps/web/utils/llms/config.ts (1)
  • Provider (7-17)
apps/web/env.ts (1)
  • env (18-250)
apps/web/app/api/organizations/[organizationId]/stats/route.ts (2)
apps/web/utils/middleware.ts (1)
  • withAuth (378-386)
apps/web/utils/organizations/access.ts (1)
  • fetchAndCheckIsAdmin (60-82)
⏰ 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: cubic · AI code reviewer
  • GitHub Check: Review for correctness
  • GitHub Check: test
🔇 Additional comments (19)
apps/web/app/api/organizations/[organizationId]/stats/route.ts (4)

1-14: LGTM on API setup and type exports.

The route correctly uses withAuth middleware, exports OrgStatsResponse using the Awaited<ReturnType<>> pattern as per guidelines, and validates query params with Zod.


34-56: LGTM on the GET handler.

Correctly uses withAuth with admin validation via fetchAndCheckIsAdmin, validates query params with Zod, and returns NextResponse.json() as expected.


78-128: LGTM on email volume bucketing.

The raw SQL query is properly parameterized using Prisma.sql template literals, preventing SQL injection. The bucketing logic correctly handles BigInt conversion and boundary checks.


235-240: Verify: active_members is not date-filtered.

The active_members count returns all organization members regardless of the fromDate/toDate filters, while total_emails and total_rules are filtered. This may be intentional (showing total org size), but could be confusing if users expect "members active during period."

apps/web/components/InviteMemberModal.tsx (1)

83-85: LGTM on button size change.

The size="sm" change aligns with the new Analytics button styling in Members.tsx, maintaining UI consistency.

apps/web/app/(app)/organization/[organizationId]/Members.tsx (1)

118-129: LGTM on the Analytics button addition.

Clean implementation grouping the Analytics link and InviteMemberModal together. The Link usage with asChild is correct for client-side navigation, and button styling is consistent.

apps/web/app/(app)/organization/[organizationId]/page.tsx (1)

20-27: LGTM on OrganizationTabs integration.

The component properly handles the optional organizationName with optional chaining, and the spacing adjustment improves visual consistency with the new tab layout.

apps/web/app/(app)/organization/[organizationId]/OrganizationTabs.tsx (1)

1-44: LGTM on the new OrganizationTabs component.

Well-structured client component that correctly uses usePathname for tab state derivation. The component location follows the project's page structure conventions (per learnings). The TabSelect integration looks correct based on the relevant code snippets.

apps/web/app/(app)/organization/[organizationId]/stats/page.tsx (1)

6-11: LGTM! Correct Next.js 15 async params pattern.

The function signature and params resolution correctly implement the Next.js 15 pattern for dynamic route parameters as Promises.

apps/web/app/(app)/organization/[organizationId]/stats/OrgStats.tsx (5)

1-20: LGTM! Proper client component setup and imports.

The component correctly uses the "use client" directive and follows best practices for specific imports to minimize bundle size.


22-54: LGTM! Clean state management and data fetching.

The component properly uses React hooks and SWR for data fetching as per coding guidelines. The date range handling and query parameter construction are well-implemented.


56-127: LGTM! Well-structured loading and data presentation.

The component properly uses the LoadingContent wrapper with appropriate skeleton states and follows responsive design patterns. The conditional rendering ensures data exists before accessing nested properties.


130-150: LGTM! Clean presentational component.

The StatCard component follows best practices for functional components and properly uses shadcn/ui Card components.


152-209: LGTM! Robust chart component with good error handling.

The BucketChart component includes proper empty state handling, defensive coding with the maxValue fallback, and clear data visualization. The inline style for dynamic width calculation is appropriate for this use case.

version.txt (1)

1-1: Version bump looks consistent with new features.

v2.21.60 aligns with the added Azure provider and related changes; no issues here.

apps/web/utils/llms/config.ts (1)

15-16: Provider enum and options correctly extended for Azure.

Provider.AZURE and the corresponding "Azure" option integrate cleanly with the existing provider map and conditional Ollama handling; no further changes needed here.

Also applies to: 24-30

apps/web/env.ts (1)

14-16: Env schema correctly extended for Azure provider.

Including "azure" in llmProviderEnum and adding optional AZURE_RESOURCE_NAME / AZURE_API_KEY in the server schema keeps env validation in sync with the new provider and docs.

If you change Azure-related requirements (e.g. making these mandatory when Azure is the default provider), ensure any future validation logic remains consistent across env.ts, .env.example, and the docs.

Also applies to: 62-64

docs/hosting/environment-variables.md (1)

39-49: Environment-variable docs are aligned with Azure support and new LLM options.

The updated provider list (including azure), new economy/chat/backup LLM variables, and the dedicated Azure OpenAI rows accurately reflect the current env.ts schema and .env.example.

Also applies to: 57-59

apps/web/package.json (1)

21-21: Azure AI SDK dependency fits existing provider stack.

Adding @ai-sdk/azure alongside the other @ai-sdk/* providers is coherent with the existing pattern and correctly scoped to apps/web/package.json. The version 2.0.82 aligns with the existing @ai-sdk/* versions in the workspace.

Comment on lines 13 to 16
const organization = await prisma.organization.findUnique({
where: { id: organizationId },
select: { name: true },
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n "useOrganizationMembers" apps/web/ -A 5

Repository: elie222/inbox-zero

Length of output: 1895


🏁 Script executed:

fd -t f "middleware" apps/web/ | head -20

Repository: elie222/inbox-zero

Length of output: 124


🏁 Script executed:

rg -n "Members" apps/web/app/\(app\)/organization/\[organizationId\]/page.tsx -B 5 -A 5

Repository: elie222/inbox-zero

Length of output: 754


🏁 Script executed:

cat -n apps/web/utils/middleware.ts

Repository: elie222/inbox-zero

Length of output: 16885


🏁 Script executed:

fd -t f "members" apps/web/app/api/ | grep organizations

Repository: elie222/inbox-zero

Length of output: 44


🏁 Script executed:

rg -n "api/organizations" apps/web/app/ --type ts --type tsx

Repository: elie222/inbox-zero

Length of output: 89


🏁 Script executed:

fd -t f -p "members" apps/web/app/api

Repository: elie222/inbox-zero

Length of output: 126


🏁 Script executed:

rg -n "organizations.*members" apps/web/app/api/ -l

Repository: elie222/inbox-zero

Length of output: 126


🏁 Script executed:

find apps/web/app/api -type f -name "*members*" -o -path "*organizations*members*"

Repository: elie222/inbox-zero

Length of output: 182


🏁 Script executed:

cat apps/web/utils/organizations/access.ts

Repository: elie222/inbox-zero

Length of output: 1813


🏁 Script executed:

cat -n apps/web/app/api/organizations/[organizationId]/members/route.ts

Repository: elie222/inbox-zero

Length of output: 2456


🏁 Script executed:

find apps/web/app/\(app\) -name "layout.tsx" -o -name "middleware.ts"

Repository: elie222/inbox-zero

Length of output: 91


🏁 Script executed:

cat -n apps/web/app/\(app\)/organization/\[organizationId\]/page.tsx

Repository: elie222/inbox-zero

Length of output: 1093


🏁 Script executed:

rg -n "getServerSession|auth\(\)" apps/web/app/\(app\)/organization/ -A 3

Repository: elie222/inbox-zero

Length of output: 44


🏁 Script executed:

cat -n apps/web/app/\(app\)/layout.tsx

Repository: elie222/inbox-zero

Length of output: 3399


🏁 Script executed:

rg -n "organizationName" apps/web/app/\(app\)/organization/\[organizationId\]/ -B 2 -A 2

Repository: elie222/inbox-zero

Length of output: 2524


🏁 Script executed:

rg -n "organization.*findUnique\|findFirst" apps/web/app/ --type ts --type tsx | head -20

Repository: elie222/inbox-zero

Length of output: 89


Add authorization check before accessing organization data.

The page queries organization data by organizationId from URL params without verifying the current user is a member of that organization. Any authenticated user can access any organization's name by manipulating the URL. Add a membership check (e.g., using fetchAndCheckIsAdmin or a similar member-level validator) before rendering the page, or at minimum before querying the organization data.

🤖 Prompt for AI Agents
In apps/web/app/(app)/organization/[organizationId]/page.tsx around lines 13 to
16, the code queries organization data directly from the URL param without
verifying the current user is a member; add an authorization check before any DB
access by calling the existing membership validator (e.g., fetchAndCheckIsAdmin
or a member-level check) with the request/context and organizationId, handle
failures by throwing a redirect or 403 response, and only after the check
succeeds perform the prisma.organization.findUnique query to fetch the name.

Comment on lines 13 to 16
const organization = await prisma.organization.findUnique({
where: { id: organizationId },
select: { name: true },
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Add authorization check before querying organization data.

This query fetches organization data without verifying the current user has permission to view this organization's statistics. An authorization check is needed to ensure the user is a member or admin of the organization. Additionally, if the organization doesn't exist, organization will be null, which should be handled explicitly rather than passing undefined values to the page render.

Comment on lines 18 to 29
return (
<PageWrapper>
<OrganizationTabs
organizationId={organizationId}
organizationName={organization?.name}
/>

<div className="mt-6">
<OrgStats organizationId={organizationId} />
</div>
</PageWrapper>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle missing organization gracefully.

If the organization doesn't exist, the page still renders but with organizationName as undefined. This creates a poor user experience and may cause display issues.

Consider adding a check and returning a not-found response:

  const organization = await prisma.organization.findUnique({
    where: { id: organizationId },
    select: { name: true },
  });
+
+  if (!organization) {
+    notFound();
+  }

  return (
    <PageWrapper>

You'll need to import notFound from next/navigation:

+import { notFound } from "next/navigation";
 import { PageWrapper } from "@/components/PageWrapper";

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/web/app/(app)/organization/[organizationId]/stats/page.tsx around lines
18-29, the page renders even when the fetched organization is missing, passing
organizationName as undefined; add a null-check after fetching the organization
and call notFound() (imported from next/navigation) when organization is falsy
so the route returns a 404 instead of rendering with undefined props; ensure you
add the import at the top and perform the check before returning the JSX.

import { createGroq } from "@ai-sdk/groq";
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import { createGateway } from "@ai-sdk/gateway";
import { createAzure } from "@ai-sdk/azure";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Azure provider integration follows established patterns.

The createAzure import, Provider.AZURE case, and getProviderApiKey mapping align with how other providers (OpenAI, Google, Groq) are integrated. Defaulting to "gpt-5.1" is consistent with the OpenAI approach.

However, unlike other providers, the Azure configuration relies on two environment variables (AZURE_RESOURCE_NAME and AZURE_API_KEY) rather than a single API key. If AZURE_RESOURCE_NAME is missing or misconfigured, errors occur only at runtime. Consider adding an explicit validation check early in the provider selection logic to fail fast with a clear error message when Azure is selected but AZURE_RESOURCE_NAME is not configured.

🤖 Prompt for AI Agents
In apps/web/utils/llms/model.ts around line 9, when Provider.AZURE is selected
there is no early validation that AZURE_RESOURCE_NAME is set, which leads to
runtime failures; update the provider selection logic to check
process.env.AZURE_RESOURCE_NAME (and optionally AZURE_API_KEY) immediately when
Provider.AZURE is chosen and throw or return a clear, descriptive error if
missing so the app fails fast with guidance to set the environment variable(s).

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)
apps/web/.env.example (1)

88-94: Fix invalid Azure OpenAI model names and naming inconsistency.

Two issues:

  1. The model names "gpt-5.1" and "gpt-5-mini" are invalid—GPT-5 has not been released.
  2. Inconsistent naming: Line 92 uses "gpt-5-mini" while the CLI (line 419 in packages/cli/src/main.ts) uses "gpt-5.1-mini".

Use valid Azure OpenAI model identifiers such as "gpt-4o", "gpt-4o-mini", or other supported models, and ensure consistency between the CLI and .env.example.

This issue is related to the model name problem flagged in packages/cli/src/main.ts line 419.

📜 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 eaa470c and 4b223ac.

📒 Files selected for processing (6)
  • apps/web/.env.example (1 hunks)
  • apps/web/env.ts (2 hunks)
  • apps/web/utils/llms/config.ts (1 hunks)
  • apps/web/utils/llms/model.ts (3 hunks)
  • docs/hosting/environment-variables.md (2 hunks)
  • packages/cli/src/main.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/utils/llms/model.ts
  • apps/web/env.ts
🧰 Additional context used
📓 Path-based instructions (12)
!(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:

  • docs/hosting/environment-variables.md
  • apps/web/.env.example
  • apps/web/utils/llms/config.ts
  • packages/cli/src/main.ts
apps/web/**/{.env.example,env.ts,turbo.json}

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

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

Files:

  • apps/web/.env.example
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/llms/config.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.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/llms/config.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.ts
  • packages/cli/src/main.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/llms/config.ts
  • packages/cli/src/main.ts
🧠 Learnings (7)
📚 Learning: 2025-11-25T14:36:45.807Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/environment-variables.mdc:0-0
Timestamp: 2025-11-25T14:36:45.807Z
Learning: Applies to .env.example : Add new environment variables to `.env.example` with example values

Applied to files:

  • apps/web/.env.example
📚 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/**/{.env.example,env.ts,turbo.json} : Add environment variables to `.env.example`, `env.ts`, and `turbo.json`

Applied to files:

  • apps/web/.env.example
📚 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/llms/config.ts
  • packages/cli/src/main.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:

  • packages/cli/src/main.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:

  • packages/cli/src/main.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:

  • packages/cli/src/main.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:

  • packages/cli/src/main.ts
🧬 Code graph analysis (1)
packages/cli/src/main.ts (1)
apps/web/env.ts (1)
  • env (18-250)
⏰ 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: test
  • GitHub Check: Review for correctness
🔇 Additional comments (5)
packages/cli/src/main.ts (3)

391-391: LGTM!

The Azure OpenAI provider option is correctly added to the LLM provider selection.


472-502: Azure credential handling is well-structured.

The implementation correctly:

  • Prompts users for Azure Base URL and API Key with appropriate placeholders
  • Validates that both fields are required
  • Handles cancellation properly
  • Stores credentials in the correct environment variables

This follows the same pattern as Bedrock credential handling and aligns with the environment variables defined in apps/web/env.ts.


419-419: The Azure OpenAI model identifiers "gpt-5.1" and "gpt-5.1-mini" are valid. Both models are available in the Azure OpenAI catalog as of December 2025. No changes required.

Likely an incorrect or invalid review comment.

docs/hosting/environment-variables.md (2)

39-39: LGTM!

The documentation correctly adds "azure" to the list of supported LLM providers.


57-59: LGTM!

The Azure OpenAI credentials section is well-documented with a clear example URL format and follows the same structure as other provider credential sections.

GROQ: "groq",
OPENROUTER: "openrouter",
AI_GATEWAY: "aigateway",
AZURE: "azure",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's look at the config file to understand the full context
echo "=== Content of config.ts ==="
cat -n apps/web/utils/llms/config.ts | head -50

echo ""
echo "=== Search for providerOptions usage ==="
rg -nP --type=ts --type=tsx -C3 'providerOptions' -g '!node_modules' -g '!.next'

Repository: elie222/inbox-zero

Length of output: 1308


🏁 Script executed:

#!/bin/bash
# Search for providerOptions usage
echo "=== Search for providerOptions usage in TypeScript/React files ==="
rg -nP 'providerOptions' -g '!node_modules' -g '!.next' -C 3

echo ""
echo "=== Search for Azure environment variables or config ==="
rg -nP 'AZURE' -g '!node_modules' -g '!.next' -C 2

echo ""
echo "=== Search for Bedrock in config or usage (to compare pattern) ==="
rg -nP 'BEDROCK|bedrock' -g '!node_modules' -g '!.next' -C 2

Repository: elie222/inbox-zero

Length of output: 29822


Add Azure to the providerOptions array.

Azure is missing from the providerOptions UI dropdown (lines 19-30) despite having full backend support in model.ts (lines 142-151) and being selectable in the CLI. Users cannot currently select Azure as a provider in the web settings UI. Add Azure to providerOptions to match the pattern of other implemented providers like OpenAI, Anthropic, and Google.

🤖 Prompt for AI Agents
In apps/web/utils/llms/config.ts around lines 15–30, the providerOptions array
is missing the Azure entry even though backend support exists; add an Azure
entry to providerOptions following the same shape as the other providers (i.e.,
the same object keys used for OpenAI/Anthropic/Google such as provider
key/value/label and optional icon/meta fields) so "azure" appears in the UI
dropdown and matches backend model selection.

Copy link

Choose a reason for hiding this comment

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

Issue on line in packages/cli/src/main.ts:1:

azure creds collected in runSetup (AZURE_BASE_URL, AZURE_API_KEY) aren’t written to the .env. generateEnvFile only handles bedrock or generic API keys and never sets the Azure vars, so Azure will fail at runtime. Consider adding an azure branch that sets AZURE_BASE_URL and AZURE_API_KEY.

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

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.

2 participants