Skip to content

Styling clean up#456

Merged
elie222 merged 4 commits intomainfrom
feat/rule-tab
May 26, 2025
Merged

Styling clean up#456
elie222 merged 4 commits intomainfrom
feat/rule-tab

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented May 26, 2025

Summary by CodeRabbit

  • New Features

    • Added support for displaying email creation dates in the Pending table.
    • View Email buttons now support a new "sm" size option.
    • Introduced interactive diff views to visualize changes in rule conditions and actions.
  • Bug Fixes

    • Email cells now always display the date and a consistent View Email button.
    • Removed redundant or commented-out UI elements in history and rules tables.
  • Style

    • Updated action badges to display vertically for improved readability.
    • Adjusted button icons and labels for clarity.
  • Chores

    • Added a configuration note regarding project commands.

@vercel
Copy link

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview May 26, 2025 8:48pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 26, 2025

"""

Walkthrough

This update modifies several UI components in the email assistant application. It removes optional props and conditional rendering from EmailCell, adjusts the layout and display logic in rule and badge components, disables thread-related toggles and columns, updates button iconography and sizing, adds diff visualization for rule updates, and introduces a new configuration file.

Changes

Files/Groups Change Summary
.cursor/rules/notes.mdc Added new configuration file with metadata and usage note.
apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx Refactored EmailCell to remove optional props; updated avatar and date rendering; minor RuleCell layout tweaks and added commented-out action cell.
apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx Changed button icon from HammerIcon to MessageCircleIcon; set button size to "sm"; shortened label text.
apps/web/app/(app)/[emailAccountId]/assistant/History.tsx Removed ActionItemsCell import and usage; updated EmailCell usage to match new prop requirements.
apps/web/app/(app)/[emailAccountId]/assistant/Pending.tsx Passed required createdAt prop to EmailCell.
apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx Disabled thread-related toggles and columns by commenting out JSX; changed badge layout from horizontal row to vertical column.
apps/web/components/ViewEmailButton.tsx Extended size prop type to include "sm".
apps/web/utils/condition.ts Removed "AI: " prefix from appended rule.instructions string in conditionsToString function.
apps/web/components/assistant-chat/message.tsx Passed full result object and optional chained ruleId to ToolCard component.
apps/web/components/assistant-chat/tools.tsx Enhanced ToolCard and subcomponents to support toggling and displaying diffs of updated rule conditions and actions; added new components for diff toggle and collapsible diff display; updated function signatures to accept result prop.
apps/web/utils/ai/assistant/chat.ts Added explicit TypeScript result types for rule update tools; enhanced update_rule_conditions and update_rule_actions tools to return success status, rule ID, original and updated conditions/actions; improved error handling with structured return objects.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant EmailCell
    participant ViewEmailButton
    participant DateCell
    participant ToolCard
    participant DiffToggleButton
    participant CollapsibleDiff

    User->>UI_Component: Triggers render of assistant tables
    UI_Component->>EmailCell: Render EmailCell (createdAt required, no avatar/date toggles)
    EmailCell->>ViewEmailButton: Render fixed ViewEmailButton at start
    EmailCell->>DateCell: Render date unconditionally
    UI_Component->>ToolCard: Render with full result prop and optional ruleId
    ToolCard->>DiffToggleButton: Show toggle if changes exist
    DiffToggleButton->>CollapsibleDiff: Toggle display of diffs for conditions/actions
Loading

Possibly related PRs

Poem

In the warren of code, a button grew small,
Avatars vanished, no toggles at all.
Badges stack neatly, rules now aligned,
Diffs reveal changes, with toggles combined.
A rabbit reviewed and found it all fine—
🐇✨ Cheers to the changes, from rabbit to mine!
"""

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/components/assistant-chat/tools.tsx

Oops! 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.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/components/assistant-chat/message.tsx

Oops! 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.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

apps/web/utils/ai/assistant/chat.ts

Oops! 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.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

✨ 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: 1

🔭 Outside diff range comments (1)
apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx (1)

23-39: 💡 Verification agent

🧩 Analysis chain

Verify EmailCell signature changes don't break other usages.

The EmailCell component signature has been simplified by making createdAt required and removing the optional hideAvatar and showDate props. Ensure all other usages of this component across the codebase have been updated accordingly.


