Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughThis pull request refactors Ollama model configuration from public client-side to private server-side environment variables, updates the Ollama provider package to ollama-ai-provider-v2 (1.5.5), and adjusts provider validation, configuration, and model selection logic accordingly. The version is bumped to v2.21.59. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/web/utils/llms/model.ts (1)
9-9: Ollama integration wiring is coherent; consider a tiny cleanup
- The new Ollama branch correctly:
- Uses
env.OLLAMA_MODELand fails fast if it’s missing.- Uses
env.OLLAMA_BASE_URLfor the provider.- Disables backup models by setting
backupModel: null, which makes sense for local Ollama.getProviderApiKeyreturning"ollama-local"is a reasonable way to satisfy existing selection logic whenProvider.OLLAMAis enabled.Two optional nits:
- The
if (!provider) throw new Error("Provider.OLLAMA is not defined");check is effectively unreachable given howProvider.OLLAMAis defined; you could drop it to reduce noise.- If you intend to support
ECONOMY_LLM_PROVIDER/CHAT_LLM_PROVIDER="ollama"with different models, note that the current implementation always usesenv.OLLAMA_MODELand ignores theaiModelargument for Ollama; if that’s intentional, it might be worth a brief comment in the Ollama case for future readers.Also applies to: 141-152, 347-347
apps/web/utils/llms/model.test.ts (1)
34-36: Ollama tests correctly exercise env‑driven config; optional mock cleanup
- The new
ollama-ai-provider-v2mock and env mock fields (OLLAMA_BASE_URL,OLLAMA_MODEL) are consistent with the implementation.- The
"should configure Ollama model correctly via env vars"test covers the main happy path (provider, modelName, model existence, andbackupModel === null) and gives good regression coverage for the new wiring.Minor optional cleanup:
- The
vi.mock("./config", ...)addingsupportsOllama: trueis now redundant sincesupportsOllamawas removed fromconfig.ts. You can safely drop that mock to simplify the test setup.Also applies to: 53-58, 63-69, 156-172
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
apps/web/env.ts(1 hunks)apps/web/package.json(1 hunks)apps/web/utils/actions/settings.validation.ts(0 hunks)apps/web/utils/llms/config.ts(1 hunks)apps/web/utils/llms/model.test.ts(3 hunks)apps/web/utils/llms/model.ts(3 hunks)docs/hosting/environment-variables.md(1 hunks)turbo.json(1 hunks)version.txt(1 hunks)
💤 Files with no reviewable changes (1)
- apps/web/utils/actions/settings.validation.ts
🧰 Additional context used
📓 Path-based instructions (20)
**/package.json
📄 CodeRabbit inference engine (.cursor/rules/installing-packages.mdc)
Use
pnpmas 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/webworkspace 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.jsondocs/hosting/environment-variables.mdturbo.jsonapps/web/env.tsversion.txtapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
turbo.json
📄 CodeRabbit inference engine (.cursor/rules/environment-variables.mdc)
Add new environment variables to
turbo.jsonundertasks.build.envas a global dependency for the build task
Files:
turbo.json
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 filesImport specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
Files:
apps/web/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
apps/web/**/{.env.example,env.ts,turbo.json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/env.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor 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 conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()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
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
apps/web/env.ts
📄 CodeRabbit inference engine (.cursor/rules/environment-variables.mdc)
apps/web/env.ts: Add server-only environment variables toapps/web/env.tsunder theserverobject with Zod schema validation
Add client-side environment variables toapps/web/env.tsunder theclientobject withNEXT_PUBLIC_prefix and Zod schema validation
Add client-side environment variables toapps/web/env.tsunder theexperimental__runtimeEnvobject 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,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.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'sselectoption. 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. AllfindUnique/findFirstcalls 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
AllfindManyqueries 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.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.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/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-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 thescopeprop 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 assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
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 atitleelement 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
AssigntabIndexto non-interactive HTML elements witharia-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 atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/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/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.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/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.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, andapps/web/__tests__/for LLM-specific tests
Files:
apps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.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 inutils/llms/model.ts, and usage tracking inutils/usage.ts
Files:
apps/web/utils/llms/model.ts
**/{server,api,actions,utils}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/{server,api,actions,utils}/**/*.ts: UsecreateScopedLoggerfrom "@/utils/logger" for logging in backend code
Add thecreateScopedLoggerinstantiation 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, usecreateScopedLogger().with()to attach context once and reuse the logger without passing variables repeatedly
Files:
apps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Usevitestfor testing the application
Tests should be colocated next to the tested file with.test.tsor.test.tsxextension (e.g.,dir/format.tsanddir/format.test.ts)
Mockserver-onlyusingvi.mock("server-only", () => ({}))
Mock Prisma usingvi.mock("@/utils/prisma")and import the mock from@/utils/__mocks__/prisma
Usevi.clearAllMocks()inbeforeEachto clean up mocks between tests
Each test should be independent
Use descriptive test names
Mock external dependencies in tests
Do not mock the Logger
Avoid testing implementation details
Use test helpersgetEmail,getEmailAccount, andgetRulefrom@/__tests__/helpersfor mocking emails, accounts, and rules
Files:
apps/web/utils/llms/model.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/utils/llms/model.test.ts
🧠 Learnings (26)
📚 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:
docs/hosting/environment-variables.mdturbo.jsonapps/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 : 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:
docs/hosting/environment-variables.mdturbo.jsonapps/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,apps/web/env.ts} : Client-side environment variables must be prefixed with `NEXT_PUBLIC_`
Applied to files:
docs/hosting/environment-variables.mdturbo.jsonapps/web/env.ts
📚 Learning: 2025-11-25T14:36:18.416Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-11-25T14:36:18.416Z
Learning: Applies to apps/web/**/*NEXT_PUBLIC_* : Prefix client-side environment variables with `NEXT_PUBLIC_`
Applied to files:
docs/hosting/environment-variables.mdturbo.jsonapps/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:
docs/hosting/environment-variables.md
📚 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 turbo.json : Add new environment variables to `turbo.json` under `tasks.build.env` as a global dependency for the build task
Applied to files:
turbo.json
📚 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 turbo.json : Add environment variables to `turbo.json` under `tasks.build.env` array to declare build-time dependencies
Applied to files:
turbo.json
📚 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:
turbo.jsonapps/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
📚 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: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/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.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/env.tsapps/web/utils/llms/model.tsapps/web/utils/llms/config.tsapps/web/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Don't hardcode sensitive data like API keys and tokens
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 : Use TypeScript types for all LLM function parameters and return values, and define clear interfaces for complex input/output structures
Applied to files:
apps/web/utils/llms/model.tsapps/web/utils/llms/model.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/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:40:00.833Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-25T14:40:00.833Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : AI tests must be placed in the `__tests__` directory and are not run by default (they use a real LLM)
Applied to files:
apps/web/utils/llms/model.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 : Mock 'server-only' module with empty object in LLM test files: `vi.mock("server-only", () => ({}))`
Applied to files:
apps/web/utils/llms/model.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/utils/llms/model.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,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.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 : Place all LLM-related tests in `apps/web/__tests__/` directory
Applied to files:
apps/web/utils/llms/model.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/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:40:00.833Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-25T14:40:00.833Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `server-only` using `vi.mock("server-only", () => ({}))`
Applied to files:
apps/web/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:40:00.833Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-25T14:40:00.833Z
Learning: Applies to **/*.test.{ts,tsx} : Mock Prisma using `vi.mock("@/utils/prisma")` and import the mock from `@/utils/__mocks__/prisma`
Applied to files:
apps/web/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:40:00.833Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-25T14:40:00.833Z
Learning: Applies to **/*.test.{ts,tsx} : Use `vi.clearAllMocks()` in `beforeEach` to clean up mocks between tests
Applied to files:
apps/web/utils/llms/model.test.ts
📚 Learning: 2025-11-25T14:40:00.833Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-25T14:40:00.833Z
Learning: Applies to **/*.test.{ts,tsx} : Mock external dependencies in tests
Applied to files:
apps/web/utils/llms/model.test.ts
🧬 Code graph analysis (1)
apps/web/utils/llms/model.ts (2)
apps/web/env.ts (1)
env(17-246)apps/web/utils/llms/config.ts (1)
Provider(5-14)
⏰ 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: cubic · AI code reviewer
- GitHub Check: test
- GitHub Check: Review for correctness
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
version.txt (1)
1-1: Version bump is consistent with PR scopeVersion update looks good and matches the Ollama-related changes elsewhere.
turbo.json (1)
45-45: AddingOLLAMA_MODELto build env is correctIncluding
OLLAMA_MODELintasks.build.envkeeps Turbo’s build dependencies in sync with the new server env var. Based on learnings, this is the right place for it.apps/web/utils/llms/config.ts (1)
13-13: Conditional exposure ofProvider.OLLAMAis a good safeguardTying
Provider.OLLAMAtoenv.OLLAMA_MODELkeeps the provider only available when it’s actually configured, which matches the server-only env design.docs/hosting/environment-variables.md (1)
63-67: Docs now correctly reflect server‑side Ollama config and QStash keysSwitching to
OLLAMA_MODELin the Ollama section and documentingQSTASH_NEXT_SIGNING_KEYkeeps this page aligned with the env schema and server-only model config.apps/web/package.json (1)
136-136: Verify Ollama provider package migrationSwitching to
ollama-ai-provider-v2@1.5.5appears consistent with the codebase changes. Ensure:
- No remaining imports from the old
ollama-ai-providerpackage exist- The new package is properly imported where needed (e.g.,
utils/llms/model.ts)apps/web/env.ts (1)
6-15: Env schema for Ollama is consistent with server-only configurationAdding
"ollama"tollmProviderEnumand definingOLLAMA_MODELas a server-only optional string aligns with the new Ollama integration. Verify thatOLLAMA_MODELis also present inapps/web/.env.examplewith a sample value for self-hosters.
| @@ -139,16 +139,17 @@ function selectModel( | |||
| }; | |||
| } | |||
| case Provider.OLLAMA: { | |||
There was a problem hiding this comment.
case Provider.OLLAMA is unreachable when env.OLLAMA_MODEL is unset (since Provider.OLLAMA is then undefined). This makes aiProvider === 'ollama' hit the default with a misleading error. Consider matching the literal 'ollama' (or validate earlier) so the intended OLLAMA_MODEL error is thrown.
| case Provider.OLLAMA: { | |
| case "ollama": { |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
Restore Ollama provider in web app by loading
Provider.OLLAMAfrom server env and selecting models viautils.llms.model.selectModelusingOLLAMA_MODELandOLLAMA_BASE_URLSwitch to
ollama-ai-provider-v2, wireProvider.OLLAMAto server env viaOLLAMA_MODEL, and implement theProvider.OLLAMAbranch inutils.llms.model.selectModelto create the model fromcreateOllama({ baseURL: env.OLLAMA_BASE_URL })(env.OLLAMA_MODEL); update env validation, docs, and Turbo passthrough to useOLLAMA_MODELinstead ofNEXT_PUBLIC_OLLAMA_MODEL.📍Where to Start
Start with the
selectModelimplementation forProvider.OLLAMAin model.ts, then review provider exposure in config.ts and env parsing in env.ts.📊 Macroscope summarized 2941364. 4 files reviewed, 6 issues evaluated, 6 issues filtered, 0 comments posted
🗂️ Filtered Issues
apps/web/env.ts — 0 comments posted, 2 evaluated, 2 filtered
NEXT_PUBLIC_OLLAMA_MODELwas removed fromclientandexperimental__runtimeEnv, while a server-onlyOLLAMA_MODELwas added (line 62). Any client code that previously relied onenv.client.NEXT_PUBLIC_OLLAMA_MODELor the variable being exposed to the browser will now receiveundefinedand may misbehave. If the intent was to move this to server-only, ensure all client usages are removed or replaced. [ Low confidence ]NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITSis defined asz.number().default(5)(line 151) but environment variables are strings, andexperimental__runtimeEnvpasses throughprocess.env.NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITSas a string (line 228). If the variable is set (e.g., "5" or "0"),z.number()will fail validation instead of coercing. Usez.coerce.number()to accept numeric strings or ensure the var is unset to use the default. [ Out of scope ]apps/web/utils/actions/settings.validation.ts — 0 comments posted, 1 evaluated, 1 filtered
saveAiSettingsBodyenum omitsProvider.AI_GATEWAY, while the UI exposes it viaproviderOptions. This ensures any submission withaiProvider: 'aigateway'will fail validation. IncludeProvider.AI_GATEWAYin the enum or remove it from the options to maintain contract parity. [ Out of scope ]apps/web/utils/llms/config.ts — 0 comments posted, 1 evaluated, 1 filtered
Provider.AI_GATEWAYviaproviderOptions, allowing users to select "AI Gateway", but the schemasaveAiSettingsBodyenum does not includeProvider.AI_GATEWAY. This creates a contract mismatch: selecting AI Gateway in the UI will fail Zod validation on submit. Align the enum with the options or remove the option. [ Low confidence ]apps/web/utils/llms/model.ts — 0 comments posted, 2 evaluated, 2 filtered
Provider.OLLAMAswitch case, the guardif (!provider) throw new Error("Provider.OLLAMA is not defined");is ineffective. Whenenv.OLLAMA_MODELis unset,Provider.OLLAMAisundefined, making thecase Provider.OLLAMAlabelundefinedand unreachable for an inputaiProvider === 'ollama'. The code will fall through to the default case and throw a misleading "LLM provider not supported" error instead of the intended "OLLAMA_MODEL environment variable is not set" message. Consider handling the string literal'ollama'explicitly or validating earlier with a clear error. [ Already posted ]BEDROCKcase, the code uses non-null assertionsenv.BEDROCK_ACCESS_KEY!andenv.BEDROCK_SECRET_KEY!, but these env vars are optional. IfselectModelis called withaiProviderset tobedrockwhile the credentials are unset, this yields undefined credentials at runtime, likely causing provider initialization/failures. Add explicit validation and a clear error before constructing the provider. [ Out of scope ]Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.