Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(email): keep a closed phone reply composer closed after Save Draft (#9277)

teo52de19c8b15f
diff --git a/apps/web/src/features/email-thread/primitives/thread-reply-area.test.ts b/apps/web/src/features/email-thread/primitives/thread-reply-area.test.ts
index fedb5488fc..4c14afef79 100644
--- a/apps/web/src/features/email-thread/primitives/thread-reply-area.test.ts
+++ b/apps/web/src/features/email-thread/primitives/thread-reply-area.test.ts
@@ -45,6 +45,7 @@ function setup(touch: boolean) {
return {
area,
draft,
+ close: () => setMobileId(undefined),
bottomOpen,
mobileId,
setThreadId,
@@ -87,6 +88,27 @@ describe('thread reply placement', () => {
}
);
+ it('keeps a closed touch composer closed when the saved draft updates', () => {
+ const state = setup(true);
+ const parent = message('parent');
+ expect(state.mobileId()).toBe('parent');
+ state.close();
+ state.setDrafts({
+ parent: { ...state.draft, updated_at: '2026-10-31T19:13:00.000Z' },
+ });
+ state.setMessages([{ ...parent }]);
+ expect(state.mobileId()).toBeUndefined();
+
+ // A draft that appears before the composer was ever shown still opens it.
+ batch(() => {
+ state.setThreadId('second');
+ state.setDrafts({});
+ });
+ expect(state.mobileId()).toBeUndefined();
+ state.setDrafts({ parent: state.draft });
+ expect(state.mobileId()).toBe('parent');
+ });
+
it('uses draft-only threads while respecting ownership and settlement gates', () => {
const state = setup(false);
state.setMessages([]);
diff --git a/apps/web/src/features/email-thread/primitives/thread-reply-area.ts b/apps/web/src/features/email-thread/primitives/thread-reply-area.ts
index ea06ed535a..be579e1ae9 100644
--- a/apps/web/src/features/email-thread/primitives/thread-reply-area.ts
+++ b/apps/web/src/features/email-thread/primitives/thread-reply-area.ts
@@ -26,10 +26,18 @@ export function createThreadReplyArea(options: {
// mount, which can let the reset clobber the auto-open if both data
// sources are synchronously available).
let prevThreadId: string | undefined;
+ // Once the full-screen composer has been shown in this thread, closing it
+ // is final: Save Draft updates the draft, and reopening on that change
+ // would keep the user in the composer.
+ let mobileReplyShown = false;
+ createEffect(() => {
+ if (options.mobileReply.open()) mobileReplyShown = true;
+ });
createEffect(() => {
const tid = options.threadId();
if (prevThreadId !== tid) {
prevThreadId = tid;
+ mobileReplyShown = false;
options.bottomReply.setOpen(false);
options.mobileReply.close();
}
@@ -38,7 +46,8 @@ export function createThreadReplyArea(options: {
if (!lastMessage?.db_id) return;
if (options.drafts.getDraftForMessage(lastMessage.db_id)) {
if (options.isTouch()) {
- options.mobileReply.openForMessage(lastMessage.db_id);
+ if (!mobileReplyShown)
+ options.mobileReply.openForMessage(lastMessage.db_id);
} else {
options.bottomReply.setOpen(true);
}
diff --git a/docs/agent-guide/email.md b/docs/agent-guide/email.md
index 263fdb5845..4c9f4ac8c7 100644
--- a/docs/agent-guide/email.md
+++ b/docs/agent-guide/email.md
@@ -596,6 +596,9 @@ a failed local save keeps the composer and draft options open. The message list
stays mounted underneath so closing a reply preserves its scroll position.
On touch, a saved reply shows as a **Draft** row with its opening words under the
message it answers (which stays expanded); tapping it reopens the draft.
+Opening a thread whose last message has a reply draft opens the composer once;
+after Back → Save Draft it stays closed while the save finishes, until the
+**Draft** row is tapped or the thread is opened again.
On desktop, a saved reply that reappears with its thread (opening it, stepping
to it with j/k, the reading pane following the list) stays unfocused, so the
next j moves on instead of typing into it; `r` or a click continues it.