Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 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. WalkthroughReplaces string-based thread queries with structured fields (after, before, isUnread) across API, validation, hooks, and provider adapters; removes the legacy Google threads controller; refactors cold-email action to use a provider-agnostic EmailProvider; updates UI query propagation and bumps version to v2.10.5. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Web UI
participant API as /api/threads
participant Validation as threadsQuery.parse
participant Core as getThreads
participant Prov as EmailProvider
participant Ext as Email Service
User->>UI: Request threads (after/before/isUnread)
UI->>API: GET /api/threads?after&before&isUnread
API->>Validation: parse(query with after/before/isUnread)
Validation->>Core: getThreads({ after, before, isUnread, ... })
Core->>Prov: getThreadsWithQuery(ThreadsQuery)
alt Provider = Google
Prov->>Prov: build Gmail q from parts (from, after, before, is:unread, -label:INBOX)
Prov->>Ext: Gmail API threads.list(q=...)
else Provider = Microsoft
Prov->>Prov: build OData filter (receivedDateTime gt/lt, isRead eq false)
Prov->>Ext: Graph API messages(filter=...)
end
Ext-->>Prov: threads + nextPageToken
Prov-->>Core: threads result
Core-->>API: { threads, nextPageToken }
API-->>UI: JSON response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
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.
3 issues found across 11 files
Prompt for AI agents (all 3 issues)
Understand the root cause of the following 3 issues and fix them.
<file name="apps/web/hooks/useThreads.ts">
<violation number="1" location="apps/web/hooks/useThreads.ts:26">
Passing query as any to URLSearchParams will include keys with undefined values (e.g., limit=undefined, type=undefined), altering intended nullish handling and weakening type safety. Filter out nullish keys and stringify values before building the query string.</violation>
</file>
<file name="apps/web/app/api/threads/validation.ts">
<violation number="1" location="apps/web/app/api/threads/validation.ts:9">
Empty string (?after=) causes Invalid Date and a 400; preprocess '' to undefined so the filter is ignored instead of failing.</violation>
<violation number="2" location="apps/web/app/api/threads/validation.ts:10">
Empty string (?before=) will fail date coercion; preprocess '' to undefined to skip the filter.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: params | ||
| const url = `/api/threads?${new URLSearchParams(query as any).toString()}`; |
There was a problem hiding this comment.
Passing query as any to URLSearchParams will include keys with undefined values (e.g., limit=undefined, type=undefined), altering intended nullish handling and weakening type safety. Filter out nullish keys and stringify values before building the query string.
Prompt for AI agents
Address the following comment on apps/web/hooks/useThreads.ts at line 26:
<comment>Passing query as any to URLSearchParams will include keys with undefined values (e.g., limit=undefined, type=undefined), altering intended nullish handling and weakening type safety. Filter out nullish keys and stringify values before building the query string.</comment>
<file context>
@@ -15,11 +16,14 @@ export function useThreads({
+ };
+
+ // biome-ignore lint/suspicious/noExplicitAny: params
+ const url = `/api/threads?${new URLSearchParams(query as any).toString()}`;
const { data, isLoading, error, mutate } = useSWR<ThreadsResponse>(url, {
refreshInterval,
</file context>
| nextPageToken: z.string().nullish(), | ||
| labelId: z.string().nullish(), // For Google | ||
| after: z.coerce.date().nullish(), | ||
| before: z.coerce.date().nullish(), |
There was a problem hiding this comment.
Empty string (?before=) will fail date coercion; preprocess '' to undefined to skip the filter.
Prompt for AI agents
Address the following comment on apps/web/app/api/threads/validation.ts at line 10:
<comment>Empty string (?before=) will fail date coercion; preprocess '' to undefined to skip the filter.</comment>
<file context>
@@ -4,8 +4,10 @@ export const threadsQuery = z.object({
nextPageToken: z.string().nullish(),
labelId: z.string().nullish(), // For Google
+ after: z.coerce.date().nullish(),
+ before: z.coerce.date().nullish(),
+ isUnread: z.coerce.boolean().nullish(),
});
</file context>
| q: z.string().nullish(), | ||
| nextPageToken: z.string().nullish(), | ||
| labelId: z.string().nullish(), // For Google | ||
| after: z.coerce.date().nullish(), |
There was a problem hiding this comment.
Empty string (?after=) causes Invalid Date and a 400; preprocess '' to undefined so the filter is ignored instead of failing.
Prompt for AI agents
Address the following comment on apps/web/app/api/threads/validation.ts at line 9:
<comment>Empty string (?after=) causes Invalid Date and a 400; preprocess '' to undefined so the filter is ignored instead of failing.</comment>
<file context>
@@ -4,8 +4,10 @@ export const threadsQuery = z.object({
- q: z.string().nullish(),
nextPageToken: z.string().nullish(),
labelId: z.string().nullish(), // For Google
+ after: z.coerce.date().nullish(),
+ before: z.coerce.date().nullish(),
+ isUnread: z.coerce.boolean().nullish(),
</file context>
Summary by CodeRabbit
New Features
Improvements
Refactor
Chores