Skip to content

Comments

Feature/themes customization#1323

Closed
snehendu098 wants to merge 45 commits intoMail-0:stagingfrom
snehendu098:feature/themes-customization
Closed

Feature/themes customization#1323
snehendu098 wants to merge 45 commits intoMail-0:stagingfrom
snehendu098:feature/themes-customization

Conversation

@snehendu098
Copy link
Contributor

@snehendu098 snehendu098 commented Jun 17, 2025

Description

Created the ability for users to create new themes and apply their created themes in the application


Type of Change

Please delete options that are not relevant.

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature with breaking changes)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • 🔒 Security enhancement
  • ⚡ Performance improvement

Areas Affected

Please check all that apply:

  • Email Integration (Gmail, IMAP, etc.)
  • User Interface/Experience
  • Authentication/Authorization
  • Data Storage/Management
  • API Endpoints
  • Documentation
  • Testing Infrastructure
  • Development Workflow
  • Deployment/Infrastructure

Testing Done

Describe the tests you've done:

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • Cross-browser testing (if UI changes)
  • Mobile responsiveness verified (if UI changes)

Security Considerations

For changes involving data or authentication:

  • No sensitive data is exposed
  • Authentication checks are in place
  • Input validation is implemented
  • Rate limiting is considered (if applicable)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • I have updated the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix/feature works
  • All tests pass locally
  • Any dependent changes are merged and published

Screenshots/Recordings

Screencast_from_2025-06-03_00-47-47.mp4

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive theming system enabling users to create, customize, save, and apply light and dark UI themes with live preview and marketplace browsing.
    • Added a settings page for managing and selecting themes, supporting default and user-created themes.
    • Enabled theme sharing via public/private toggling and copying of public themes.
    • Added a color picker, slider, and enhanced theme preview tools for customization.
  • UI Improvements

    • Refined color schemes and background styles for improved consistency and visual clarity across mail components.
    • Updated navigation and button interactions for smoother, more intuitive user experience.
  • Bug Fixes

    • Corrected theme application in mail iframes to ensure proper text and background color rendering.
  • Chores

    • Updated dependencies to support new theming features.
    • Improved environment and ignore files for better development workflow.
  • Database

    • Added a new database table to store user and public themes, supporting all theme operations.
  • Documentation

    • Expanded type definitions and validation schemas to support theme management.
  • Refactor

    • Replaced third-party theme provider with a custom context for more flexible theme handling.
    • Simplified settings and navigation logic for maintainability.

snehendu098 and others added 30 commits May 26, 2025 12:24
## Description

Improved error handling in the ZeroAgent class by providing more specific error messages when authentication fails. The changes include:

1. Enhanced the error message in the execute method to specify whether the failure is due to missing driver or connectionId
2. Improved the error message in onConnect method to clarify when a token is missing
3. Removed redundant driver check in onChatMessage method as this validation is already handled elsewhere
4. Cleaned up imports by removing unused WSMessage type

## Type of Change

- [x] 🐛 Bug fix (non-breaking change which fixes an issue)
- [x] 🔒 Security enhancement

## Areas Affected

- [x] Authentication/Authorization
- [x] API Endpoints

## Testing Done

- [x] Manual testing performed

## Security Considerations

- [x] Authentication checks are in place

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings

_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
done:
- adds new hook `useOptimisticAction`
	- in mail-lsit
	- in thread-display
- adds undo action to toast (design needs updating)

wip:
- undo sent email within 10-20 seconds
- update toast design/undo button
- add shortcut to undo 😎
- safari causing slight issues but it works
# READ CAREFULLY THEN REMOVE

Remove bullet points that are not relevant.

PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.

- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.

## Description

Please provide a clear description of your changes.

---

## Type of Change

Please delete options that are not relevant.

- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement

## Areas Affected

Please check all that apply:

- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure

## Testing Done

Describe the tests you've done:

- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)

## Security Considerations

For changes involving data or authentication:

- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)

## Checklist

- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published

## Additional Notes

Add any other context about the pull request here.

## Screenshots/Recordings

Add screenshots or recordings here if applicable.

---

_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
# Improve Thread Context Menu and Optimistic Updates

This PR refactors the thread context menu and optimistic state handling in the mail application to fix several issues:

1. Simplifies the `ThreadContextMenu` component by removing the redundant `emailId` prop and only using `threadId`
2. Adds support for optimistic marking as unread in the thread context menu
3. Improves the optimistic state handling in the mail list by:
   - Using a consistent thread ID across components
   - Properly displaying optimistic read/unread state
   - Fixing star toggling functionality
4. Enhances the optimistic actions system to invalidate specific queries rather than refetching everything

## Type of Change

- [x] 🐛 Bug fix (non-breaking change which fixes an issue)
- [x] ⚡ Performance improvement

## Areas Affected

- [x] User Interface/Experience
- [x] Data Storage/Management

## Testing Done

- [x] Manual testing performed

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings

_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
# READ CAREFULLY THEN REMOVE

Remove bullet points that are not relevant.

PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.

- Pull requests that do not follow these guidelines will be closed without review or comment.
- If you use AI to write your PR description your pr will be close without review or comment.
- If you are unsure about anything, feel free to ask for clarification.

## Description

Please provide a clear description of your changes.

---

## Type of Change

Please delete options that are not relevant.

- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature with breaking changes)
- [ ] 📝 Documentation update
- [ ] 🎨 UI/UX improvement
- [ ] 🔒 Security enhancement
- [ ] ⚡ Performance improvement

## Areas Affected

Please check all that apply:

- [ ] Email Integration (Gmail, IMAP, etc.)
- [ ] User Interface/Experience
- [ ] Authentication/Authorization
- [ ] Data Storage/Management
- [ ] API Endpoints
- [ ] Documentation
- [ ] Testing Infrastructure
- [ ] Development Workflow
- [ ] Deployment/Infrastructure

## Testing Done

Describe the tests you've done:

- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] Cross-browser testing (if UI changes)
- [ ] Mobile responsiveness verified (if UI changes)

## Security Considerations

For changes involving data or authentication:

- [ ] No sensitive data is exposed
- [ ] Authentication checks are in place
- [ ] Input validation is implemented
- [ ] Rate limiting is considered (if applicable)

