Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR introduces retry infrastructure for Gmail and Outlook API calls to handle transient failures. It adds retry utilities with custom backoff logic across both platforms and applies them consistently to multiple API wrapper functions. Additionally, it includes minor UI and error-logging updates, plus a version bump. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Retry as withRetry<br/>(Gmail/Outlook)
participant pRetry
participant API as Cloud API<br/>(Gmail/Outlook)
Client->>Retry: operation()
Retry->>pRetry: wrap with retry config
loop Retry Loop (max attempts)
pRetry->>API: call API
alt Transient Error
API-->>pRetry: 429/5xx/ServiceNotAvailable
pRetry->>Retry: extract error info
Retry->>Retry: isRetryableError()?
alt Retryable
Retry->>Retry: calculateRetryDelay()
Note over Retry: parse Retry-After header<br/>or apply exponential backoff
Retry->>Retry: sleep(delay)
Note over Retry: retry attempt
else Non-Retryable
Retry->>Retry: log error
Retry-->>Client: throw error
end
else Success
API-->>pRetry: data
pRetry-->>Retry: ✓
Retry-->>Client: return data
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Areas requiring extra attention:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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 (5)
apps/web/utils/ai/choose-rule/draft-management.ts (1)
105-110: Improve type safety and remove redundant optional chaining.The error handling logic uses
(error as any)multiple times and includes redundant optional chaining after theinstanceofcheck. This bypasses TypeScript's type safety and reduces code maintainability.Apply this diff to refactor with better type safety:
- logger.error("Error finding or deleting previous draft", { - error: - (error as any)?.error instanceof Error - ? (error as any)?.error?.message - : error, - }); + const errorToLog = + typeof error === "object" && + error !== null && + "error" in error && + (error as { error: unknown }).error instanceof Error + ? (error as { error: Error }).error.message + : error; + logger.error("Error finding or deleting previous draft", { error: errorToLog });Alternatively, extract this pattern into a utility function if this error structure is common across retry handlers:
function extractErrorMessage(error: unknown): unknown { if ( typeof error === "object" && error !== null && "error" in error && (error as { error: unknown }).error instanceof Error ) { return (error as { error: Error }).error.message; } return error; }As per coding guidelines
apps/web/utils/outlook/retry.test.ts (1)
1-144: LGTM! Comprehensive test coverage for Outlook retry utilities.The test suite thoroughly covers the main retry logic paths including error extraction, retryability detection, and delay calculation. Tests are well-structured and assertions are correct.
Consider adding a test case for the "quota exceeded" message pattern that's also detected in
isRetryableError:+ it("identifies quota exceeded by message pattern", () => { + const errorInfo = { status: 403, errorMessage: "Quota exceeded" }; + const result = isRetryableError(errorInfo); + expect(result.isRateLimit).toBe(true); + expect(result.retryable).toBe(true); + });apps/web/utils/gmail/retry.ts (1)
119-119: Remove duplicate type assertion.Line 119 has a redundant type assertion.
Apply this diff to remove the duplicate:
- )?.error as string as string) ?? + )?.error as string) ??apps/web/utils/outlook/thread.ts (1)
92-160: Consider adding retry wrappers to remaining thread functions.The functions
getThreadsWithNextPageToken(line 116),getThreadsFromSender(line 140), andgetThreadsFromSenderWithSubject(line 167) perform similar Outlook Graph API calls but don't have retry wrappers. For consistency and resilience, consider wrapping their.get()calls withwithOutlookRetry.Based on learnings
apps/web/utils/outlook/message.ts (1)
79-114: Consider adding retry wrapper to folder ID fetching.The
getFolderIdsfunction performs Outlook Graph API calls (line 88-91) to fetch well-known folder IDs but doesn't usewithOutlookRetry. Since this function is called by multiple message-fetching operations and folder ID resolution failures could cascade, consider wrapping the API call with the retry helper.Based on learnings
Apply this pattern:
const response = await client .getClient() .api(`/me/mailFolders/${folderName}`) .select("id") .get();Could become:
- const response = await client - .getClient() - .api(`/me/mailFolders/${folderName}`) - .select("id") - .get(); + const response = await withOutlookRetry(() => + client + .getClient() + .api(`/me/mailFolders/${folderName}`) + .select("id") + .get() + );
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
apps/web/app/(landing)/home/HeroAB.tsx(2 hunks)apps/web/utils/ai/choose-rule/draft-management.ts(1 hunks)apps/web/utils/gmail/attachment.ts(1 hunks)apps/web/utils/gmail/filter.ts(3 hunks)apps/web/utils/gmail/history.ts(2 hunks)apps/web/utils/gmail/label.ts(3 hunks)apps/web/utils/gmail/retry.ts(1 hunks)apps/web/utils/gmail/settings.ts(1 hunks)apps/web/utils/gmail/signature-settings.ts(2 hunks)apps/web/utils/gmail/thread.ts(4 hunks)apps/web/utils/gmail/watch.ts(1 hunks)apps/web/utils/outlook/message.ts(6 hunks)apps/web/utils/outlook/retry.test.ts(1 hunks)apps/web/utils/outlook/retry.ts(1 hunks)apps/web/utils/outlook/thread.ts(3 hunks)version.txt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (20)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use@/for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX
Files:
apps/web/utils/gmail/thread.tsapps/web/app/(landing)/home/HeroAB.tsxapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/utils/gmail/thread.tsapps/web/app/(landing)/home/HeroAB.tsxapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsversion.txtapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
apps/web/utils/gmail/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/gmail-api.mdc)
Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')
Files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/gmail/settings.tsapps/web/utils/gmail/retry.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport Prisma in the project using
import prisma from "@/utils/prisma";
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.
Files:
apps/web/utils/gmail/thread.tsapps/web/app/(landing)/home/HeroAB.tsxapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
apps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logic
Files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
apps/web/utils/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size
Files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...
Files:
apps/web/utils/gmail/thread.tsapps/web/app/(landing)/home/HeroAB.tsxapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
!pages/_document.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.
Files:
apps/web/utils/gmail/thread.tsapps/web/app/(landing)/home/HeroAB.tsxapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsversion.txtapps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/gmail/retry.ts
apps/web/app/**
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
NextJS app router structure with (app) directory
Files:
apps/web/app/(landing)/home/HeroAB.tsx
apps/web/**/*.tsx
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.tsx: Follow tailwindcss patterns with prettier-plugin-tailwindcss
Prefer functional components with hooks
Use shadcn/ui components when available
Ensure responsive design with mobile-first approach
Follow consistent naming conventions (PascalCase for components)
Use LoadingContent component for async data
Useresult?.serverErrorwithtoastErrorandtoastSuccess
UseLoadingContentcomponent to handle loading and error states consistently
Passloading,error, and children props toLoadingContent
Files:
apps/web/app/(landing)/home/HeroAB.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.tsx: Use React Hook Form with Zod for validation
Validate form inputs before submission
Show validation errors inline next to form fields
Files:
apps/web/app/(landing)/home/HeroAB.tsx
apps/web/app/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Components with
onClickmust be client components withuse clientdirective
Files:
apps/web/app/(landing)/home/HeroAB.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{jsx,tsx}: Don't destructure props inside JSX components in Solid projects.
Don't use both children and dangerouslySetInnerHTML props on the same element.
Don't use Array index in keys.
Don't assign to React component props.
Don't define React components inside other components.
Don't use event handlers on non-interactive elements.
Don't assign JSX properties multiple times.
Don't add extra closing tags for components without children.
Use <>...</> instead of ....
Don't insert comments as text nodes.
Don't use the return value of React.render.
Make sure all dependencies are correctly specified in React hooks.
Make sure all React hooks are called from the top level of component functions.
Don't use unnecessary fragments.
Don't pass children as props.
Use semantic elements instead of role attributes in JSX.
Files:
apps/web/app/(landing)/home/HeroAB.tsx
**/*.{html,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{html,jsx,tsx}: Don't use or elements.
Don't use accessKey attribute on any HTML element.
Don't set aria-hidden="true" on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Only use the scope prop on elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assign tabIndex to non-interactive HTML elements.
Don't use positive integers for tabIndex property.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include a title element for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
Assign tabIndex to non-interactive HTML elements with aria-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include a type attribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden with aria-hidden).
Always include a lang attribute on the html element.
Always include a title attribute for iframe elements.
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress.
Accompany onMouseOver/onMouseOut with onFocus/onBlur.
Include caption tracks for audio and video elements.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with ARIA roles.
Use valid ARIA state and property values.
Use valid values for the autocomplete attribute on input eleme...Files:
apps/web/app/(landing)/home/HeroAB.tsx**/*.test.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
Include security tests in your test suites to verify authentication, authorization, and error handling.
Files:
apps/web/utils/outlook/retry.test.ts**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't use export or module.exports in test files.
Don't use focused tests.
Don't use disabled tests.
Make sure the assertion function, like expect, is placed inside an it() function call.
Don't nest describe() blocks too deeply in test files.
Don't use focused tests.
Don't use disabled tests.
Don't use export or module.exports in test files.Files:
apps/web/utils/outlook/retry.test.ts**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Use Vitest (vitest) as the testing framework
Colocate tests next to the file under test (e.g., dir/format.ts with dir/format.test.ts)
In tests, mock theserver-onlymodule withvi.mock("server-only", () => ({}));
When testing code that uses Prisma, mock it withvi.mock("@/utils/prisma")and use the mock from@/utils/__mocks__/prisma
Use provided helpers for mocks: import{ getEmail, getEmailAccount, getRule }from@/__tests__/helpers
Each test should be independent
Use descriptive test names
Mock external dependencies in tests
Clean up mocks between tests (e.g.,vi.clearAllMocks()inbeforeEach)
Avoid testing implementation details; focus on observable behavior
Do not mock the LoggerFiles:
apps/web/utils/outlook/retry.test.tsapps/web/utils/ai/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
apps/web/utils/ai/**/*.{ts,tsx}: Place main LLM feature implementations under apps/web/utils/ai/
LLM feature functions should follow the provided TypeScript pattern (separate system/user prompts, use createGenerateObject, Zod schema validation, early validation, return result.object)
Keep system prompts and user prompts separate
System prompt should define the LLM's role and task specifications
User prompt should contain the actual data and context
Always define a Zod schema for response validation
Make Zod schemas as specific as possible to guide LLM output
Use descriptive scoped loggers for each feature
Log inputs and outputs with appropriate log levels and include relevant context
Implement early returns for invalid inputs
Use proper error types and logging for failures
Implement fallbacks for AI failures
Add retry logic for transient failures using withRetry
Use XML-like tags to structure data in prompts
Remove excessive whitespace and truncate long inputs in prompts
Format prompt data consistently across similar functions
Use TypeScript types for all parameters and return values in LLM features
Define clear interfaces for complex input/output structures in LLM featuresFiles:
apps/web/utils/ai/choose-rule/draft-management.tsapps/web/utils/{ai,llms}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Keep related AI functions co-located and extract common patterns into utilities; document complex AI logic with clear comments
Files:
apps/web/utils/ai/choose-rule/draft-management.ts🧠 Learnings (13)
📓 Common learnings
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-09-17T22:05:28.646Z Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Add retry logic for transient failures using withRetry📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-09-17T22:05:28.646Z Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Add retry logic for transient failures using withRetryApplied to files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/outlook/thread.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/message.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/history.tsapps/web/utils/gmail/watch.tsapps/web/utils/outlook/retry.tsapps/web/utils/gmail/settings.tsapps/web/utils/gmail/retry.ts📚 Learning: 2025-07-18T15:05:34.899Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/gmail-api.mdc:0-0 Timestamp: 2025-07-18T15:05:34.899Z Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')Applied to files:
apps/web/utils/gmail/thread.tsapps/web/utils/gmail/label.tsapps/web/utils/gmail/signature-settings.tsapps/web/utils/gmail/attachment.tsapps/web/utils/gmail/filter.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/watch.tsapps/web/utils/gmail/settings.tsapps/web/utils/gmail/retry.ts📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-09-17T22:05:28.646Z Learning: Applies to apps/web/utils/{ai,llms}/**/*.{ts,tsx} : Keep related AI functions co-located and extract common patterns into utilities; document complex AI logic with clear commentsApplied to files:
apps/web/utils/gmail/label.tsapps/web/utils/outlook/retry.test.tsapps/web/utils/ai/choose-rule/draft-management.ts📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm-test.mdc:0-0 Timestamp: 2025-10-02T23:23:48.064Z Learning: Applies to apps/web/__tests__/**/*.test.ts : Include standard test cases: happy path, error handling, edge cases (empty/null), different user configurations, and various input formatsApplied to files:
apps/web/utils/outlook/retry.test.ts📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm-test.mdc:0-0 Timestamp: 2025-10-02T23:23:48.064Z Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpersApplied to files:
apps/web/utils/outlook/retry.test.tsapps/web/utils/gmail/settings.ts📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-09-17T22:05:28.646Z Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Use proper error types and logging for failuresApplied to files:
apps/web/utils/outlook/retry.test.tsapps/web/utils/ai/choose-rule/draft-management.ts📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm-test.mdc:0-0 Timestamp: 2025-10-02T23:23:48.064Z Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths, including cases where no AI processing is requiredApplied to files:
apps/web/utils/outlook/retry.test.ts📚 Learning: 2025-07-20T09:00:41.968Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/security-audit.mdc:0-0 Timestamp: 2025-07-20T09:00:41.968Z Learning: Applies to apps/web/app/api/**/*.{ts,js} : Review all new withError usage in API routes to ensure custom authentication is implemented where required.Applied to files:
apps/web/utils/outlook/retry.test.ts📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm-test.mdc:0-0 Timestamp: 2025-10-02T23:23:48.064Z Learning: Applies to apps/web/__tests__/**/*.test.ts : Create helper functions for common test data (e.g., getUser, getTestData) to reduce duplicationApplied to files:
apps/web/utils/outlook/retry.test.ts📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm.mdc:0-0 Timestamp: 2025-09-17T22:05:28.646Z Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Implement fallbacks for AI failuresApplied to files:
apps/web/utils/outlook/retry.test.tsapps/web/utils/ai/choose-rule/draft-management.ts📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/llm-test.mdc:0-0 Timestamp: 2025-10-02T23:23:48.064Z Learning: Applies to apps/web/__tests__/**/*.test.ts : Use Vitest in LLM tests and import { describe, expect, test, vi, beforeEach } from "vitest"Applied to files:
apps/web/utils/outlook/retry.test.ts📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR Repo: elie222/inbox-zero PR: 0 File: .cursor/rules/testing.mdc:0-0 Timestamp: 2025-09-20T18:24:34.280Z Learning: Applies to **/*.test.{ts,tsx} : Use provided helpers for mocks: import `{ getEmail, getEmailAccount, getRule }` from `@/__tests__/helpers`Applied to files:
apps/web/utils/gmail/settings.ts🧬 Code graph analysis (12)
apps/web/utils/gmail/thread.ts (2)
apps/web/utils/types.ts (1)
ThreadWithPayloadMessages(43-45)apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/gmail/label.ts (2)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/label.ts (1)
getLabelColor(65-90)apps/web/utils/gmail/signature-settings.ts (1)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/outlook/thread.ts (1)
apps/web/utils/outlook/retry.ts (1)
withOutlookRetry(18-76)apps/web/utils/gmail/attachment.ts (1)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/gmail/filter.ts (1)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/outlook/message.ts (1)
apps/web/utils/outlook/retry.ts (1)
withOutlookRetry(18-76)apps/web/utils/outlook/retry.test.ts (1)
apps/web/utils/outlook/retry.ts (3)
extractErrorInfo(81-107)isRetryableError(112-142)calculateRetryDelay(147-183)apps/web/utils/gmail/history.ts (1)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/utils/gmail/watch.ts (2)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)apps/web/env.ts (1)
env(16-242)apps/web/utils/outlook/retry.ts (1)
apps/web/utils/logger.ts (1)
createScopedLogger(17-80)apps/web/utils/gmail/settings.ts (1)
apps/web/utils/gmail/retry.ts (1)
withGmailRetry(18-72)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🔇 Additional comments (18)
version.txt (1)
1-1: LGTM! Version bump is appropriate.The version increment from v2.18.3 to v2.18.4 aligns with the retry infrastructure additions in this PR.
apps/web/app/(landing)/home/HeroAB.tsx (1)
54-54: LGTM! Animation easing refinement.The change from
ease-in-outtoease-outprovides a more natural fade-in effect for the hero text, starting quickly and decelerating smoothly.Also applies to: 63-63
apps/web/utils/gmail/retry.ts (2)
18-72: LGTM! Well-implemented retry wrapper for Gmail API.The
withGmailRetryfunction provides comprehensive retry logic with proper error classification, custom backoff strategies, and logging. The implementation correctly handles rate limits, server errors, and failed preconditions with appropriate retry delays.Based on learnings: This adds retry logic for transient failures as recommended for API utilities.
155-159: Failed precondition retry handling is appropriate.The addition of retry logic for
failedPreconditionerrors (400 status) is a good enhancement, as Gmail sometimes returns transient precondition failures that resolve on retry. The shorter backoff delays (1s-10s) are appropriate for this error type.apps/web/utils/gmail/thread.ts (4)
16-18: LGTM! Retry logic added to getThread.The Gmail API call is now properly wrapped with
withGmailRetryto handle transient failures.
38-45: LGTM! Retry logic added to getThreads.The Gmail API call is now properly wrapped with
withGmailRetryto handle transient failures.
66-74: LGTM! Retry logic added to getThreadsWithNextPageToken.The Gmail API call is now properly wrapped with
withGmailRetryto handle transient failures.
107-113: LGTM! Retry logic added to getThreadsFromSender.The Gmail API call is now properly wrapped with
withGmailRetryto handle transient failures.apps/web/utils/gmail/history.ts (1)
12-19: LGTM! Retry logic added to getHistory.The Gmail history API call is now properly wrapped with
withGmailRetryto handle transient failures. The implementation is consistent with other Gmail utilities in this PR.apps/web/utils/gmail/signature-settings.ts (1)
22-26: LGTM! Retry logic added to getGmailSignatures.The Gmail sendAs API call is now properly wrapped with
withGmailRetryto handle transient failures. The retry wrapper integrates well with the existing try-catch error handling.apps/web/utils/gmail/attachment.ts (1)
9-15: LGTM! Retry logic added to getGmailAttachment.The Gmail attachment API call is now properly wrapped with
withGmailRetryto handle transient failures. The implementation is consistent with other Gmail utilities in this PR.apps/web/utils/gmail/settings.ts (1)
2-2: LGTM! Retry logic properly applied.The retry wrapper is correctly applied to both Gmail settings API calls without altering their return values or behavior.
Based on learnings
Also applies to: 5-7, 12-16
apps/web/utils/gmail/watch.ts (1)
4-4: LGTM! Retry wrappers applied correctly.Both
watchGmailandunwatchGmailnow have retry capability for transient failures, maintaining the original request payloads and return values.Based on learnings
Also applies to: 7-16, 22-22
apps/web/utils/gmail/filter.ts (1)
4-4: LGTM! Retry logic integrated with existing error handling.The retry wrappers are properly applied to all filter operations while preserving the existing "Filter already exists" error handling in
createFilter.Based on learnings
Also applies to: 15-26, 61-63, 67-69
apps/web/utils/gmail/label.ts (1)
16-16: LGTM! Comprehensive retry coverage for label operations.All Gmail label API calls are now wrapped with retry logic while preserving existing error handling for edge cases like missing labels and label name conflicts.
Based on learnings
Also applies to: 56-65, 125-134, 179-185, 195-207, 226-239, 278-280, 312-314
apps/web/utils/outlook/thread.ts (1)
7-7: LGTM! Retry wrappers applied to core thread operations.The retry logic is properly integrated with existing error handling and in-memory sorting.
Based on learnings
Also applies to: 19-29, 68-73
apps/web/utils/outlook/message.ts (1)
7-7: LGTM! Retry wrappers applied to message operations.All primary message-fetching operations now have retry capability for handling transient failures.
Based on learnings
Also applies to: 278-278, 332-332, 425-425, 450-458, 489-489
apps/web/utils/outlook/retry.ts (1)
1-183: LGTM! Well-structured Outlook retry utility.The retry implementation follows best practices:
- Comprehensive error info extraction from various error shapes
- Proper detection of transient failures (rate limits, server errors)
- Intelligent delay calculation with Retry-After header support
- Exponential backoff for server errors and fixed delay for rate limits
- Detailed logging for observability
The pattern aligns with the established Gmail retry utilities and coding guidelines.
Based on learnings
Summary by CodeRabbit
Bug Fixes
Chores