Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe updates introduce a synthetic "cold email blocker" rule to the rules UI, conditionally displaying it based on account settings and handling it with special UI logic. Additional changes rename sidebar navigation labels, adjust sidebar logo text color class, remove explicit "dark" CSS classes from sidebar components, and update the sidebar background color variable in the global CSS, affecting the application's visual appearance. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RulesComponent
participant useEmailAccountFull
participant UI
User->>RulesComponent: Visit rules page
RulesComponent->>useEmailAccountFull: Fetch email account data
useEmailAccountFull-->>RulesComponent: Return account settings (incl. coldEmailBlocker)
RulesComponent->>RulesComponent: Compute baseRules
alt coldEmailBlocker enabled
RulesComponent->>RulesComponent: Append synthetic cold email blocker rule
end
RulesComponent->>UI: Render rules list (with special handling for cold email blocker)
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/web/components/SideNav.tsxOops! Something went wrong! :( ESLint: 9.24.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ 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: 0
🧹 Nitpick comments (1)
apps/web/app/(app)/[emailAccountId]/automation/Rules.tsx (1)
79-163: Consider extracting the cold email blocker rule creation logic.The synthetic rule creation logic is quite extensive (lines 108-161). Consider extracting it into a separate function for better readability and testability.
+function createColdEmailBlockerRule( + emailAccountData: EmailAccountFullResponse | undefined, + emailAccountId: string, +): RulesResponse[number] | null { + const enabled: ColdEmailSetting[] = [ + ColdEmailSetting.LABEL, + ColdEmailSetting.ARCHIVE_AND_LABEL, + ColdEmailSetting.ARCHIVE_AND_READ_AND_LABEL, + ]; + + const shouldArchived: ColdEmailSetting[] = [ + ColdEmailSetting.ARCHIVE_AND_LABEL, + ColdEmailSetting.ARCHIVE_AND_READ_AND_LABEL, + ]; + + const coldEmailBlockerEnabled = + emailAccountData?.coldEmailBlocker && + enabled.includes(emailAccountData?.coldEmailBlocker); + + if (!coldEmailBlockerEnabled) return null; + + const showArchiveAction = + emailAccountData?.coldEmailBlocker && + shouldArchived.includes(emailAccountData?.coldEmailBlocker); + + return { + id: COLD_EMAIL_BLOCKER_RULE_ID, + name: "Block Cold Emails", + instructions: emailAccountData?.coldEmailPrompt || null, + automate: true, + enabled: true, + runOnThreads: false, + actions: [ + { + id: "cold-email-blocker-label", + type: ActionType.LABEL, + label: inboxZeroLabels.cold_email.name.split("/")[1], + createdAt: new Date(), + updatedAt: new Date(), + ruleId: COLD_EMAIL_BLOCKER_RULE_ID, + to: null, + subject: null, + content: null, + cc: null, + bcc: null, + url: null, + }, + showArchiveAction + ? { + id: "cold-email-blocker-archive", + type: ActionType.ARCHIVE, + label: null, + createdAt: new Date(), + updatedAt: new Date(), + ruleId: COLD_EMAIL_BLOCKER_RULE_ID, + to: null, + subject: null, + content: null, + cc: null, + bcc: null, + url: null, + } + : null, + ].filter(isDefined), + categoryFilters: [], + group: null, + emailAccountId: emailAccountId, + createdAt: new Date(), + updatedAt: new Date(), + categoryFilterType: null, + conditionalOperator: LogicalOperator.OR, + groupId: null, + systemType: null, + to: null, + from: null, + subject: null, + body: null, + }; +} const rules: RulesResponse = useMemo(() => { - const enabled: ColdEmailSetting[] = [ - ColdEmailSetting.LABEL, - ColdEmailSetting.ARCHIVE_AND_LABEL, - ColdEmailSetting.ARCHIVE_AND_READ_AND_LABEL, - ]; - - const shouldArchived: ColdEmailSetting[] = [ - ColdEmailSetting.ARCHIVE_AND_LABEL, - ColdEmailSetting.ARCHIVE_AND_READ_AND_LABEL, - ]; - - const coldEmailBlockerEnabled = - emailAccountData?.coldEmailBlocker && - enabled.includes(emailAccountData?.coldEmailBlocker); - - if (!coldEmailBlockerEnabled) return baseRules; - - const showArchiveAction = - emailAccountData?.coldEmailBlocker && - shouldArchived.includes(emailAccountData?.coldEmailBlocker); - - // Works differently to rules, but we want to show it in the list for user simplicity - const coldEmailBlockerRule: RulesResponse[number] = { - // ... (lines 109-160) - }; - return [...(baseRules || []), coldEmailBlockerRule]; + const coldEmailBlockerRule = createColdEmailBlockerRule( + emailAccountData, + emailAccountId + ); + + if (!coldEmailBlockerRule) return baseRules; + + return [...(baseRules || []), coldEmailBlockerRule]; }, [baseRules, emailAccountData, emailAccountId]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/(app)/[emailAccountId]/automation/Rules.tsx(6 hunks)apps/web/components/SideNav.tsx(1 hunks)apps/web/components/ui/sidebar.tsx(2 hunks)apps/web/styles/globals.css(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/app/(app)/[emailAccountId]/automation/Rules.tsx (5)
apps/web/hooks/useEmailAccountFull.ts (1)
useEmailAccountFull(5-10)apps/web/app/api/user/rules/route.ts (1)
RulesResponse(5-5)apps/web/utils/label.ts (1)
inboxZeroLabels(28-64)apps/web/utils/types.ts (1)
isDefined(8-10)apps/web/utils/path.ts (1)
prefixPath(1-4)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Static Code Analysis Js
- GitHub Check: Jit Security
🔇 Additional comments (6)
apps/web/styles/globals.css (1)
38-38: LGTM!The change from 98% to 100% lightness creates a cleaner, pure white sidebar background that aligns with the PR's goal of refining the sidebar appearance.
apps/web/components/SideNav.tsx (1)
267-267: Good theming improvement!Changing from
text-whitetotext-foregroundmakes the logo text color adapt properly to the theme instead of being hardcoded to white. This ensures better contrast and consistency across light and dark themes.apps/web/components/ui/sidebar.tsx (1)
210-210: Excellent theme flexibility improvement!Removing the hardcoded "dark" classes allows these sidebar components to properly respond to the theme context instead of forcing dark mode styling. This change, combined with the CSS variable updates, creates a more cohesive theming system.
Also applies to: 227-227
apps/web/app/(app)/[emailAccountId]/automation/Rules.tsx (3)
16-16: Well-structured imports for the new cold email blocker feature.The new imports are properly organized and all appear to be used in the implementation.
Also applies to: 51-61
62-62: Good use of a descriptive constant.The constant name clearly indicates this is a special identifier for the synthetic cold email blocker rule.
191-201: Excellent implementation of special handling for the cold email blocker rule!The UI correctly handles the synthetic cold email blocker rule by:
- Using a different navigation path (
/cold-email-blocker)- Preventing toggle of the
runOnThreadssetting- Hiding enable/disable and delete options
- Opening edit/history links in new tabs
This ensures users understand this is a special system rule with different behavior.
Also applies to: 241-242, 274-298, 304-381
Summary by CodeRabbit
New Features
Style