Skip to content

Conversation

retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Aug 11, 2025

Summary by cubic

Added undo send support for reply emails and fixed default recipient and subject selection when replying.

  • New Features

    • Users can now undo sending reply and reply-all emails, restoring their draft and recipients.
  • Bug Fixes

    • Reply and reply-all now correctly prefill the "To", "Cc", and subject fields based on the original message.

Summary by CodeRabbit

  • New Features

    • Undo Send now restores reply/forward drafts within threads, pre-filling message, recipients, subject prefixes (Re:/Fwd:), and attachments.
    • Reply composer now auto-generates accurate default recipients for Reply, Reply All, and Forward, and applies subject prefixes only when needed.
  • Bug Fixes

    • Adds safeguards to prevent server-side errors when reading undo data and clears temporary undo data when the composer closes.
    • Improves post-undo navigation behavior between standalone compose and in-thread reply flows.

Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds reply-context-aware undo-send support and prefill logic. Reply composer initializes fields from localStorage-stored undo data (including deserialized attachments) or computed defaults per mode. The undo hook now accepts a context to store/restore separate data for replies vs. new compose, and updates URL/history accordingly.

Changes

Cohort / File(s) Summary
Reply composer undo + defaults
apps/mail/components/mail/reply-composer.tsx
Reads undoReplyEmailData from localStorage with SSR guards; validates thread/reply context; deserializes attachments via deserializeFiles; computes defaultTo/defaultCc/defaultSubject via useMemo for reply/replyAll/forward; initializes composer fields (message, to/cc/bcc, subject, attachments); clears undo data on close; passes context to handleUndoSend; updates imports to include deserializeFiles and EmailData.
Undo hook with reply context
apps/mail/hooks/use-undo-send.ts
Adds ReplyMode and UndoContext types; extends handleUndoSend(result, settings, emailData, context?); stores undo data under undoReplyEmailData with __replyContext for replies, or undoEmailData for compose; adjusts URL/history keys per context; wraps persisted data with context.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant RC as ReplyComposer
  participant UH as useUndoSend
  participant LS as localStorage
  participant H as History/Router

  U->>RC: Open reply/replyAll/forward
  RC->>LS: Read undoReplyEmailData
  LS-->>RC: Undo data + __replyContext
  RC->>RC: Validate context, deserialize files, prefill fields

  U->>RC: Send
  RC->>UH: handleUndoSend(..., emailData, {kind:'reply', threadId, mode, activeReplyId, draftId})
  UH->>LS: Store undoReplyEmailData (+__replyContext)
  UH->>H: Update URL/history (reply context)

  U->>UH: Undo
  UH->>RC: Trigger restore flow
  RC->>LS: Clear undoReplyEmailData on close
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • MrgSub
  • ahmetskilinc

Poem

Re: the code, we bend the flow,
Fwd: the state where emails go.
Undo spins time like a Falcon’s burn,
Threads align, attachments return.
LocalStorage whispers, “try again,” 🚀
Reply or compose—precision, then send.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-reply

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

1 issue found across 2 files • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between df4f38d and d5ad0fc.

📒 Files selected for processing (2)
  • apps/mail/components/mail/reply-composer.tsx (6 hunks)
  • apps/mail/hooks/use-undo-send.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{css,js,ts,jsx,tsx,mdx}

📄 CodeRabbit Inference Engine (.cursor/rules/tailwind-css-v4.mdc)

**/*.{css,js,ts,jsx,tsx,mdx}: Chain variants together for composable variants (e.g., group-has-data-potato:opacity-100).
Use new variants such as starting, not-*, inert, nth-*, in-*, open (for :popover-open), and ** for all descendants.
Do not use deprecated utilities like bg-opacity-*, text-opacity-*, border-opacity-*, and divide-opacity-*; use the new syntax (e.g., bg-black/50).
Use renamed utilities: shadow-sm is now shadow-xs, shadow is now shadow-sm, drop-shadow-sm is now drop-shadow-xs, drop-shadow is now drop-shadow-sm, blur-sm is now blur-xs, blur is now blur-sm, rounded-sm is now rounded-xs, rounded is now rounded-sm, outline-none is now outline-hidden.
Use bg-(--brand-color) syntax for CSS variables in arbitrary values instead of bg-[--brand-color].
Stacked variants now apply left-to-right instead of right-to-left.

Files:

  • apps/mail/hooks/use-undo-send.ts
  • apps/mail/components/mail/reply-composer.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

**/*.{js,jsx,ts,tsx}: Use 2-space indentation
Use single quotes
Limit lines to 100 characters
Semicolons are required

Files:

  • apps/mail/hooks/use-undo-send.ts
  • apps/mail/components/mail/reply-composer.tsx
**/*.{js,jsx,ts,tsx,css}

📄 CodeRabbit Inference Engine (AGENT.md)

Use Prettier with sort-imports and Tailwind plugins

Files:

  • apps/mail/hooks/use-undo-send.ts
  • apps/mail/components/mail/reply-composer.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (AGENT.md)

Enable TypeScript strict mode

Files:

  • apps/mail/hooks/use-undo-send.ts
  • apps/mail/components/mail/reply-composer.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: retrogtx
PR: Mail-0/Zero#1573
File: apps/mail/components/create/template-button.tsx:197-216
Timestamp: 2025-07-28T05:37:50.566Z
Learning: retrogtx prefers less nitpicky code review suggestions and may dismiss detailed accessibility/best practice recommendations with casual responses like "bro please".
🧬 Code Graph Analysis (2)
apps/mail/hooks/use-undo-send.ts (1)
apps/server/src/lib/schemas.ts (1)
  • UserSettings (118-118)
apps/mail/components/mail/reply-composer.tsx (3)
apps/mail/hooks/use-undo-send.ts (2)
  • EmailData (8-17)
  • deserializeFiles (60-69)
apps/server/src/lib/schemas.ts (1)
  • deserializeFiles (11-23)
apps/mail/lib/schemas.ts (1)
  • deserializeFiles (34-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/mail/components/mail/reply-composer.tsx (1)

59-62: Gate undo data by mode too, not just thread/reply id.

Prevents restoring a reply-all payload into a plain reply (or vice versa). Simple guard, less surprise.

-      const matches = !!ctx && ctx.threadId === currentThread && ctx.activeReplyId === currentReply;
+      const matches =
+        !!ctx &&
+        ctx.threadId === currentThread &&
+        ctx.activeReplyId === currentReply &&
+        ctx.mode === mode;

@ahmetskilinc ahmetskilinc added the Ready This label is used when a PR is ready to be merged. label Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready This label is used when a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants