Skip to content

Comments

disable default images loading#606

Merged
nizzyabi merged 3 commits intostagingfrom
feat/dont-load-images-by-default-in-emails
Apr 6, 2025
Merged

disable default images loading#606
nizzyabi merged 3 commits intostagingfrom
feat/dont-load-images-by-default-in-emails

Conversation

@ahmetskilinc
Copy link
Contributor

@ahmetskilinc ahmetskilinc commented Apr 6, 2025

default:
CleanShot 2025-04-06 at 21 56 05@2x

settings toggle:
CleanShot 2025-04-06 at 21 56 22@2x

settings enabled:
CleanShot 2025-04-06 at 21 56 49@2x

Summary by CodeRabbit

  • Style
    • Revamped the layout of the settings page for a cleaner, more consistent form display.
  • New Features
    • Introduced dynamic control over external image visibility in emails, including a warning message and a clickable toggle.
    • Updated interface text to clearly communicate image security options and behaviors.
    • Added localization entries to enhance user understanding of image visibility settings.

@vercel
Copy link

vercel bot commented Apr 6, 2025

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

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2025 11:10pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates the mail application’s UI and email rendering behavior. In the settings page, the layout for form fields has been adjusted, with specific fields commented out or modified. Concurrently, the mail iframe now uses a settings hook to manage the visibility of external images. This change introduces a toggle mechanism that conditionally updates the content security policy via the email template function. Additionally, new localization entries have been added to support user guidance regarding image display preferences.

Changes

File(s) Change Summary
apps/mail/app/.../page.tsx Updated layout structure for form fields in the GeneralPage component. The outer div’s flex properties were rearranged, the dynamicContent field was commented out, and the externalImages field had a minor class adjustment.
apps/mail/components/mail/mail-iframe.tsx Introduced external images management: added a useSettings hook and an imagesEnabled state to enable a conditional warning and toggle mechanism for image visibility.
apps/mail/lib/email-utils.ts Updated the template function to accept an imagesEnabled parameter for appending a conditional CSP meta tag based on image visibility.
apps/mail/locales/en.json Added new localization entries for image visibility options, including warnings and instructions related to hidden images.

Possibly related PRs

  • disable default images loading #606: Involves modifications to the handling of external images in the MailIframe component and the template function, focusing on visibility and loading behavior.
  • i18n #437: Introduces translation functionality in the GeneralPage component, providing a direct connection to the layout modifications made in this PR.

Suggested labels

design

Poem

I'm a cheeky code rabbit on the run,
Hopping through layouts under the sun.
Toggling images with a gentle click,
Securing mails with a CSP trick.
With each line of code, I cheer with glee,
Celebrating changes as spry as can be!
🐰💻


📜 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 92f3e77 and 9e2414f.

📒 Files selected for processing (1)
  • apps/mail/lib/email-utils.ts (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 0

🧹 Nitpick comments (1)
apps/mail/components/mail/mail-iframe.tsx (1)

63-73: Good UI implementation for security warning.

The warning banner is well-implemented with:

  1. Conditional rendering that only shows when appropriate
  2. Clear security messaging
  3. An accessible toggle control for users to enable/disable images
  4. Proper translations using the localization system

A minor suggestion would be to add an icon to make the warning more noticeable.

Consider adding an icon to the warning banner for better visibility:

- <div className="flex items-center justify-start bg-amber-500 p-2 text-sm text-amber-900">
+ <div className="flex items-center justify-start bg-amber-500 p-2 text-sm text-amber-900">
+   <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
+     <path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
+   </svg>
    <p>{t('common.actions.hiddenImagesWarning')}</p>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 243f88d and 92f3e77.

📒 Files selected for processing (4)
  • apps/mail/app/(routes)/settings/general/page.tsx (3 hunks)
  • apps/mail/components/mail/mail-iframe.tsx (2 hunks)
  • apps/mail/lib/email-utils.ts (1 hunks)
  • apps/mail/locales/en.json (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/mail/components/mail/mail-iframe.tsx (1)
apps/mail/lib/email-utils.ts (1)
  • template (6-53)
🔇 Additional comments (12)
apps/mail/lib/email-utils.ts (3)

6-6: Good addition of the optional parameter.

The imagesEnabled parameter with a default value of false aligns with secure-by-default principles, ensuring images are not loaded unless explicitly enabled.


11-15: Nice improvement to CSP handling.

Good use of filtering to skip existing CSP meta tags to avoid duplicate or contradictory security policies.


17-21: Well-implemented conditional CSP.

The Content Security Policy is appropriately configured based on the imagesEnabled state. When disabled, img-src 'none' effectively blocks all images, while the enabled state allows images from any source.

apps/mail/app/(routes)/settings/general/page.tsx (3)

222-223: Layout restructuring looks good.

The wrapper div is properly structured with responsive classes for different screen sizes.


223-241: Appropriate removal of unused form field.

Commenting out the dynamicContent form field aligns with the PR's focus on image loading controls.


246-246: Improved responsive layout for form item.

The CSS class reordering creates a cleaner, more maintainable class list while maintaining the same responsive behavior.

apps/mail/locales/en.json (3)

34-36: Good addition of user-facing messages.

These localization strings clearly communicate the security implications and give users clear options for managing image display.


159-161: Well-organized menu options.

Adding the image control options to the thread display menu provides users with contextual access to this functionality.


333-334: Clear security settings description.

The security section additions effectively communicate the default behavior and reasoning behind it.

apps/mail/components/mail/mail-iframe.tsx (3)

3-3: Good addition of the settings hook.

Importing useSettings enables the component to access user preferences for image display.


9-10: Well-implemented state management.

The component correctly initializes the imagesEnabled state based on user settings, defaulting to false for security if settings are unavailable.


15-15: Proper dependency management in memoization.

The useMemo hook correctly includes imagesEnabled as a dependency, ensuring the template is regenerated when the image display preference changes.

@SwedishChef1
Copy link

SwedishChef1 commented Apr 6, 2025

Screenshot 2025-04-06 at 2 03 45 PM

@ahmetskilinc can we update the text color on the banner? full black or 0a0a0a or smth

or make the banner lighter

@nizzyabi nizzyabi merged commit fdf5349 into staging Apr 6, 2025
4 checks passed
@ahmetskilinc ahmetskilinc deleted the feat/dont-load-images-by-default-in-emails branch April 26, 2025 14:36
@coderabbitai coderabbitai bot mentioned this pull request May 2, 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.

3 participants