🏁 Script executed:

#!/bin/bash
# Description: Search for EmailCell usage to verify all calls match the new signature
# Expected: All usages should pass createdAt and not use hideAvatar or showDate props

echo "Searching for EmailCell component usage..."
rg -A 10 -B 2 "EmailCell" --type tsx --type ts

echo -e "\nSearching for potentially outdated prop usage..."
rg "hideAvatar|showDate" --type tsx --type ts

Length of output: 358


🏁 Script executed:

#!/bin/bash
# Search for EmailCell usage in TSX files to verify new signature compliance
echo "Searching for <EmailCell usage in TSX files..."
rg --glob "*.tsx" -n "<EmailCell"

echo -e "\nSearching for any hideAvatar or showDate prop usages..."
rg --glob "*.{ts,tsx}" -n "hideAvatar|showDate"

Length of output: 733


🏁 Script executed:

#!/bin/bash
# Extract EmailCell usage contexts in key files to verify passed props
files=(
  "apps/web/app/(app)/onboarding/OnboardingBulkUnsubscriber.tsx"
  "apps/web/app/(app)/[emailAccountId]/assistant/Pending.tsx"
  "apps/web/app/(app)/[emailAccountId]/assistant/History.tsx"
  "apps/web/components/GroupedTable.tsx"
)
for file in "${files[@]}"; do
  echo "---- $file ----"
  rg -n -C2 "<EmailCell" "$file"
done

Length of output: 2223


🏁 Script executed:

#!/bin/bash
files=(
  "apps/web/app/(app)/onboarding/OnboardingBulkUnsubscriber.tsx"
  "apps/web/app/(app)/[emailAccountId]/assistant/Pending.tsx"
  "apps/web/app/(app)/[emailAccountId]/assistant/History.tsx"
  "apps/web/components/GroupedTable.tsx"
)
for file in "${files[@]}"; do
  echo "---- $file ----"
  rg -n "<EmailCell" "$file" | while IFS=: read -r ln _; do
    echo "Context for <EmailCell at line $ln:"
    sed -n "${ln},$((ln+10))p" "$file"
    echo
  done
done

Length of output: 3858


Fix missing props in EmailCell usages

The EmailCell signature now requires all of {from, subject, snippet, threadId, messageId, userEmail, createdAt} and no longer accepts emailAddress, hideAvatar or showDate. Two call sites are still using the old API and must be updated:

• apps/web/app/(app)/onboarding/OnboardingBulkUnsubscriber.tsx (line 161)
<EmailCell emailAddress={row.name} />

• apps/web/components/GroupedTable.tsx (lines 143 & 329)
<EmailCell emailAddress={row.original.address} className="…" />

Pending.tsx and History.tsx correctly pass all required props. Please replace the outdated calls above to match the new signature or switch to a more appropriate component.

🧹 Nitpick comments (4)
apps/web/app/(app)/[emailAccountId]/assistant/History.tsx (1)

114-114: Remove commented code instead of leaving it.

Consider removing this commented line entirely rather than leaving it as a comment, since this appears to be a deliberate removal of the ActionItemsCell functionality.

-                {/* <ActionItemsCell actionItems={p.actionItems} /> */}
apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx (2)

177-184: Remove commented code block.

This large block of commented code for the "Threads" table header should be removed entirely rather than left as comments, since this appears to be a deliberate UI simplification.

-                  {/* {size === "md" && (
-                    <TableHead>
-                      <div className="flex items-center justify-center gap-1">
-                        <span>Threads</span>
-                        <ThreadsExplanation size="sm" />
-                      </div>
-                    </TableHead>
-                  )} */}

237-261: Remove large commented code block.

This substantial block of commented code for thread toggles should be removed entirely rather than left as comments, since this appears to be a deliberate removal of thread toggle functionality.

-                      {/* {size === "md" && (
-                        <TableCell>
-                          <div className="flex justify-center">
-                            <Toggle
-                              enabled={rule.runOnThreads}
-                              name="runOnThreads"
-                              onChange={async () => {
-                                if (isColdEmailBlocker) return;
-
-                                const result = await setRuleRunOnThreads({
-                                  ruleId: rule.id,
-                                  runOnThreads: !rule.runOnThreads,
-                                });
-
-                                if (result?.serverError) {
-                                  toastError({
-                                    description: `There was an error updating your rule. ${result.serverError || ""}`,
-                                  });
-                                }
-                                mutate();
-                              }}
-                            />
-                          </div>
-                        </TableCell>
-                      )} */}
apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx (1)

155-155: Remove commented code.

Consider removing this commented line entirely rather than leaving it as a comment, since this appears to be part of the deliberate ActionItemsCell removal across the codebase.

-      {/* <ActionItemsCell actionItems={p.actionItems} /> */}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd726db and ad84d10.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .cursor/rules/notes.mdc (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx (3 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx (2 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/History.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/Pending.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx (5 hunks)
  • apps/web/components/ViewEmailButton.tsx (1 hunks)
  • apps/web/package.json (0 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/package.json
🔇 Additional comments (7)
apps/web/components/ViewEmailButton.tsx (1)

15-15: Good addition of the "sm" size option.

The extension of the size prop to include "sm" is clean and maintains backward compatibility while providing more flexibility for button sizing across the application.

.cursor/rules/notes.mdc (1)

1-6: Appropriate development configuration file.

This Cursor IDE configuration file sets up sensible development guidelines by preventing automatic execution of build commands unless explicitly requested. The alwaysApply: true setting ensures consistent enforcement.

apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx (2)

1-1: Good icon choice for chat functionality.

The change from HammerIcon to MessageCircleIcon better represents the chat-based fix functionality and improves semantic clarity.


37-39: Excellent UI consistency improvements.

The explicit size="sm" aligns with the ViewEmailButton size options, and the shortened button text "Fix" is more concise while maintaining clarity. The icon styling remains consistent.

apps/web/app/(app)/[emailAccountId]/assistant/Rules.tsx (1)

436-445: Good layout improvement for action badges.

The change from horizontal flex layout to vertical flex column with gap is a good improvement for displaying action badges, especially when there are multiple badges. The addition of w-fit ensures badges don't stretch unnecessarily.

apps/web/app/(app)/[emailAccountId]/assistant/ExecutedRulesTable.tsx (2)

45-45: Good simplification with ViewEmailButton.

The replacement of conditional avatar display with a consistent ViewEmailButton is a good simplification that provides better UX consistency.


84-141: Improved code structure and formatting.

The reformatting of the RuleCell component with better indentation and structure improves readability while maintaining the same functionality.

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

🧹 Nitpick comments (1)
apps/web/components/assistant-chat/tools.tsx (1)

184-187: Consider optimizing change detection logic.

The change detection logic works correctly but could be optimized:

  • For conditions: Direct string comparison is efficient
  • For actions: JSON.stringify comparison works but may not be the most performant for large action arrays

Consider using a more efficient comparison for actions:

-  const hasChanges =
-    originalActions &&
-    updatedActions &&
-    JSON.stringify(originalActions) !== JSON.stringify(updatedActions);
+  const hasChanges = useMemo(() => {
+    if (!originalActions || !updatedActions) return false;
+    if (originalActions.length !== updatedActions.length) return true;
+    return originalActions.some((orig, i) => {
+      const updated = updatedActions[i];
+      return orig.type !== updated.type || 
+             JSON.stringify(orig.fields) !== JSON.stringify(updated.fields);
+    });
+  }, [originalActions, updatedActions]);

Also applies to: 262-265

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3de1628 and cb15fbe.

📒 Files selected for processing (3)
  • apps/web/components/assistant-chat/message.tsx (1 hunks)
  • apps/web/components/assistant-chat/tools.tsx (14 hunks)
  • apps/web/utils/ai/assistant/chat.ts (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/components/assistant-chat/tools.tsx (2)
apps/web/utils/ai/assistant/chat.ts (5)
  • UpdateRuleConditionsResult (46-68)
  • UpdateRuleConditionSchema (41-43)
  • UpdateRuleActionsResult (99-119)
  • UpdateRuleActionsSchema (97-97)
  • UpdateLearnedPatternsSchema (143-145)
apps/web/components/Tooltip.tsx (1)
  • Tooltip (17-37)
apps/web/utils/ai/assistant/chat.ts (1)
apps/web/utils/index.ts (1)
  • filterNullProperties (11-17)
🔇 Additional comments (11)
apps/web/components/assistant-chat/message.tsx (1)

118-119: LGTM! Safe integration of enhanced tool result data.

The addition of the full result prop and the use of optional chaining for ruleId is well-implemented. This change enables the new diff visualization features while maintaining backward compatibility and preventing potential runtime errors if result is undefined.

apps/web/components/assistant-chat/tools.tsx (5)

170-170: LGTM! Proper state management for diff toggling.

The useState implementation for showChanges is correctly implemented in both components, enabling user control over diff visibility.

Also applies to: 259-259


267-284: LGTM! Well-structured action formatting.

The formatActions function properly handles all action field types and creates a readable string representation for diff display.


515-580: LGTM! Well-implemented diff visualization components.

The new DiffToggleButton and CollapsibleDiff components are well-structured with:

  • Proper accessibility through tooltips
  • Smooth animations using framer-motion
  • Color-coded diff display for better UX
  • Proper conditional rendering

459-460: LGTM! Consistent button sizing improvements.

The standardization of button sizes to size="sm" and explicit dimensions (h-8 w-8 p-0) improves UI consistency across the component.

Also applies to: 469-470


42-63:

Details

✅ Verification successful

Verify type casting safety for result objects.

The type casting result as UpdateRuleConditionsResult and result as UpdateRuleActionsResult could potentially be unsafe if the result doesn't match the expected structure. Consider adding runtime type checking or null safety.


🏁 Script executed:

#!/bin/bash
# Description: Verify that the result objects always match the expected types in the codebase

# Search for other usages of these result types to understand the data flow
ast-grep --pattern 'UpdateRuleConditionsResult'
ast-grep --pattern 'UpdateRuleActionsResult'

# Check if there are any type guards or validation for these result objects
rg -A 5 "UpdateRuleConditionsResult|UpdateRuleActionsResult"

Length of output: 4989


🏁 Script executed:

#!/bin/bash
# Get context around the usage of result in tools.tsx
rg -n "case \"update_rule_conditions\"" -A 20 -B 10 apps/web/components/assistant-chat/tools.tsx

Length of output: 1317


🏁 Script executed:

#!/bin/bash
# Display the top part of tools.tsx to see the component signature
head -n 60 apps/web/components/assistant-chat/tools.tsx

Length of output: 2237


No Action Required on Type Casting

The result object is produced by our full-stack TypeScript functions (update_rule_conditions and update_rule_actions) and consumed here with matching TS types, so the casts result as UpdateRuleConditionsResult and result as UpdateRuleActionsResult are safe. Compile-time checks guarantee the shape—no additional runtime validation is needed.

apps/web/utils/ai/assistant/chat.ts (5)

46-68: LGTM! Well-structured result types for enhanced tool responses.

The new UpdateRuleConditionsResult and UpdateRuleActionsResult types provide comprehensive structure for:

  • Success/failure status
  • Rule identification
  • Original and updated state capture
  • Error messaging

This enables the new diff visualization functionality while maintaining clear data contracts.

Also applies to: 99-119


623-631: LGTM! Optimized database queries with specific field selection.

The enhanced select clauses improve performance by fetching only the required fields for condition and action updates, rather than retrieving entire records.

Also applies to: 698-713


635-641: LGTM! Consistent error handling with structured responses.

The standardized error responses now include:

  • success: false flag
  • Empty ruleId string for consistency
  • Descriptive error messages

This provides a consistent API contract for error scenarios across all update operations.

Also applies to: 717-722, 776-777


643-652: LGTM! Comprehensive state capture for diff functionality.

The implementation properly captures both original and updated states using the filterNullProperties utility, enabling accurate before/after comparisons in the UI. The data transformation is consistent across both conditions and actions.

Also applies to: 665-676, 725-737


678-683: LGTM! Enhanced return values support new diff visualization.

The structured return objects now include both original and updated states, enabling the frontend to display meaningful diffs while maintaining the existing success/error patterns.

Also applies to: 755-760

@elie222 elie222 merged commit ade6432 into main May 26, 2025
7 checks passed
@elie222 elie222 deleted the feat/rule-tab branch May 26, 2025 20:50
@coderabbitai coderabbitai bot mentioned this pull request May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments