feat: Alert user when attachment keywords are present but no file is attached#1509
Conversation
WalkthroughA new feature was added to the email composer to detect if the email text references attachments but no files are attached. The send logic now checks for attachment-related keywords and, if found without any attachments, prompts the user with a warning dialog before allowing them to proceed or recheck. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EmailComposer
participant ModalDialog
User->>EmailComposer: Click Send
EmailComposer->>EmailComposer: Check for attachment keywords & attachments
alt Keywords found & no attachments
EmailComposer->>ModalDialog: Show attachment warning
alt User chooses "Send Anyway"
ModalDialog->>EmailComposer: Proceed with send
EmailComposer->>EmailComposer: Send email
else User chooses "Recheck"
ModalDialog->>EmailComposer: Close warning, no send
end
else No keywords or attachments present
EmailComposer->>EmailComposer: Send email
end
Poem
📜 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: 1
🧹 Nitpick comments (1)
apps/mail/components/create/email-composer.tsx (1)
158-165: Consider expanding keywords and optimizing placement.The current keyword list covers common cases but could be more comprehensive. Consider adding keywords like "file attached", "attached file", "please find attached", etc.
Also, this array could be moved outside the component to avoid recreation on each render:
+const ATTACHMENT_KEYWORDS = [ + 'attachment', + 'attached', + 'attaching', + 'see the file', + 'see the files', + 'file attached', + 'attached file', + 'please find attached', +]; export function EmailComposer({ // ... props }: EmailComposerProps) { - const attachmentKeywords = [ - 'attachment', - 'attached', - 'attaching', - 'see the file', - 'see the files', - ];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/mail/components/create/email-composer.tsx(5 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: danteissaias
PR: Mail-0/Zero#618
File: apps/mail/components/mail/mail-iframe.tsx:0-0
Timestamp: 2025-04-07T20:46:04.726Z
Learning: In the Zero mail application, the "Trust Sender" button for external images is only shown when a sender is not already in the trusted senders list (`settings?.trustedSenders`). This is controlled by the condition `!imagesEnabled && !settings?.externalImages`, where `imagesEnabled` is based on `isTrustedSender || settings?.externalImages` and `isTrustedSender` is determined by `settings?.trustedSenders?.includes(senderEmail)`. This design pattern prevents duplicate entries in the trusted senders list.
apps/mail/components/create/email-composer.tsx (3)
Learnt from: retrogtx
PR: Mail-0/Zero#1468
File: apps/server/src/trpc/routes/mail.ts:386-391
Timestamp: 2025-06-27T04:59:29.709Z
Learning: In apps/server/src/trpc/routes/mail.ts, the attachment processing logic conditionally handles mixed attachment types - it preserves existing File-like objects with arrayBuffer methods while only converting serialized attachments that need processing through toAttachmentFiles.
Learnt from: retrogtx
PR: Mail-0/Zero#1328
File: apps/mail/lib/hotkeys/mail-list-hotkeys.tsx:202-209
Timestamp: 2025-06-18T17:26:50.918Z
Learning: In apps/mail/lib/hotkeys/mail-list-hotkeys.tsx, the switchCategoryByIndex function using hardcoded indices for category hotkeys does not break when users reorder categories, contrary to the theoretical index-shifting issue. The actual implementation has constraints or mechanisms that prevent hotkey targeting issues.
Learnt from: danteissaias
PR: Mail-0/Zero#618
File: apps/mail/components/mail/mail-iframe.tsx:12-12
Timestamp: 2025-04-07T20:46:11.697Z
Learning: In the Mail-0/Zero application, sender emails are guaranteed to be non-empty when passed to components that handle them, making additional empty string validation unnecessary.
🧬 Code Graph Analysis (1)
apps/mail/components/create/email-composer.tsx (1)
apps/mail/components/ui/dialog.tsx (6)
Dialog(107-107)DialogContent(112-112)DialogHeader(113-113)DialogTitle(115-115)DialogDescription(116-116)DialogFooter(114-114)
🔇 Additional comments (3)
apps/mail/components/create/email-composer.tsx (3)
134-134: LGTM: Clean state addition for dialog control.The new state variable follows the existing pattern used by other dialogs in the component.
367-401: LGTM: Clean function refactoring maintains original behavior.The rename from
handleSendtoproceedWithSendcreates a clear separation of concerns while preserving all existing send logic intact.
1446-1474: LGTM: Well-implemented warning dialog with clear UX.The dialog follows the existing component patterns and provides a clear user experience with appropriate action options. The button handlers correctly manage state and flow control.
Description
Alerts the user if the email contains words like "attached" but no file is actually attached.
Type of Change
Please delete options that are not relevant.
Areas Affected
Please check all that apply:
Testing Done
Describe the tests you've done:
Security Considerations
For changes involving data or authentication:
Checklist
Additional Notes
Add any other context about the pull request here.
Screenshots/Recordings
Before:
Screen.Recording.2025-06-27.at.12.19.52.PM.mov
After:
Screen.Recording.2025-06-27.at.12.17.22.PM.mov
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.
Summary by CodeRabbit