Skip to content

fix(email): keep messages with draft replies expanded in thread view#5041

Merged
evanhutnik merged 1 commit into
mainfrom
evan/email-draft-expanded
Jul 20, 2026
Merged

fix(email): keep messages with draft replies expanded in thread view#5041
evanhutnik merged 1 commit into
mainfrom
evan/email-draft-expanded

Conversation

@evanhutnik

Copy link
Copy Markdown
Contributor

Summary

In the email thread view, a draft reply renders inline inside the message it replies to — but only while that message is expanded. If you started a draft on a message and then a newer message arrived, the drafted-on message collapsed (it was no longer the last/unread message) and the draft vanished from view.

Messages with an in-progress draft reply now always stay expanded, matching Gmail and Superhuman behavior.

Changes

  • Added a hasDraft condition to the isExpanded memo in MessageList.tsx, backed by context.drafts.getDraftForMessage() (a reactive store populated from the thread query, so this applies on initial load and when a draft appears later).
  • Scoped to desktop only: on mobile the inline reply input never renders inside messages (drafts are edited in the compose drawer), so force-expanding there would show an expanded message with no draft attached.

A draft reply renders inline inside the message it replies to, but only
while that message is expanded. When a newer message arrived, the
drafted-on message collapsed and the draft disappeared from view. Now a
message with an in-progress draft stays expanded (desktop only — mobile
edits drafts in the compose drawer), matching Gmail/Superhuman.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Message threads with an in-progress desktop draft reply now open automatically, making it easier to review and continue drafting.
  • Bug Fixes

    • Improved message expansion behavior so draft replies remain visible alongside existing expansion rules.

Walkthrough

Updated MessageList expansion logic to detect in-progress desktop draft replies by message ID. Messages now expand when a draft exists, in addition to manual expansion, last-message, and unread/new-message conditions. Mobile behavior continues to exclude draft-based expansion.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses conventional commits format and accurately summarizes the message-expansion fix.
Description check ✅ Passed The description clearly matches the PR changes and explains the draft-reply expansion behavior.
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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/web/src/features/block-email/component/MessageList.tsx (1)

140-159: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Replace createMemo with derived signals for cheap derivations.

hasDraft and isExpanded perform simple object lookups and boolean evaluations. As per coding guidelines, do not use createMemo for cheap derivations; use standard functions (derived signals) instead to avoid unnecessary reactive node overhead.

♻️ Proposed refactor
-            const hasDraft = createMemo(() => {
+            const hasDraft = () => {
               const messageID = message().db_id;
               if (!messageID || isMobile()) return false;
               return !!context.drafts.getDraftForMessage(messageID);
-            });
+            };
 
-            const isExpanded = createMemo(() => {
+            const isExpanded = () => {
               const messageID = message().db_id;
 
               if (!messageID) return false;
               const manuallyExpanded =
                 context.messages.isBodyExpanded(messageID);
 
               return (
                 manuallyExpanded ||
                 isLastMessage() ||
                 isNewMessage() ||
                 hasDraft()
               );
-            });
+            };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/features/block-email/component/MessageList.tsx` around lines 140
- 159, Replace the createMemo wrappers for hasDraft and isExpanded with standard
derived functions while preserving their existing message ID checks, draft
lookup, and expansion conditions. Update their call sites if needed to use the
derived-function form, without changing behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/web/src/features/block-email/component/MessageList.tsx`:
- Around line 140-159: Replace the createMemo wrappers for hasDraft and
isExpanded with standard derived functions while preserving their existing
message ID checks, draft lookup, and expansion conditions. Update their call
sites if needed to use the derived-function form, without changing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d305ee94-5261-41aa-9467-bfe2cfceed25

📥 Commits

Reviewing files that changed from the base of the PR and between 816d9b1 and cb98dfe.

📒 Files selected for processing (1)
  • apps/web/src/features/block-email/component/MessageList.tsx

@github-actions

Copy link
Copy Markdown

@evanhutnik
evanhutnik merged commit d5c3846 into main Jul 20, 2026
24 checks passed
@evanhutnik
evanhutnik deleted the evan/email-draft-expanded branch July 20, 2026 19:55
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