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
feat(email): ui revamp (#898)
teobd88fc790a8c
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsxindex d34e8f0a0f..290fd1bea2 100644--- a/js/app/packages/block-email/component/BaseInput.tsx+++ b/js/app/packages/block-email/component/BaseInput.tsx@@ -590,6 +590,34 @@ export function BaseInput(props: {hotkeyToken: TOKENS.email.sendAndMarkDone,displayPriority: 10,});++ registerHotkey({+ hotkey: 'escape',+ scopeId: composeHotkeyScope,+ description: 'Close reply',+ keyDownHandler: () => {+ const draft = collectDraft();+ const isEmpty = draft === null;++ if (isEmpty) {+ // Delete draft and close reply+ deleteDraftAndReset();+ } else {+ // Move focus back to the message+ const focusedId = ctx.messages.focusedID();+ if (focusedId) {+ const messageEl = document.querySelector(+ `[data-message-body-id="${focusedId}"]`+ ) as HTMLElement | null;+ messageEl?.focus();+ }+ }+ return true;+ },+ runWithInputFocused: true,+ hotkeyToken: TOKENS.email.cancelReply,+ displayPriority: 8,+ });}});diff --git a/js/app/packages/block-email/component/CollapsedMessage.tsx b/js/app/packages/block-email/component/CollapsedMessage.tsxnew file mode 100644index 0000000000..3c994d15a3--- /dev/null+++ b/js/app/packages/block-email/component/CollapsedMessage.tsx@@ -0,0 +1,128 @@+import { BozzyBracket } from '@core/component/BozzyBracket';+import { UserIcon } from '@core/component/UserIcon';+import type { MessageWithBodyReplyless } from '@service-email/generated/schemas';+import { useEmail, useUserId } from '@service-gql/client';+import { createMemo, createSignal } from 'solid-js';+import {+ getSenderDisplayName,+ isMessageFromCurrentUser,+} from '../util/emailUser';++interface CollapsedMessageProps {+ message: MessageWithBodyReplyless;+ isFocused: boolean;+ onClick: () => void;+}++export function CollapsedMessage(props: CollapsedMessageProps) {+ const [hover, setHover] = createSignal(false);+ const currentUserEmail = useEmail();+ const currentUserId = useUserId();++ const isFromCurrentUser = createMemo(() =>+ isMessageFromCurrentUser(props.message, currentUserEmail())+ );++ const senderDisplay = createMemo(() =>+ getSenderDisplayName(props.message, currentUserEmail())+ );++ const snippet = createMemo(() => {+ // Prefer body_text for snippet, fall back to stripping HTML+ if (props.message.body_text) {+ return props.message.body_text.replace(/\s+/g, ' ').trim();+ }+ if (props.message.body_html_sanitized) {+ const parser = new DOMParser();+ const doc = parser.parseFromString(+ props.message.body_html_sanitized,+ 'text/html'+ );+ return doc.body.textContent?.replace(/\s+/g, ' ').trim() ?? '';+ }+ return '';+ });++ const handleKeyDown = (e: KeyboardEvent) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ props.onClick();+ }+ };++ return (+ <div class="shrink-0 flex justify-center w-full">+ <div class="macro-message-width w-full">+ <BozzyBracket+ active={props.isFocused}+ hover={hover()}+ class="[--user-icon-width:30px] @sm:[--user-icon-width:40px] [--left-of-connector:20px] @sm:[--left-of-connector:28px]"+ >+ <div+ class="relative flex flex-row items-center w-full py-2 cursor-pointer opacity-60 hover:opacity-100 transition-all"+ data-message-body-id={props.message.db_id}+ tabIndex={0}+ onClick={props.onClick}+ onKeyDown={handleKeyDown}+ onMouseEnter={() => setHover(true)}+ onMouseLeave={() => setHover(false)}+ >+ {/* Rail line - behind avatar */}+ <div+ class="absolute top-0 bottom-0 border-l border-edge-muted z-0"+ style={{+ left: 'var(--left-of-connector)',+ }}+ />++ {/* Avatar - centered on the rail, in front of rail */}+ <div+ class="relative z-10 flex justify-center items-center shrink-0"+ style={{+ width: 'var(--user-icon-width)',+ height: 'var(--user-icon-width)',+ 'margin-left':+ 'calc(var(--left-of-connector) - var(--user-icon-width) / 2)',+ }}+ >+ <UserIcon+ {...(isFromCurrentUser()+ ? { id: currentUserId() ?? '' }+ : { email: props.message.from?.email ?? '' })}+ isDeleted={false}+ size="fill"+ suppressClick={true}+ />+ </div>++ {/* Sender + Snippet - aligned with expanded message content */}+ <div+ class="flex-1 flex items-center min-w-0 text-sm"+ style={{+ 'padding-left':+ 'calc(var(--left-of-connector) - var(--user-icon-width) / 2)',+ }}+ >+ <span class="text-ink-muted w-16 shrink-0 truncate">+ {senderDisplay()}+ </span>+ <span class="text-ink-extra-muted truncate">{snippet()}</span>+ </div>++ {/* Date */}+ <div class="text-xs text-ink-muted shrink-0 ml-4 pr-2">+ {props.message.internal_date_ts &&+ new Date(props.message.internal_date_ts).toLocaleDateString(+ 'en-US',+ {+ month: 'short',+ day: 'numeric',+ }+ )}+ </div>+ </div>+ </BozzyBracket>+ </div>+ </div>+ );+}diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsxindex dc21200ea9..ad60558fa3 100644--- a/js/app/packages/block-email/component/Email.tsx+++ b/js/app/packages/block-email/component/Email.tsx@@ -27,6 +27,10 @@ import { EmailInput } from './EmailInput';import { MessageList } from './MessageList';import { TopBar } from './TopBar';+const TARGET_MESSAGE_HIGHLIGHT_MS = 800;+const SCROLL_ANIMATION_MS = 1000;+const SCROLL_AFTER_SEND_DELAY_MS = 100;+type EmailViewProps = {title: Accessor<string>;threadId: Accessor<string>;@@ -132,11 +136,11 @@ function EmailContent(props: EmailViewProps) {if (context.messages.targetMessageID() === messageId) {setTimeout(() => {context.messages.setTargetMessageID(undefined);- }, 800);+ }, TARGET_MESSAGE_HIGHLIGHT_MS);}// Clear scrolling flag after animation- setTimeout(() => setIsScrollingToMessage(false), 1000);+ setTimeout(() => setIsScrollingToMessage(false), SCROLL_ANIMATION_MS);return true;};@@ -261,7 +265,7 @@ function EmailContent(props: EmailViewProps) {if (prev === false) {setTimeout(() => {scrollToLastMessage('smooth');- }, 100);+ }, SCROLL_AFTER_SEND_DELAY_MS);}return true;});@@ -322,6 +326,25 @@ function EmailContent(props: EmailViewProps) {hotkey: 'enter',description: 'Focus Email Input',keyDownHandler: () => {+ const focusedId = context.messages.focusedID();++ // If a message is focused and collapsed, expand it+ if (focusedId && !context.messages.isBodyExpanded(focusedId)) {+ context.messages.setExpandedBodyId(focusedId, true);+ return true;+ }++ // If message is expanded and not the last message, trigger reply to that message+ if (focusedId && context.messages.isBodyExpanded(focusedId)) {+ const messages = context.messages.list();+ const lastMessage = messages[messages.length - 1];+ if (lastMessage?.db_id !== focusedId) {+ context.messages.setReplyingToMessageId(focusedId);+ return true;+ }+ }++ // Otherwise, focus the main email inputif (markdownDomRef) {markdownDomRef.focus();return true;@@ -332,6 +355,44 @@ function EmailContent(props: EmailViewProps) {hide: true,});+ registerScopeSignalHotkey(scopeId, {+ hotkey: 'escape',+ description: 'Collapse message',+ keyDownHandler: () => {+ // Skip if focus is in an editable area (compose input handles its own Escape)+ const activeEl = document.activeElement;+ if (+ activeEl?.tagName === 'INPUT' ||+ activeEl?.tagName === 'TEXTAREA' ||+ activeEl?.getAttribute('contenteditable') === 'true'+ ) {+ return false;+ }++ const focusedId = context.messages.focusedID();+ if (!focusedId) return false;++ // If there's an active reply, just clear it (don't collapse the message)+ if (context.messages.replyingToMessageId() === focusedId) {+ context.messages.setReplyingToMessageId(undefined);+ return true;+ }++ // If message is expanded and not the last message, collapse it+ if (context.messages.isBodyExpanded(focusedId)) {+ const messages = context.messages.list();+ const lastMessage = messages[messages.length - 1];+ if (lastMessage?.db_id !== focusedId) {+ context.messages.setExpandedBodyId(focusedId, false);+ return true;+ }+ }+ return false;+ },+ hotkeyToken: TOKENS.email.cancelReply,+ hide: true,+ });+return (<EmailFormContextProvider><div class="w-full h-full bg-panel select-none overscroll-none overflow-hidden flex flex-col">@@ -340,7 +401,10 @@ function EmailContent(props: EmailViewProps) {class="w-full flex-1 flex flex-col items-center overflow-hidden"ref={context.registerMessagesContainer}>- <MessageList initialLoadComplete={context.initialLoadComplete()} />+ <MessageList+ initialLoadComplete={context.initialLoadComplete()}+ title={props.title()}+ /></div><Showwhen={diff --git a/js/app/packages/block-email/component/EmailContext.tsx b/js/app/packages/block-email/component/EmailContext.tsxindex c2a4a9ccec..893ac7a1e1 100644--- a/js/app/packages/block-email/component/EmailContext.tsx+++ b/js/app/packages/block-email/component/EmailContext.tsx@@ -68,6 +68,11 @@ export type EmailContextValues = {setTargetMessageID: (id: string | undefined) => void;focusedID: Accessor<string | undefined>;setFocused: (messageID: string | undefined) => void;+ expandedBodyIds: Record<string, boolean>;+ setExpandedBodyId: (id: string, expanded: boolean) => void;+ isBodyExpanded: (id: string) => boolean;+ replyingToMessageId: Accessor<string | undefined>;+ setReplyingToMessageId: (id: string | undefined) => void;};thread: Accessor<APIThread | undefined>;permissions: Accessor<{@@ -157,6 +162,10 @@ export function EmailProvider(props: FlowProps<{ threadID: string }>) {);const [focusedMessageId, setFocusedMessageId] = createSignal<string>();+ const [replyingToMessageId, setReplyingToMessageId] = createSignal<string>();+ const [expandedMessageBodyIds, setExpandedMessageBodyIds] = createStore<+ Record<string, boolean>+ >({});const [searchParams] = useSearchParams();const searchParamsMessageId = () => {const messageID = searchParams[URL_PARAMS.messageId];@@ -419,6 +428,12 @@ export function EmailProvider(props: FlowProps<{ threadID: string }>) {setTargetMessageID: setTargetMessageId,list: createMemo(() => threadQuery.data?.filtered ?? []),unfiltered: createMemo(() => threadQuery.data?.messages ?? []),+ expandedBodyIds: expandedMessageBodyIds,+ setExpandedBodyId: (id: string, expanded: boolean) =>+ setExpandedMessageBodyIds(id, expanded),+ isBodyExpanded: (id: string) => expandedMessageBodyIds[id] ?? false,+ replyingToMessageId,+ setReplyingToMessageId,},permissions: createMemo(() => {const perms = getPermissions(threadQuery.data?.access_level);diff --git a/js/app/packages/block-email/component/EmailMessageTopBar.tsx b/js/app/packages/block-email/component/EmailMessageTopBar.tsxindex e5503e0e3a..4c85f3a9d9 100644--- a/js/app/packages/block-email/component/EmailMessageTopBar.tsx+++ b/js/app/packages/block-email/component/EmailMessageTopBar.tsx@@ -1,18 +1,29 @@import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';import { Tooltip } from '@core/component/Tooltip';-import { formatDate } from '@core/util/date';import CaretDown from '@icon/regular/caret-down.svg';-import CaretUp from '@icon/regular/caret-up.svg';+import X from '@icon/regular/x.svg';import type { MessageWithBodyReplyless } from '@service-email/generated/schemas';-import { type Accessor, For, type Setter, Show } from 'solid-js';-import type { SetStoreFunction } from 'solid-js/store';-import { getFirstName } from '../util/name';+import { useEmail } from '@service-gql/client';+import {+ type Accessor,+ createMemo,+ createSignal,+ For,+ type JSX,+ type Setter,+ Show,+} from 'solid-js';+import {+ getRecipientDisplayName,+ getSenderDisplayName,+ isMessageFromCurrentUser,+} from '../util/emailUser';import { type EmailMessageAction, MessageActions } from './MessageActions';interface EmailMessageTopBarProps {message: MessageWithBodyReplyless;focused: boolean;- setExpandedMessageBodyIds: SetStoreFunction<Record<string, boolean>>;+ setExpandedBodyId: (id: string, expanded: boolean) => void;isBodyExpanded: Accessor<boolean>;expandedHeader: Accessor<boolean>;setExpandedHeader: Setter<boolean>;@@ -22,262 +33,230 @@ interface EmailMessageTopBarProps {hiddenActions?: EmailMessageAction[];}-export function EmailMessageTopBar(props: EmailMessageTopBarProps) {+interface Recipient {+ name?: string | null;+ email?: string | null;+}++function formatFullDate(timestamp: string): string {+ return new Date(timestamp)+ .toLocaleString('en-US', {+ weekday: 'long',+ year: 'numeric',+ month: 'long',+ day: 'numeric',+ hour: 'numeric',+ minute: '2-digit',+ timeZoneName: 'short',+ })+ .replace(',', '');+}++function formatShortDate(timestamp: string): string {+ return new Date(timestamp).toLocaleDateString('en-US', {+ month: 'short',+ day: 'numeric',+ });+}++function formatRecipientList(recipients: string[]): string {+ if (recipients.length === 0) return '';+ if (recipients.length === 1) return recipients[0];+ if (recipients.length === 2) return `${recipients[0]} & ${recipients[1]}`;+ const rest = recipients.slice(0, -1);+ const last = recipients[recipients.length - 1];+ return `${rest.join(', ')} & ${last}`;+}++function RecipientRow(props: {+ label: string;+ recipients: Recipient[];+ bold?: boolean;+}): JSX.Element {return (- <div- class="pr-2 font-mono"- onClick={(e) => {- if (props.message.db_id) {- props.setFocusedMessageId(props.message.db_id);- }- if (- (e.target as Element).localName === 'button' ||- (e.target as Element).localName === 'svg' ||- (e.target as Element).localName === 'path' ||- (e.target as Element).tagName === 'SPAN' ||- (e.target as Element).closest('[role="tooltip"]')- ) {- return;- }- if (props.isBodyExpanded() && props.message.db_id) {- props.setExpandedMessageBodyIds(props.message.db_id, false);- } else if (props.message.db_id) {- props.setExpandedMessageBodyIds(props.message.db_id, true);- }- }}- >- {/* Top Bar Main Row */}- <div class={`flex flex-row w-full items-center justify-between`}>- {/* Name and Email */}- <div class="shrink-1 min-w-0 flex flex-row items-center text-sm gap-2">- {/* Sender Name */}- <div class="truncate text-ink-muted select-tex cursor-text">+ <Show when={props.recipients.length > 0}>+ <div class="flex flex-row gap-2">+ <span class="text-ink-extra-muted min-w-10">{props.label}</span>+ <span class="select-text cursor-text">+ <For each={props.recipients}>+ {(r, index) => (+ <>+ <span+ classList={{ 'font-semibold': props.bold, 'text-ink': true }}+ >+ {r.name ?? r.email}+ </span>+ <Show when={r.name && r.email}>+ <span class="text-ink-muted"> <{r.email}></span>+ </Show>+ <Show when={index() < props.recipients.length - 1}>+ <span class="text-ink-muted">, </span>+ </Show>+ </>+ )}+ </For>+ </span>+ </div>+ </Show>+ );+}++function ExpandedHeader(props: {+ message: MessageWithBodyReplyless;+ onClose: () => void;+}): JSX.Element {+ return (+ <div class="flex flex-col gap-1 text-sm">+ <div class="flex flex-row gap-2">+ <span class="text-ink-extra-muted min-w-10">From</span>+ <span class="select-text cursor-text">+ <span class="font-semibold text-ink">{props.message.from?.name ?? props.message.from?.email}- </div>- {/* Sender Email */}- <Show when={props.isBodyExpanded() && props.message.from?.name}>- <div class="truncate flex-1 min-w-0 text-ink-muted text-xs">- <- <span class="text-accent-ink select-text cursor-text">- {props.message.from?.email}- </span>- >- </div>+ </span>+ <Show when={props.message.from?.name && props.message.from?.email}>+ <span class="text-ink-muted">+ {' '}+ <{props.message.from?.email}>+ </span></Show>+ </span>+ </div>+ <RecipientRow label="To" recipients={props.message.to} />+ <RecipientRow label="Cc" recipients={props.message.cc} bold />+ <RecipientRow label="Bcc" recipients={props.message.bcc} bold />+ <div class="flex flex-row items-center gap-2 text-ink-extra-muted">+ <Show when={props.message.internal_date_ts}>+ <span>{formatFullDate(props.message.internal_date_ts!)}</span>+ </Show>+ <DeprecatedIconButton+ theme="clear"+ icon={X}+ onclick={props.onClose}+ iconSize={12}+ />+ </div>+ </div>+ );+}++function CollapsedHeader(props: {+ senderName: string;+ recipientSummary: string;+ isHovering: boolean;+ onExpand: () => void;+ message: MessageWithBodyReplyless;+ focused: boolean;+ setShowReply: Setter<boolean>;+ isLastMessage?: boolean;+ hiddenActions?: EmailMessageAction[];+}): JSX.Element {+ return (+ <div class="flex flex-row w-full items-center justify-between">+ <div class="flex flex-row items-center gap-1 text-sm min-w-0">+ <span class="text-ink-muted truncate">+ {props.senderName} to {props.recipientSummary}+ </span>+ <div+ class="transition-opacity"+ classList={{+ 'opacity-0': !props.isHovering,+ 'opacity-100': props.isHovering,+ }}+ >+ <Tooltip tooltip={<span class="text-xs">Expand Message Header</span>}>+ <DeprecatedIconButton+ theme="clear"+ icon={CaretDown}+ onclick={(e) => {+ e.stopPropagation();+ props.onExpand();+ }}+ iconSize={12}+ />+ </Tooltip></div>- {/* Date and Actions */}- <div class="flex flex-row gap-4 items-center">- {/* Date */}+ </div>+ <div class="flex flex-row gap-4 items-center shrink-0">+ <MessageActions+ message={props.message}+ showActions={props.focused}+ setShowReply={props.setShowReply}+ isLastMessage={props.isLastMessage}+ hiddenActions={props.hiddenActions}+ />+ <Show when={props.message.internal_date_ts}><div class="text-xs text-ink-muted">- {props.message.internal_date_ts &&- formatDate(- new Date(props.message.internal_date_ts).getTime() / 1000- )}+ {formatShortDate(props.message.internal_date_ts!)}</div>- <MessageActions- message={props.message}- showActions={props.focused}- setShowReply={props.setShowReply}- isLastMessage={props.isLastMessage}- hiddenActions={props.hiddenActions}- />- </div>+ </Show></div>- {/* Recipient Fields */}+ </div>+ );+}++export function EmailMessageTopBar(props: EmailMessageTopBarProps) {+ const [isHovering, setIsHovering] = createSignal(false);+ const userEmail = useEmail();++ const _isFromCurrentUser = createMemo(() =>+ isMessageFromCurrentUser(props.message, userEmail())+ );++ const senderName = createMemo(() =>+ getSenderDisplayName(props.message, userEmail())+ );++ const recipientSummary = createMemo(() => {+ const currentEmail = userEmail();+ const allRecipients = [...props.message.to, ...props.message.cc];+ const names = allRecipients.map((r) =>+ getRecipientDisplayName(r, currentEmail)+ );+ return formatRecipientList(names);+ });++ const shouldIgnoreClick = (target: Element) =>+ target.localName === 'button' ||+ target.localName === 'svg' ||+ target.localName === 'path' ||+ target.tagName === 'SPAN' ||+ target.closest('[role="tooltip"]');++ const handleClick = (e: MouseEvent) => {+ const id = props.message.db_id;+ if (id) props.setFocusedMessageId(id);+ if (shouldIgnoreClick(e.target as Element)) return;+ if (id) props.setExpandedBodyId(id, !props.isBodyExpanded());+ };++ return (+ <div+ class="pr-2 font-mono"+ onMouseEnter={() => setIsHovering(true)}+ onMouseLeave={() => setIsHovering(false)}+ onClick={handleClick}+ ><Show when={props.isBodyExpanded()}><Show- when={props.expandedHeader()}+ when={!props.expandedHeader()}fallback={- <div class="flex flex-row items-center gap-2 -mt-1">- {/* normal one line TO, CC, BCC field */}- <div class="text-xs select-text select-children cursor-text text-nowrap overflow-hidden">- <span>to </span>- <For each={props.message.to}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span>- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.to.length - 1 ||- props.message.cc.length > 0- ? ', '- : '')}- </span>- </Tooltip>- )}- </For>- <For each={props.message.cc}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span>- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.cc.length - 1 ? ', ' : '')}- </span>- </Tooltip>- )}- </For>- <Show when={props.message.bcc.length > 0}>, bcc: </Show>- <For each={props.message.bcc}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span>- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.bcc.length - 1 ? ', ' : '')}- </span>- </Tooltip>- )}- </For>- </div>- {/* Expand Header Button */}- <DeprecatedIconButton- theme="clear"- icon={CaretDown}- onclick={() => {- props.setExpandedHeader(true);- }}- iconSize={12}- class="h-[17px]!"- />- </div>+ <ExpandedHeader+ message={props.message}+ onClose={() => props.setExpandedHeader(false)}+ />}>- {/* Expanded TO */}- <Show when={props.message.to.length > 0}>- <div class="flex flex-row items-start gap-2 text-sm">- <span class="text-ink-extra-muted min-w-7">to</span>- <div class="text-sm select-text cursor-text">- <For each={props.message.to}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span class="select-text">- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.to.length - 1 ? ', ' : '')}- </span>- </Tooltip>- )}- </For>- {/* Expand Header Button */}-- <Show- when={- props.message.cc.length === 0 &&- props.message.bcc.length === 0- }- >- <DeprecatedIconButton- theme="clear"- icon={CaretUp}- onclick={() => {- props.setExpandedHeader(false);- }}- iconSize={12}- class="h-[17px]! pl-2! inline-block!"- />- </Show>- </div>- </div>- </Show>- {/* Expanded CC */}- <Show when={props.message.cc.length > 0}>- <div class="flex flex-row items-start gap-2 text-sm">- <span class="text-ink-extra-muted min-w-7">cc</span>- <div class="text-sm select-text cursor-text">- <For each={props.message.cc}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span class="select-text">- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.cc.length - 1 ? ', ' : '')}- </span>- </Tooltip>- )}- </For>- {/* Expand Header Button */}-- <Show when={props.message.bcc.length === 0}>- <DeprecatedIconButton- theme="clear"- icon={CaretUp}- onclick={() => {- props.setExpandedHeader(false);- }}- iconSize={12}- class="h-[17px]! pl-2! inline-block!"- />- </Show>- </div>- </div>- </Show>- {/* bcc */}- <Show when={props.message.bcc.length > 0}>- <div class="flex flex-row items-start gap-2 text-sm">- <span class="text-ink-extra-muted min-w-7">bcc</span>- <div class="text-sm select-text cursor-text">- <For each={props.message.bcc}>- {(t, index) => (- <Tooltip- tooltip={- <div class="text-xs select-text cursor-text">- {t.email}- </div>- }- class="inline"- >- <span class="select-text">- {(t.name ? getFirstName(t.name) : t.email) +- (index() < props.message.bcc.length - 1 ? ', ' : '')}- </span>- </Tooltip>- )}- </For>- {/* Expand Header Button */}-- <DeprecatedIconButton- theme="clear"- icon={CaretUp}- onclick={() => {- props.setExpandedHeader(false);- }}- iconSize={12}- class="h-[17px]! pl-2! inline-block!"- />- </div>- </div>- </Show>+ <CollapsedHeader+ senderName={senderName()}+ recipientSummary={recipientSummary()}+ isHovering={isHovering()}+ onExpand={() => props.setExpandedHeader(true)}+ message={props.message}+ focused={props.focused}+ setShowReply={props.setShowReply}+ isLastMessage={props.isLastMessage}+ hiddenActions={props.hiddenActions}+ /></Show></Show></div>diff --git a/js/app/packages/block-email/component/MessageActions.tsx b/js/app/packages/block-email/component/MessageActions.tsxindex b460e79226..0bf17417bb 100644--- a/js/app/packages/block-email/component/MessageActions.tsx+++ b/js/app/packages/block-email/component/MessageActions.tsx@@ -3,7 +3,6 @@ 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 { MessageWithBodyReplyless } from '@service-email/generated/schemas';-// import EnvelopSimple from '@icon/regular/envelope-simple.svg';import { useEmail } from '@service-gql/client';import { type Setter, Show } from 'solid-js';import { getEmailFormRegistry } from './EmailFormContext';@@ -41,78 +40,70 @@ export function MessageActions(props: {};return (- <Show when={canShowActions()}>- <div class="flex flex-row items-center gap-4">- <Show- when={- shouldShowReplyAll() && !props.hiddenActions?.includes('reply-all')- }- fallback={- <Show when={!props.hiddenActions?.includes('reply')}>- <DeprecatedIconButton- icon={ArrowBendUpLeft}- theme="clear"- onClick={() => {- if (!props.isLastMessage) {- props.setShowReply(true);- }- const form = formRegistry.getOrInit(- props.message.db_id ?? ''- );- form.setReplyType('reply');- form.setShouldFocusInput(true);- }}- tooltip={{- label: 'Reply',- }}- />- </Show>- }- >- <DeprecatedIconButton- icon={ArrowBendDoubleUpLeft}- theme="clear"- onClick={() => {- if (!props.isLastMessage) {- props.setShowReply(true);- }- const form = formRegistry.getOrInit(props.message.db_id ?? '');- form.setReplyType('reply-all');- form.setShouldFocusInput(true);- }}- tooltip={{- label: 'Reply all',- }}- />- </Show>- <Show when={!props.hiddenActions?.includes('forward')}>- <DeprecatedIconButton- icon={ArrowBendUpRight}- theme="clear"- onClick={() => {- if (!props.isLastMessage) {- props.setShowReply(true);- }- const form = formRegistry.getOrInit(props.message.db_id ?? '');- form.setReplyType('forward');- form.setShouldFocusInput(true);- }}- tooltip={{- label: 'Forward',- }}- />- </Show>- {/* <IconButton- icon={EnvelopSimple}+ <div+ class="flex flex-row items-center gap-4 transition-opacity"+ classList={{+ 'opacity-0 pointer-events-none': !canShowActions(),+ 'opacity-100': canShowActions(),+ }}+ >+ <Show+ when={+ shouldShowReplyAll() && !props.hiddenActions?.includes('reply-all')+ }+ fallback={+ <Show when={!props.hiddenActions?.includes('reply')}>+ <DeprecatedIconButton+ icon={ArrowBendUpLeft}+ theme="clear"+ onClick={() => {+ if (!props.isLastMessage) {+ props.setShowReply(true);+ }+ const form = formRegistry.getOrInit(props.message.db_id ?? '');+ form.setReplyType('reply');+ form.setShouldFocusInput(true);+ }}+ tooltip={{+ label: 'Reply',+ }}+ />+ </Show>+ }+ >+ <DeprecatedIconButton+ icon={ArrowBendDoubleUpLeft}theme="clear"- onClick={async () => {- // TODO: Implement mark as unread+ onClick={() => {+ if (!props.isLastMessage) {+ props.setShowReply(true);+ }+ const form = formRegistry.getOrInit(props.message.db_id ?? '');+ form.setReplyType('reply-all');+ form.setShouldFocusInput(true);}}tooltip={{- label: 'Mark as unread',+ label: 'Reply all',}}- /> */}- </div>- </Show>+ />+ </Show>+ <Show when={!props.hiddenActions?.includes('forward')}>+ <DeprecatedIconButton+ icon={ArrowBendUpRight}+ theme="clear"+ onClick={() => {+ if (!props.isLastMessage) {+ props.setShowReply(true);+ }+ const form = formRegistry.getOrInit(props.message.db_id ?? '');+ form.setReplyType('forward');+ form.setShouldFocusInput(true);+ }}+ tooltip={{+ label: 'Forward',+ }}+ />+ </Show>+ </div>);}diff --git a/js/app/packages/block-email/component/MessageContainer.tsx b/js/app/packages/block-email/component/MessageContainer.tsxindex 842bb40233..7ad6dfa59d 100644--- a/js/app/packages/block-email/component/MessageContainer.tsx+++ b/js/app/packages/block-email/component/MessageContainer.tsx@@ -1,9 +1,11 @@import { useSplitLayout } from '@app/component/split-layout/layout';import { EmailAttachmentPill } from '@block-email/component/AttachmentPill';+import { CollapsedMessage } from '@block-email/component/CollapsedMessage';import { useEmailContext } from '@block-email/component/EmailContext';import { EmailInput } from '@block-email/component/EmailInput';import { EmailMessageBody } from '@block-email/component/EmailMessageBody';import { EmailMessageTopBar } from '@block-email/component/EmailMessageTopBar';+import { isMessageFromCurrentUser } from '@block-email/util/emailUser';import { ImageGalleryPreview } from '@core/component/ImageGalleryPreview';import { ImagePreview } from '@core/component/ImagePreview';import { Message } from '@core/component/Message';@@ -19,7 +21,7 @@ import type {Attachment,MessageWithBodyReplyless,} from '@service-email/generated/schemas';-import { useUserId } from '@service-gql/client';+import { useEmail, useUserId } from '@service-gql/client';import { storageServiceClient } from '@service-storage/client';import type { FileType } from '@service-storage/generated/schemas/fileType';import {@@ -31,13 +33,10 @@ import {Show,Switch,} from 'solid-js';-import type { SetStoreFunction } from 'solid-js/store';import { Portal } from 'solid-js/web';interface MessageContainerProps {message: MessageWithBodyReplyless;- expandedMessageBodyIds: Record<string, boolean>;- setExpandedMessageBodyIds: SetStoreFunction<Record<string, boolean>>;isFirstMessage: boolean;isLastMessage: boolean;isFocused: boolean;@@ -57,13 +56,35 @@ export function MessageContainer(props: MessageContainerProps) {const [threadAppendMountTarget, setThreadAppendMountTarget] = createSignal<HTMLElement | undefined>();- const [showReply, setShowReply] = createSignal<boolean>(false);+ const [showReplyInternal, setShowReplyInternal] =+ createSignal<boolean>(false);++ const showReply = () =>+ showReplyInternal() ||+ context.messages.replyingToMessageId() === props.message.db_id;++ const setShowReply = (value: boolean | ((prev: boolean) => boolean)) => {+ const newValue =+ typeof value === 'function' ? value(showReplyInternal()) : value;+ setShowReplyInternal(newValue);+ if (+ !newValue &&+ context.messages.replyingToMessageId() === props.message.db_id+ ) {+ context.messages.setReplyingToMessageId(undefined);+ }+ };const userId = useUserId();+ const currentUserEmail = useEmail();const [currentUserName] = useDisplayName(tryMacroId(userId() ?? ''));+ const isFromCurrentUser = createMemo(() =>+ isMessageFromCurrentUser(props.message, currentUserEmail())+ );+const isBodyExpanded = createMemo(() => {- return props.expandedMessageBodyIds[props.message.db_id ?? ''];+ return context.messages.isBodyExpanded(props.message.db_id ?? '');});const isNewMessage = createMemo(() => {@@ -121,14 +142,13 @@ export function MessageContainer(props: MessageContainerProps) {);});- // expand appropriate messagescreateEffect(() => {const id = props.message.db_id;if (props.isLastMessage && id) {- props.setExpandedMessageBodyIds(id, true);+ context.messages.setExpandedBodyId(id, true);}if (isNewMessage() && id) {- props.setExpandedMessageBodyIds(id, true);+ context.messages.setExpandedBodyId(id, true);}});@@ -182,126 +202,149 @@ export function MessageContainer(props: MessageContainerProps) {});};- return (- <div class="shrink-0 flex justify-center w-full">- <div class="macro-message-width w-full">- <Message- id={props.message.db_id ?? undefined}- focused={props.isFocused}- isFirstMessage={props.isFirstMessage}- isLastMessage={props.isLastMessage}- senderId={props.message.from?.email}- isNewMessage={isNewMessage()}- isTarget={props.isTarget}- >- <Message.TopBar>- <EmailMessageTopBar- message={props.message}- focused={props.isFocused}- setExpandedMessageBodyIds={props.setExpandedMessageBodyIds}- isBodyExpanded={isBodyExpanded}- expandedHeader={expandedHeader}- setExpandedHeader={setExpandedHeader}- setFocusedMessageId={context.messages.setFocused}- setShowReply={setShowReply}- isLastMessage={props.isLastMessage}- hiddenActions={- !context.permissions().isOwner- ? ['reply', 'reply-all', 'forward']- : undefined- }- />- </Message.TopBar>- <Message.Body>- <EmailMessageBody- message={props.message}- isBodyExpanded={isBodyExpanded}- setExpandedMessageBody={(id) =>- props.setExpandedMessageBodyIds(id, true)- }- setFocusedMessageId={context.messages.setFocused}- isFirstMessageInThread={props.isFirstMessage}- />- </Message.Body>- {/* Image attachments */}- <Show when={imageAttachmentsWithSfs().length > 0}>- <Switch>- <Match when={imageAttachmentsWithSfs().length === 1}>- <div class="max-w-[400px] w-fit mt-2">- <ImagePreview- image={{- id: imageAttachmentsWithSfs()[0].sfs_id!,- }}- variant="dynamic"- />- </div>- </Match>- <Match when={imageAttachmentsWithSfs().length > 1}>- <div class="flex flex-wrap gap-2 mt-2">- <ImageGalleryPreview- images={imageAttachmentsWithSfs().map((a) => ({- id: a.sfs_id!,- }))}- variant="dynamic"- attachmentIds={imageAttachmentsWithSfs().map(- (a) => a.db_id!- )}- />- </div>- </Match>- </Switch>- </Show>+ const handleExpand = () => {+ if (props.message.db_id) {+ context.messages.setExpandedBodyId(props.message.db_id, true);+ context.messages.setFocused(props.message.db_id);+ }+ };- {/* Video attachments */}- <Show when={videoAttachmentsWithSfs().length > 0}>- <For each={videoAttachmentsWithSfs()}>- {(attachment) => (- <VideoPreview id={attachment.sfs_id!} variant="dynamic" />- )}- </For>- </Show>+ return (+ <Show+ when={isBodyExpanded()}+ fallback={+ <CollapsedMessage+ message={props.message}+ isFocused={props.isFocused}+ onClick={handleExpand}+ />+ }+ >+ {/* Expanded message view */}+ <div class="shrink-0 flex justify-center w-full">+ <div class="macro-message-width w-full">+ <Message+ id={props.message.db_id ?? undefined}+ focused={props.isFocused}+ isFirstMessage={props.isFirstMessage}+ isLastMessage={props.isLastMessage}+ senderId={+ isFromCurrentUser() ? userId() : props.message.from?.email+ }+ isNewMessage={isNewMessage()}+ isTarget={props.isTarget}+ >+ <Message.TopBar>+ <EmailMessageTopBar+ message={props.message}+ focused={props.isFocused}+ setExpandedBodyId={context.messages.setExpandedBodyId}+ isBodyExpanded={isBodyExpanded}+ expandedHeader={expandedHeader}+ setExpandedHeader={setExpandedHeader}+ setFocusedMessageId={context.messages.setFocused}+ setShowReply={setShowReply}+ isLastMessage={props.isLastMessage}+ hiddenActions={+ !context.permissions().isOwner+ ? ['reply', 'reply-all', 'forward']+ : undefined+ }+ />+ </Message.TopBar>+ <Message.Body>+ <EmailMessageBody+ message={props.message}+ isBodyExpanded={isBodyExpanded}+ setExpandedMessageBody={(id) =>+ context.messages.setExpandedBodyId(id, true)+ }+ setFocusedMessageId={context.messages.setFocused}+ isFirstMessageInThread={props.isFirstMessage}+ />+ </Message.Body>+ {/* Image attachments */}+ <Show when={imageAttachmentsWithSfs().length > 0}>+ <Switch>+ <Match when={imageAttachmentsWithSfs().length === 1}>+ <div class="max-w-[400px] w-fit mt-2">+ <ImagePreview+ image={{+ id: imageAttachmentsWithSfs()[0].sfs_id!,+ }}+ variant="dynamic"+ />+ </div>+ </Match>+ <Match when={imageAttachmentsWithSfs().length > 1}>+ <div class="flex flex-wrap gap-2 mt-2">+ <ImageGalleryPreview+ images={imageAttachmentsWithSfs().map((a) => ({+ id: a.sfs_id!,+ }))}+ variant="dynamic"+ attachmentIds={imageAttachmentsWithSfs().map(+ (a) => a.db_id!+ )}+ />+ </div>+ </Match>+ </Switch>+ </Show>- {/* Other attachments (non-media or without sfs_id) */}- <Show when={otherAttachments().length > 0}>- <div class="flex flex-row overflow-x-scroll mt-2 gap-2">- <For each={otherAttachments()}>+ {/* Video attachments */}+ <Show when={videoAttachmentsWithSfs().length > 0}>+ <For each={videoAttachmentsWithSfs()}>{(attachment) => (- <EmailAttachmentPill- attachment={attachment}- onClick={onClickAttachment}- />+ <VideoPreview id={attachment.sfs_id!} variant="dynamic" />)}</For>- </div>- </Show>- </Message>- <Show when={(showReply() || draftChild()) && !props.isLastMessage}>- <Message- focused={false}- unfocusable- senderId={userId()}- isFirstMessage={false}- isLastMessage={false}- threadDepth={1}- isFirstInThread- isLastInThread- shouldShowThreadAppendInput- setThreadAppendMountTarget={(el) => setThreadAppendMountTarget(el)}- >- <Message.TopBar name={currentUserName()} />- <div class="h-4" />+ </Show>++ {/* Other attachments (non-media or without sfs_id) */}+ <Show when={otherAttachments().length > 0}>+ <div class="flex flex-row overflow-x-scroll mt-2 gap-2">+ <For each={otherAttachments()}>+ {(attachment) => (+ <EmailAttachmentPill+ attachment={attachment}+ onClick={onClickAttachment}+ />+ )}+ </For>+ </div>+ </Show></Message>- <Show when={context.permissions().isOwner}>- <Portal mount={threadAppendMountTarget()}>- <EmailInput- replyingTo={() => props.message}- setShowReply={setShowReply}- draft={draftChild()}- />- </Portal>+ <Show when={(showReply() || draftChild()) && !props.isLastMessage}>+ <Message+ focused={false}+ unfocusable+ senderId={userId()}+ isFirstMessage={false}+ isLastMessage={false}+ threadDepth={1}+ isFirstInThread+ isLastInThread+ shouldShowThreadAppendInput+ setThreadAppendMountTarget={(el) =>+ setThreadAppendMountTarget(el)+ }+ >+ <Message.TopBar name={currentUserName()} />+ <div class="h-4" />+ </Message>+ <Show when={context.permissions().isOwner}>+ <Portal mount={threadAppendMountTarget()}>+ <EmailInput+ replyingTo={() => props.message}+ setShowReply={setShowReply}+ draft={draftChild()}+ />+ </Portal>+ </Show></Show>- </Show>+ </div></div>- </div>+ </Show>);}diff --git a/js/app/packages/block-email/component/MessageList.tsx b/js/app/packages/block-email/component/MessageList.tsxindex a20a5648a7..4948327a0b 100644--- a/js/app/packages/block-email/component/MessageList.tsx+++ b/js/app/packages/block-email/component/MessageList.tsx@@ -1,20 +1,17 @@import { useEmailContext } from '@block-email/component/EmailContext';import { isScrollingToMessage } from '@block-email/signal/scrollState';import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';-import { createMemo, createSelector, For } from 'solid-js';-import { createStore } from 'solid-js/store';+import { createMemo, createSelector, For, Show } from 'solid-js';import { MessageContainer } from './MessageContainer';interface MessageListProps {initialLoadComplete: boolean;+ title: string;}export function MessageList(props: MessageListProps) {const getIsScrollingToMessage = isScrollingToMessage.get;const context = useEmailContext();- const [expandedMessageBodyIds, setExpandedMessageBodyIds] = createStore<- Record<string, boolean>- >({});const isFocusedSelector = createSelector(context.messages.focusedID,(a, b) => !!a && !!b && a === b@@ -82,13 +79,20 @@ export function MessageList(props: MessageListProps) {isFocused={isFocusedSelector(message.db_id ?? undefined)}isTarget={isTargetSelector(message.db_id ?? undefined)}message={message}- expandedMessageBodyIds={expandedMessageBodyIds}- setExpandedMessageBodyIds={setExpandedMessageBodyIds}/>);}}</For></StaticMarkdownContext>+ <Show when={props.title}>+ <div class="shrink-0 w-full flex justify-center pb-4">+ <div class="macro-message-width w-full">+ <h1 class="text-4xl font-semibold text-ink pt-8 pb-4">+ {props.title}+ </h1>+ </div>+ </div>+ </Show></div>);}diff --git a/js/app/packages/block-email/util/emailUser.ts b/js/app/packages/block-email/util/emailUser.tsnew file mode 100644index 0000000000..12efe8dd83--- /dev/null+++ b/js/app/packages/block-email/util/emailUser.ts@@ -0,0 +1,51 @@+import type { MessageWithBodyReplyless } from '@service-email/generated/schemas';+import { getFirstName } from './name';++/**+ * Check if a message is from the current user+ */+export function isMessageFromCurrentUser(+ message: MessageWithBodyReplyless,+ currentUserEmail?: string+): boolean {+ if (!currentUserEmail) return false;+ const fromEmail = message.from?.email?.toLowerCase();+ const userEmail = currentUserEmail.toLowerCase();+ return fromEmail !== undefined && fromEmail === userEmail;+}++/**+ * Get the sender display name, showing "Me" for the current user+ */+export function getSenderDisplayName(+ message: MessageWithBodyReplyless,+ currentUserEmail?: string+): string {+ if (isMessageFromCurrentUser(message, currentUserEmail)) {+ return 'Me';+ }+ const from = message.from;+ if (!from) return 'Unknown';+ if (from.name) {+ return getFirstName(from.name);+ }+ return from.email ?? 'Unknown';+}++interface Recipient {+ name?: string | null;+ email?: string | null;+}++/**+ * Get recipient display name, showing "Me" for the current user+ */+export function getRecipientDisplayName(+ recipient: Recipient,+ currentUserEmail?: string+): string {+ if (recipient.email === currentUserEmail) return 'Me';+ return recipient.name+ ? getFirstName(recipient.name)+ : (recipient.email?.split('@')[0] ?? '');+}