## Checklist

- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] Any dependent changes are merged and published

## Additional Notes

Add any other context about the pull request here.

## Screenshots/Recordings

Add screenshots or recordings here if applicable.

---

_By submitting this pull request, I confirm that my contribution is made under the terms of the project's license._
## Description

Added support for optimistic toggling of "Important" flag in emails. This enhancement allows users to mark emails as important with immediate UI feedback while the action processes in the background. The implementation follows the same pattern as other optimistic actions like starring and marking as read.

Also fixed a few UI issues including removing extra whitespace in the AI chat component and removing debug mode from the Party provider.

## Type of Change

- [x] ✨ New feature (non-breaking change which adds functionality)
- [x] 🐛 Bug fix (non-breaking change which fixes an issue)
- [x] 🎨 UI/UX improvement

## Areas Affected

- [x] User Interface/Experience
- [x] Email Integration (Gmail, IMAP, etc.)

## Testing Done

- [x] Manual testing performed

## Checklist

- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] My code follows the project's style guidelines

## Additional Notes

The implementation includes:
1. Adding the Important button to the thread list UI
2. Supporting optimistic state updates for the Important flag
3. Fixing the ZeroAgent to use user ID instead of email for better identification
4. Removing debug mode from Party provider to reduce console noise
### TL;DR

Improved mail list hotkey functionality by adding a `shouldUseHover` flag to determine when to use hover actions versus bulk selection actions.

### What changed?

- Added a `shouldUseHover` flag that checks if bulk selection is empty
- Updated hotkey handlers (markAsRead, markAsUnread, archiveEmail) to use this flag when determining whether to act on hovered email or selected emails
- Removed unused imports and functions:
  - Removed `useQueryClient`, `useTRPC`, `useStats` imports
  - Removed `refetch`, `mutateStats`, `invalidateCount` functions
  - Removed a console.log statement in the selectAll function
- Updated dependency arrays in useCallback hooks to include the new `shouldUseHover` flag

### How to test?

1. Test mail list hotkeys with no emails selected:
   - Hover over an email and use keyboard shortcuts to mark as read/unread or archive
   - Verify actions apply only to the hovered email

2. Test mail list hotkeys with emails selected:
   - Select multiple emails and use keyboard shortcuts
   - Verify actions apply to all selected emails regardless of hover state

### Why make this change?

This change improves the user experience by making the hotkey behavior more predictable and intuitive. When users have explicitly selected emails, actions should apply to those selections. When no emails are selected, actions should apply to the currently hovered email. This creates a more consistent interaction model and prevents accidental operations on unintended emails.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

