Skip to content

fix(email): clean up reply draft when the body is emptied#4286

Merged
gbirman merged 2 commits into
mainfrom
gbirman/macro-2009-dont-save-empty-drafts
Jun 23, 2026
Merged

fix(email): clean up reply draft when the body is emptied#4286
gbirman merged 2 commits into
mainfrom
gbirman/macro-2009-dont-save-empty-drafts

Conversation

@gbirman

@gbirman gbirman commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Emptying a reply's body left an empty draft behind because hasDraftContent counted the auto-derived reply recipients as content, so collectDraft never returned null and the draft was re-saved instead of deleted. The reply path now omits recipients from the content check (compose still counts user-entered recipients), so clearing a reply deletes its draft. Verified in-app: typing creates a draft, clearing the body removes it.

@macro-application

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cc3c234b-45e7-45f2-9cb8-723ba57a105f

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

In BaseInput.collectDraft(), the call to hasDraftContent no longer passes the sum of to, cc, and bcc recipient counts as an argument. Draft emptiness is now determined solely by body text, subject, and attachment count. A companion JSDoc update on hasDraftContent in prepareEmailBody.ts documents that reply/forward subjects alone do not constitute meaningful content and that the recipientCount parameter is intended only for user-entered compose recipients, not auto-derived reply recipients.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix:' prefix, is under 72 characters (57 chars), and clearly describes the main change: preventing empty reply drafts from being saved.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the bug (empty reply drafts being saved), the root cause (recipients counted as content), and the fix (omitting recipients from reply content check).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

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

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

hasDraftContent counted the auto-derived reply recipients, so clearing a reply's body left an empty draft behind instead of deleting it. The reply path now omits recipients from the content check; compose still counts user-entered recipients.
@gbirman gbirman force-pushed the gbirman/macro-2009-dont-save-empty-drafts branch from 89ace92 to d166b89 Compare June 23, 2026 19:46
@gbirman gbirman marked this pull request as ready for review June 23, 2026 20:38
The delete-draft mutation invalidated the soup entity by draft-message id, but email soup entities are keyed by thread id, so it was a no-op and the drafts tab stayed stale until a manual refresh. Pass the thread id and refetch the thread entity (mirroring the save path), flipping its is_draft flag so the thread leaves the drafts tab while remaining in the inbox.
@gbirman gbirman force-pushed the gbirman/macro-2009-dont-save-empty-drafts branch from 2d09536 to 74a4d40 Compare June 23, 2026 21:14
@gbirman gbirman requested a review from evanhutnik June 23, 2026 21:17
@gbirman gbirman merged commit 3ba96ad into main Jun 23, 2026
20 checks passed
@gbirman gbirman deleted the gbirman/macro-2009-dont-save-empty-drafts branch June 23, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant