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): open reply composer on tablet touch devices (#7908)

Jacob Beckerman8553d8e281e8
diff --git a/apps/web/src/features/email-thread/context/email-thread-context.ts b/apps/web/src/features/email-thread/context/email-thread-context.ts
index 81f04f09bd..02f8f607ea 100644
--- a/apps/web/src/features/email-thread/context/email-thread-context.ts
+++ b/apps/web/src/features/email-thread/context/email-thread-context.ts
@@ -55,7 +55,6 @@ export interface EmailThreadContext {
viewerEmail: Accessor<string | undefined>;
viewerLoading: Accessor<boolean>;
isTouch: Accessor<boolean>;
- isMobile: Accessor<boolean>;
createCommands(
thread: Accessor<EmailThread | undefined>
): EmailThreadCommands;
diff --git a/apps/web/src/features/email-thread/email-thread.tsx b/apps/web/src/features/email-thread/email-thread.tsx
index 23770b9637..abf8dcba0b 100644
--- a/apps/web/src/features/email-thread/email-thread.tsx
+++ b/apps/web/src/features/email-thread/email-thread.tsx
@@ -1,6 +1,5 @@
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import { useEmail, useUserContext } from '@core/context/user';
-import { isMobile } from '@core/mobile/isMobile';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { useContacts } from '@core/user';
import { createEffectOnEntityTypeNotification } from '@notifications';
@@ -67,7 +66,6 @@ export function EmailThread(props: EmailThreadProps) {
source,
viewerEmail,
viewerLoading: user.isLoading,
- isMobile,
isTouch: isTouchDevice,
recipients: createMemo(() =>
contacts().map((contact) => convertContactInfoToEmailRecipient(contact))
diff --git a/apps/web/src/features/email-thread/primitives/reply-actions.test.ts b/apps/web/src/features/email-thread/primitives/reply-actions.test.ts
new file mode 100644
index 0000000000..a3e06a2696
--- /dev/null
+++ b/apps/web/src/features/email-thread/primitives/reply-actions.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it, vi } from 'vitest';
+import { message } from '../tests/fixtures';
+import type { EmailThreadState } from './email-thread-state';
+import { openEmailReplyComposerForMessage } from './reply-actions';
+
+function setup() {
+ const ctx = {
+ replyRequest: { set: vi.fn() },
+ mobileReplyComposer: { openForMessage: vi.fn() },
+ messages: {
+ setBottomReplyOpen: vi.fn(),
+ setExpandedBodyId: vi.fn(),
+ setFocused: vi.fn(),
+ setReplyingToMessageId: vi.fn(),
+ },
+ };
+ return { ctx, state: ctx as unknown as EmailThreadState };
+}
+
+describe('openEmailReplyComposerForMessage', () => {
+ // Tablets are touch at desktop widths. The inline reply input never renders
+ // on touch, so replying there must open the compose drawer.
+ it('opens the compose drawer on touch', () => {
+ const { ctx, state } = setup();
+
+ openEmailReplyComposerForMessage({
+ ctx: state,
+ isTouch: true,
+ message: message('last'),
+ replyType: 'reply-all',
+ isLastMessage: true,
+ });
+
+ expect(ctx.replyRequest.set).toHaveBeenCalledWith('last', 'reply-all');
+ expect(ctx.mobileReplyComposer.openForMessage).toHaveBeenCalledWith('last');
+ expect(ctx.messages.setBottomReplyOpen).not.toHaveBeenCalled();
+ });
+
+ it('opens the inline reply input without touch', () => {
+ const { ctx, state } = setup();
+
+ openEmailReplyComposerForMessage({
+ ctx: state,
+ isTouch: false,
+ message: message('last'),
+ replyType: 'forward',
+ isLastMessage: true,
+ });
+
+ expect(ctx.mobileReplyComposer.openForMessage).not.toHaveBeenCalled();
+ expect(ctx.messages.setBottomReplyOpen).toHaveBeenCalledWith(true);
+ });
+});
diff --git a/apps/web/src/features/email-thread/primitives/reply-actions.ts b/apps/web/src/features/email-thread/primitives/reply-actions.ts
index fd8e0f2757..095257a9d8 100644
--- a/apps/web/src/features/email-thread/primitives/reply-actions.ts
+++ b/apps/web/src/features/email-thread/primitives/reply-actions.ts
@@ -6,7 +6,10 @@ import type { EmailThreadState } from './email-thread-state';
export function openEmailReplyComposerForMessage(args: {
ctx: EmailThreadState;
- isMobile: boolean;
+ /** Touch layouts reply in the compose drawer; the inline reply input only
+ * renders for non-touch. Phone width alone is not the gate: tablets are
+ * touch at desktop widths. */
+ isTouch: boolean;
message: EmailMessage;
replyType: ReplyType;
isLastMessage?: boolean;
@@ -21,7 +24,7 @@ export function openEmailReplyComposerForMessage(args: {
// the registry key includes a seed only the composer knows.
args.ctx.replyRequest.set(messageId, args.replyType);
- if (args.isMobile) {
+ if (args.isTouch) {
args.ctx.mobileReplyComposer.openForMessage(messageId);
return true;
}
diff --git a/apps/web/src/features/email-thread/primitives/thread-navigation.ts b/apps/web/src/features/email-thread/primitives/thread-navigation.ts
index e5bf404627..b8d96219fc 100644
--- a/apps/web/src/features/email-thread/primitives/thread-navigation.ts
+++ b/apps/web/src/features/email-thread/primitives/thread-navigation.ts
@@ -469,7 +469,7 @@ export function createThreadNavigation(
return openEmailReplyComposerForMessage({
ctx: context,
- isMobile: threadContext.isMobile(),
+ isTouch: threadContext.isTouch(),
message: target.message,
replyType,
isLastMessage: target.isLastMessage,
@@ -533,7 +533,7 @@ export function createThreadNavigation(
return openEmailReplyComposerForMessage({
ctx: context,
- isMobile: threadContext.isMobile(),
+ isTouch: threadContext.isTouch(),
message: target.message,
replyType: 'reply-all',
isLastMessage: target.isLastMessage,
diff --git a/apps/web/src/features/email-thread/tests/fixtures.ts b/apps/web/src/features/email-thread/tests/fixtures.ts
index 890de0f4e5..33bbbcd4d1 100644
--- a/apps/web/src/features/email-thread/tests/fixtures.ts
+++ b/apps/web/src/features/email-thread/tests/fixtures.ts
@@ -41,7 +41,6 @@ export function createThreadContext(
viewerEmail: () => '[email protected]',
viewerLoading: () => false,
isTouch: () => false,
- isMobile: () => false,
createCommands: () => ({
archiveThread: () => false,
isThreadDone: () => false,
diff --git a/apps/web/src/features/email-thread/views/bottom-reply-buttons.tsx b/apps/web/src/features/email-thread/views/bottom-reply-buttons.tsx
index 86c439ace0..9002a74605 100644
--- a/apps/web/src/features/email-thread/views/bottom-reply-buttons.tsx
+++ b/apps/web/src/features/email-thread/views/bottom-reply-buttons.tsx
@@ -65,7 +65,7 @@ export function BottomReplyButtons(props: {
const messageId = props.lastMessage.db_id;
if (!messageId) return;
openEmailReplyComposerForMessage({
- isMobile: viewContext.thread.isMobile(),
+ isTouch: viewContext.thread.isTouch(),
ctx,
message: props.lastMessage,
replyType: type,
diff --git a/apps/web/src/features/email-thread/views/message-container.tsx b/apps/web/src/features/email-thread/views/message-container.tsx
index e77c8912bd..73924408b9 100644
--- a/apps/web/src/features/email-thread/views/message-container.tsx
+++ b/apps/web/src/features/email-thread/views/message-container.tsx
@@ -133,7 +133,7 @@ export function MessageContainer(props: MessageContainerProps) {
replyType,
isLastMessage: props.isLastMessage,
setShowReply,
- isMobile: threadContext.isMobile(),
+ isTouch: threadContext.isTouch(),
})
: undefined
}