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
style(email): email input hk fixes and starting mobile drawer (#4580)
Seamusa07434749a6c
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsxindex 878b7ddc3c..75553a5e19 100644--- a/js/app/packages/block-email/component/BaseInput.tsx+++ b/js/app/packages/block-email/component/BaseInput.tsx@@ -54,12 +54,15 @@ 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 ClockIcon from '@phosphor/clock.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 XIcon from '@phosphor/x.svg';import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';import { queryClient } from '@queries/client';import {@@ -453,6 +456,9 @@ export function BaseInput(props: {setShowReply?: Setter<boolean>;markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;unframed?: boolean;+ mobileDrawer?: {+ onClose: () => void;+ };}) {const ctx = useEmailContext();const form = createMemo(() => {@@ -981,6 +987,26 @@ export function BaseInput(props: {));+ createEffect(() => {+ const requestMessageId = ctx.replyRequest.messageId();+ const requestReplyType = ctx.replyRequest.replyType();+ const currentMessageId = replyingToDbId();++ if (+ !requestMessageId ||+ !requestReplyType ||+ requestMessageId !== currentMessageId+ ) {+ return;+ }++ if (form().replyType() !== requestReplyType) {+ form().setReplyType(requestReplyType);+ }+ form().setShouldFocusInput(true);+ ctx.replyRequest.clear();+ });+const handleChipDragStart = (field: 'to' | 'cc' | 'bcc',recipient: EmailRecipient,@@ -1528,28 +1554,105 @@ export function BaseInput(props: {);const hasBodyText = () => bodyMacro().trim().length > 0;+ const isMobileDrawer = () => props.mobileDrawer !== undefined;+ const sendActionHidden = () =>+ isMobile() &&+ !hasBodyText() &&+ // Forwards carry the quoted thread as content, so send is available without typing anything.+ effectiveReplyType() !== 'forward';+ const sendActionDisabled = () =>+ uploadAttachmentMutation.isPending ||+ sendMutation.isPending ||+ !!form().sendTime();+ const scheduleSendDisabled = () =>+ form().recipients().to.length === 0 &&+ form().recipients().cc.length === 0 &&+ form().recipients().bcc.length === 0;+ const scrollAreaSignatureHtml = () =>+ isMobileDrawer() ? replySignatureHtml() : undefined;+ const footerSignatureHtml = () =>+ isMobileDrawer() ? undefined : replySignatureHtml();+ const mobileRecipientSelectorClass =+ 'min-w-0 flex-1 bg-transparent rounded-none! [&_input]:ml-0! [&_input]:basis-full! [&_input]:w-full! [&_input]:min-w-28! [&_input]:text-[17px] [&_input]:leading-6 [&_input]:text-ink [&_input]:placeholder:text-ink-placeholder';+ const mobileDrawerRowClass =+ 'w-full gap-2 min-h-16 border-b border-edge-muted/70 focus-within:border-accent';++ const toggleQuotedText = () => {+ const replyingTo = props.replyingTo();+ if (!replyingTo) return;++ const currentlyAppended = form().replyAppended();+ form().setReplyAppended(!currentlyAppended);- const ReplyTypeDropdown = () => (+ editor()?.dispatchCommand(TOGGLE_APPEND_EMAIL_THREAD_COMMAND, {+ replyingTo,+ replyType: effectiveReplyType(),+ visible: !currentlyAppended,+ });++ editor()?.update(() => {+ $getRoot().getFirstChild()?.selectStart();+ });+ };++ const AttachButton = (buttonProps?: {+ variant?: 'ghost' | 'base';+ class?: string;+ }) => (+ <Button+ ref={(el) =>+ fileSelector(el, () => ({+ multiple: true,+ onSelect: handleAddAttachments,+ }))+ }+ size="icon-sm"+ variant={buttonProps?.variant}+ class={buttonProps?.class}+ tooltip="Attach"+ >+ <Paperclip />+ </Button>+ );++ const ReplyTypeDropdown = (dropdownProps?: {+ triggerVariant?: 'ghost' | 'base';+ triggerSize?: 'sm' | 'md';+ triggerClass?: string;+ iconOnly?: boolean;+ }) => (<Dropdown>- <Dropdown.Trigger as={Button} size="md">+ <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" />- <span>Reply</span>+ <Show when={!dropdownProps?.iconOnly}>+ <span>Reply</span>+ </Show></Match><Match when={effectiveReplyType() === 'reply-all'}><ReplyAll class="size-4 shrink-0" />- <span>Reply All</span>+ <Show when={!dropdownProps?.iconOnly}>+ <span>Reply All</span>+ </Show></Match><Match when={effectiveReplyType() === 'forward'}><Forward class="size-4 shrink-0" />- <span>Forward</span>+ <Show when={!dropdownProps?.iconOnly}>+ <span>Forward</span>+ </Show></Match></Switch><ChevronDown class="size-3" /></Dropdown.Trigger>- <Dropdown.Content>+ <Dropdown.Content portalScope={isMobileDrawer() ? 'local' : undefined}><Dropdown.Group><Dropdown.Item onSelect={() => form().setReplyType('reply')}><Reply class="size-4 shrink-0" />@@ -1576,10 +1679,70 @@ export function BaseInput(props: {</Dropdown>);+ const MobileOverflowMenu = () => (+ <Dropdown>+ <Dropdown.Trigger+ as={Button}+ variant="ghost"+ size="icon-sm"+ class="rounded-full border border-edge-muted/70 bg-transparent"+ tooltip="More"+ >+ <DotsThree class="size-4" />+ </Dropdown.Trigger>+ <Dropdown.Content portalScope="local" class="min-w-44">+ <Dropdown.Group>+ <Show when={ENABLE_EMAIL_SCHEDULED_SEND && !sendActionHidden()}>+ <EmailDateSelector+ sendTime={form().sendTime() ?? null}+ onSendTimeChange={handleSendTimeChange}+ disabled={scheduleSendDisabled()}+ disablePortal={isMobile()}+ trigger={(state) => (+ <div+ aria-disabled={scheduleSendDisabled()}+ class={cn(+ 'group rounded-lg w-full min-w-44 flex items-center gap-1.5 p-1.5 px-2 text-left font-normal text-sm cursor-default outline-none hover:bg-ink/5 group-data-[expanded]/date-selector-trigger:bg-ink/5',+ scheduleSendDisabled() &&+ 'opacity-50 cursor-not-allowed hover:bg-transparent'+ )}+ >+ <ClockIcon+ class={cn(+ 'size-4 shrink-0',+ state.selectedDate && 'text-accent'+ )}+ />+ <span class="flex-1 truncate">Schedule send</span>+ <Show when={state.formattedDate}>+ {(date) => (+ <span class="max-w-20 truncate text-xs text-ink-extra-muted">+ {date()}+ </span>+ )}+ </Show>+ </div>+ )}+ />+ </Show>+ <Dropdown.Item+ onSelect={() => setShowFormatRibbon(!showFormatRibbon())}+ >+ <TextAa class="size-4 shrink-0" />+ <span class="flex-1 truncate">+ {showFormatRibbon() ? 'Hide formatting' : 'Show formatting'}+ </span>+ </Dropdown.Item>+ </Dropdown.Group>+ </Dropdown.Content>+ </Dropdown>+ );+return (<Surfaceclass={cn(- 'relative flex flex-col flex-1 max-w-full',+ 'relative flex flex-col flex-1 max-w-full min-h-0',+ isMobileDrawer() && 'h-full',props.unframed ? 'rounded-none' : 'rounded-xl')}style={props.unframed ? { 'background-color': 'transparent' } : undefined}@@ -1597,190 +1760,360 @@ export function BaseInput(props: {depth={2}solid>- <div- class={cn(- 'relative min-w-0 text-sm text-ink-muted flex items-center gap-2 wrap p-2 pt-4'- )}- >- <Show- when={showExpandedRecipients()}- fallback={- <>- <ReplyTypeDropdown />- <div- class="flex flex-1 items-center gap-1.5 min-w-0 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>- </>- }+ <Show when={props.mobileDrawer}>+ <div+ data-corvu-no-drag=""+ class="shrink-0 h-12 px-3 flex items-center justify-between">- <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>- <FromInboxSelector- links={emailLinksQuery.data?.links ?? []}- activeLinkId={activeLinkId()}- onSelect={persistDraftOnSenderSwitch}- />- </div>- <div class="flex items-center ml-auto shrink-0">- <Show when={!showCc()}>- <Button- size="sm"- class="rounded-lg"- onClick={() => {- setShowCc(true);- queueMicrotask(() => ccRef()?.focus());- }}- >- Cc- </Button>- </Show>- <Show when={!showBcc()}>- <Button- size="sm"- class="rounded-lg"- onClick={() => {- setShowBcc(true);- queueMicrotask(() => bccRef()?.focus());- }}+ <div class="flex items-center gap-1 min-w-0">+ <Button+ variant="ghost"+ size="icon-sm"+ class="rounded-full border border-edge-muted/70 bg-transparent"+ tooltip={savedDraftId() ? 'Delete draft' : 'Discard draft'}+ onClick={deleteDraftAndReset}+ >+ <XIcon class="size-4" />+ </Button>+ </div>+ <div class="ml-auto flex items-center gap-1">+ <AttachButton+ variant="ghost"+ class="rounded-full border border-edge-muted/70 bg-transparent"+ />+ <MobileOverflowMenu />+ <SendButton+ disabled={sendActionDisabled() || sendActionHidden()}+ pending={sendMutation.isPending}+ onClick={() => sendEmail()}+ />+ </div>+ </div>+ </Show>+ <Show+ when={isMobileDrawer()}+ fallback={+ <>+ <div class="relative min-w-0 text-sm text-ink-muted flex items-center gap-2 wrap p-2 pt-4">+ <Show+ when={showExpandedRecipients()}+ fallback={+ <>+ <ReplyTypeDropdown />+ <div+ class="flex flex-1 items-center gap-1.5 min-w-0 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>+ </>+ }+ >+ <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>+ <FromInboxSelector+ links={emailLinksQuery.data?.links ?? []}+ activeLinkId={activeLinkId()}+ onSelect={persistDraftOnSenderSwitch}+ />+ </div>+ <div class="flex items-center ml-auto shrink-0">+ <Show when={!showCc()}>+ <Button+ size="sm"+ class="rounded-lg"+ onClick={() => {+ setShowCc(true);+ queueMicrotask(() => ccRef()?.focus());+ }}+ >+ Cc+ </Button>+ </Show>+ <Show when={!showBcc()}>+ <Button+ size="sm"+ class="rounded-lg"+ onClick={() => {+ setShowBcc(true);+ queueMicrotask(() => bccRef()?.focus());+ }}+ >+ Bcc+ </Button>+ </Show>+ </div>+ </div>++ <RecipientDropRow+ field="to"+ class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"+ dragState={recipientDragState}+ onDrop={handleRecipientDrop}>- Bcc- </Button>- </Show>- </div>+ <div class="w-14 shrink-0 text-sm text-ink-placeholder">+ To+ </div>+ <RecipientSelector<EmailRecipient['kind']>+ class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"+ inputRef={setToRef}+ options={ctx.recipientOptions}+ selfEmail={activeInboxEmail()}+ selectedOptions={form().recipients().to}+ setSelectedOptions={withDraftSave((v) =>+ form().setRecipients('to', v)+ )}+ triggerMode="input"+ hideBorder+ noPadding+ onChipDragStart={(option, e) =>+ handleChipDragStart('to', option, e)+ }+ onChipDragEnd={handleChipDragEnd}+ />+ </RecipientDropRow>+ {/* Expanded CC */}+ <Show when={showCc() || form().recipients().cc.length > 0}>+ <RecipientDropRow+ field="cc"+ class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"+ dragState={recipientDragState}+ onDrop={handleRecipientDrop}+ >+ <div class="w-14 shrink-0 text-sm text-ink-placeholder">+ Cc+ </div>+ <RecipientSelector<EmailRecipient['kind']>+ class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"+ inputRef={setCcRef}+ options={ctx.recipientOptions}+ selfEmail={activeInboxEmail()}+ selectedOptions={form().recipients().cc}+ setSelectedOptions={withDraftSave((v) =>+ form().setRecipients('cc', v)+ )}+ triggerMode="input"+ hideBorder+ noPadding+ onChipDragStart={(option, e) =>+ handleChipDragStart('cc', option, e)+ }+ onChipDragEnd={handleChipDragEnd}+ />+ </RecipientDropRow>+ </Show>+ {/* Expanded BCC */}+ <Show when={showBcc() || form().recipients().bcc.length > 0}>+ <RecipientDropRow+ field="bcc"+ class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"+ dragState={recipientDragState}+ onDrop={handleRecipientDrop}+ >+ <div class="w-14 shrink-0 text-sm text-ink-placeholder">+ Bcc+ </div>+ <RecipientSelector<EmailRecipient['kind']>+ class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"+ inputRef={setBccRef}+ options={ctx.recipientOptions}+ selfEmail={activeInboxEmail()}+ selectedOptions={form().recipients().bcc}+ setSelectedOptions={withDraftSave((v) =>+ form().setRecipients('bcc', v)+ )}+ triggerMode="input"+ hideBorder+ noPadding+ onChipDragStart={(option, e) =>+ handleChipDragStart('bcc', option, e)+ }+ onChipDragEnd={handleChipDragEnd}+ />+ </RecipientDropRow>+ </Show>+ </div>+ </Show></div>+ <div+ class={cn(+ 'flex-row items-center',+ props.isEditingExisting || props.newMessage ? 'flex' : 'hidden'+ )}+ >+ <div class="text-sm min-w-16 pl-4">Subject</div>+ <input+ type="text"+ class="flex-1 text-sm bg-transparent outline-none border-0 px-3 py-1"+ value={form().subject()}+ onInput={(e) => {+ form().setSubject(e.currentTarget.value);+ scheduleDraftSave();+ }}+ placeholder="Subject"+ />+ </div>+ </>+ }+ >+ <div class="relative min-w-0 text-[17px] leading-6 text-ink-muted px-5 pt-1">+ <RecipientDropRow+ field="to"+ class={cn(mobileDrawerRowClass, 'items-start py-2')}+ dragState={recipientDragState}+ onDrop={handleRecipientDrop}+ >+ <ReplyTypeDropdown+ triggerVariant="ghost"+ triggerSize="sm"+ triggerClass="mt-0 h-[30px] shrink-0 rounded-full border border-edge-muted/70 bg-transparent px-2"+ iconOnly+ />+ <RecipientSelector<EmailRecipient['kind']>+ class={mobileRecipientSelectorClass}+ inputRef={setToRef}+ options={ctx.recipientOptions}+ selfEmail={activeInboxEmail()}+ selectedOptions={form().recipients().to}+ setSelectedOptions={withDraftSave((v) =>+ form().setRecipients('to', v)+ )}+ triggerMode="input"+ hideBorder+ noPadding+ onChipDragStart={(option, e) =>+ handleChipDragStart('to', option, e)+ }+ onChipDragEnd={handleChipDragEnd}+ />+ </RecipientDropRow>+ <div+ class="min-h-14 border-b border-edge-muted/70 flex items-center min-w-0"+ data-corvu-no-drag=""+ >+ <button+ type="button"+ class="shrink-0 text-left text-ink-placeholder"+ onClick={() => {+ setShowCc(true);+ setShowBcc(true);+ queueMicrotask(() => ccRef()?.focus());+ }}+ >+ Cc/Bcc+ </button>+ <span class="shrink-0 text-ink-placeholder">, From: </span>+ <FromInboxSelector+ compact+ class="min-w-0 truncate text-ink-muted"+ links={emailLinksQuery.data?.links ?? []}+ activeLinkId={activeLinkId()}+ onSelect={persistDraftOnSenderSwitch}+ />+ </div>++ <Show when={showCc() || form().recipients().cc.length > 0}><RecipientDropRow- field="to"- class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"+ field="cc"+ class={cn(mobileDrawerRowClass, 'items-center py-2')}dragState={recipientDragState}onDrop={handleRecipientDrop}>- <div class="w-14 shrink-0 text-sm text-ink-placeholder">To</div>+ <div class="shrink-0 text-ink-placeholder">Cc:</div><RecipientSelector<EmailRecipient['kind']>- class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"- inputRef={setToRef}+ class={mobileRecipientSelectorClass}+ inputRef={setCcRef}options={ctx.recipientOptions}selfEmail={activeInboxEmail()}- selectedOptions={form().recipients().to}+ selectedOptions={form().recipients().cc}setSelectedOptions={withDraftSave((v) =>- form().setRecipients('to', v)+ form().setRecipients('cc', v))}triggerMode="input"hideBordernoPaddingonChipDragStart={(option, e) =>- handleChipDragStart('to', option, e)+ handleChipDragStart('cc', option, e)}onChipDragEnd={handleChipDragEnd}/></RecipientDropRow>- {/* Expanded CC */}- <Show when={showCc() || form().recipients().cc.length > 0}>- <RecipientDropRow- field="cc"- class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"- dragState={recipientDragState}- onDrop={handleRecipientDrop}- >- <div class="w-14 shrink-0 text-sm text-ink-placeholder">Cc</div>- <RecipientSelector<EmailRecipient['kind']>- class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"- inputRef={setCcRef}- options={ctx.recipientOptions}- selfEmail={activeInboxEmail()}- selectedOptions={form().recipients().cc}- setSelectedOptions={withDraftSave((v) =>- form().setRecipients('cc', v)- )}- triggerMode="input"- hideBorder- noPadding- onChipDragStart={(option, e) =>- handleChipDragStart('cc', option, e)- }- onChipDragEnd={handleChipDragEnd}- />- </RecipientDropRow>- </Show>- {/* Expanded BCC */}- <Show when={showBcc() || form().recipients().bcc.length > 0}>- <RecipientDropRow- field="bcc"- class="w-full gap-2 py-3 border-b border-edge-muted focus-within:border-accent items-center"- dragState={recipientDragState}- onDrop={handleRecipientDrop}- >- <div class="w-14 shrink-0 text-sm text-ink-placeholder">- Bcc- </div>- <RecipientSelector<EmailRecipient['kind']>- class="min-w-0 bg-transparent rounded-none! [&_input]:ml-0!"- inputRef={setBccRef}- options={ctx.recipientOptions}- selfEmail={activeInboxEmail()}- selectedOptions={form().recipients().bcc}- setSelectedOptions={withDraftSave((v) =>- form().setRecipients('bcc', v)- )}- triggerMode="input"- hideBorder- noPadding- onChipDragStart={(option, e) =>- handleChipDragStart('bcc', option, e)- }- onChipDragEnd={handleChipDragEnd}- />- </RecipientDropRow>- </Show>+ </Show>++ <Show when={showBcc() || form().recipients().bcc.length > 0}>+ <RecipientDropRow+ field="bcc"+ class={cn(mobileDrawerRowClass, 'items-center py-2')}+ dragState={recipientDragState}+ onDrop={handleRecipientDrop}+ >+ <div class="shrink-0 text-ink-placeholder">Bcc:</div>+ <RecipientSelector<EmailRecipient['kind']>+ class={mobileRecipientSelectorClass}+ inputRef={setBccRef}+ options={ctx.recipientOptions}+ selfEmail={activeInboxEmail()}+ selectedOptions={form().recipients().bcc}+ setSelectedOptions={withDraftSave((v) =>+ form().setRecipients('bcc', v)+ )}+ triggerMode="input"+ hideBorder+ noPadding+ onChipDragStart={(option, e) =>+ handleChipDragStart('bcc', option, e)+ }+ onChipDragEnd={handleChipDragEnd}+ />+ </RecipientDropRow>+ </Show>++ <div class="min-h-14 border-b border-edge-muted/70 flex items-center">+ <input+ type="text"+ class="w-full bg-transparent outline-none border-0 text-[17px] leading-6 text-ink placeholder:text-ink-placeholder"+ value={form().subject()}+ onInput={(e) => {+ form().setSubject(e.currentTarget.value);+ scheduleDraftSave();+ }}+ placeholder="Subject:"+ /></div>- </Show>- </div>- <div- class={cn(- 'flex-row items-center',- props.isEditingExisting || props.newMessage ? 'flex' : 'hidden'- )}- >- <div class="text-sm min-w-16 pl-4">Subject</div>- <input- type="text"- class="flex-1 text-sm bg-transparent outline-none border-0 px-3 py-1"- value={form().subject()}- onInput={(e) => {- form().setSubject(e.currentTarget.value);- scheduleDraftSave();- }}- placeholder="Subject"- />- </div>+ </div>+ </Show><divclass={cn(- 'size-full flex flex-col',+ isMobileDrawer()+ ? 'relative flex-1 flex flex-col min-h-0'+ : 'size-full flex flex-col min-h-0',showExpandedRecipients() && 'mt-4')}>@@ -1799,7 +2132,12 @@ export function BaseInput(props: {</Show><divref={setScrollContainer}- class="relative min-h-18 max-h-[calc(60*var(--dvh,1dvh))] mobile:max-h-[calc(32*var(--dvh,1dvh))] overflow-y-auto w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1"+ class={cn(+ 'relative min-h-18 max-h-[calc(60*var(--dvh,1dvh))] overflow-y-auto w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1',+ isMobileDrawer()+ ? 'mobile:max-h-none flex-1 min-h-0 px-5 pt-6 pb-4'+ : 'mobile:max-h-[calc(32*var(--dvh,1dvh))]'+ )}onclick={() => {editor()?.focus();}}@@ -1838,16 +2176,47 @@ export function BaseInput(props: {<MarkdownShellconfig={editorConfig}class={cn(- 'ph-no-capture cursor-text text-sm wrap-break-word text-ink h-auto overflow-visible',+ 'ph-no-capture cursor-text wrap-break-word text-ink h-auto overflow-visible',+ isMobileDrawer() ? 'text-[17px] leading-6' : 'text-sm',isDragging() && 'blur')}disabled={sendMutation.isPending}initialValue={initialHtml() ? undefined : props.preloadedBody}- placeholder="Reply — @mention to share or cc people"+ placeholder={+ isMobileDrawer()+ ? 'Use `@` to reference files'+ : 'Reply — @mention to share or cc people'+ }portalScope="split"refFn={(el) => props.markdownDomRef?.(el)}onConnect={handleEditorConnect}/>+ <Show when={isMobileDrawer() && props.replyingTo()}>+ <div+ class="shrink-0 pt-2 pb-1"+ data-corvu-no-drag=""+ onClick={(e) => e.stopPropagation()}+ >+ <Tooltip+ label={+ form().replyAppended()+ ? 'Hide quoted text'+ : 'Show quoted text'+ }+ >+ <KToggleButton+ as={Button}+ variant="ghost"+ size="icon-sm"+ class="rounded-full bg-transparent"+ pressed={form().replyAppended()}+ onChange={toggleQuotedText}+ >+ <DotsThree class="size-4" />+ </KToggleButton>+ </Tooltip>+ </div>+ </Show><Show when={!hasPaidAccess()}><div class="text-ink/50 mt-[1lh]" data-watermark><MacroSignatureButton />@@ -1897,120 +2266,92 @@ export function BaseInput(props: {)}</For></div>+ <Show when={scrollAreaSignatureHtml()}>+ {(html) => (+ <SignaturePreview+ html={html()}+ onDismiss={() => setIncludeSignature(false)}+ />+ )}+ </Show></div>- <Show when={replySignatureHtml()}>- {(html) => (- <SignaturePreview- html={html()}- onDismiss={() => setIncludeSignature(false)}- />- )}- </Show>- {/* No fixed height: the send button (size-7.5) is taller than the icon- buttons, and a fixed h-9 minus the vertical padding left it 4px short- — with items-end it bled upward over the signature bar above. */}- <div class="flex flex-row w-full justify-between items-end px-2 pb-2 pt-1.5 space-x-2">- <div class="flex flex-row items-center gap-1">- <div class="relative flex">+ <Show when={!isMobileDrawer()}>+ <Show when={footerSignatureHtml()}>+ {(html) => (+ <SignaturePreview+ html={html()}+ onDismiss={() => setIncludeSignature(false)}+ />+ )}+ </Show>+ {/* No fixed height: the send button (size-7.5) is taller than the icon+ buttons, and a fixed h-9 minus the vertical padding left it 4px short+ — with items-end it bled upward over the signature bar above. */}+ <div class="shrink-0 flex flex-row w-full justify-between items-end space-x-2 px-2 pb-2 pt-1.5">+ <div class="flex flex-row items-center gap-1">+ <div class="relative flex">+ <AttachButton />+ </div>+<Button- ref={(el) =>- fileSelector(el, () => ({- multiple: true,- onSelect: handleAddAttachments,- }))- }+ onclick={() => {+ setShowFormatRibbon(!showFormatRibbon());+ }}+ variant="ghost"+ tooltip="Show formatting toolbar"size="icon-sm"- tooltip="Attach">- <Paperclip />+ <TextAa /></Button>- </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}+ <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'}size="icon-sm"- pressed={form().replyAppended()}- onChange={() => {- const replyingToID = props.replyingTo()?.replying_to_id;- if (!replyingToID) return;-- const currentlyAppended = form().replyAppended();- form().setReplyAppended(!currentlyAppended);-- editor()?.dispatchCommand(- TOGGLE_APPEND_EMAIL_THREAD_COMMAND,- {- replyingTo: props.replyingTo(),- replyType: effectiveReplyType(),- visible: !currentlyAppended,- }- );-- editor()?.update(() => {- $getRoot().getFirstChild()?.selectStart();- });- }}>- <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'}- size="icon-sm"- >- <Trash />- </Button>- </div>+ <Trash />+ </Button>+ </div>- <div class="flex flex-row items-center gap-1">- <Show when={ENABLE_EMAIL_SCHEDULED_SEND}>- <EmailDateSelector- sendTime={form().sendTime() ?? null}- onSendTimeChange={handleSendTimeChange}+ <div class="flex flex-row items-center gap-1">+ <Show when={ENABLE_EMAIL_SCHEDULED_SEND && !sendActionHidden()}>+ <EmailDateSelector+ sendTime={form().sendTime() ?? null}+ onSendTimeChange={handleSendTimeChange}+ disabled={scheduleSendDisabled()}+ disablePortal={isMobile()}+ />+ </Show>+ <SendButtondisabled={- form().recipients().to.length === 0 &&- form().recipients().cc.length === 0 &&- form().recipients().bcc.length === 0+ uploadAttachmentMutation.isPending ||+ sendMutation.isPending ||+ !!form().sendTime()}- disablePortal={isMobile()}+ pending={sendMutation.isPending}+ hidden={sendActionHidden()}+ onClick={() => sendEmail()}/>- </Show>- <SendButton- disabled={- uploadAttachmentMutation.isPending ||- sendMutation.isPending ||- !!form().sendTime()- }- pending={sendMutation.isPending}- hidden={- isMobile() &&- !hasBodyText() &&- // Forwards carry the quoted thread as content, so send is- // available without typing anything.- effectiveReplyType() !== 'forward'- }- onClick={() => sendEmail()}- />+ </div></div>- </div>+ </Show></div></Surface>);diff --git a/js/app/packages/block-email/component/BottomReplyButtons.tsx b/js/app/packages/block-email/component/BottomReplyButtons.tsxindex ad21d4ffef..a912ad0871 100644--- a/js/app/packages/block-email/component/BottomReplyButtons.tsx+++ b/js/app/packages/block-email/component/BottomReplyButtons.tsx@@ -12,6 +12,7 @@ import { isReplyAllEligible } from '../util/recipientConversion';import type { ReplyType } from '../util/replyType';import { useEmailContext } from './EmailContext';import { getEmailFormRegistry } from './EmailFormContext';+import { openEmailReplyComposerForMessage } from './emailReplyActions';function ReplyActionButton(props: {icon: Component<{ class?: string }>;@@ -50,13 +51,13 @@ export function BottomReplyButtons(props: { lastMessage: ApiMessage }) {createCallback(() => {const messageId = props.lastMessage.db_id;if (!messageId) return;- const form = formRegistry.getOrInit({- type: 'replying_to',- messageID: messageId,+ openEmailReplyComposerForMessage({+ ctx,+ formRegistry,+ message: props.lastMessage,+ replyType: type,+ isLastMessage: true,});- form.setReplyType(type);- form.setShouldFocusInput(true);- ctx.messages.setBottomReplyOpen(true);});return (diff --git a/js/app/packages/block-email/component/CollapsedMessage.tsx b/js/app/packages/block-email/component/CollapsedMessage.tsxindex 87accd7605..22d655c92c 100644--- a/js/app/packages/block-email/component/CollapsedMessage.tsx+++ b/js/app/packages/block-email/component/CollapsedMessage.tsx@@ -11,6 +11,7 @@ interface CollapsedMessageProps {message: ApiMessage;isFocused: boolean;onClick: () => void;+ onFocus?: () => void;}export function CollapsedMessage(props: CollapsedMessageProps) {@@ -45,6 +46,7 @@ export function CollapsedMessage(props: CollapsedMessageProps) {const handleKeyDown = (e: KeyboardEvent) => {if (e.key === 'Enter') {e.preventDefault();+ e.stopPropagation();props.onClick();}};@@ -62,6 +64,7 @@ export function CollapsedMessage(props: CollapsedMessageProps) {data-message-body-id={props.message.db_id}tabIndex={0}onClick={props.onClick}+ onFocus={props.onFocus}onKeyDown={handleKeyDown}><divdiff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsxindex ce0e5f2094..256867c8dc 100644--- a/js/app/packages/block-email/component/Email.tsx+++ b/js/app/packages/block-email/component/Email.tsx@@ -7,9 +7,7 @@ import {EmailProvider,useEmailContext,} from '@block-email/component/EmailContext';-import { EmailInput } from '@block-email/component/EmailInput';import { CustomScrollbar } from '@core/component/CustomScrollbar';-import { FloatingInputLoader } from '@core/component/FloatingInputLoader';import { useUserContext } from '@core/context/user';import { TOKENS } from '@core/hotkey/tokens';import { registerScopeSignalHotkey } from '@core/hotkey/utils';@@ -23,7 +21,7 @@ import { AnimatedTaskIcon } from '@icon/wide-task';import { buildMentionMarkdownString } from '@lexical-core';import type { ApiMessage } from '@service-email/generated/schemas';import { createCallback } from '@solid-primitives/rootless';-import { Button, cn } from '@ui';+import { Button } from '@ui';import {type Accessor,createEffect,@@ -37,11 +35,14 @@ import {} from 'solid-js';import { isScrollingToMessage } from '../signal/scrollState';import { registerEmailHotkeys } from '../util/emailHotkeys';+import type { ReplyType } from '../util/replyType';import { scrollToMessage } from '../util/scrollToMessage';import { BottomReplyButtons } from './BottomReplyButtons';import { EmailFormContextProvider } from './EmailFormContext';import { EmailParticipants } from './EmailParticipants';+import { openEmailReplyComposerForMessage } from './emailReplyActions';import { MessageList } from './MessageList';+import { MobileEmailComposeDrawer } from './MobileEmailComposeDrawer';import { ModalsProvider } from './ModalsProvider';import { EmailSidePanelSections } from './sidepanel/EmailSidePanelSections';import { TopBar } from './TopBar';@@ -440,17 +441,6 @@ function EmailContent(props: EmailViewProps) {const navigateToPreviousMessage = () => navigateMessage('prev');const navigateToNextMessage = () => navigateMessage('next');- onMount(() => {- registerEmailHotkeys(scopeId(), {- blockSender: context.blockSender,- markDone: context.archiveThread,- markSenderSignal: context.markSenderSignal,- markSenderNoise: context.markSenderNoise,- navigateToPreviousMessage,- navigateToNextMessage,- });- });-// In preview mode, switching between Soup tabs was causing this createEffect to overflow the stack. We should figure out that root cause, this flag fixes it for now.let hasRun = false;createEffect(() => {@@ -464,29 +454,86 @@ function EmailContent(props: EmailViewProps) {let markdownDomRef!: HTMLDivElement;+ const getHotkeyTarget = () => {+ const messages = context.messages.list();+ if (messages.length === 0) return;++ const focusedId = context.messages.focusedID();+ const focusedMessage = focusedId+ ? messages.find((message) => message.db_id === focusedId)+ : undefined;+ const message = focusedMessage ?? messages.at(-1);+ if (!message?.db_id) return;++ return {+ message,+ isLastMessage: messages.at(-1)?.db_id === message.db_id,+ };+ };++ const isMessageRenderedExpanded = (+ target: NonNullable<ReturnType<typeof getHotkeyTarget>>+ ) => {+ const messageId = target.message.db_id;+ if (!messageId) return false;++ const isNewMessage = target.message.labels.some(+ (label) => label.provider_label_id === 'UNREAD'+ );++ return (+ context.messages.isBodyExpanded(messageId) ||+ target.isLastMessage ||+ isNewMessage+ );+ };++ const openHotkeyTarget = (replyType: ReplyType) => {+ const target = getHotkeyTarget();+ if (!target) return false;++ return openEmailReplyComposerForMessage({+ ctx: context,+ message: target.message,+ replyType,+ isLastMessage: target.isLastMessage,+ });+ };++ onMount(() => {+ registerEmailHotkeys(scopeId(), {+ replyToFocusedMessage: () => openHotkeyTarget('reply'),+ forwardFocusedMessage: () => openHotkeyTarget('forward'),+ blockSender: context.blockSender,+ markDone: context.archiveThread,+ markSenderSignal: context.markSenderSignal,+ markSenderNoise: context.markSenderNoise,+ navigateToPreviousMessage,+ navigateToNextMessage,+ });+ });+registerScopeSignalHotkey(scopeId, {hotkey: 'enter',- description: 'Focus Email Input',+ description: 'Reply to message',keyDownHandler: () => {const focusedId = context.messages.focusedID();+ const target = getHotkeyTarget();- // 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);+ if (focusedId && target?.message.db_id === focusedId) {+ if (!isMessageRenderedExpanded(target)) {+ context.messages.setExpandedBodyId(focusedId, true);return true;}++ return openEmailReplyComposerForMessage({+ ctx: context,+ message: target.message,+ replyType: 'reply',+ isLastMessage: target.isLastMessage,+ });}- // Otherwise, focus the main email inputif (markdownDomRef) {markdownDomRef.focus();return true;@@ -547,12 +594,17 @@ function EmailContent(props: EmailViewProps) {if (prevThreadId !== tid) {prevThreadId = tid;context.messages.setBottomReplyOpen(false);+ context.mobileReplyComposer.close();}const filtered = context.messages.list();const lastMessage = filtered.at(-1);if (!lastMessage?.db_id) return;if (context.drafts.getDraftForMessage(lastMessage.db_id)) {- context.messages.setBottomReplyOpen(true);+ if (isMobile()) {+ context.mobileReplyComposer.openForMessage(lastMessage.db_id);+ } else {+ context.messages.setBottomReplyOpen(true);+ }}});@@ -586,10 +638,11 @@ function EmailContent(props: EmailViewProps) {// The bottom reply area renders when the user can compose and there's a// message to reply to or a draft to edit. Returns the reply info so it can// drive the keyed <Show> around the reply area.- const replyArea = () =>- context.permissions().isOwner &&- context.drafts.initialDraftsSettled() &&- emailReplyInfo();+ const replyArea = () => {+ if (!context.permissions().isOwner) return;+ if (!context.drafts.initialDraftsSettled()) return;+ return emailReplyInfo();+ };// The expanded compose input, as opposed to the collapsed reply buttons// (which float in the mobile accessory region).@@ -599,6 +652,11 @@ function EmailContent(props: EmailViewProps) {// Whether the compose input is rendered in normal flow.const replyInputInFlow = () => Boolean(replyArea() && replyInputOpen());+ const mobileBottomReplyMessage = createMemo(() => {+ if (context.mobileReplyComposer.open()) return;+ return replyArea()?.replyingTo;+ });+return (<ModalsProvider subject={props.title}><Show when={!isUserLoading()}>@@ -700,56 +758,18 @@ function EmailContent(props: EmailViewProps) {scrollContainer={context.messagesListRef}/></div>- <Show when={isMobile() && replyArea()}>- {(info) => (- <div- class={cn(- 'shrink-0 w-full pb-4',- // Edge-to-edge mobile: the in-flow input clears the- // bottom chrome itself; when collapsed, the reply- // buttons float in the accessory region instead and- // this wrapper drops out of the layout.- replyInputInFlow()- ? 'mobile:pb-[calc(var(--mobile-content-inset-bottom,0)+1rem)]'- : 'mobile:hidden'- )}- >- <div class="relative w-full flex flex-row justify-center macro-message-width macro-message-padding mx-auto">- <FloatingInputLoader- isLoading={context.query.isFetching}- loadingText="Loading messages"- />- <Show- when={replyInputOpen()}- fallback={- <Show when={info().replyingTo}>- {(lastMessage) => (- <BottomReplyButtons- lastMessage={lastMessage()}- />- )}- </Show>- }- >- <EmailInput- replyingTo={() => info().replyingTo}- draft={info().draft}- setShowReply={(v) => {- const next =- typeof v === 'function'- ? v(context.messages.bottomReplyOpen())- : v;- context.messages.setBottomReplyOpen(next);- }}- markdownDomRef={(el) => {- markdownDomRef = el;- }}- />- </Show>- </div>- </div>+ <Show when={isMobile() && mobileBottomReplyMessage()}>+ {(lastMessage) => (+ <BottomReplyButtons lastMessage={lastMessage()} />)}</Show>+ <Show when={isMobile()}>+ <MobileEmailComposeDrawer+ markdownDomRef={(el) => {+ markdownDomRef = el;+ }}+ />+ </Show></div></EmailFormContextProvider></Match>diff --git a/js/app/packages/block-email/component/EmailContext.tsx b/js/app/packages/block-email/component/EmailContext.tsxindex ba9c1b5376..3a6581f103 100644--- a/js/app/packages/block-email/component/EmailContext.tsx+++ b/js/app/packages/block-email/component/EmailContext.tsx@@ -53,6 +53,7 @@ import {useContext,} from 'solid-js';import { createStore } from 'solid-js/store';+import type { ReplyType } from '../util/replyType';/*** Tracks thread IDs that had a draft saved since the last query fetch.@@ -99,6 +100,19 @@ type EmailContextValues = {// Sender emails (lowercased) with a CATEGORY_PERSONAL message in the threadpersonalSenders: Accessor<Set<string>>;};+ mobileReplyComposer: {+ open: Accessor<boolean>;+ messageId: Accessor<string | undefined>;+ setOpen: (open: boolean) => void;+ openForMessage: (id: string) => void;+ close: () => void;+ };+ replyRequest: {+ messageId: Accessor<string | undefined>;+ replyType: Accessor<ReplyType | undefined>;+ set: (messageId: string, replyType: ReplyType) => void;+ clear: () => void;+ };thread: Accessor<ApiThread | undefined>;permissions: Accessor<{type: Permissions;@@ -196,6 +210,13 @@ export function EmailProvider(props: FlowProps<{ threadID: string }>) {const [focusedMessageId, setFocusedMessageId] = createSignal<string>();const [replyingToMessageId, setReplyingToMessageId] = createSignal<string>();const [bottomReplyOpen, setBottomReplyOpen] = createSignal(false);+ const [mobileReplyComposerOpen, setMobileReplyComposerOpen] =+ createSignal(false);+ const [mobileReplyComposerMessageId, setMobileReplyComposerMessageId] =+ createSignal<string>();+ const [replyRequestMessageId, setReplyRequestMessageId] =+ createSignal<string>();+ const [replyRequestType, setReplyRequestType] = createSignal<ReplyType>();const [expandedMessageBodyIds, setExpandedMessageBodyIds] = createStore<Record<string, boolean>>({});@@ -608,6 +629,31 @@ export function EmailProvider(props: FlowProps<{ threadID: string }>) {bottomReplyOpen,setBottomReplyOpen,},+ mobileReplyComposer: {+ open: mobileReplyComposerOpen,+ messageId: mobileReplyComposerMessageId,+ setOpen: setMobileReplyComposerOpen,+ openForMessage: (id: string) => {+ setMobileReplyComposerMessageId(id);+ setMobileReplyComposerOpen(true);+ },+ close: () => {+ setMobileReplyComposerOpen(false);+ setMobileReplyComposerMessageId(undefined);+ },+ },+ replyRequest: {+ messageId: replyRequestMessageId,+ replyType: replyRequestType,+ set: (messageId: string, replyType: ReplyType) => {+ setReplyRequestMessageId(messageId);+ setReplyRequestType(replyType);+ },+ clear: () => {+ setReplyRequestMessageId(undefined);+ setReplyRequestType(undefined);+ },+ },permissions: createMemo(() => {const perms = getPermissions(threadQuery.data?.access_level);return {diff --git a/js/app/packages/block-email/component/EmailInput.tsx b/js/app/packages/block-email/component/EmailInput.tsxindex 4c8b67d2eb..6780aca379 100644--- a/js/app/packages/block-email/component/EmailInput.tsx+++ b/js/app/packages/block-email/component/EmailInput.tsx@@ -15,6 +15,9 @@ interface EmailInputProps {setShowReply?: Setter<boolean>;markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;unframed?: boolean;+ mobileDrawer?: {+ onClose: () => void;+ };}export function EmailInput(props: EmailInputProps) {@@ -54,6 +57,7 @@ export function EmailInput(props: EmailInputProps) {setShowReply={props.setShowReply}markdownDomRef={props.markdownDomRef}unframed={props.unframed}+ mobileDrawer={props.mobileDrawer}isEditingExisting={props.replyingTo() == null && props.draft != null}/></Layer>diff --git a/js/app/packages/block-email/component/FromInboxSelector.tsx b/js/app/packages/block-email/component/FromInboxSelector.tsxindex d5d2c4ea8c..5b2d1c4745 100644--- a/js/app/packages/block-email/component/FromInboxSelector.tsx+++ b/js/app/packages/block-email/component/FromInboxSelector.tsx@@ -42,6 +42,8 @@ export function FromInboxSelector(props: {links: FromInbox[];activeLinkId: string | undefined;onSelect: (linkId: string) => void;+ compact?: boolean;+ class?: string;}) {const activeInbox = () =>props.links.find((l) => l.id === props.activeLinkId) ?? props.links[0];@@ -49,6 +51,43 @@ export function FromInboxSelector(props: {[...props.links].sort((a, b) =>a.email_address.localeCompare(b.email_address));++ if (props.compact) {+ return (+ <Show when={activeInbox()}>+ {(active) => (+ <Show+ when={props.links.length > 1}+ fallback={<span class={props.class}>{active().email_address}</span>}+ >+ <Dropdown>+ <Dropdown.Trigger+ class={`inline-flex min-w-0 max-w-full items-center gap-1 ${props.class ?? ''}`}+ >+ <span class="min-w-0 truncate">{active().email_address}</span>+ <ChevronDown class="size-3 shrink-0" />+ </Dropdown.Trigger>+ <Dropdown.Content>+ <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.tsxindex 487af25f02..14251028af 100644--- a/js/app/packages/block-email/component/MessageActions.tsx+++ b/js/app/packages/block-email/component/MessageActions.tsx@@ -8,7 +8,9 @@ import type { ApiMessage } from '@service-email/generated/schemas';import { createCallback } from '@solid-primitives/rootless';import { Button } from '@ui';import { type Setter, Show } from 'solid-js';+import { useEmailContext } from './EmailContext';import { getEmailFormRegistry } from './EmailFormContext';+import { openEmailReplyComposerForMessage } from './emailReplyActions';const EMAIL_MESSAGE_ACTIONS = ['reply', 'reply-all', 'forward'] as const;export type EmailMessageAction = (typeof EMAIL_MESSAGE_ACTIONS)[number];@@ -20,6 +22,7 @@ export function MessageActions(props: {isLastMessage?: boolean;hiddenActions?: EmailMessageAction[];}) {+ const ctx = useEmailContext();const formRegistry = getEmailFormRegistry();const userEmail = useEmail();const shouldShowReplyAll = () =>@@ -37,13 +40,14 @@ export function MessageActions(props: {const onChangeReplyType = (type: ReplyType) => {return createCallback(() => {- props.setShowReply(true);- const form = formRegistry.getOrInit({- type: 'replying_to',- messageID: props.message.db_id ?? '',+ openEmailReplyComposerForMessage({+ ctx,+ formRegistry,+ message: props.message,+ replyType: type,+ isLastMessage: props.isLastMessage,+ setShowReply: props.setShowReply,});- form.setReplyType(type);- form.setShouldFocusInput(true);});};diff --git a/js/app/packages/block-email/component/MessageContainer.tsx b/js/app/packages/block-email/component/MessageContainer.tsxindex 6a923bde0b..a1893d6336 100644--- a/js/app/packages/block-email/component/MessageContainer.tsx+++ b/js/app/packages/block-email/component/MessageContainer.tsx@@ -52,10 +52,9 @@ export function MessageContainer(props: MessageContainerProps) {context.messages.replyingToMessageId() === props.message.db_id;const showInlineReplyInput = createMemo(() => {+ if (isMobile()) return false;if (!props.isLastMessage) return showReply() || !!draftChild();- return (- !isMobile() && (context.messages.bottomReplyOpen() || !!draftChild())- );+ return context.messages.bottomReplyOpen() || !!draftChild();});const showDesktopLastReplyControls = createMemo(@@ -219,6 +218,11 @@ export function MessageContainer(props: MessageContainerProps) {message={props.message}isFocused={props.isFocused}onClick={handleExpand}+ onFocus={() => {+ if (props.message.db_id) {+ context.messages.setFocused(props.message.db_id);+ }+ }}/>}>@@ -226,7 +230,7 @@ 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"+ class="relative rounded-lg overflow-hidden p-2 ring scroll-m-px"classList={{'bg-active/60 ring-edge': props.isFocused,'bg-ink-muted/4 ring-transparent': !props.isFocused,diff --git a/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsx b/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsxnew file mode 100644index 0000000000..34844dab8d--- /dev/null+++ b/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsx@@ -0,0 +1,109 @@+import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import { FloatingInputLoader } from '@core/component/FloatingInputLoader';+import { createMemo, Show } from 'solid-js';+import { useEmailContext } from './EmailContext';+import { EmailInput } from './EmailInput';++const DEFAULT_DRAWER_SNAP = 0.75;+const EXPANDED_DRAWER_SNAP = 0.92;++function drawerHeightStyle(openPercentage: number) {+ const height = `${Math.round(+ Math.max(+ DEFAULT_DRAWER_SNAP,+ Math.min(EXPANDED_DRAWER_SNAP, openPercentage)+ ) * 100+ )}dvh`;++ return {+ height,+ 'max-height': height,+ };+}++export function MobileEmailComposeDrawer(props: {+ markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;+}) {+ const context = useEmailContext();++ const replyInfo = createMemo(() => {+ const messageId = context.mobileReplyComposer.messageId();+ if (!messageId || !context.permissions().isOwner) return;++ const replyingTo = context.messages+ .unfiltered()+ .find((message) => message.db_id === messageId);+ if (!replyingTo) return;++ return {+ replyingTo,+ draft: context.drafts.getDraftForMessage(messageId),+ };+ });++ const setDrawerOpen = (open: boolean) => {+ if (open) {+ context.mobileReplyComposer.setOpen(true);+ return;+ }++ context.mobileReplyComposer.close();+ context.messages.setBottomReplyOpen(false);+ };++ return (+ <Show when={replyInfo()}>+ {(info) => (+ <MobileDrawer+ side="bottom"+ open={context.mobileReplyComposer.open()}+ onOpenChange={setDrawerOpen}+ preventScroll={false}+ preventScrollbarShift={false}+ snapPoints={[DEFAULT_DRAWER_SNAP, EXPANDED_DRAWER_SNAP]}+ defaultSnapPoint={DEFAULT_DRAWER_SNAP}+ >+ {(drawer) => (+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />+ <MobileDrawer.Content+ aria-label="Reply composer"+ class="!h-[100dvh] !max-h-[100dvh] overflow-hidden pb-0"+ >+ <div+ class="min-h-0 flex flex-col"+ style={drawerHeightStyle(drawer.openPercentage)}+ >+ <MobileDrawer.Handle class="pb-1" />+ <div class="relative min-h-0 flex-1 flex flex-col">+ <FloatingInputLoader+ isLoading={context.query.isFetching}+ loadingText="Loading messages"+ />+ <EmailInput+ replyingTo={() => info().replyingTo}+ draft={info().draft}+ setShowReply={(value) => {+ const next =+ typeof value === 'function'+ ? value(context.mobileReplyComposer.open())+ : value;+ setDrawerOpen(next);+ return next;+ }}+ markdownDomRef={props.markdownDomRef}+ unframed+ mobileDrawer={{+ onClose: () => setDrawerOpen(false),+ }}+ />+ </div>+ </div>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ )}+ </MobileDrawer>+ )}+ </Show>+ );+}diff --git a/js/app/packages/block-email/component/email-date-selector.tsx b/js/app/packages/block-email/component/email-date-selector.tsxindex 7dcf9d9513..22055c3c6b 100644--- a/js/app/packages/block-email/component/email-date-selector.tsx+++ b/js/app/packages/block-email/component/email-date-selector.tsx@@ -5,7 +5,7 @@ import IconX from '@phosphor/x.svg';import { Button, Tooltip } from '@ui';import { addYears } from 'date-fns/addYears';import { format } from 'date-fns/format';-import { Show, type VoidComponent } from 'solid-js';+import { type JSX, Show, type VoidComponent } from 'solid-js';interface EmailDateSelectorProps {sendTime?: Date | null;@@ -16,6 +16,10 @@ interface EmailDateSelectorProps {disablePortal?: boolean;/** Disable the schedule button */disabled?: boolean;+ trigger?: (state: {+ selectedDate: Date | null;+ formattedDate: string | undefined;+ }) => JSX.Element;}export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (props@@ -37,6 +41,13 @@ export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (: undefined;const showExpanded = () => !isCompact() && !!formattedDate();+ if (props.trigger) {+ return props.trigger({+ selectedDate: state.selectedDate,+ formattedDate: formattedDate(),+ });+ }+return (<Showwhen={showExpanded()}diff --git a/js/app/packages/block-email/component/emailReplyActions.ts b/js/app/packages/block-email/component/emailReplyActions.tsnew file mode 100644index 0000000000..34d36087fa--- /dev/null+++ b/js/app/packages/block-email/component/emailReplyActions.ts@@ -0,0 +1,49 @@+import { isMobile } from '@core/mobile/isMobile';+import type { ApiMessage } from '@service-email/generated/schemas';+import type { Setter } from 'solid-js';+import type { ReplyType } from '../util/replyType';+import type { useEmailContext } from './EmailContext';+import type { getEmailFormRegistry } from './EmailFormContext';++export function openEmailReplyComposerForMessage(args: {+ ctx: ReturnType<typeof useEmailContext>;+ formRegistry?: ReturnType<typeof getEmailFormRegistry>;+ message: ApiMessage;+ replyType: ReplyType;+ isLastMessage?: boolean;+ setShowReply?: Setter<boolean>;+}) {+ const messageId = args.message.db_id;+ if (!messageId) return false;++ args.ctx.replyRequest.set(messageId, args.replyType);++ if (args.formRegistry) {+ const form = args.formRegistry.getOrInit({+ type: 'replying_to',+ messageID: messageId,+ });+ form.setReplyType(args.replyType);+ form.setShouldFocusInput(true);+ }++ if (isMobile()) {+ args.ctx.mobileReplyComposer.openForMessage(messageId);+ return true;+ }++ if (args.setShowReply) {+ args.setShowReply(true);+ return true;+ }++ if (args.isLastMessage) {+ args.ctx.messages.setBottomReplyOpen(true);+ } else {+ args.ctx.messages.setExpandedBodyId(messageId, true);+ args.ctx.messages.setFocused(messageId);+ args.ctx.messages.setReplyingToMessageId(messageId);+ }++ return true;+}diff --git a/js/app/packages/block-email/util/emailHotkeys.ts b/js/app/packages/block-email/util/emailHotkeys.tsindex c6b4b44850..5b710dd2d7 100644--- a/js/app/packages/block-email/util/emailHotkeys.ts+++ b/js/app/packages/block-email/util/emailHotkeys.ts@@ -2,6 +2,9 @@ import { TOKENS } from '@core/hotkey/tokens';import { registerHotkey } from 'core/hotkey/hotkeys';interface EmailHotkeyHandlers {+ replyToFocusedMessage: () => boolean;+ replyAllToFocusedMessage?: () => boolean;+ forwardFocusedMessage: () => boolean;blockSender: () => boolean;markDone: () => boolean;markSenderSignal: () => boolean;@@ -14,38 +17,31 @@ export function registerEmailHotkeys(scopeId: string,handlers: EmailHotkeyHandlers) {+ if (handlers.replyAllToFocusedMessage) {+ registerHotkey({+ hotkey: 'opt+r',+ scopeId: scopeId,+ description: 'Reply all to message',+ keyDownHandler: handlers.replyAllToFocusedMessage,+ hotkeyToken: TOKENS.email.replyAll,+ displayPriority: 8,+ });+ }+registerHotkey({- hotkey: 'opt+r',+ hotkey: 'r',scopeId: scopeId,- description: 'Reply to thread',- keyDownHandler: () => {- // handlers.setReplyMode('reply');- return true;- },+ description: 'Reply to message',+ keyDownHandler: handlers.replyToFocusedMessage,hotkeyToken: TOKENS.email.reply,displayPriority: 9,});- registerHotkey({- hotkey: 'r',- scopeId: scopeId,- description: 'Reply all to thread',- keyDownHandler: () => {- // handlers.setReplyMode('reply-all');- return true;- },- hotkeyToken: TOKENS.email.replyAll,- displayPriority: 8,- });+registerHotkey({hotkey: 'f',scopeId: scopeId,- description: 'Forward thread',- keyDownHandler: () => {- // TODO: Populate to field- // TODO: Attachments from last/current selected message- // handlers.setReplyMode('forward');- return true;- },+ description: 'Forward message',+ keyDownHandler: handlers.forwardFocusedMessage,hotkeyToken: TOKENS.email.forward,displayPriority: 7,});