Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(email): Reply all logic (#3230)
Evan Hutnikedf64f9fd03e
diff --git a/js/app/packages/block-email/component/BottomReplyButtons.tsx b/js/app/packages/block-email/component/BottomReplyButtons.tsxindex 1d87f6baa6..2aed21b218 100644--- a/js/app/packages/block-email/component/BottomReplyButtons.tsx+++ b/js/app/packages/block-email/component/BottomReplyButtons.tsx@@ -1,8 +1,12 @@+import { useEmail } from '@core/context/user';+import ArrowBendDoubleUpLeft from '@icon/regular/arrow-bend-double-up-left.svg';import ArrowBendUpLeft from '@icon/regular/arrow-bend-up-left.svg';import ArrowBendUpRight from '@icon/regular/arrow-bend-up-right.svg';import type { ApiMessage } from '@service-email/generated/schemas';import { createCallback } from '@solid-primitives/rootless';import { Button } from '@ui';+import { Show } from 'solid-js';+import { isReplyAllEligible } from '../util/recipientConversion';import type { ReplyType } from '../util/replyType';import { useEmailContext } from './EmailContext';import { getEmailFormRegistry } from './EmailFormContext';@@ -10,6 +14,10 @@ import { getEmailFormRegistry } from './EmailFormContext';export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {const ctx = useEmailContext();const formRegistry = getEmailFormRegistry();+ const userEmail = useEmail();++ const shouldShowReplyAll = () =>+ isReplyAllEligible(props.lastMessage, userEmail() ?? '');const open = (type: ReplyType) =>createCallback(() => {@@ -25,25 +33,38 @@ export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {});return (- <div class="w-full border-t border-edge-muted flex flex-row items-center justify-center gap-2 pt-3 pb-2">- <Button- variant="base"- size="md"- class="rounded-full px-4 py-1"- onClick={open('reply')}- >- <ArrowBendUpLeft class="size-4" />- <span>Reply</span>- </Button>- <Button- variant="base"- size="md"- class="rounded-full px-4 py-1"- onClick={open('forward')}- >- <ArrowBendUpRight class="size-4" />- <span>Forward</span>- </Button>+ <div class="w-full border-t border-edge-muted pt-3 pb-2">+ <div class="flex flex-row items-center gap-2 pl-[calc(var(--user-icon-width)+2*var(--message-padding-x))]">+ <Button+ variant="base"+ size="md"+ class="rounded-full px-4 py-1"+ onClick={open('reply')}+ >+ <ArrowBendUpLeft class="size-4" />+ <span>Reply</span>+ </Button>+ <Show when={shouldShowReplyAll()}>+ <Button+ variant="base"+ size="md"+ class="rounded-full px-4 py-1"+ onClick={open('reply-all')}+ >+ <ArrowBendDoubleUpLeft class="size-4" />+ <span>Reply all</span>+ </Button>+ </Show>+ <Button+ variant="base"+ size="md"+ class="rounded-full px-4 py-1"+ onClick={open('forward')}+ >+ <ArrowBendUpRight class="size-4" />+ <span>Forward</span>+ </Button>+ </div></div>);}diff --git a/js/app/packages/block-email/component/MessageActions.tsx b/js/app/packages/block-email/component/MessageActions.tsxindex 7cf1a158a2..abb1ef31a8 100644--- a/js/app/packages/block-email/component/MessageActions.tsx+++ b/js/app/packages/block-email/component/MessageActions.tsx@@ -1,3 +1,4 @@+import { isReplyAllEligible } from '@block-email/util/recipientConversion';import type { ReplyType } from '@block-email/util/replyType';import { useEmail } from '@core/context/user';import ArrowBendDoubleUpLeft from '@icon/regular/arrow-bend-double-up-left.svg';@@ -21,15 +22,8 @@ export function MessageActions(props: {}) {const formRegistry = getEmailFormRegistry();const userEmail = useEmail();- const filteredTo = () => {- return props.message.to.filter((to) => to.email !== userEmail());- };- const filteredCc = () => {- return props.message.cc.filter((cc) => cc.email !== userEmail());- };- const shouldShowReplyAll = () => {- return filteredTo().length + filteredCc().length > 1;- };+ const shouldShowReplyAll = () =>+ isReplyAllEligible(props.message, userEmail() ?? '');const canShowActions = () => {if (!props.showActions) return false;@@ -55,27 +49,25 @@ export function MessageActions(props: {return (<div- class="flex flex-row items-center gap-4 transition-opacity"+ class="flex flex-row items-center gap-1 transition-opacity"classList={{'opacity-0 pointer-events-none': !canShowActions(),'opacity-100': canShowActions(),}}>+ <Show when={!props.hiddenActions?.includes('reply')}>+ <Button+ class="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"+ onClick={onChangeReplyType('reply')}+ tooltip="Reply"+ >+ <ArrowBendUpLeft class="size-5" />+ </Button>+ </Show><Showwhen={shouldShowReplyAll() && !props.hiddenActions?.includes('reply-all')}- fallback={- <Show when={!props.hiddenActions?.includes('reply')}>- <Button- class="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"- onClick={onChangeReplyType('reply')}- tooltip="Reply"- >- <ArrowBendUpLeft class="size-5" />- </Button>- </Show>- }><Buttonclass="size-8 p-0 border-0 bg-transparent hover:bg-hover hover-transition-bg text-ink gap-0.5 active:bg-hover active:text-ink active:border-transparent"diff --git a/js/app/packages/block-email/util/recipientConversion.ts b/js/app/packages/block-email/util/recipientConversion.tsindex eb4704fcfb..1e414ca21e 100644--- a/js/app/packages/block-email/util/recipientConversion.ts+++ b/js/app/packages/block-email/util/recipientConversion.ts@@ -75,6 +75,22 @@ export const getReplyAllRecipients = (return { to, cc, bcc: [] };};+// Whether Reply-all is meaningfully different from Reply for this message.+// Hidden when the user sent the message (Reply == Reply-all per+// getReplyRecipientsFromParent), or when no recipient remains in to/cc+// after filtering out both the user and the sender.+export const isReplyAllEligible = (+ message: ApiMessage,+ userEmail: string+): boolean => {+ const sender = message.from?.email;+ if (sender === userEmail) return false;+ const isOther = (email: string) => email !== userEmail && email !== sender;+ const otherTo = message.to.filter((r) => isOther(r.email));+ const otherCc = message.cc.filter((r) => isOther(r.email));+ return otherTo.length + otherCc.length > 0;+};+export const getReplyRecipientsFromParent = (replyingTo: ApiMessage | undefined,userEmail: string