"""

Walkthrough

This update introduces a comprehensive theming system for the mail application. It adds database schema, server-side logic, and TRPC endpoints for user and public themes, as well as client-side context, hooks, utilities, and UI for theme creation, selection, and management. Numerous styling and background color variables are refactored for dynamic theming.

Changes

File(s) / Group Change Summary
.env.example Added ELEVENLABS_API_KEY variable.
.gitignore Added /update-check to ignore list; added trailing newline.
apps/mail/app/(routes)/settings/appearance/page.tsx Replaced manual appearance settings page with ThemesPage component.
apps/mail/app/globals.css Renamed CSS variables, fixed dark background value, reformatted gradients and comments.
apps/mail/components/context/theme-context.tsx Added theme context/provider and hook for theme state management.
apps/mail/components/magicui/file-tree.tsx Updated folder container hover background class.
apps/mail/components/mail/mail-display.tsx Restyled label icons and backgrounds; minor formatting fixes.
apps/mail/components/mail/mail-iframe.tsx Added explicit text color styling for iframe body based on theme.
apps/mail/components/mail/mail.tsx, apps/mail/components/mail/thread-display.tsx Adjusted mutation calls, UI styling, and color classes for consistency and theming.
apps/mail/components/theme/theme-customizer.tsx (new) Added theme creator UI for building custom themes with live preview.
apps/mail/components/theme/theme-switcher.tsx (deleted) Removed old theme switcher component.
apps/mail/components/theme/theme-view.tsx (new) Added ThemesPage for theme selection, browsing, and creation dialog.
apps/mail/components/ui/nav-main.tsx Updated hover and active background colors for navigation buttons.
apps/mail/components/ui/settings-content.tsx Updated root container background class to use bg-sidebar.
apps/mail/components/ui/slider.tsx (new) Added Radix UI-based slider component for UI controls.
apps/mail/hooks/use-themes.ts (new) Added hooks for querying and mutating theme data with React Query and TRPC.
apps/mail/lib/hotkeys/mail-list-hotkeys.tsx Fixed destructuring bug in threads hook; renamed variable (potential new bug).
apps/mail/lib/themes/index.tsx (new) Added default light and dark theme definitions.
apps/mail/lib/themes/theme-utils.ts (new) Added utilities for parsing, generating, and converting theme colors and CSS.
apps/mail/package.json Added dependencies: @radix-ui/react-slider, @tabler/icons-react, @tanstack/react-table, react-color, and types.
apps/mail/providers/client-providers.tsx Switched from next-themes to custom ThemeContextProvider.
apps/mail/tailwind.config.ts Updated color definitions to use CSS variables for dynamic theming.
apps/mail/types/index.ts Added types/interfaces for theme names, variants, colors, and theme data.
apps/server/src/db/migrations/0028_soft_blazing_skull.sql Added migration: created mail0_theme table for theme storage.
apps/server/src/db/migrations/meta/0028_snapshot.json Reformatted arrays in migration snapshot for compactness.
apps/server/src/db/migrations/meta/_journal.json Added new migration entry for theme table.
apps/server/src/db/schema.ts Added theme table schema with fields and relations.
apps/server/src/lib/schemas.ts Added Zod schemas/types for theme validation and structure.
apps/server/src/lib/theme-manager.ts (new) Added ThemeManager class for theme CRUD and query logic.
apps/server/src/trpc/index.ts Added themesRouter to TRPC app router; commented out voiceRouter.
apps/server/src/trpc/routes/themes.ts (new) Added TRPC router for theme operations (CRUD, public, marketplace, copy, toggle).
apps/server/src/main.ts Added theme-related DB methods and RPC handlers for theme CRUD and queries.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (ThemesPage/ThemeCreator)
    participant ThemeContext
    participant Theme Hooks
    participant TRPC ThemesRouter
    participant DB (ThemeManager)

    User->>UI (ThemesPage): Selects or creates a theme
    UI (ThemesPage)->>Theme Hooks: Fetches user/public themes
    Theme Hooks->>TRPC ThemesRouter: list/marketplace/getPublic
    TRPC ThemesRouter->>DB (ThemeManager): Query themes
    DB (ThemeManager)-->>TRPC ThemesRouter: Return theme data
    TRPC ThemesRouter-->>Theme Hooks: Return theme data
    Theme Hooks-->>UI (ThemesPage): Provide themes

    User->>UI (ThemeCreator): Customizes and saves a theme
    UI (ThemeCreator)->>Theme Hooks: createTheme/updateTheme
    Theme Hooks->>TRPC ThemesRouter: create/update
    TRPC ThemesRouter->>DB (ThemeManager): Insert/update theme
    DB (ThemeManager)-->>TRPC ThemesRouter: Confirm operation
    TRPC ThemesRouter-->>Theme Hooks: Success/failure
    Theme Hooks-->>UI (ThemeCreator): Show toast/result

    User->>UI (ThemesPage): Applies a theme
    UI (ThemesPage)->>ThemeContext: applyTheme/revertToDefault
    ThemeContext->>DOM: Injects CSS, toggles dark mode
Loading

Suggested reviewers

  • MrgSub

Poem

A bunny with a brush and a CSS dream
Painted the mail app with themes so supreme.
Light and dark, and hues in between,
New tables and routers keep everything clean.
Now users can style, preview, and share—
Custom mail themes hop everywhere!
🐇🎨✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1712ede and 40576c6.

📒 Files selected for processing (1)
  • apps/server/src/main.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/server/src/main.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 18

🔭 Outside diff range comments (6)
apps/mail/lib/hotkeys/mail-list-hotkeys.tsx (1)

102-109: idsToMark is now undefined – breaks ‘mark as important’

You renamed the local variable to idsToArchive but the mutator still references the old name. This throws at runtime.

-    const idsToArchive = mail.bulkSelected;
-    if (idsToArchive.length === 0) {
+    const idsToMark = mail.bulkSelected;
+    if (idsToMark.length === 0) {
       toast.info(t('common.mail.noEmailsToSelect'));
       return;
     }
 
-    optimisticToggleImportant(idsToMark, true);
+    optimisticToggleImportant(idsToMark, true);

(Alternatively keep the new variable name and change the call site – just make them consistent.)

Add a quick unit test for this handler; it’s easy to miss in manual QA.

apps/server/src/db/migrations/meta/_journal.json (1)

202-214: Duplicate migration index (idx = 28) will break migration ordering

Two entries share idx: 28 (0028_worried_molecule_man and 0028_soft_blazing_skull).
Most migration runners expect a strictly monotonic index and will either abort or apply in undefined order.

Increment the second entry to 29 (and subsequent snapshots/scripts) or re-sequence the file.

apps/mail/providers/client-providers.tsx (1)

9-15: Remove leftover ThemeProvider import & unused theme variable

ThemeProvider is no longer rendered but is still imported; likewise the computed theme value is never used. Most TS/ESLint configs will fail with no-unused-vars / no-unused-imports, breaking the build.

-import { ThemeProvider } from 'next-themes';
 ...
-  const theme = data?.settings.colorTheme || 'system';

If you still need the raw colorTheme elsewhere, keep the variable and pass it to the custom provider; otherwise delete both lines.

apps/mail/components/mail/thread-display.tsx (1)

719-737: Hard-coded hex colours bypass new theme system

The container now uses bg-[#ffffff] / dark:bg-[#1a1a1a] and several child nodes use explicit hex text colours.
These override the CSS variables injected by ThemeContextProvider, meaning custom themes won’t affect this view.

Replace with semantic classes (bg-background, bg-card, text-muted-foreground, etc.) or CSS vars:

- '… rounded-xl bg-[#ffffff] transition-all duration-300 dark:bg-[#1a1a1a]',
+ '… rounded-xl bg-background transition-all duration-300 dark:bg-background',

Same for the dark:text-[#959595] literals below.

Failing to align with the new token system undermines the very feature this PR adds.

apps/mail/app/(routes)/settings/appearance/page.tsx (2)

2-12: Remove unused imports to avoid dead code & bundle bloat

All imported symbols here are no longer referenced after the refactor. They will trigger linter errors and inflate the bundle size.

-import { useMutation, useQuery } from '@tanstack/react-query';
-import ThemesPage from '@/components/theme/theme-view';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { useTRPC } from '@/providers/query-provider';
-import { useSettings } from '@/hooks/use-settings';
-import { useTranslations } from 'use-intl';
-import { useForm } from 'react-hook-form';
-import { useTheme } from 'next-themes';
-import { useState } from 'react';
-import { toast } from 'sonner';
-import * as z from 'zod';
+import { useTranslations } from 'use-intl';
+import ThemesPage from '@/components/theme/theme-view';

14-18: Delete leftover form schema / type definitions

formSchema and the Theme alias are now unused. Keeping them around confuses future readers.

-const formSchema = z.object({
-  colorTheme: z.enum(['dark', 'light', 'system', '']),
-});
-
-type Theme = 'dark' | 'light' | 'system';
🧹 Nitpick comments (14)
.gitignore (2)

61-61: Confirm /update-check ignore pattern.

Ensure that /update-check is indeed a generated artifact from your devcontainer or build process and not a directory users need to commit. Consider adding a comment above this entry to clarify its origin and purpose.


63-63: Validate ignoring tools.json.

Verify that tools.json is always auto-generated and not part of necessary configuration (e.g., workspace or CI settings). If it’s intentionally ephemeral, this entry is appropriate; otherwise document or remove it.

.env.example (1)

36-37: Keep env keys ordered and ensure trailing newline

Linters flag ELEVENLABS_API_KEY because:

  1. Keys are expected to stay alphabetically grouped (it should sit above TWILIO_ACCOUNT_SID).
  2. The file is missing a terminating blank line.
-TWILIO_PHONE_NUMBER=
-ELEVENLABS_API_KEY=
+ELEVENLABS_API_KEY=
+TWILIO_PHONE_NUMBER=
+
apps/mail/components/mail/mail-iframe.tsx (1)

95-99: No-op blank line – consider removing to avoid noisy diffs

The additional blank line adds churn without functional gain. Trimming it keeps history cleaner.

apps/mail/components/magicui/file-tree.tsx (1)

234-235: Class string no longer needs a template literal

Since there’s no interpolation, the back-ticked string could be a plain string, or you could inline into cn directly. Not critical but removes unnecessary template overhead.

-          `hover:bg-accent/50 flex items-center gap-1 rounded-lg px-2 py-1.5 text-sm`,
+          'hover:bg-accent/50 flex items-center gap-1 rounded-lg px-2 py-1.5 text-sm',
apps/mail/components/ui/slider.tsx (1)

12-25: Vertical orientation styles missing

@radix-ui/react-slider exposes data-orientation="vertical" when orientation="vertical".
Without explicit height / width tweaks, the track & thumb look broken in vertical mode.

- <SliderPrimitive.Track className="relative h-1.5 w-full …">
+ <SliderPrimitive.Track className="relative data-[orientation=horizontal]:h-1.5
+                                   data-[orientation=horizontal]:w-full
+                                   data-[orientation=vertical]:h-full
+                                   data-[orientation=vertical]:w-1.5
+                                   …">

Same goes for Thumb transform offsets.
Fine if your app never uses vertical sliders, but worth guarding for future reuse.

apps/mail/hooks/use-themes.ts (1)

1-246: Well-implemented theme hooks with proper React Query patterns.

The hooks are well-structured with appropriate cache invalidation, error handling, and TypeScript typing. The infinite query pattern for marketplace themes is correctly implemented.

Consider using more explicit boolean checks instead of double negation for clarity:

-          enabled: !!session?.user.id,
+          enabled: session?.user.id !== undefined,
-          enabled: !!themeId && !!session?.user.id,
+          enabled: themeId !== undefined && session?.user.id !== undefined,
-          enabled: !!themeId,
+          enabled: themeId !== undefined && themeId !== null,
apps/server/src/lib/schemas.ts (1)

75-107: Validate color strings more strictly

themeColorsSchema currently accepts any string for each color value. Allowing arbitrary strings will make it easy for malformed values (e.g. "rgb( )" or "foo") to slip through, break CSS, and crash the customiser.
Consider constraining each entry with a basic regexp such as /^\d+(\.\d+)? \d+% \d+%$/ (or a dedicated helper) so only valid H S L tokens are persisted.

apps/mail/types/index.ts (1)

163-168: Missing semicolon & lint violation

A semicolon after css: string keeps the style consistent with the rest of the file and avoids lint noise.

-  css: string
+  css: string;
apps/mail/components/theme/theme-customizer.tsx (2)

261-313: NodeJS.Timeout type leaks Node typings into the browser

The closure typed as NodeJS.Timeout pulls in the Node DOM-shim and may break builds configured with dom only libs.
Use ReturnType<typeof setTimeout> (or simply number) instead.


389-400: Event listener leak

handleClickOutside is registered on document but never removed on component unmount.
Wrap the cleanup in the returned function of useEffect:

useEffect(() => {
  const handleClickOutside = (event: MouseEvent) => { … };
  document.addEventListener('mousedown', handleClickOutside);
  return () => {
    document.removeEventListener('mousedown', handleClickOutside);
  };
}, []);
apps/server/src/lib/theme-manager.ts (1)

86-92: Redundant equality checks slow public-theme search

Inside the searchQuery branch you already use like() for partial matches; the two eq() clauses on the same fields add no value and force the planner to evaluate extra OR predicates.

-              eq(theme.name, searchQuery),
-              eq(theme.description, searchQuery),
               like(theme.name, `%${searchQuery}%`),
               like(theme.description, `%${searchQuery}%`),

Removing the eq terms simplifies the SQL without changing behaviour.

apps/mail/components/context/theme-context.tsx (1)

147-191: Left-over console logs will pollute production console

All console.log/console.warn statements inside applyTheme, revertToDefault, etc. should be removed or gated behind process.env.NODE_ENV !== 'production' checks.

apps/mail/lib/themes/theme-utils.ts (1)

373-391: Remove or export unused invertColor function.

The invertColor function is defined but never used in this file. Either remove it or export it if it's intended for use elsewhere.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31229e8 and 3dab6cb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (33)
  • .env.example (1 hunks)
  • .gitignore (1 hunks)
  • apps/mail/app/(routes)/settings/appearance/page.tsx (2 hunks)
  • apps/mail/app/globals.css (12 hunks)
  • apps/mail/app/routes.ts (1 hunks)
  • apps/mail/components/context/theme-context.tsx (1 hunks)
  • apps/mail/components/magicui/file-tree.tsx (1 hunks)
  • apps/mail/components/mail/mail-display.tsx (3 hunks)
  • apps/mail/components/mail/mail-iframe.tsx (2 hunks)
  • apps/mail/components/mail/mail.tsx (6 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
  • apps/mail/components/theme/theme-customizer.tsx (1 hunks)
  • apps/mail/components/theme/theme-switcher.tsx (0 hunks)
  • apps/mail/components/theme/theme-view.tsx (1 hunks)
  • apps/mail/components/ui/nav-main.tsx (2 hunks)
  • apps/mail/components/ui/settings-content.tsx (1 hunks)
  • apps/mail/components/ui/slider.tsx (1 hunks)
  • apps/mail/hooks/use-themes.ts (1 hunks)
  • apps/mail/lib/hotkeys/mail-list-hotkeys.tsx (2 hunks)
  • apps/mail/lib/themes/index.tsx (1 hunks)
  • apps/mail/lib/themes/theme-utils.ts (1 hunks)
  • apps/mail/package.json (3 hunks)
  • apps/mail/providers/client-providers.tsx (2 hunks)
  • apps/mail/tailwind.config.ts (2 hunks)
  • apps/mail/types/index.ts (1 hunks)
  • apps/server/src/db/migrations/0028_soft_blazing_skull.sql (1 hunks)
  • apps/server/src/db/migrations/meta/0028_snapshot.json (13 hunks)
  • apps/server/src/db/migrations/meta/_journal.json (1 hunks)
  • apps/server/src/db/schema.ts (2 hunks)
  • apps/server/src/lib/schemas.ts (2 hunks)
  • apps/server/src/lib/theme-manager.ts (1 hunks)
  • apps/server/src/trpc/index.ts (2 hunks)
  • apps/server/src/trpc/routes/themes.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/mail/components/theme/theme-switcher.tsx
🧰 Additional context used
🧬 Code Graph Analysis (9)
apps/server/src/trpc/index.ts (1)
apps/server/src/trpc/routes/themes.ts (1)
  • themesRouter (18-181)
apps/mail/lib/hotkeys/mail-list-hotkeys.tsx (1)
apps/mail/hooks/use-threads.ts (1)
  • useThreads (12-59)
apps/mail/app/(routes)/settings/appearance/page.tsx (1)
apps/mail/components/theme/theme-view.tsx (1)
  • ThemesPage (54-440)
apps/mail/components/ui/slider.tsx (1)
apps/mail/lib/utils.ts (1)
  • cn (51-51)
apps/mail/types/index.ts (1)
apps/server/src/lib/schemas.ts (1)
  • ThemeData (125-125)
apps/server/src/lib/schemas.ts (1)
apps/mail/types/index.ts (1)
  • ThemeData (170-179)
apps/server/src/lib/theme-manager.ts (4)
apps/server/src/db/index.ts (1)
  • DB (11-11)
apps/server/src/lib/schemas.ts (4)
  • Theme (3-13)
  • ThemeData (125-125)
  • CreateTheme (126-126)
  • UpdateTheme (127-127)
apps/server/src/db/schema.ts (1)
  • theme (177-189)
apps/mail/types/index.ts (1)
  • ThemeData (170-179)
apps/mail/components/mail/mail-display.tsx (1)
apps/mail/components/icons/icons.tsx (2)
  • Lightning (774-789)
  • Users (510-540)
apps/mail/lib/themes/theme-utils.ts (4)
apps/mail/types/index.ts (4)
  • ThemeColors (145-161)
  • ApiThemeResponse (163-168)
  • ThemeData (170-179)
  • CustomTheme (181-191)
apps/mail/components/theme/theme-customizer.tsx (1)
  • hslToHex (123-182)
apps/server/src/lib/schemas.ts (3)
  • ThemeColorSchema (128-128)
  • ThemeData (125-125)
  • Theme (3-13)
apps/server/src/db/schema.ts (1)
  • theme (177-189)
🪛 dotenv-linter (3.3.0)
.env.example

[warning] 37-37: [EndingBlankLine] No blank line at the end of the file


[warning] 37-37: [UnorderedKey] The ELEVENLABS_API_KEY key should go before the TWILIO_ACCOUNT_SID key

🪛 Biome (1.9.4)
apps/mail/lib/hotkeys/mail-list-hotkeys.tsx

[error] 18-18: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)

apps/mail/components/theme/theme-view.tsx

[error] 233-359: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

apps/mail/lib/themes/theme-utils.ts

[error] 132-132: background is assigned to itself.

This is where is assigned.

(lint/correctness/noSelfAssign)


[error] 303-303: background is assigned to itself.

This is where is assigned.

(lint/correctness/noSelfAssign)

🔇 Additional comments (19)
apps/mail/app/routes.ts (1)

51-53: Commented-out route may orphan the create-theme page

/settings/appearance/create is now unreachable yet its page component still exists. If the new theming UX no longer needs a dedicated route, delete the file (and related imports) to avoid dead code; otherwise re-enable the route.

apps/mail/components/ui/settings-content.tsx (1)

7-7: Background class update looks good

Switching to the bg-sidebar token keeps the component in sync with the new CSS-variable driven theming system. No issues spotted.

apps/server/src/trpc/index.ts (1)

7-11: Router wiring OK – double-check voice route deactivation

themesRouter is correctly added to appRouter. Confirm that commenting out voiceRouter is intentional and that no client code still calls /voice endpoints; otherwise those requests will now 404.

apps/mail/package.json (1)

26-37: New UI dependencies – verify bundle & licence impact

@radix-ui/react-slider, @tabler/icons-react, @tanstack/react-table, and react-color are heavy packages.
Please confirm:

  1. Tree-shaking keeps the client bundle delta acceptable.
  2. Licences (Radix MIT, Tabler MIT, react-color MIT) are compatible with project policy.
  3. No duplication with existing colour pickers (react-colorful is already present).

Also applies to: 93-94, 128-129

apps/mail/tailwind.config.ts (2)

20-25: darkBackground and lightBackground now point to the same CSS variable

Both colours resolve to hsl(var(--sidebar)), making the distinction between dark and light moot.
If the intention was a dynamic variable that changes per theme, consider renaming to a single sidebarBackground token or mapping to different variables (--sidebar-dark / --sidebar-light) to avoid confusion.


75-76: Variable rename aligns with CSS change – good catch

Switching --sidebar-background to --sidebar keeps the Tailwind theme in sync with globals.css.

apps/mail/providers/client-providers.tsx (1)

19-27: Consider passing the user’s preferred theme into ThemeContextProvider

Previously ThemeProvider consumed the theme prop so user preference persisted. After the swap the preference isn’t forwarded, so the context may fall back to its default (usually “system”). If the new provider accepts an initial theme, wire it here:

<ThemeContextProvider initialTheme={data?.settings.colorTheme}></ThemeContextProvider>
apps/mail/components/mail/mail-display.tsx (1)

334-338: Tailwind class fill-primary-foreground not standard

fill-primary-foreground isn’t generated by default Tailwind presets.
If you rely on the shadcn-ui palette it should be fill-primary-foreground/??.
Otherwise, extend the safelist or replace with text-primary-foreground + fill-current.

Verify it compiles; otherwise icon fill will fall back to currentColor.

apps/server/src/db/migrations/meta/0028_snapshot.json (1)

1-835: Snapshot change looks good

Changes are formatting-only; data integrity and constraints remain unchanged.

apps/mail/components/mail/mail.tsx (4)

562-562: Minor styling adjustment looks good.

The button styling change is appropriate and maintains consistency.


608-609: Good use of CSS variables for theming.

The change from hardcoded colors to CSS variables (bg-[#ffffff] and dark:bg-[#1a1a1a]) enables proper theme support.


623-623: Consistent theming for mobile view.

Good consistency with the desktop thread panel styling.


919-919: Excellent use of CSS variable for theme support.

Replacing the hardcoded color #F59E0D with bg-primary enables proper theme customization for the important category.

apps/mail/components/ui/nav-main.tsx (1)

300-335: Excellent refactoring to declarative routing.

The migration from imperative navigation to React Router's Link component is well-executed. All functionality is preserved including click handlers, target attributes, and mobile sidebar behavior.

apps/server/src/trpc/routes/themes.ts (1)

1-181: Well-implemented TRPC router with proper security controls.

The theme router implementation is excellent:

  • Proper rate limiting on mutation endpoints
  • Good separation between public and private procedures
  • Comprehensive input validation with Zod schemas
  • Clean middleware pattern for ThemeManager injection
  • Appropriate rate limits for different operations
apps/server/src/lib/theme-manager.ts (1)

153-180: updateTheme allows empty payload – unintended no-op

createThemeSchema.partial() makes every field optional; updateTheme then forwards the untouched updateData straight to the DB.
Calling the endpoint with { id } and nothing else silently updates only updatedAt, which is surprising.

Recommend rejecting empty updates:

if (Object.keys(updateData).length === 0) {
  throw new Error('No fields provided to update');
}
apps/mail/lib/themes/theme-utils.ts (3)

1-3: LGTM!

The import statements are correctly structured and necessary for the theme utilities.


499-510: Verify handling of undefined rootColors.

The function passes item.themeData?.rootColors to generateThemeCss, which could be undefined. Ensure generateThemeCss properly handles this case.

Looking at the generateThemeCss function, it uses default values when colors are undefined, so this should work correctly. However, consider adding explicit validation for better code clarity.


355-355: ```shell
#!/bin/bash

Display lines 340 to 370 from theme-utils.ts to review generateThemeCss output mapping

sed -n '340,370p' apps/mail/lib/themes/theme-utils.ts


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@MrgSub
Copy link
Collaborator

MrgSub commented Jun 20, 2025

@snehendu098 please cleanup comments, address coderabbit and resolve conflicts, happy to merge and test and award the bounty

@MrgSub MrgSub added the High Priority High Priority Work label Jun 20, 2025
@snehendu098
Copy link
Contributor Author

@MrgSub working on it ser, was out for a hackathon

@snehendu098 snehendu098 force-pushed the feature/themes-customization branch from babd83e to dc17035 Compare June 23, 2025 17:22
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 (2)
apps/mail/lib/themes/theme-utils.ts (2)

108-161: Consolidate duplicate hslToHex implementations.

The hslToHex function is duplicated in apps/mail/components/theme/theme-customizer.tsx. Consider importing and using this utility function there instead of maintaining duplicate implementations.


286-334: Add dark theme CSS generation support.

This function only generates light theme CSS. Given that the application supports dark themes (as evidenced by extractDarkThemeColors and hasDarkMode functions), this function should also support generating dark theme CSS.

Consider extending this function to accept both light and dark color schemes and generate appropriate CSS for both variants.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between babd83e and dc17035.

📒 Files selected for processing (14)
  • apps/mail/app/globals.css (12 hunks)
  • apps/mail/components/context/theme-context.tsx (1 hunks)
  • apps/mail/components/mail/mail-iframe.tsx (1 hunks)
  • apps/mail/components/mail/mail.tsx (10 hunks)
  • apps/mail/components/theme/theme-customizer.tsx (1 hunks)
  • apps/mail/components/theme/theme-view.tsx (1 hunks)
  • apps/mail/lib/hotkeys/mail-list-hotkeys.tsx (2 hunks)
  • apps/mail/lib/themes/index.tsx (1 hunks)
  • apps/mail/lib/themes/theme-utils.ts (1 hunks)
  • apps/mail/types/index.ts (1 hunks)
  • apps/server/src/db/migrations/0028_soft_blazing_skull.sql (1 hunks)
  • apps/server/src/db/schema.ts (2 hunks)
  • apps/server/src/lib/schemas.ts (2 hunks)
  • apps/server/src/lib/theme-manager.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/mail/lib/themes/index.tsx
  • apps/server/src/db/migrations/0028_soft_blazing_skull.sql
🚧 Files skipped from review as they are similar to previous changes (10)
  • apps/mail/components/mail/mail-iframe.tsx
  • apps/mail/lib/hotkeys/mail-list-hotkeys.tsx
  • apps/mail/app/globals.css
  • apps/server/src/db/schema.ts
  • apps/mail/components/context/theme-context.tsx
  • apps/mail/types/index.ts
  • apps/mail/components/theme/theme-view.tsx
  • apps/mail/components/mail/mail.tsx
  • apps/server/src/lib/schemas.ts
  • apps/server/src/lib/theme-manager.ts
🔇 Additional comments (11)
apps/mail/lib/themes/theme-utils.ts (5)

38-105: LGTM! Self-assignment issue has been resolved.

The extractThemeColors function now correctly handles the panel color extraction without the self-assignment issue that was previously identified. The error handling and regex-based color extraction logic are well implemented.


164-204: LGTM! Proper hex to HSL conversion implementation.

The function correctly implements the hex to HSL conversion algorithm and returns the appropriate space-separated format for CSS custom properties.


207-274: LGTM! Self-assignment issue has been resolved.

The extractDarkThemeColors function now correctly handles the panel color extraction without the self-assignment issue that was previously identified. The implementation mirrors the light theme extraction function appropriately.


277-283: LGTM! Simple and effective theme detection.

The hasDarkMode and hasLightMode functions correctly use regex patterns to detect theme support in CSS strings.


337-373: LGTM! Well-structured theme data transformation.

The function properly handles the transformation from API responses to client theme data, correctly splitting themes into light and dark variants when both are supported.

apps/mail/components/theme/theme-customizer.tsx (6)

1-88: LGTM! Proper imports and comprehensive theme definitions.

The component correctly imports the color conversion utilities from theme-utils.ts and defines comprehensive default themes for both light and dark modes with proper HSL color values.


91-141: LGTM! Well-organized color groups and utility functions.

The color grouping provides good organization for the UI, and the rem value parsing/formatting functions properly handle edge cases with appropriate defaults.


142-294: LGTM! Excellent iframe communication strategy.

The component implements a robust multi-method approach for iframe theme application with proper fallbacks, debouncing for performance, and script injection for cross-origin communication. The state management is well-structured.


296-349: LGTM! Error handling has been properly implemented.

The handleSaveTheme function now includes proper error handling with try-catch blocks and user feedback via toast messages, addressing the previously identified issue.


351-422: LGTM! Well-implemented color input with smart positioning.

The ColorInput component provides excellent UX with intelligent color picker positioning that respects viewport boundaries and supports both visual and text-based color editing.


424-697: LGTM! Comprehensive and accessible UI implementation.

The component renders a well-structured interface with proper accessibility, conditional rendering for different theme modes, and effective real-time preview using an iframe. The layout is intuitive and functional.

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 (2)
apps/mail/lib/themes/theme-utils.ts (2)

108-161: Consolidate duplicate hslToHex implementations.

The hslToHex function is duplicated in apps/mail/components/theme/theme-customizer.tsx. Consider importing and using this utility function there instead of maintaining duplicate implementations.


286-334: Add dark theme CSS generation support.

This function only generates light theme CSS. Given that the application supports dark themes (as evidenced by extractDarkThemeColors and hasDarkMode functions), this function should also support generating dark theme CSS.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc17035 and f281a49.

📒 Files selected for processing (1)
  • apps/mail/lib/themes/theme-utils.ts (1 hunks)
🔇 Additional comments (7)
apps/mail/lib/themes/theme-utils.ts (7)

38-105: Function looks well-implemented.

The extractThemeColors function correctly parses CSS variables from the :root section and handles error cases appropriately. The logic for extracting panel colors and other theme properties is sound.


164-204: Hex to HSL conversion is correctly implemented.

The mathematical logic for converting hex colors to HSL format is accurate and the function handles edge cases properly.


207-274: Dark theme extraction function is well-implemented.

The extractDarkThemeColors function correctly mirrors the light theme extraction logic for the .dark selector and handles errors appropriately.


277-283: Theme mode detection functions are correct.

Simple and effective utility functions for detecting dark and light mode support in CSS.


337-373: Theme data generation function is well-structured.

The generateThemeData function correctly transforms API responses into client-side theme data, properly handling both light and dark variants and using the appropriate extraction functions.


1-35: File structure and default values are well-organized.

The imports, type definitions, and default theme values are properly structured and use correct HSL formatting.


320-328: Consider browser compatibility for CSS color functions.

The rgb(from var(--shadow-color) r g b / opacity) syntax uses modern CSS color functions that may not be supported in older browsers. Consider providing fallbacks or using a more widely supported approach.

What is the browser support status for CSS "rgb(from var() r g b)" color function syntax?

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

🧹 Nitpick comments (4)
apps/server/src/lib/theme-manager.ts (2)

4-6: Remove unnecessary constructor.

The empty constructor serves no purpose and should be removed as flagged by static analysis.

-export class ThemeManager {
-  constructor() {}
-
+export class ThemeManager {

16-20: Improve type safety for theme data transformation.

The type casting as ThemePallette and as Theme without validation could lead to runtime errors if the database returns unexpected data structures.

Consider adding validation or using a schema validator:

-      themeData: row.themeData as ThemePallette,
+      themeData: themeDataSchema.parse(row.themeData),

Also applies to: 37-41, 53-57

apps/server/src/main.ts (2)

184-186: Remove unnecessary type assertion.

The type assertion as typeof theme.$inferInsert is unnecessary since the payload type already excludes userId. This assertion could hide potential type errors.

-  async createTheme(payload: Omit<typeof theme.$inferInsert, 'userId'> & { connectionId: string | null }): Promise<typeof theme.$inferSelect[]> {
-    return await this.mainDo.createTheme(this.userId, payload as typeof theme.$inferInsert);
+  async createTheme(payload: Omit<typeof theme.$inferInsert, 'userId'> & { connectionId: string | null }): Promise<typeof theme.$inferSelect[]> {
+    return await this.mainDo.createTheme(this.userId, payload);
  }

531-531: Consider removing manual updatedAt setting.

The schema definition shows that the theme table has an $onUpdate trigger that automatically updates the updatedAt field. Manually setting it here might be redundant.

#!/bin/bash
# Description: Verify if the theme table schema has an $onUpdate trigger for updatedAt

# Search for the theme table definition to confirm the $onUpdate trigger
ast-grep --pattern 'export const theme = createTable($$$)'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f281a49 and 1712ede.

📒 Files selected for processing (22)
  • apps/mail/components/mail/mail-display.tsx (1 hunks)
  • apps/mail/components/mail/mail-iframe.tsx (1 hunks)
  • apps/mail/components/mail/mail.tsx (4 hunks)
  • apps/mail/components/mail/thread-display.tsx (3 hunks)
  • apps/mail/components/theme/theme-customizer.tsx (1 hunks)
  • apps/mail/components/theme/theme-view.tsx (1 hunks)
  • apps/mail/components/ui/nav-main.tsx (2 hunks)
  • apps/mail/lib/hotkeys/mail-list-hotkeys.tsx (2 hunks)
  • apps/mail/providers/client-providers.tsx (3 hunks)
  • apps/mail/types/index.ts (1 hunks)
  • apps/server/src/ctx.ts (1 hunks)
  • apps/server/src/db/migrations/0029_loose_lizard.sql (1 hunks)
  • apps/server/src/db/migrations/0030_fresh_ogun.sql (1 hunks)
  • apps/server/src/db/migrations/meta/0029_snapshot.json (17 hunks)
  • apps/server/src/db/migrations/meta/0030_snapshot.json (4 hunks)
  • apps/server/src/db/migrations/meta/_journal.json (1 hunks)
  • apps/server/src/db/schema.ts (2 hunks)
  • apps/server/src/lib/schemas.ts (2 hunks)
  • apps/server/src/lib/theme-manager.ts (1 hunks)
  • apps/server/src/main.ts (3 hunks)
  • apps/server/src/trpc/index.ts (2 hunks)
  • apps/server/src/trpc/routes/themes.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/server/src/ctx.ts
  • apps/server/src/db/migrations/0030_fresh_ogun.sql
🚧 Files skipped from review as they are similar to previous changes (14)
  • apps/server/src/trpc/index.ts
  • apps/mail/lib/hotkeys/mail-list-hotkeys.tsx
  • apps/mail/providers/client-providers.tsx
  • apps/mail/components/ui/nav-main.tsx
  • apps/mail/components/mail/mail-display.tsx
  • apps/mail/components/mail/mail-iframe.tsx
  • apps/server/src/db/schema.ts
  • apps/mail/components/theme/theme-customizer.tsx
  • apps/server/src/trpc/routes/themes.ts
  • apps/server/src/lib/schemas.ts
  • apps/mail/types/index.ts
  • apps/mail/components/mail/thread-display.tsx
  • apps/mail/components/mail/mail.tsx
  • apps/mail/components/theme/theme-view.tsx
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: snehendu098
PR: Mail-0/Zero#1323
File: apps/mail/lib/themes/theme-utils.ts:318-318
Timestamp: 2025-06-24T06:22:58.753Z
Learning: In the Mail-0/Zero theme system (apps/mail/lib/themes/theme-utils.ts), when color themes are being applied, all color values come in HSL format, so there's no need for additional format validation when converting colors with hslToHex().
apps/server/src/lib/theme-manager.ts (1)
Learnt from: snehendu098
PR: Mail-0/Zero#1323
File: apps/mail/lib/themes/theme-utils.ts:318-318
Timestamp: 2025-06-24T06:22:58.753Z
Learning: In the Mail-0/Zero theme system (apps/mail/lib/themes/theme-utils.ts), when color themes are being applied, all color values come in HSL format, so there's no need for additional format validation when converting colors with hslToHex().
🧬 Code Graph Analysis (2)
apps/server/src/main.ts (1)
apps/server/src/db/schema.ts (1)
  • theme (177-191)
apps/server/src/lib/theme-manager.ts (2)
apps/server/src/lib/schemas.ts (4)
  • Theme (3-13)
  • ThemePallette (198-198)
  • CreateTheme (199-199)
  • UpdateTheme (200-200)
apps/server/src/lib/server-utils.ts (1)
  • getZeroDB (7-11)
🪛 Biome (1.9.4)
apps/server/src/lib/theme-manager.ts

[error] 5-5: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

🔇 Additional comments (9)
apps/server/src/db/migrations/meta/_journal.json (1)

209-228: ```shell
#!/bin/bash

Verify missing migrations in the journal file

echo "Searching for missing migration entries in apps/server/src/db/migrations/meta/_journal.json..."
for tag in "0028_worried_molecule_man" "0029_common_network" "0029_thin_triathlon" "0030_blue_grandmaster"; do
echo -n "$tag: "
grep -R "$tag" -n apps/server/src/db/migrations/meta/_journal.json || echo "not found"
done


</details>
<details>
<summary>apps/server/src/db/migrations/0029_loose_lizard.sql (1)</summary>

`1-14`: **Well-structured migration for theme functionality.**

The migration properly establishes the theme table with:
- UUID primary key with auto-generation
- Appropriate foreign key constraints with cascade deletes
- JSONB storage for flexible theme data
- Sensible defaults and nullable fields

</details>
<details>
<summary>apps/server/src/db/migrations/meta/0030_snapshot.json (2)</summary>

`783-880`: **Theme table schema is consistent with migration.**

The `mail0_theme` table definition in the snapshot correctly matches the migration, with proper:
- UUID primary key with auto-generation
- Foreign keys to user and connection tables with cascade delete
- JSONB theme data storage
- Public visibility flag with appropriate default

---

`402-637`: **OAuth tables appear unrelated to theme feature.**

The addition of `mail0_oauth_access_token`, `mail0_oauth_application`, and `mail0_oauth_consent` tables seems unrelated to the theme customization feature described in the PR objectives.


```shell
#!/bin/bash
# Description: Check if OAuth-related changes are part of this PR
# Expected: Verify if these OAuth tables are intentionally included

echo "Searching for OAuth-related code changes in this PR..."
rg -i "oauth" --type ts --type tsx --type sql
apps/server/src/lib/theme-manager.ts (2)

119-130: Enhance error handling in copyPublicTheme.

The method should verify that the user has permission to copy the theme and ensure the theme actually exists before attempting to copy it.

  async copyPublicTheme(
    userId: string,
    connectionId: string,
    publicThemeId: string,
  ): Promise<Theme> {
    const db = await getZeroDB(userId);
-   const publicTheme = (await db.findThemeById(publicThemeId)) as Theme | undefined;
+   const publicTheme = await this.getThemeById('public', publicThemeId);
    if (!publicTheme || !publicTheme.isPublic) {
      throw new Error('Public theme not found');
    }

Likely an incorrect or invalid review comment.


44-58: ```shell
#!/bin/bash

Retrieve the full implementation of findPublicThemes in the Durable Object (applicable lines)

rg "async findPublicThemes" -n -A20 apps/server/src/main.ts


</details>
<details>
<summary>apps/server/src/db/migrations/meta/0029_snapshot.json (1)</summary>

`783-880`: **Theme table structure is consistent across migration snapshots.**

The theme table definition matches between migration snapshots, ensuring consistency in the migration chain.

</details>
<details>
<summary>apps/server/src/main.ts (2)</summary>

`16-16`: **LGTM!**

The `theme` import is correctly added to support the new theme functionality.

---

`23-23`: **LGTM!**

The `like` operator import is appropriately added for search functionality in public themes.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@snehendu098
Copy link
Contributor Author

@MrgSub please review the code

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

This PR has merge conflicts and has been open for more than 3 days. It will be automatically closed. Please resolve the conflicts and reopen the PR if you'd like to continue working on it.

@github-actions github-actions bot closed this Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority High Priority Work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants