Conversation
fix: local dev mode for zero backend
…t for improved functionality
fix: use different cookie based on NODE_ENV
…ection ID for improved accuracy
… connection ID for improved accuracy
fix(thread): attachment rendering
…ed clarity and usability
…date queries based on thread ID
…fetching in NotificationProvider
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update introduces a new environment variable and modifies the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Layout
participant NotificationProvider
Client->>Layout: Request mail layout
Layout->>Layout: Extract headers
Layout->>NotificationProvider: Pass headers as props
NotificationProvider-->>Client: Render with notifications
sequenceDiagram
participant Server
participant DurableObject
participant User
Server->>DurableObject: notifyUser({connectionId, threadId, type})
DurableObject->>User: Broadcast message (threadId:type)
User-->>Server: (Optional) Acknowledge receipt
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
apps/mail/app/(full-width)/pricing/page.tsx (1)
347-347: 🛠️ Refactor suggestionVerify the onClick handler on Enterprise contact button
The Enterprise plan's "Contact us" button still has an
onClick={handleUpgrade}handler, but this doesn't seem appropriate since the button already has a direct link to the contact calendar page.<Link href="https://cal.com/team/0/chat" target="_blank"> - <Button className="h-8 w-full" onClick={handleUpgrade}> + <Button className="h-8 w-full"> Contact us </Button> </Link>
🧹 Nitpick comments (2)
apps/server/src/lib/driver/google.ts (1)
1037-1067: Well-structured helper method for attachment extractionThe new
findAttachmentsmethod effectively:
- Recursively traverses message parts to find all attachments
- Properly filters inline attachments with content IDs (which are handled separately)
- Handles nested message structures and RFC822 message attachments
- Simplifies the main code flow in the
getmethodThis is a good example of the Single Responsibility Principle, extracting complex logic into a focused helper method.
However, there are a few potential improvements:
private findAttachments(parts: any[]): any[] { + // Consider adding type definitions instead of using 'any' let results: any[] = []; for (const part of parts) { if (part.filename && part.filename.length > 0) {apps/server/src/main.ts (1)
89-111: Improved notification method with better type safety and loggingThe refactoring of the
notifyUsermethod is well-executed. The changes include:
- Converting to an async function with a properly typed parameter object
- Adding comprehensive logging for better debugging and traceability
- Using
connectionIdinstead of email for deriving the durable object ID- Changing the message format to include thread ID and notification type
- Properly awaiting the broadcast call
However, there is an opportunity to make error handling more robust:
public async notifyUser({ connectionId, threadId, type, }: { connectionId: string; threadId: string; type: 'start' | 'end'; }) { console.log(`Notifying user ${connectionId} for thread ${threadId} with type ${type}`); const durableObject = env.DURABLE_MAILBOX.idFromName(`${connectionId}`); if (env.DURABLE_MAILBOX.get(durableObject)) { const stub = env.DURABLE_MAILBOX.get(durableObject); if (stub) { console.log(`Broadcasting message for thread ${threadId} with type ${type}`); - await stub.broadcast(threadId + ':' + type); + try { + await stub.broadcast(threadId + ':' + type); + console.log(`Successfully broadcasted message for thread ${threadId}`); + } catch (error) { + console.error(`Failed to broadcast message for thread ${threadId}:`, error); + } - console.log(`Successfully broadcasted message for thread ${threadId}`); } else { console.log(`No stub found for connection ${connectionId}`); } } else { console.log(`No durable object found for connection ${connectionId}`); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
.env.example(2 hunks)apps/mail/app/(full-width)/pricing/page.tsx(4 hunks)apps/mail/app/(routes)/mail/layout.tsx(1 hunks)apps/mail/components/mail/mail-display.tsx(2 hunks)apps/mail/components/mail/mail.tsx(2 hunks)apps/mail/components/party.tsx(1 hunks)apps/server/package.json(1 hunks)apps/server/src/lib/auth.ts(3 hunks)apps/server/src/lib/driver/google.ts(2 hunks)apps/server/src/main.ts(1 hunks)apps/server/src/trpc/routes/brain.ts(1 hunks)apps/server/wrangler.jsonc(0 hunks)
💤 Files with no reviewable changes (1)
- apps/server/wrangler.jsonc
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/mail/app/(full-width)/pricing/page.tsx (1)
apps/mail/components/icons/icons.tsx (1)
CircleCheck(145-160)
🔇 Additional comments (21)
.env.example (2)
11-11: Properly formatted environment variable with quotesUsing quotes for string values in environment variables is a good practice for consistency and to avoid issues with special characters.
32-32:Details
✅ Verification successful
New environment variable added for brain limit
This variable defines a default limit for the number of items that can be processed by the brain function, referenced in the
getConnectionLimitfunction in the brain router.
🏁 Script executed:
#!/bin/bash # Check where the DEFAULT_BRAIN_LIMIT is used rg "DEFAULT_BRAIN_LIMIT" --type tsLength of output: 139
DEFAULT_BRAIN_LIMIT Verified and Approved
I’ve confirmed that
DEFAULT_BRAIN_LIMITis referenced inapps/server/src/trpc/routes/brain.tswithin thegetConnectionLimitfunction:
- apps/server/src/trpc/routes/brain.ts:
return limit ? Number(limit) : Number(env.DEFAULT_BRAIN_LIMIT);No further changes needed—this new environment variable is correctly defined and used.
apps/server/src/trpc/routes/brain.ts (1)
66-71: Simplified summary generation by using direct method callThe code has been improved by replacing an external fetch call with a direct method call to
env.zero.getSummary. This change:
- Reduces complexity by eliminating the HTTP request construction
- Updates the return type to match the new data structure with long and short summary fields
- Simplifies error handling by leveraging the existing TRPC infrastructure
This is a good refactoring that will likely improve performance and maintainability.
apps/server/src/lib/driver/google.ts (1)
296-324: Improved attachment handling with dedicated helper methodThe code now uses a dedicated helper method
findAttachmentsto locate all attachment parts before processing them. This is a good refactoring that centralizes the attachment finding logic.apps/mail/app/(routes)/mail/layout.tsx (2)
7-7: Header retrieval activated for notification systemThe code now properly retrieves the current request headers using Next.js'
headers()function, which will be passed to the NotificationProvider.
13-13: NotificationProvider integration completeThe previously commented out NotificationProvider is now active in the layout, with proper header forwarding, which enables the socket-based notification system for mail updates.
apps/mail/components/mail/mail-display.tsx (2)
253-253: Updated summary data structure access pathThe code now correctly accesses the summary data through the nested
data.shortpath, reflecting changes in the underlying API response structure.
270-270: Consistent data structure update for Markdown renderingThis line properly updates the same data structure change as line 253, maintaining consistency in how summary data is accessed throughout the component.
apps/server/src/lib/auth.ts (3)
9-9: Enhanced type imports for authenticationAdded proper type imports for
AccountandBetterAuthOptionsfrom better-auth package for improved type checking and consistency.
208-208: Environment-aware cookie prefix implementationAdded environment-specific cookie prefix handling, which helps prevent cookie conflicts between development and production environments.
324-324: Type assertion for auth configurationAdded type assertion using
satisfies BetterAuthOptionsto ensure the configuration object adheres to the expected type structure, improving type safety and preventing potential configuration errors.apps/mail/components/party.tsx (4)
2-2: Switched from Jotai to React QueryReplaced Jotai atoms with React Query's
useQueryClientand a customuseThreadshook for thread management, providing better integration with the TRPC API layer and more consistent state management.Also applies to: 5-5
9-12: Enhanced state management for thread updatesImplemented React Query for thread state management with the TRPC client and refetch capabilities, providing better integration with the server-side notifications.
15-15: Updated socket room identificationChanged the socket room identifier to use connection ID instead of email with suffix, which aligns with server-side changes in how users are notified of updates.
23-35: Improved notification message handlingImplemented a more robust message handling system that:
- Properly parses message format with threadId and type
- Invalidates specific thread queries when receiving 'end' notifications
- Explicitly refetches threads to ensure UI updates
- Includes logging for better debugging and traceability
This change aligns with server-side notification format updates and ensures proper thread data refreshing.
apps/mail/components/mail/mail.tsx (2)
69-100: Good enhancement to label data structureThe change from a simple array of strings to an array of objects with
nameandusecaseproperties provides more context and clarity for each label. Exporting this constant allows reuse in other components, which improves code modularity.
119-121: Update correctly handles new label structureThe
handleResetToDefaultfunction has been properly updated to work with the new label structure, mapping each label object to extract the name property and construct the appropriate tag object structure.apps/mail/app/(full-width)/pricing/page.tsx (4)
224-227: CSS class ordering improved for consistencyThe reordering of CSS classes follows a consistent pattern, improving code readability and maintainability.
229-229: Consistent styling across all pricing tiersThe plan container CSS classes have been reordered consistently across all three pricing tiers (Free, Pro, and Enterprise), making the code more maintainable.
Also applies to: 275-275, 310-310
240-242: Improved readability of feature limitationsThe feature limitations for free tier are now more consistently formatted, with
<span>elements properly used for the usage limits and appropriate spacing between elements.Also applies to: 248-250, 253-256
270-270: Removed upgrade handler from Free plan buttonThe
onClick={handleUpgrade}handler has been removed from the Free plan's "Get Started" button, which is appropriate since free plan users should simply be directed to sign up rather than going through an upgrade flow.
| "build": "wrangler deploy --minify --dry-run", | ||
| "deploy": "wrangler deploy --minify", | ||
| "types": "wrangler types --e staging" | ||
| "types": "wrangler types --env staging" |
There was a problem hiding this comment.
Fixed incorrect flag in wrangler command
Corrected the flag from --e staging to --env staging in the types script. This ensures the proper environment is specified when generating types.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores