Skip to content

Comments

minor fixes#1619

Merged
MrgSub merged 1 commit intostagingfrom
07-03-minor_fixes
Jul 4, 2025
Merged

minor fixes#1619
MrgSub merged 1 commit intostagingfrom
07-03-minor_fixes

Conversation

@MrgSub
Copy link
Collaborator

@MrgSub MrgSub commented Jul 4, 2025

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 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.

Summary by CodeRabbit

  • New Features

    • Images within emails are now supported and will be displayed when permitted.
  • Improvements

    • Enhanced email content handling for improved caching and performance.
    • Updated navigation logic for better integration with the command palette and query state.
  • Bug Fixes

    • Minor formatting and consistency improvements across settings and navigation interfaces.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The updates adjust how email content and privacy settings are managed and displayed. The MailContent component now requires an id prop, shifting its query cache key from the HTML content to this identifier. Email sanitization rules are updated to allow img tags. Privacy settings and navigation logic are streamlined.

Changes

File(s) Change Summary
apps/mail/app/(routes)/settings/privacy/page.tsx Refactored form state management: removed explicit defaultValues, now reads externalImages directly from settings, and improved form reset logic. Minor formatting changes.
apps/mail/components/mail/mail-content.tsx Added required id prop to MailContentProps; cache key in useQuery now uses id instead of html.
apps/mail/components/mail/mail-display.tsx Passes id prop (from emailData.id) to MailContent component.
apps/mail/hooks/use-mail-navigation.ts Replaced useCommandPalette with useQueryState for palette state; updated navigation logic to use threadId from query state. Formatting tweaks.
apps/server/src/lib/email-processor.ts Email HTML sanitization now allows img tags by updating allowedTags configuration.

Sequence Diagram(s)

sequenceDiagram
    participant MailDisplay
    participant MailContent
    participant EmailProcessor

    MailDisplay->>MailContent: Render with { id, html, senderEmail }
    MailContent->>MailContent: useQuery([id, ...])
    MailContent->>EmailProcessor: Sanitize html (allowing img tags)
    EmailProcessor-->>MailContent: Sanitized HTML
    MailContent-->>MailDisplay: Rendered content
Loading

Possibly related PRs

  • new email renderer #1584: The main PR modifies the MailContent component by adding an id prop and changing its query cache key, directly building on the MailContent component introduced and implemented in the retrieved PR new email renderer #1584.

Poem

In the garden of code, a new path appears,
With images now safe, no need for fears.
An email’s ID leads the cache on its quest,
While privacy settings are neatly addressed.
The rabbit hops on, with a satisfied cheer—
For every small change brings progress near! 🐇✨


📜 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 e048af0 and 5790d77.

📒 Files selected for processing (5)
  • apps/mail/app/(routes)/settings/privacy/page.tsx (4 hunks)
  • apps/mail/components/mail/mail-content.tsx (2 hunks)
  • apps/mail/components/mail/mail-display.tsx (1 hunks)
  • apps/mail/hooks/use-mail-navigation.ts (5 hunks)
  • apps/server/src/lib/email-processor.ts (1 hunks)
✨ 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
Collaborator Author

MrgSub commented Jul 4, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@MrgSub MrgSub mentioned this pull request Jul 4, 2025
34 tasks
@MrgSub MrgSub marked this pull request as ready for review July 4, 2025 06:12
Copy link
Collaborator Author

MrgSub commented Jul 4, 2025

Merge activity

  • Jul 4, 6:12 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 4, 6:12 AM UTC: @MrgSub merged this pull request with Graphite.

@MrgSub MrgSub merged commit 3fd7b97 into staging Jul 4, 2025
6 of 7 checks passed
@MrgSub MrgSub deleted the 07-03-minor_fixes branch July 4, 2025 06:12
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Minor but important fixes across email handling and security components, focusing on content identification and sanitization.

  • Added required 'id' prop to apps/mail/components/mail/mail-content.tsx for proper email content caching and identification
  • Enhanced security in apps/server/src/lib/email-processor.ts by implementing stricter HTML tag whitelisting while preserving image support
  • Fixed form handling in apps/mail/app/(routes)/settings/privacy/page.tsx to properly initialize and manage external image settings
  • Improved mail navigation in apps/mail/hooks/use-mail-navigation.ts by removing redundant URL checks and updating state management

5 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile

Comment on lines 33 to 35
const form = useForm<z.infer<typeof userSettingsSchema>>({
resolver: zodResolver(userSettingsSchema),
defaultValues: {
externalImages: true,
trustedSenders: [],
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Form validation will fail until form is initialized. Add default values here to match schema.

Suggested change
const form = useForm<z.infer<typeof userSettingsSchema>>({
resolver: zodResolver(userSettingsSchema),
defaultValues: {
externalImages: true,
trustedSenders: [],
},
});
const form = useForm<z.infer<typeof userSettingsSchema>>({
resolver: zodResolver(userSettingsSchema),
defaultValues: {
externalImages: false,
trustedSenders: []
}
});

Comment on lines +27 to +28
const [threadId] = useQueryState('threadId');
const [isCommandPaletteOpen] = useQueryState('isCommandPaletteOpen');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Both these query state hooks should specify their types. Add generic type parameters to useQueryState.

Suggested change
const [threadId] = useQueryState('threadId');
const [isCommandPaletteOpen] = useQueryState('isCommandPaletteOpen');
const [threadId] = useQueryState<string | null>('threadId');
const [isCommandPaletteOpen] = useQueryState<boolean>('isCommandPaletteOpen');

const sanitizeConfig: sanitizeHtml.IOptions = {
allowedTags: false,
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
allowedAttributes: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Setting allowedAttributes: false permits all attributes. Consider whitelisting specific attributes needed for email display (src, href, style, etc).

Suggested change
allowedAttributes: false,
allowedAttributes: {
'*': ['style', 'class'],
'a': ['href', 'target', 'rel'],
'img': ['src', 'alt', 'width', 'height']
},

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: UI Reactivity Lost with State Change

The change from form.watch('externalImages') to data?.settings.externalImages breaks UI reactivity. The trusted senders section's visibility no longer updates immediately when the user toggles the 'external images' switch, as it now depends on the saved server state rather than the current form state. This results in inconsistent UI behavior until the form is saved.

apps/mail/app/(routes)/settings/privacy/page.tsx#L36-L37

const externalImages = data?.settings.externalImages;

Fix in CursorFix in Web


Bug: Navigation Logic Error Due to Variable Shadowing

Variable shadowing causes incorrect navigation logic. A local threadId (derived from message.id) shadows the threadId from useQueryState within the navigateToThread function. This makes the if (threadId) condition evaluate the local message.id (always truthy for valid messages) instead of the threadId from the URL query parameter. Consequently, navigation now always occurs if a message ID exists, deviating from the original behavior which required a threadId URL parameter.

apps/mail/hooks/use-mail-navigation.ts#L26-L92

onNavigateRef.current = onNavigate;
const [threadId] = useQueryState('threadId');
const [isCommandPaletteOpen] = useQueryState('isCommandPaletteOpen');
const hoveredMailRef = useRef<string | null>(null);
const keyboardActiveRef = useRef(false);
const lastMoveTime = useRef(0);
useEffect(() => {
if (!keyboardActiveRef.current) {
// setFocusedIndex(null);
}
}, [items, setFocusedIndex]);
const resetNavigation = useCallback(() => {
setFocusedIndex(null);
onNavigateRef.current(null);
keyboardActiveRef.current = false;
}, [setFocusedIndex, onNavigateRef]);
const getThreadElement = useCallback(
(index: number | null) => {
if (index === null || !containerRef.current) return null;
return containerRef.current.querySelector(
`[data-thread-id="${itemsRef.current[index]?.id}"]`,
) as HTMLElement | null;
},
[containerRef],
);
const scrollIntoView = useCallback(
(index: number, behavior: ScrollBehavior = 'smooth') => {
const threadElement = getThreadElement(index);
if (!threadElement || !containerRef.current) return;
const container = containerRef.current;
const containerRect = container.getBoundingClientRect();
const threadRect = threadElement.getBoundingClientRect();
if (threadRect.top < containerRect.top || threadRect.bottom > containerRect.bottom) {
threadElement.scrollIntoView({
block: 'nearest',
behavior,
});
}
},
[containerRef, getThreadElement],
);
const navigateToThread = useCallback(
(index: number) => {
if (index === null || !itemsRef.current[index]) return;
const message = itemsRef.current[index];
const threadId = message.id;
if (threadId) {
onNavigateRef.current(threadId);
optimisticMarkAsRead([threadId], true);
}
setMail((prev) => ({
...prev,
bulkSelected: [],
}));
},
[setMail, threadId],

Fix in CursorFix in Web


Bug: Hotkey Conflicts Due to Command Palette State Handling

The isCommandPaletteOpen variable, which controls hotkey enablement, was incorrectly changed from useCommandPalette().open to useQueryState('isCommandPaletteOpen'). As useQueryState returns an array (which is always truthy), !isCommandPaletteOpen will always evaluate to false. This causes keyboard navigation hotkeys to remain enabled even when the command palette is open, leading to conflicting inputs.

apps/mail/hooks/use-mail-navigation.ts#L27-L28

const [threadId] = useQueryState('threadId');
const [isCommandPaletteOpen] = useQueryState('isCommandPaletteOpen');

Fix in CursorFix in Web


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@coderabbitai coderabbitai bot mentioned this pull request Jul 23, 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