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.

style(email): simplify styling for email reply (#4729)

Seamusfd148147ce43
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 6f4dae5977..9f089653df 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -7,11 +7,6 @@ import {
MAX_ATTACHMENTS_BYTES_SIZE,
} from '@block-email/constants';
import { addUserMentionToCc } from '@block-email/util/mentionToCc';
-import { FormatButtons } from '@channel/Input/FormatButtons';
-import {
- applyInlineFormat,
- applyNodeFormat,
-} from '@channel/Input/utils/formatting';
import { useHasPaidAccess } from '@core/auth';
import { useBlockId } from '@core/block';
import { FileDropOverlay } from '@core/component/FileDropOverlay';
@@ -33,7 +28,6 @@ import {
import { useEmail } from '@core/context/user';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { fileSelector } from '@core/directive/fileSelector';
-import { observedSize } from '@core/directive/observedSize';
import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
@@ -49,18 +43,11 @@ import {
$removeAllWatermarkNodes,
} from '@lexical-core';
import { logger } from '@observability';
-import ReplyAll from '@phosphor/arrow-bend-double-up-left.svg';
-import Reply from '@phosphor/arrow-bend-up-left.svg';
-import Forward from '@phosphor/arrow-bend-up-right.svg';
-
import ChevronDown from '@phosphor/caret-down.svg';
import CaretRight from '@phosphor/caret-right.svg';
import DotsThree from '@phosphor/dots-three.svg';
import Paperclip from '@phosphor/paperclip.svg';
-import PencilSimple from '@phosphor/pencil-simple.svg';
-import Quotes from '@phosphor/quotes.svg';
-import TextAa from '@phosphor/text-aa.svg';
import Trash from '@phosphor/trash.svg';
import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { queryClient } from '@queries/client';
@@ -93,16 +80,7 @@ import type {
ApiMessage,
} from '@service-email/generated/schemas';
import { isIOS } from '@solid-primitives/platform';
-import {
- Button,
- cn,
- Dropdown,
- HoverCard,
- Layer,
- SendButton,
- Surface,
- Tooltip,
-} from '@ui';
+import { Button, cn, Layer, SendButton, Surface, Tooltip } from '@ui';
import { iosCursorScrollPlugin } from 'core/component/LexicalMarkdown/plugins/ios-cursor-scroll';
import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';
import { $addUpdateTag, $getRoot } from 'lexical';
@@ -145,7 +123,6 @@ import { FromInboxSelector } from './FromInboxSelector';
false && fileFolderDrop;
false && fileSelector;
-false && observedSize;
const getRecipientDisplayName = (item: EmailRecipient): string => {
switch (item.kind) {
@@ -157,20 +134,6 @@ const getRecipientDisplayName = (item: EmailRecipient): string => {
}
};
-// Shared constants for recipient display - used in both measurement and rendering
-const MAX_VISIBLE_RECIPIENTS = 3;
-const RECIPIENT_SEPARATOR = ',\u00A0'; // comma + non-breaking space
-const MORE_SUFFIX_TEMPLATE = '+99 more'; // worst-case for measurement
-
-// Build the display text for a recipient (used for measurement)
-const buildRecipientText = (
- prefix: string,
- displayName: string,
- showSeparator: boolean
-): string => {
- return prefix + displayName + (showSeparator ? RECIPIENT_SEPARATOR : '');
-};
-
type RecipientFieldId = 'to' | 'cc' | 'bcc';
function RecipientDropRow(props: {
@@ -222,159 +185,6 @@ function RecipientDropRow(props: {
);
}
-function TruncatedRecipientList(props: {
- toRecipients: EmailRecipient[];
- ccRecipients: EmailRecipient[];
- bccRecipients: EmailRecipient[];
- onClick: () => void;
-}) {
- let measureRef: HTMLSpanElement | undefined;
-
- const [visibleCount, setVisibleCount] = createSignal<number>(0);
- const [containerRect, setContainerRect] = createSignal<DOMRect | undefined>();
-
- // Combine all recipients into a flat list with group info for display
- const allRecipients = createMemo(() => {
- const result: { recipient: EmailRecipient; prefix: string }[] = [];
-
- // Add "to" recipients
- props.toRecipients.forEach((r, i) => {
- const prefix = i === 0 ? 'to ' : '';
- result.push({ recipient: r, prefix });
- });
-
- // Add "cc" recipients (show "cc" prefix only if no "to" recipients)
- props.ccRecipients.forEach((r, i) => {
- const prefix = i === 0 && props.toRecipients.length === 0 ? 'cc ' : '';
- result.push({ recipient: r, prefix });
- });
-
- // Add "bcc" recipients with label
- props.bccRecipients.forEach((r, i) => {
- const prefix = i === 0 ? 'bcc ' : '';
- result.push({ recipient: r, prefix });
- });
-
- return result;
- });
-
- const totalCount = createMemo(() => allRecipients().length);
-
- // Measure text width using hidden element
- const measureText = (text: string): number => {
- if (!measureRef) return 0;
- measureRef.textContent = text;
- return measureRef.offsetWidth;
- };
-
- // Calculate how many recipients fit in the container
- const calculateVisibleCount = () => {
- const width = containerRect()?.width ?? 0;
- if (width <= 0 || !measureRef) return;
-
- const recipients = allRecipients();
- if (recipients.length === 0) {
- setVisibleCount(0);
- return;
- }
-
- // Reserve space for "+N more" suffix
- const moreTextWidth = measureText(MORE_SUFFIX_TEMPLATE);
- const availableWidth = width - moreTextWidth;
-
- let usedWidth = 0;
- let count = 0;
-
- const maxRecipients = Math.min(recipients.length, MAX_VISIBLE_RECIPIENTS);
- for (let i = 0; i < maxRecipients; i++) {
- const { recipient, prefix } = recipients[i];
- const displayName = getRecipientDisplayName(recipient);
- // Show separator if not the last recipient OR if there will be hidden recipients
- const showSeparator = i < recipients.length - 1;
- const text = buildRecipientText(prefix, displayName, showSeparator);
- const textWidth = measureText(text);
-
- // Check if this recipient fits (always show at least one)
- if (usedWidth + textWidth <= availableWidth || i === 0) {
- usedWidth += textWidth;
- count++;
- } else {
- break;
- }
- }
-
- setVisibleCount(count);
- };
-
- // Recalculate visible count when size or recipients change
- createEffect(() => {
- // Track dependencies
- containerRect();
- allRecipients();
- // Use requestAnimationFrame to ensure measurement element is ready
- requestAnimationFrame(() => {
- calculateVisibleCount();
- });
- });
-
- const visibleRecipients = createMemo(() => {
- return allRecipients().slice(0, visibleCount());
- });
-
- const hiddenCount = createMemo(() => {
- return totalCount() - visibleCount();
- });
-
- return (
- <div
- use:observedSize={{ setSize: setContainerRect }}
- class="flex items-center text-sm overflow-hidden whitespace-nowrap min-w-0"
- onclick={props.onClick}
- >
- {/* Hidden measurement element - must have same font styles */}
- <span
- ref={measureRef}
- class="absolute invisible whitespace-nowrap text-sm"
- aria-hidden="true"
- />
-
- <Show
- when={totalCount() > 0}
- fallback={<span class="text-failure-ink">Recipients required</span>}
- >
- <For each={visibleRecipients()}>
- {(item, index) => (
- <>
- <HoverCard
- content={
- <div class="text-xs select-text cursor-text">
- {item.recipient.data.email}
- </div>
- }
- >
- <span class="shrink-0">
- {item.prefix}
- {getRecipientDisplayName(item.recipient)}
- </span>
- </HoverCard>
- <Show
- when={
- index() < visibleRecipients().length - 1 || hiddenCount() > 0
- }
- >
- <span>{RECIPIENT_SEPARATOR}</span>
- </Show>
- </>
- )}
- </For>
- <Show when={hiddenCount() > 0}>
- <span class="text-ink-muted shrink-0">+{hiddenCount()} more</span>
- </Show>
- </Show>
- </div>
- );
-}
-
type UndoReplySnapshot = {
threadId: string;
draftId: string;
@@ -544,9 +354,6 @@ export function BaseInput(props: {
const [showExpandedRecipients, setShowExpandedRecipients] =
createSignal<boolean>(false);
const [isDragging, setIsDragging] = createSignal<boolean>();
- const [showFormatRibbon, setShowFormatRibbon] = createSignal<boolean>(
- props.newMessage ?? false
- );
const [toRef, setToRef] = createSignal<HTMLInputElement>();
const [ccRef, setCcRef] = createSignal<HTMLInputElement>();
const [bccRef, setBccRef] = createSignal<HTMLInputElement>();
@@ -1152,7 +959,6 @@ export function BaseInput(props: {
let composeContainerRef: HTMLDivElement | undefined;
let bottomBarRef: HTMLDivElement | undefined;
useTouchOutsideToDismissKeyboard(() => composeContainerRef);
- const [isFocused, setIsFocused] = createSignal(false);
const sendEmail = async (markDone = false) => {
if (sendMutation.isPending || uploadAttachmentMutation.isPending) return;
@@ -1639,6 +1445,21 @@ export function BaseInput(props: {
isMobileDrawer() ? replySignatureHtml() : undefined;
const footerSignatureHtml = () =>
isMobileDrawer() ? undefined : replySignatureHtml();
+ const replyingToSummary = () => {
+ const recipients = [
+ ...form().recipients().to,
+ ...form().recipients().cc,
+ ...form().recipients().bcc,
+ ];
+ const firstRecipient = recipients[0];
+ const action =
+ effectiveReplyType() === 'forward' ? 'Forwarding' : 'Replying to';
+ if (!firstRecipient) return action;
+
+ const remainingCount = recipients.length - 1;
+ const suffix = remainingCount > 0 ? ` + ${remainingCount}` : '';
+ return `${action} ${getRecipientDisplayName(firstRecipient)}${suffix}`;
+ };
const mobileRecipientSelectorClass =
'min-w-0 flex-1 bg-transparent rounded-none! [&_input]:ml-0! [&_input]:min-w-0! [&_input]:text-[17px] [&_input]:leading-6 [&_input]:text-ink [&_input]:placeholder:text-ink-placeholder';
const mobileDrawerRowClass =
@@ -1748,89 +1569,18 @@ export function BaseInput(props: {
</Button>
);
- const ReplyTypeDropdown = (dropdownProps?: {
- triggerVariant?: 'ghost' | 'base';
- triggerSize?: 'sm' | 'md';
- triggerClass?: string;
- iconOnly?: boolean;
- }) => (
- <Dropdown>
- <Dropdown.Trigger
- as={Button}
- size={dropdownProps?.triggerSize ?? 'md'}
- variant={dropdownProps?.triggerVariant}
- class={dropdownProps?.triggerClass}
- noTouchResize={dropdownProps?.iconOnly}
- >
- <Switch>
- <Match when={effectiveReplyType() === 'reply'}>
- <Reply class="size-4 shrink-0" />
- <Show when={!dropdownProps?.iconOnly}>
- <span>Reply</span>
- </Show>
- </Match>
-
- <Match when={effectiveReplyType() === 'reply-all'}>
- <ReplyAll class="size-4 shrink-0" />
- <Show when={!dropdownProps?.iconOnly}>
- <span>Reply All</span>
- </Show>
- </Match>
- <Match when={effectiveReplyType() === 'forward'}>
- <Forward class="size-4 shrink-0" />
- <Show when={!dropdownProps?.iconOnly}>
- <span>Forward</span>
- </Show>
- </Match>
- </Switch>
- <ChevronDown class="size-3" />
- </Dropdown.Trigger>
- <Dropdown.Content portalScope={isMobileDrawer() ? 'local' : undefined}>
- <Dropdown.Group>
- <Dropdown.Item onSelect={() => form().setReplyType('reply')}>
- <Reply class="size-4 shrink-0" />
- <span class="flex-1 truncate">Reply</span>
- </Dropdown.Item>
- <Show
- when={
- (props.replyingTo()?.to.length ?? 0) +
- (props.replyingTo()?.cc.length ?? 0) >
- 1
- }
- >
- <Dropdown.Item onSelect={() => form().setReplyType('reply-all')}>
- <ReplyAll class="size-4 shrink-0" />
- <span class="flex-1 truncate">Reply All</span>
- </Dropdown.Item>
- </Show>
- <Dropdown.Item onSelect={() => form().setReplyType('forward')}>
- <Forward class="size-4 shrink-0" />
- <span class="flex-1 truncate">Forward</span>
- </Dropdown.Item>
- </Dropdown.Group>
- </Dropdown.Content>
- </Dropdown>
- );
-
return (
<Surface
class={cn(
'relative flex flex-col flex-1 max-w-full min-h-0',
isMobileDrawer() && 'min-h-full overflow-y-scroll overscroll-y-none',
- props.unframed ? 'rounded-none' : 'rounded-xl'
+ props.unframed ? 'rounded-lg' : 'rounded-xl'
)}
style={props.unframed ? { 'background-color': 'transparent' } : undefined}
hideBorder={props.unframed}
- onFocusOut={(e) => {
- const next = e.relatedTarget as Node | null;
- if (next && e.currentTarget.contains(next)) return;
- setIsFocused(false);
- }}
- onFocusIn={() => setIsFocused(true)}
ref={(el) => {
composeContainerRef = el;
}}
- active={isFocused()}
depth={2}
solid
>
@@ -1869,50 +1619,38 @@ export function BaseInput(props: {
when={isMobileDrawer()}
fallback={
<>
- <div class="relative min-w-0 text-sm text-ink-muted flex items-center gap-2 wrap p-2 pt-4">
+ <div
+ class={cn(
+ 'relative mb-4 min-w-0 text-sm text-ink-muted flex items-center gap-2 wrap',
+ !showExpandedRecipients() && 'py-3'
+ )}
+ >
<Show
when={showExpandedRecipients()}
fallback={
- <>
- <ReplyTypeDropdown />
- <div
- class="flex flex-1 items-center gap-1.5 min-w-0 text-sm text-ink-muted"
+ <div class="flex flex-1 min-w-0">
+ <button
+ type="button"
+ class="flex w-full min-w-0 items-center gap-2 text-sm text-ink-muted"
onClick={() => setShowExpandedRecipients(true)}
>
- <Show
- when={!isMobile()}
- fallback={
- <PencilSimple class="size-4 shrink-0 text-ink-muted ml-auto" />
- }
- >
- <TruncatedRecipientList
- toRecipients={form().recipients().to}
- ccRecipients={form().recipients().cc}
- bccRecipients={form().recipients().bcc}
- onClick={() => setShowExpandedRecipients(true)}
- />
- <Show
- when={(emailLinksQuery.data?.links.length ?? 0) > 1}
- >
- <span class="shrink-0 text-ink-extra-muted">·</span>
- <span class="min-w-0 shrink-2 truncate">
- from {activeInboxEmail()}
- </span>
- </Show>
- <PencilSimple class="size-3.5 shrink-0 text-ink-extra-muted" />
- </Show>
- </div>
- </>
+ <span class="block min-w-0 flex-1 truncate text-left">
+ {replyingToSummary()}
+ </span>
+ <CaretRight class="size-3 shrink-0 text-ink-extra-muted" />
+ </button>
+ </div>
}
>
<div class="min-w-0 w-full">
- <div class="flex items-center gap-2 min-w-0">
- <ReplyTypeDropdown />
- <div class="flex items-center gap-2 min-w-0 flex-1 py-1">
- <div class="text-sm shrink-0 text-ink-placeholder">
- from
+ <div class="flex items-center gap-2 min-w-0 border-b border-edge-muted">
+ <div class="flex items-center gap-2 min-w-0 flex-1 py-3">
+ <div class="w-14 shrink-0 text-sm text-ink-placeholder">
+ From
</div>
<FromInboxSelector
+ pill
+ class="min-w-0"
links={emailLinksQuery.data?.links ?? []}
activeLinkId={activeLinkId()}
onSelect={persistDraftOnSenderSwitch}
@@ -2199,23 +1937,10 @@ export function BaseInput(props: {
showExpandedRecipients() && 'mt-4'
)}
>
- <Show when={showFormatRibbon()}>
- <div class="flex flex-row w-full gap-2 items-center px-3 py-1.5">
- <FormatButtons
- selectionState={() => editorConfig.selection}
- onInlineFormat={(format) => {
- applyInlineFormat(editor(), format);
- }}
- onNodeFormat={(transform) => {
- applyNodeFormat(editor(), transform);
- }}
- />
- </div>
- </Show>
<div
ref={setScrollContainer}
class={cn(
- 'relative min-h-18 w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1',
+ 'relative min-h-18 w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-0 py-1',
isMobileDrawer()
? 'max-h-none flex-1 overflow-visible px-5 pt-6 pb-4'
: cn(
@@ -2311,14 +2036,13 @@ export function BaseInput(props: {
</Show>
<Show
when={
- isMobileDrawer() &&
props.replyingTo() &&
// The collapse pill above already covers this state
!(form().replyAppended() && quoteCollapsed())
}
>
<div
- class="shrink-0 pt-2 pb-1"
+ class="shrink-0 pt-1"
data-corvu-no-drag=""
onClick={(e) => e.stopPropagation()}
>
@@ -2333,11 +2057,11 @@ export function BaseInput(props: {
as={Button}
variant="ghost"
size="icon-sm"
- class="rounded-full bg-transparent"
+ class="size-5 rounded bg-transparent p-0 text-ink-extra-muted hover:text-ink-muted [&_:where(svg)]:size-5"
pressed={form().replyAppended()}
onChange={toggleQuotedText}
>
- <DotsThree class="size-4" />
+ <DotsThree />
</KToggleButton>
</Tooltip>
</div>
@@ -2375,41 +2099,13 @@ export function BaseInput(props: {
— with items-end it bled upward over the signature bar above. */}
<div
ref={bottomBarRef}
- class="shrink-0 flex flex-row w-full justify-between items-end space-x-2 px-2 pb-2 pt-1.5"
+ class="shrink-0 flex flex-row w-full justify-between items-end space-x-2 px-0 pb-0 pt-1.5"
>
<div class="flex flex-row items-center gap-1">
<div class="relative flex">
<AttachButton />
</div>
- <Button
- onclick={() => {
- setShowFormatRibbon(!showFormatRibbon());
- }}
- variant="ghost"
- tooltip="Show formatting toolbar"
- size="icon-sm"
- >
- <TextAa />
- </Button>
-
- <Tooltip
- label={
- form().replyAppended()
- ? 'Hide quoted text'
- : 'Show quoted text'
- }
- >
- <KToggleButton
- as={Button}
- size="icon-sm"
- pressed={form().replyAppended()}
- onChange={toggleQuotedText}
- >
- <Quotes />
- </KToggleButton>
- </Tooltip>
- <div aria-hidden="true" class="mx-1 h-4 w-px bg-edge-muted/70" />
<Button
onclick={deleteDraftAndReset}
tooltip={savedDraftId() ? 'Delete draft' : 'Discard'}
diff --git a/js/app/packages/block-email/component/BottomReplyButtons.tsx b/js/app/packages/block-email/component/BottomReplyButtons.tsx
index a912ad0871..e5420c6349 100644
--- a/js/app/packages/block-email/component/BottomReplyButtons.tsx
+++ b/js/app/packages/block-email/component/BottomReplyButtons.tsx
@@ -1,14 +1,14 @@
import { FloatRegionOrInline } from '@app/component/mobile/float-regions/FloatRegion';
+import { inboxIconProps } from '@core/component/inboxIcon';
+import { UserIcon } from '@core/component/UserIcon';
import { useEmail } from '@core/context/user';
import { isMobile } from '@core/mobile/isMobile';
-import ArrowBendDoubleUpLeft from '@phosphor/arrow-bend-double-up-left.svg';
import ArrowBendUpLeft from '@phosphor/arrow-bend-up-left.svg';
import ArrowBendUpRight from '@phosphor/arrow-bend-up-right.svg';
import type { ApiMessage } from '@service-email/generated/schemas';
import { createCallback } from '@solid-primitives/rootless';
import { Button, cn } from '@ui';
-import { type Component, Show } from 'solid-js';
-import { isReplyAllEligible } from '../util/recipientConversion';
+import type { Component } from 'solid-js';
import type { ReplyType } from '../util/replyType';
import { useEmailContext } from './EmailContext';
import { getEmailFormRegistry } from './EmailFormContext';
@@ -42,10 +42,7 @@ function ReplyActionButton(props: {
export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {
const ctx = useEmailContext();
const formRegistry = getEmailFormRegistry();
- const userEmail = useEmail();
-
- const shouldShowReplyAll = () =>
- isReplyAllEligible(props.lastMessage, userEmail() ?? '');
+ const currentUserEmail = useEmail();
const open = (type: ReplyType) =>
createCallback(() => {
@@ -60,6 +57,31 @@ export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {
});
});
+ const currentUserIconProps = () => {
+ const email = currentUserEmail();
+ return email ? inboxIconProps(email) : { email: '' };
+ };
+
+ if (!isMobile()) {
+ return (
+ <div class="flex w-full items-center pt-4">
+ <button
+ type="button"
+ class="flex min-w-0 flex-1 items-center gap-2 rounded-md text-left text-sm text-ink-placeholder hover:text-ink-muted"
+ onClick={open('reply-all')}
+ >
+ <UserIcon
+ {...currentUserIconProps()}
+ size="md"
+ showTooltip={false}
+ suppressClick
+ />
+ <span class="truncate">Reply...</span>
+ </button>
+ </div>
+ );
+ }
+
return (
<FloatRegionOrInline region="accessory">
<div class="w-full p-2 pb-2 pt-4 mobile:px-(--mobile-chrome-gutter) mobile:py-0">
@@ -67,15 +89,8 @@ export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {
<ReplyActionButton
icon={ArrowBendUpLeft}
label="Reply"
- onClick={open('reply')}
+ onClick={open('reply-all')}
/>
- <Show when={shouldShowReplyAll()}>
- <ReplyActionButton
- icon={ArrowBendDoubleUpLeft}
- label="Reply all"
- onClick={open('reply-all')}
- />
- </Show>
<ReplyActionButton
icon={ArrowBendUpRight}
label="Forward"
diff --git a/js/app/packages/block-email/component/CollapsedMessage.tsx b/js/app/packages/block-email/component/CollapsedMessage.tsx
index 22d655c92c..00f660f531 100644
--- a/js/app/packages/block-email/component/CollapsedMessage.tsx
+++ b/js/app/packages/block-email/component/CollapsedMessage.tsx
@@ -2,7 +2,7 @@ import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
import { useEmail } from '@core/context/user';
import type { ApiMessage } from '@service-email/generated/schemas';
import { cn } from '@ui/utils/classname';
-import { createMemo } from 'solid-js';
+import { createMemo, Show } from 'solid-js';
import { getSenderDisplayName, getSenderMacroId } from '../util/emailUser';
import { formatShortDate } from './EmailMessageTopBar';
import { EmailUserTooltip } from './EmailUserTooltip';
@@ -21,6 +21,10 @@ export function CollapsedMessage(props: CollapsedMessageProps) {
getSenderDisplayName(props.message, currentUserEmail())
);
const senderMacroId = createMemo(() => getSenderMacroId(props.message));
+ const _allRecipients = createMemo(() => [
+ ...props.message.to,
+ ...props.message.cc,
+ ]);
const senderIconProps = createMemo<UserIconProps>(() => {
const senderId = senderMacroId();
const photoUrl = props.message.from?.photo_url ?? undefined;
@@ -56,45 +60,41 @@ export function CollapsedMessage(props: CollapsedMessageProps) {
<div class="macro-message-width macro-message-padding w-full">
<div
class={cn(
- 'relative flex items-center gap-2 px-4 py-2 rounded-lg min-w-0 ring',
+ 'relative flex flex-col gap-2 p-4 rounded-lg min-w-0 ring',
props.isFocused
? 'bg-active/60 ring-edge'
: 'bg-ink-muted/2.5 hover:bg-active/40 hover:ring-edge ring-transparent'
)}
+ style={{
+ '--user-icon-width': '1rem',
+ }}
data-message-body-id={props.message.db_id}
tabIndex={0}
onClick={props.onClick}
onFocus={props.onFocus}
onKeyDown={handleKeyDown}
>
- <div
- class="shrink-0 flex justify-center items-center"
- style={{
- width: 'var(--user-icon-width)',
- height: 'var(--user-icon-width)',
- }}
- >
- <UserIcon
- {...senderIconProps()}
- isDeleted={false}
- size="fill"
- suppressClick={true}
- />
- </div>
- <div class="shrink-0 min-w-0 max-w-28">
+ <div class="flex items-center gap-2 min-w-0 text-xs">
+ <div class="shrink-0 flex justify-center items-center size-6">
+ <UserIcon
+ {...senderIconProps()}
+ isDeleted={false}
+ size="fill"
+ suppressClick={true}
+ />
+ </div>
<EmailUserTooltip recipient={props.message.from}>
- <div class="text-sm font-medium text-ink truncate cursor-default">
+ <span class="text-ink truncate cursor-default shrink-0 max-w-32">
{senderDisplay()}
- </div>
+ </span>
</EmailUserTooltip>
+ <Show when={props.message.internal_date_ts}>
+ <span class="shrink-0 text-ink-extra-muted/60 tabular-nums">
+ {formatShortDate(props.message.internal_date_ts!)}
+ </span>
+ </Show>
</div>
- <div class="flex-1 min-w-0 text-sm text-ink-muted/60 truncate">
- {snippet()}
- </div>
- <div class="shrink-0 text-xs text-ink-extra-muted tabular-nums">
- {props.message.internal_date_ts &&
- formatShortDate(props.message.internal_date_ts)}
- </div>
+ <div class="min-w-0 text-sm text-ink-muted truncate">{snippet()}</div>
</div>
</div>
</div>
diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsx
index 256867c8dc..d86279a76a 100644
--- a/js/app/packages/block-email/component/Email.tsx
+++ b/js/app/packages/block-email/component/Email.tsx
@@ -502,7 +502,7 @@ function EmailContent(props: EmailViewProps) {
onMount(() => {
registerEmailHotkeys(scopeId(), {
- replyToFocusedMessage: () => openHotkeyTarget('reply'),
+ replyToFocusedMessage: () => openHotkeyTarget('reply-all'),
forwardFocusedMessage: () => openHotkeyTarget('forward'),
blockSender: context.blockSender,
markDone: context.archiveThread,
@@ -529,7 +529,7 @@ function EmailContent(props: EmailViewProps) {
return openEmailReplyComposerForMessage({
ctx: context,
message: target.message,
- replyType: 'reply',
+ replyType: 'reply-all',
isLastMessage: target.isLastMessage,
});
}
diff --git a/js/app/packages/block-email/component/EmailMessageBody.tsx b/js/app/packages/block-email/component/EmailMessageBody.tsx
index b7a22175f3..ab7d1da69b 100644
--- a/js/app/packages/block-email/component/EmailMessageBody.tsx
+++ b/js/app/packages/block-email/component/EmailMessageBody.tsx
@@ -152,7 +152,12 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {
// and fixed-width tables scroll, so a wide signature doesn't trip the
// fit-to-width zoom below and shrink the whole message.
const signatureContain = `.macro-email-signature{max-width:100%;overflow-x:auto;overflow-wrap:anywhere;}`;
- styleEl.textContent = `img{display: var(--macro-email-img-display, initial); max-width: 100% !important; height: auto !important;}${signatureContain}${fontOverride}`;
+ // Browser default blockquote margins apply on both sides. In long email
+ // reply chains that compounds into a narrow column, so keep quote nesting
+ // as a left indent only.
+ const quoteContain =
+ 'blockquote{margin-block:0.75em!important;margin-inline-start:1.5em!important;margin-inline-end:0!important;max-width:100%!important;box-sizing:border-box;}';
+ styleEl.textContent = `img{display: var(--macro-email-img-display, initial); max-width: 100% !important; height: auto !important;}${signatureContain}${quoteContain}${fontOverride}`;
shadow.appendChild(styleEl);
const messageDiv = document.createElement('div');
messageDiv.innerHTML = source()?.mainContent ?? '';
@@ -316,7 +321,7 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {
return (
<div
- class="ph-no-capture flex flex-col pt-1 max-sm:-ml-[calc(var(--user-icon-width)+var(--message-padding-x))]"
+ class="ph-no-capture flex flex-col pt-1"
onPointerDown={() => {
if (!props.isBodyExpanded() && props.message.db_id) {
props.setExpandedMessageBody(props.message.db_id);
@@ -356,7 +361,7 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {
<Match when={true}>{host()}</Match>
</Switch>
<Show when={!showFullHTML() && hasHiddenReplyStructure()}>
- <div class="flex items-center mt-1.5">
+ <div class="flex items-center mt-1.5 mb-2">
<Button
variant="ghost"
size="icon-sm"
diff --git a/js/app/packages/block-email/component/EmailMessageTopBar.tsx b/js/app/packages/block-email/component/EmailMessageTopBar.tsx
index 61b4271911..c3f9febab0 100644
--- a/js/app/packages/block-email/component/EmailMessageTopBar.tsx
+++ b/js/app/packages/block-email/component/EmailMessageTopBar.tsx
@@ -1,9 +1,8 @@
import { useEmail } from '@core/context/user';
import type { DateValue } from '@core/util/date';
-import CaretDown from '@phosphor/caret-down.svg';
-import CaretUp from '@phosphor/caret-up.svg';
+import CaretRight from '@phosphor/caret-right.svg';
import type { ApiMessage } from '@service-email/generated/schemas';
-import { Button, Tooltip } from '@ui';
+import { Button, cn, Tooltip } from '@ui';
import {
type Accessor,
createMemo,
@@ -32,6 +31,7 @@ interface EmailMessageTopBarProps {
setShowReply: Setter<boolean>;
isLastMessage?: boolean;
hiddenActions?: EmailMessageAction[];
+ avatar?: JSX.Element;
}
interface Recipient {
@@ -71,7 +71,7 @@ export function formatShortDate(date: DateValue): string {
function RecipientChip(props: { recipient: Recipient }): JSX.Element {
return (
<EmailUserTooltip recipient={props.recipient}>
- <span class="cursor-default whitespace-nowrap">
+ <span class="cursor-default whitespace-nowrap flex">
<span class="text-ink">
{props.recipient.name ?? props.recipient.email}
</span>
@@ -91,10 +91,10 @@ function DetailRow(props: {
}): JSX.Element {
return (
<Show when={props.recipients.length > 0}>
- <div class="flex flex-row gap-3 text-sm">
- <span class="text-ink-extra-muted shrink-0 w-10 text-sm pt-0.5">
+ <div class="flex flex-row gap-3 text-xs items-center">
+ <div class="text-ink-extra-muted flex items-center shrink-0 w-10 pt-0.5">
{props.label}
- </span>
+ </div>
<div class="flex flex-row flex-wrap gap-y-1 select-text cursor-text min-w-0">
<For each={props.recipients}>
{(r, index) => (
@@ -118,7 +118,7 @@ function ExpandedDetails(props: { message: ApiMessage }): JSX.Element {
);
return (
- <div class="mt-2.5 py-3 border-y border-ink-muted/8 flex flex-col gap-1.5 text-sm">
+ <div class="mt-2.5 py-3 border-y border-ink-muted/8 flex flex-col gap-1.5 text-xs">
<DetailRow label="From" recipients={fromRecipients()} />
<DetailRow label="To" recipients={props.message.to} />
<DetailRow label="Cc" recipients={props.message.cc} />
@@ -176,20 +176,27 @@ function HeaderTopRow(props: {
]);
return (
- <div class="flex flex-row w-full items-center justify-between">
- <div class="flex flex-row items-center gap-1.5 text-sm min-w-0">
+ <div class="flex flex-row w-full items-center justify-between gap-2 text-xs min-w-0">
+ <div class="flex flex-row items-center gap-1.5 min-w-0">
<EmailUserTooltip recipient={props.message.from}>
<span class="text-ink font-medium cursor-default">
{props.senderName}
</span>
</EmailUserTooltip>
- <span class="text-ink-extra-muted text-sm truncate">
+ <span class="text-ink-extra-muted/60 truncate">
to{' '}
<CollapsedRecipientList
recipients={allRecipients()}
currentUserEmail={props.currentUserEmail}
/>
</span>
+ <Show when={props.message.internal_date_ts}>
+ <Tooltip label={formatFullDate(props.message.internal_date_ts!)}>
+ <span class="text-xs text-ink-extra-muted/60 tabular-nums cursor-default shrink-0">
+ {formatShortDate(props.message.internal_date_ts!)}
+ </span>
+ </Tooltip>
+ </Show>
<div
classList={{
'opacity-0': !props.isHovering && !props.isExpanded,
@@ -211,28 +218,24 @@ function HeaderTopRow(props: {
props.onToggle();
}}
>
- <Show when={props.isExpanded} fallback={<CaretDown />}>
- <CaretUp />
- </Show>
+ <CaretRight
+ class={cn(
+ 'size-3! text-ink-muted/30 transition-transform',
+ props.isExpanded && 'rotate-90'
+ )}
+ />
</Button>
</Tooltip>
</div>
</div>
- <div class="flex flex-row gap-3 items-center shrink-0">
+ <div class="flex flex-row items-center shrink-0">
<MessageActions
message={props.message}
- showActions={props.focused}
+ showActions={true}
setShowReply={props.setShowReply}
isLastMessage={props.isLastMessage}
hiddenActions={props.hiddenActions}
/>
- <Show when={props.message.internal_date_ts}>
- <Tooltip label={formatFullDate(props.message.internal_date_ts!)}>
- <div class="text-xs text-ink-extra-muted tabular-nums cursor-default">
- {formatShortDate(props.message.internal_date_ts!)}
- </div>
- </Tooltip>
- </Show>
</div>
</div>
);
@@ -282,17 +285,15 @@ export function EmailMessageTopBar(props: EmailMessageTopBarProps) {
return (
<div
- class="ph-no-capture pr-1.5 flex flex-col w-full"
+ class="ph-no-capture flex flex-col w-full"
style={{ 'min-height': 'var(--user-icon-width)' }}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
onClick={handleClick}
>
<Show when={props.isBodyExpanded()}>
- <div
- class="flex items-center"
- style={{ 'min-height': 'var(--user-icon-width)' }}
- >
+ <div class="flex items-center gap-2">
+ {props.avatar}
<HeaderTopRow
senderName={senderName()}
isHovering={isHovering()}
diff --git a/js/app/packages/block-email/component/FromInboxSelector.tsx b/js/app/packages/block-email/component/FromInboxSelector.tsx
index f380db3876..f8b084e98e 100644
--- a/js/app/packages/block-email/component/FromInboxSelector.tsx
+++ b/js/app/packages/block-email/component/FromInboxSelector.tsx
@@ -33,6 +33,27 @@ function FromInboxOption(props: { inbox: FromInbox }) {
);
}
+function FromInboxPill(props: { inbox: FromInbox; selectable: boolean }) {
+ const [name] = useDisplayName(emailToMacroId(props.inbox.email_address));
+ const label = () => name() || props.inbox.email_address;
+
+ return (
+ <div class="flex flex-row shrink-0 py-1 pl-2 gap-1 pr-2 overflow-hidden items-center bg-active rounded-full text-ink">
+ <UserIcon
+ {...inboxIconProps(props.inbox.email_address)}
+ photoUrl={props.inbox.photo_url ?? undefined}
+ size="sm"
+ suppressClick
+ class="shrink-0"
+ />
+ <p class="text-sm whitespace-nowrap truncate max-w-60">{label()}</p>
+ <Show when={props.selectable}>
+ <ChevronDown class="size-3 shrink-0 text-ink-muted" />
+ </Show>
+ </div>
+ );
+}
+
/**
* Lets the user pick which linked inbox a compose/reply sends from. Renders an
* identical "from" chip in every composer: the active inbox's icon, name, and
@@ -43,6 +64,7 @@ export function FromInboxSelector(props: {
activeLinkId: string | undefined;
onSelect: (linkId: string) => void;
compact?: boolean;
+ pill?: boolean;
class?: string;
portalScope?: 'local';
}) {
@@ -89,6 +111,45 @@ export function FromInboxSelector(props: {
);
}
+ if (props.pill) {
+ return (
+ <Show when={activeInbox()}>
+ {(active) => (
+ <Show
+ when={props.links.length > 1}
+ fallback={
+ <div class={props.class}>
+ <FromInboxPill inbox={active()} selectable={false} />
+ </div>
+ }
+ >
+ <Dropdown>
+ <Dropdown.Trigger
+ class={`inline-flex min-w-0 max-w-full ${props.class ?? ''}`}
+ >
+ <FromInboxPill inbox={active()} selectable={true} />
+ </Dropdown.Trigger>
+ <Dropdown.Content portalScope={props.portalScope}>
+ <Dropdown.Group>
+ <For each={sortedLinks()}>
+ {(inbox) => (
+ <Dropdown.Item onSelect={() => props.onSelect(inbox.id)}>
+ <FromInboxOption inbox={inbox} />
+ <Show when={inbox.id === props.activeLinkId}>
+ <Check class="size-3.5 shrink-0" />
+ </Show>
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ </Show>
+ )}
+ </Show>
+ );
+ }
+
return (
<Show when={activeInbox()}>
{(active) => (
diff --git a/js/app/packages/block-email/component/MessageActions.tsx b/js/app/packages/block-email/component/MessageActions.tsx
index 14251028af..92bdb78eff 100644
--- a/js/app/packages/block-email/component/MessageActions.tsx
+++ b/js/app/packages/block-email/component/MessageActions.tsx
@@ -1,7 +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 '@phosphor/arrow-bend-double-up-left.svg';
import ArrowBendUpLeft from '@phosphor/arrow-bend-up-left.svg';
import ArrowBendUpRight from '@phosphor/arrow-bend-up-right.svg';
import type { ApiMessage } from '@service-email/generated/schemas';
@@ -24,9 +21,6 @@ export function MessageActions(props: {
}) {
const ctx = useEmailContext();
const formRegistry = getEmailFormRegistry();
- const userEmail = useEmail();
- const shouldShowReplyAll = () =>
- isReplyAllEligible(props.message, userEmail() ?? '');
const canShowActions = () => {
if (!props.showActions) return false;
@@ -62,25 +56,12 @@ export function MessageActions(props: {
<Show when={!props.hiddenActions?.includes('reply')}>
<Button
class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/8"
- onClick={onChangeReplyType('reply')}
+ onClick={onChangeReplyType('reply-all')}
tooltip="Reply"
>
<ArrowBendUpLeft class="size-3.5" />
</Button>
</Show>
- <Show
- when={
- shouldShowReplyAll() && !props.hiddenActions?.includes('reply-all')
- }
- >
- <Button
- class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/8"
- onClick={onChangeReplyType('reply-all')}
- tooltip="Reply all"
- >
- <ArrowBendDoubleUpLeft class="size-3.5" />
- </Button>
- </Show>
<Show when={!props.hiddenActions?.includes('forward')}>
<Button
class="size-6 p-0 border-0 bg-transparent rounded text-ink-muted hover:text-ink hover:bg-ink-muted/8"
diff --git a/js/app/packages/block-email/component/MessageContainer.tsx b/js/app/packages/block-email/component/MessageContainer.tsx
index a1893d6336..aeaa0932fd 100644
--- a/js/app/packages/block-email/component/MessageContainer.tsx
+++ b/js/app/packages/block-email/component/MessageContainer.tsx
@@ -8,8 +8,8 @@ import { EmailMessageTopBar } from '@block-email/component/EmailMessageTopBar';
import { getSenderMacroId } from '@block-email/util/emailUser';
import { FloatingInputLoader } from '@core/component/FloatingInputLoader';
import { ImageGalleryPreview } from '@core/component/ImageGalleryPreview';
-import { Message } from '@core/component/Message';
import { toast } from '@core/component/Toast/Toast';
+import { UserIcon, type UserIconProps } from '@core/component/UserIcon';
import { VideoPreview } from '@core/component/VideoPreview';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { isMobile } from '@core/mobile/isMobile';
@@ -90,15 +90,15 @@ export function MessageContainer(props: MessageContainerProps) {
const senderMacroId = createMemo(() => getSenderMacroId(props.message));
- const isBodyExpanded = createMemo(() => {
- return props.isExpanded;
+ const senderIconProps = createMemo<UserIconProps>(() => {
+ const senderId = senderMacroId();
+ const photoUrl = props.message.from?.photo_url ?? undefined;
+ if (senderId) return { id: senderId, photoUrl };
+ return { email: props.message.from?.email ?? '', photoUrl };
});
- const isNewMessage = createMemo(() => {
- return (
- props.message.labels.find((l) => l.provider_label_id === 'UNREAD') !==
- undefined
- );
+ const isBodyExpanded = createMemo(() => {
+ return props.isExpanded;
});
// Hide attachments that are referenced in inline images
@@ -230,45 +230,45 @@ export function MessageContainer(props: MessageContainerProps) {
<div class="shrink-0 flex justify-center w-full">
<div class="macro-message-width macro-message-padding w-full">
<div
- class="relative rounded-lg overflow-hidden p-2 ring scroll-m-px"
+ class="relative rounded-lg overflow-hidden p-4 ring"
+ style={{ '--user-icon-width': '1rem' }}
classList={{
- 'bg-active/60 ring-edge': props.isFocused,
- 'bg-ink-muted/4 ring-transparent': !props.isFocused,
+ 'bg-accent ring-transparent': props.isTarget,
+ 'bg-active/60 ring-edge': !props.isTarget && props.isFocused,
+ 'bg-ink-muted/4 ring-transparent':
+ !props.isTarget && !props.isFocused,
}}
+ data-message-body-id={props.message.db_id}
+ tabIndex={0}
>
- <Message
- id={props.message.db_id ?? undefined}
- focused={false}
- isFirstMessage={true}
- isLastMessage={props.isLastMessage}
- senderId={senderMacroId()}
- senderPhotoUrl={props.message.from?.photo_url ?? undefined}
- isNewMessage={isNewMessage()}
- isTarget={props.isTarget}
- hasReplyInputBelow={true}
- hideConnectors
- disableHoverBackground
- hasThreadChildren={showInlineReplyArea()}
- >
- <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>
+ <div class="flex flex-col min-w-0 gap-2">
+ <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
+ }
+ avatar={
+ <div class="shrink-0 flex justify-center items-center size-6">
+ <UserIcon
+ {...senderIconProps()}
+ isDeleted={false}
+ size="fill"
+ suppressClick={true}
+ />
+ </div>
+ }
+ />
+ <div class="ph-no-capture text-sm text-ink pr-4">
<EmailMessageBody
message={props.message}
personalSenders={context.messages.personalSenders}
@@ -280,7 +280,7 @@ export function MessageContainer(props: MessageContainerProps) {
isFirstMessageInThread={props.isFirstMessage}
isFocused={props.isFocused}
/>
- </Message.Body>
+ </div>
{/* Image attachments */}
<Show when={imageAttachmentsWithSfs().length > 0}>
<div class="flex flex-wrap gap-2 mt-2">
@@ -354,31 +354,33 @@ export function MessageContainer(props: MessageContainerProps) {
</For>
</div>
</Show>
- </Message>
+ </div>
<Show when={showInlineReplyArea()}>
- <div class={cn('relative border-t border-edge-muted')}>
+ <div class={cn('relative -mx-4 mb-0 border-t border-edge-muted')}>
<Show when={props.isLastMessage && !isMobile()}>
<FloatingInputLoader
isLoading={context.query.isFetching}
loadingText="Loading messages"
/>
</Show>
- <Switch>
- <Match when={showInlineReplyInput()}>
- <EmailInput
- replyingTo={() => props.message}
- setShowReply={setShowReply}
- draft={draftChild()}
- markdownDomRef={
- props.isLastMessage ? props.markdownDomRef : undefined
- }
- unframed
- />
- </Match>
- <Match when={props.isLastMessage && !isMobile()}>
- <BottomReplyButtons lastMessage={props.message} />
- </Match>
- </Switch>
+ <div class="px-4">
+ <Switch>
+ <Match when={showInlineReplyInput()}>
+ <EmailInput
+ replyingTo={() => props.message}
+ setShowReply={setShowReply}
+ draft={draftChild()}
+ markdownDomRef={
+ props.isLastMessage ? props.markdownDomRef : undefined
+ }
+ unframed
+ />
+ </Match>
+ <Match when={props.isLastMessage && !isMobile()}>
+ <BottomReplyButtons lastMessage={props.message} />
+ </Match>
+ </Switch>
+ </div>
</div>
</Show>
</div>
diff --git a/js/app/packages/block-email/component/createEmailFormState.ts b/js/app/packages/block-email/component/createEmailFormState.ts
index d097403c3c..5fcf13c12a 100644
--- a/js/app/packages/block-email/component/createEmailFormState.ts
+++ b/js/app/packages/block-email/component/createEmailFormState.ts
@@ -68,7 +68,7 @@ const EMPTY_FORM_STATE: EmailFormState = {
cc: [],
bcc: [],
},
- replyType: 'reply',
+ replyType: 'reply-all',
withQuotedText: false,
subject: '',
markdownBody: '',
diff --git a/js/app/packages/block-email/util/prepareEmailBody.ts b/js/app/packages/block-email/util/prepareEmailBody.ts
index b0b5d0eabb..75ef2f8915 100644
--- a/js/app/packages/block-email/util/prepareEmailBody.ts
+++ b/js/app/packages/block-email/util/prepareEmailBody.ts
@@ -351,7 +351,7 @@ function getAppendedReplyElement(
styleTags?.forEach((style) => {
quote.appendChild(style);
});
- quote.appendChild(innerDom.body);
+ quote.append(...Array.from(innerDom.body.childNodes));
}
wrapper.appendChild(quote);