Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(ui): make shared send button and use in chat inputs (#3417)
Seamusd5a780fa768a
diff --git a/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx b/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsxindex eb7c806008..61a2fd6721 100644--- a/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx@@ -10,7 +10,6 @@ import XIcon from '@phosphor/x.svg';import { commsServiceClient } from '@service-comms/client';import { Button, Dialog, Surface } from '@ui';import { createSignal } from 'solid-js';-import { CREATE_BUTTON_CLASS } from './create-button-style';export function NewCallButton() {const [isOpen, setIsOpen] = createSignal(false);@@ -84,7 +83,8 @@ export function NewCallButton() {<Buttonvariant="accent-reverse"size="sm"- class={CREATE_BUTTON_CLASS}+ depth={5}+ class="rounded-full px-3 py-2 pl-1 font-bold"onClick={() => setIsOpen(true)}><PlusCircleIcon class="size-3.5" />diff --git a/js/app/packages/app/component/next-soup/soup-view/create-button-style.ts b/js/app/packages/app/component/next-soup/soup-view/create-button-style.tsdeleted file mode 100644index eef131bf7c..0000000000--- a/js/app/packages/app/component/next-soup/soup-view/create-button-style.ts+++ /dev/null@@ -1 +0,0 @@-export const CREATE_BUTTON_CLASS = 'rounded-full px-3 py-2 font-bold';diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-create-button.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-create-button.tsxindex cfc6c573e7..6fc0ffbef8 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-create-button.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-create-button.tsx@@ -15,7 +15,6 @@ import PlusCircleIcon from '@phosphor/plus-circle.svg';import UploadIcon from '@phosphor/upload-simple.svg';import { Button, Dropdown, Layer } from '@ui';import { createMemo, For, Show } from 'solid-js';-import { CREATE_BUTTON_CLASS } from './create-button-style';import { NewCallButton } from './NewCallButton';// Which blocks to show as create options per view, in order@@ -141,8 +140,9 @@ export const SoupViewCreateButton = () => {const SingleOptionButton = (props: { hideLabel?: boolean }) => (<Buttonvariant="accent-reverse"+ depth={5}+ class="rounded-full px-3 py-2 pl-1 font-bold"size="sm"- class={CREATE_BUTTON_CLASS}onClick={() => handleSelect(options()[0])}><PlusCircleIcon class="size-3.5" />@@ -154,7 +154,11 @@ export const SoupViewCreateButton = () => {const MultiOptionButton = (props: { hideLabel?: boolean }) => (<Dropdown placement="bottom-start" gutter={4}>- <Dropdown.Trigger variant="accent-reverse" class={CREATE_BUTTON_CLASS}>+ <Dropdown.Trigger+ variant="accent-reverse"+ depth={5}+ class="rounded-full px-3 pl-1 py-2 font-bold"+ ><PlusCircleIcon class="size-3.5" /><Show when={!props.hideLabel}><span>{createLabel()}</span>diff --git a/js/app/packages/block-channel/component/Compose.tsx b/js/app/packages/block-channel/component/Compose.tsxindex 9f83237ec3..74fb2b5cde 100644--- a/js/app/packages/block-channel/component/Compose.tsx+++ b/js/app/packages/block-channel/component/Compose.tsx@@ -261,13 +261,17 @@ export function ChannelCompose() {</div></div></Show>- <div class="p-2">+ <div class="px-2"><ChannelInputContainer><Input.Rootinput={inputState.view()}commands={inputState.commands}>- <Surface depth={2}>+ <Surface+ depth={2}+ class="rounded-xl ring-1 ring-ink-muted/8"+ style={{ border: '0' }}+ ><Input.DropZoneonDragStart={(valid) => inputState.setIsDraggedOver(valid)}onDragEnd={() => inputState.setIsDraggedOver(false)}diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsxindex 7f4a62de86..46b07a70d2 100644--- a/js/app/packages/block-email/component/BaseInput.tsx+++ b/js/app/packages/block-email/component/BaseInput.tsx@@ -48,11 +48,11 @@ 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 ArrowUp from '@phosphor/arrow-up.svg';+import ChevronDown from '@phosphor/caret-down.svg';import Paperclip from '@phosphor/paperclip.svg';import Quotes from '@phosphor/quotes.svg';-import Spinner from '@phosphor/spinner-gap.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';@@ -79,7 +79,7 @@ import type {ApiDraftOutputDbId,ApiMessage,} from '@service-email/generated/schemas';-import { Button, cn, HoverCard, Scroll, Tooltip } from '@ui';+import { Button, cn, HoverCard, Scroll, SendButton, Tooltip } from '@ui';import {defaultSelectionData,lazyRegister,@@ -1316,7 +1316,7 @@ export function BaseInput(props: {ref={(el) => {composeContainerRef = el;}}- class="relative flex flex-col flex-1 bg-ink-muted/2.5 ring-1 ring-ink-muted/8 rounded-xl max-w-full"+ class="relative bg-surface flex flex-col flex-1 border border-ink-muted/8 rounded-xl max-w-full">{/* Top Bar */}<div class="relative flex items-start gap-2 px-3 pt-1.5 pb-0.5">@@ -1668,9 +1668,9 @@ export function BaseInput(props: {</div></Scroll></div>- <div class="flex flex-row w-full h-9 justify-between items-center px-3 pb-2 pt-0.5 space-x-2">+ <div class="flex flex-row w-full h-9 justify-between items-end px-2 pb-2 pt-0.5 space-x-2"><div class="flex flex-row items-center gap-1">- <div class="relative">+ <div class="relative flex"><Buttonref={(el) =>fileSelector(el, () => ({@@ -1749,29 +1749,16 @@ export function BaseInput(props: {</Button></div>- <Tooltip label="Send">- <Button- size="icon-sm"- variant="ghost"- disabled={- uploadAttachmentMutation.isPending ||- sendMutation.isPending ||- !!form().sendTime()- }- class={cn(- 'translate-x-[6.5px] rounded-[11px] size-[30px] bg-edge-muted/60 text-ink-muted [&_svg]:stroke-[2.5] not-disabled:bg-accent not-disabled:text-surface not-disabled:hover:bg-accent/90 data-disabled:opacity-100 data-disabled:bg-edge-muted/60 data-disabled:text-ink-muted',- isMobile() && !hasBodyText() && 'opacity-0!'- )}- onClick={() => sendEmail()}- >- <Show- when={!sendMutation.isPending}- fallback={<Spinner class="animate-spin" />}- >- <ArrowUp />- </Show>- </Button>- </Tooltip>+ <SendButton+ disabled={+ uploadAttachmentMutation.isPending ||+ sendMutation.isPending ||+ !!form().sendTime()+ }+ pending={sendMutation.isPending}+ hidden={isMobile() && !hasBodyText()}+ onClick={() => sendEmail()}+ /></div></div></div>diff --git a/js/app/packages/block-email/component/EmailInput.tsx b/js/app/packages/block-email/component/EmailInput.tsxindex 02787872bf..5232a2ce42 100644--- a/js/app/packages/block-email/component/EmailInput.tsx+++ b/js/app/packages/block-email/component/EmailInput.tsx@@ -43,7 +43,7 @@ export function EmailInput(props: EmailInputProps) {return (<Show when={ctx.drafts.initialDraftsSettled()}>- <Layer depth={1}>+ <Layer depth={2}><BaseInputreplyingTo={props.replyingTo}draft={props.draft}diff --git a/js/app/packages/block-email/component/compose/Compose.tsx b/js/app/packages/block-email/component/compose/Compose.tsxindex c759a38796..6a2e512ee6 100644--- a/js/app/packages/block-email/component/compose/Compose.tsx+++ b/js/app/packages/block-email/component/compose/Compose.tsx@@ -655,7 +655,11 @@ export function EmailCompose(props: EmailComposeProps) {</Show><div class="macro-message-width sm:macro-message-padding mx-auto w-full min-h-120 max-h-full my-2 sm:my-12 mobile:my-0 px-2 sm:px-4 mobile:px-0 overflow-hidden mobile:overflow-y-auto mobile:scrollbar-hidden mobile:min-h-full"><WrapUnlessMobile- wrapper={(children) => <Surface depth={2}>{children}</Surface>}+ wrapper={(children) => (+ <Surface depth={2} class="rounded-xl border border-ink-muted/8">+ {children}+ </Surface>+ )}><ComposeLayouttoolbar={<EmailComposeToolbar editor={editor} />}diff --git a/js/app/packages/block-email/component/compose/ComposeToolbar.tsx b/js/app/packages/block-email/component/compose/ComposeToolbar.tsxindex 2f666b9067..5a914bbf78 100644--- a/js/app/packages/block-email/component/compose/ComposeToolbar.tsx+++ b/js/app/packages/block-email/component/compose/ComposeToolbar.tsx@@ -8,16 +8,13 @@ import { ENABLE_EMAIL_SCHEDULED_SEND } from '@core/constant/featureFlags';import { fileSelector } from '@core/directive/fileSelector';import { isMobile } from '@core/mobile/isMobile';import { plural } from '@core/util/string';-import PaperPlane from '@icon/wide-paper-plane-cutout.svg';import { DropdownMenu } from '@kobalte/core/dropdown-menu';-import PaperPlaneRight from '@phosphor/paper-plane-right.svg?component-solid';import PaperclipIcon from '@phosphor/paperclip.svg?component-solid';import TextAa from '@phosphor/text-aa.svg';import Trash from '@phosphor/trash.svg';import DotsThreeIcon from '@phosphor-icons/core/bold/dots-three-bold.svg?component-solid';-import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';import PaperclipHorizontalIcon from '@phosphor-icons/core/regular/paperclip-horizontal.svg?component-solid';-import { Button, Tooltip } from '@ui';+import { Button, SendButton, Tooltip } from '@ui';import { defaultSelectionData } from 'core/component/LexicalMarkdown/plugins';import {NODE_TRANSFORM,@@ -152,7 +149,7 @@ export function EmailComposeToolbar(props: {</Button></Show><Tooltip label={ctx.sendTime() ? 'Send time is scheduled' : ''}>- <Button+ <SendButtononClick={() => ctx.onSend()}disabled={ctx.isSavingDraft?.() ||@@ -160,16 +157,10 @@ export function EmailComposeToolbar(props: {ctx.isSending() ||ctx.disabled()}- tooltip="Send"- size="icon-sm"- >- <Show- fallback={<Spinner class="animate-spin" />}- when={!ctx.isSending()}- >- <PaperPlaneRight />- </Show>- </Button>+ pending={ctx.isSending()}+ tooltip="Send email"+ shortcut="cmd+enter"+ /></Tooltip></div></Show>@@ -223,17 +214,17 @@ function MobileToolbar(props: {{ctx.isSavingDraft?.() ? 'Saving…' : 'Draft'}</Button></Show>- <Button+ <SendButtondisabled={ctx.isSending() ||ctx.isSavingDraft?.() ||ctx.disabled() ||!!ctx.sendTime()}+ pending={ctx.isSending()}onClick={() => ctx.onSend()}- >- <PaperPlane class="size-4.5 text-accent" />- </Button>+ tooltip="Send email"+ /></Tooltip><DropdownMenu placement="bottom-end"><DropdownMenu.Trigger as={Button} class="aspect-square p-1">diff --git a/js/app/packages/block-md/component/DiscussionInput.tsx b/js/app/packages/block-md/component/DiscussionInput.tsxindex aa540afb32..4262a3be39 100644--- a/js/app/packages/block-md/component/DiscussionInput.tsx+++ b/js/app/packages/block-md/component/DiscussionInput.tsx@@ -87,7 +87,7 @@ function DefaultActions(props: { input: InputData }) {</Show></Input.Actions.Left><Input.Actions.Right>- <Input.SendAction />+ <Input.SendAction tooltip="Send comment" /></Input.Actions.Right></Input.Actions>);diff --git a/js/app/packages/channel/Input/SendAction.tsx b/js/app/packages/channel/Input/SendAction.tsxindex b3af2f2bd0..cdba6f8656 100644--- a/js/app/packages/channel/Input/SendAction.tsx+++ b/js/app/packages/channel/Input/SendAction.tsx@@ -1,45 +1,39 @@import { isMobile } from '@core/mobile/isMobile';-import ArrowUp from '@phosphor/arrow-up.svg';-import SpinnerIcon from '@phosphor/spinner-gap.svg';-import { Button, cn } from '@ui';-import { children, type JSX, Show, splitProps } from 'solid-js';+import { SendButton } from '@ui';+import { type JSX, splitProps } from 'solid-js';import { useInput, useInputCommands } from './context';import { hasSendableInputContent } from './utils/sendable-content';-export function SendAction(props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) {+export type SendActionProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & {+ /** Custom tooltip label. Defaults to "Send message". */+ tooltip?: string;+};++export function SendAction(props: SendActionProps) {const input = useInput();const commands = useInputCommands();- const [local, rest] = splitProps(props, ['class', 'children']);- const resolved = children(() => local.children);+ const [local, rest] = splitProps(props, ['class', 'tooltip', 'hidden']);const isBlockedByPending = () => !!input().hasPendingAttachments;const isBlockedByEmptyInput = () => !hasSendableInputContent(input());const hasTextInput = () => (input().value?.trim().length ?? 0) > 0;+ const tooltipText = () => local.tooltip ?? 'Send message';+return (- <Button- variant="ghost"- size="icon-sm"- tooltip="Send message"- aria-label="Send message"+ <SendButton+ tooltip={tooltipText()}+ shortcut="enter"+ aria-label={tooltipText()}data-input-action="send"+ pending={isBlockedByPending()}disabled={isBlockedByPending() || isBlockedByEmptyInput()}- class={cn(- 'rounded-[11px] size-[30px] bg-edge-muted/60 text-ink-muted [&_svg]:stroke-[2.5] not-disabled:bg-accent not-disabled:text-surface not-disabled:hover:bg-accent/90 data-disabled:opacity-100 data-disabled:bg-edge-muted/60 data-disabled:text-ink-muted',- isMobile() && !hasTextInput() && 'opacity-0!',- local.class- )}+ hidden={isMobile() && !hasTextInput()}+ class={local.class}onPointerDown={(event) => {event.preventDefault();void commands.send();}}{...rest}- >- <Show- when={!isBlockedByPending()}- fallback={<SpinnerIcon class="animate-spin" />}- >- {resolved() ?? <ArrowUp />}- </Show>- </Button>+ />);}diff --git a/js/app/packages/core/component/AI/component/input/ChatInput.tsx b/js/app/packages/core/component/AI/component/input/ChatInput.tsxindex 901f498f29..93e118d3c0 100644--- a/js/app/packages/core/component/AI/component/input/ChatInput.tsx+++ b/js/app/packages/core/component/AI/component/input/ChatInput.tsx@@ -11,11 +11,9 @@ import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';import { handleFileFolderDrop } from '@core/util/upload';-import ArrowUp from '@phosphor/arrow-up.svg';import PaperclipIcon from '@phosphor/paperclip.svg';-import Stop from '@phosphor/stop.svg';import { createCallback } from '@solid-primitives/rootless';-import { Button, cn, Surface } from '@ui';+import { Button, cn, Surface, SendButton as UiSendButton } from '@ui';import { createEffect, createSignal, Show } from 'solid-js';import { AttachmentList } from './Attachment';import { ChatAttachMenu } from './ChatAttachMenu';@@ -145,37 +143,34 @@ export function ChatInput(props: ChatInputComponentProps) {const StopButton = () => (<Button- variant="base"+ variant="ghost"size="icon-sm"label="Stop generating"hotkey={TOKENS.chat.stop}onClick={() => props.onStop?.()}+ class={cn(+ 'rounded-[11px] size-7.5 text-ink-extra-muted [&_svg]:stroke-[4px]',+ 'not-disabled:bg-ink/5 not-disabled:hover:bg-ink/10',+ 'data-disabled:opacity-100 data-disabled:text-ink-extra-muted data-disabled:bg-ink-muted/5'+ )}>- <Stop />+ <div class="size-3.5 rounded-sm bg-current" /></Button>);const SendButton = () => (- <Button- variant="ghost"- size="icon-sm"- aria-label="Send"- tooltip="Send in background"- shortcut="cmd+enter"+ <UiSendButton+ tooltip={'Ask Ai'}+ shortcut="enter"tooltipPlacement="top"disabled={!canSendMessage()}- class={cn(- 'rounded-[11px] size-[30px] bg-edge-muted/60 text-ink-muted [&_svg]:stroke-[2.5] not-disabled:bg-accent not-disabled:text-surface not-disabled:hover:bg-accent/90 data-disabled:opacity-100 data-disabled:bg-edge-muted/60 data-disabled:text-ink-muted',- isMobile() && isEmptyInput() && 'opacity-0!'- )}+ hidden={isMobile() && isEmptyInput()}onClick={() =>sendMessage(isTouchDevice() ? { modelOverride: 'claude-opus-4-6' } : undefined)}- >- <ArrowUp />- </Button>+ />);const RightControls = () => (diff --git a/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx b/js/app/packages/core/component/AI/component/message/EmptyChatState.tsxindex 1c0e9fb3fc..0627571b0a 100644--- a/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx+++ b/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx@@ -5,14 +5,16 @@ import {} from '@core/constant/SettingsState';import ArrowRightIcon from '@phosphor-icons/core/assets/bold/arrow-right-bold.svg?component-solid';import AtIcon from '@phosphor-icons/core/assets/bold/at-bold.svg?component-solid';+import PaperPlaneTiltIcon from '@phosphor-icons/core/assets/bold/paper-plane-tilt-bold.svg?component-solid';import PlugsConnectedIcon from '@phosphor-icons/core/assets/bold/plugs-connected-bold.svg?component-solid';import PuzzlePieceIcon from '@phosphor-icons/core/assets/bold/puzzle-piece-bold.svg?component-solid';+import { Hotkey } from '@ui';import type { JSXElement } from 'solid-js';function EmptyStateCard(props: {icon: JSXElement;title: string;- description: string;+ description: JSXElement;action?: { label: string; onClick: () => void };}) {return (@@ -61,6 +63,17 @@ export function EmptyChatState(props: { minHeight: number }) {title="@mention anything"description="Type @ in the chat input to attach files, documents, emails, and more as context for the AI."/>+ <EmptyStateCard+ icon={<PaperPlaneTiltIcon class="size-4" />}+ title="Send in the background"+ description={+ <>+ Press <Hotkey shortcut="meta+enter" theme="subtle" /> to send your+ message in the background. You'll get a notification when the AI+ responds.+ </>+ }+ /><EmptyStateCardicon={<PlugsConnectedIcon class="size-4" />}title="Connect MCP servers"diff --git a/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx b/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsxindex 1e7c4b47a3..b69c291fef 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx@@ -338,9 +338,7 @@ export function MarkdownTextarea(props: MarkdownTextareaProps) {<NodeAccessoryRenderer editor={editor} store={accessoryStore} /><Show when={showPlaceholder()}><div class="pointer-events-none text-ink-placeholder absolute top-0">- <p class="my-1.5 pointer-events-none">- {props.placeholder ?? '...'}- </p>+ <p class="pointer-events-none">{props.placeholder ?? '...'}</p></div></Show><Show when={props.watermark}>diff --git a/js/app/packages/ui/components/SendButton.tsx b/js/app/packages/ui/components/SendButton.tsxnew file mode 100644index 0000000000..43cf305975--- /dev/null+++ b/js/app/packages/ui/components/SendButton.tsx@@ -0,0 +1,49 @@+import ArrowUp from '@phosphor/arrow-up.svg';+import SpinnerIcon from '@phosphor/spinner-gap.svg';+import { children, Show, splitProps } from 'solid-js';+import { cn } from '../utils/classname';+import { Button, type ButtonProps } from './Button';++export type SendButtonProps = Omit<ButtonProps, 'size' | 'variant'> & {+ /** Show a spinner instead of the arrow (e.g. while a send mutation is in-flight). */+ pending?: boolean;+ /** Fade the button to fully transparent — used to hide on mobile when the input is empty. */+ hidden?: boolean;+};++export function SendButton(props: SendButtonProps) {+ const [local, rest] = splitProps(props, [+ 'pending',+ 'hidden',+ 'class',+ 'children',+ 'aria-label',+ 'tooltip',+ ]);+ const resolved = children(() => local.children);++ return (+ <Button+ depth={5}+ variant="accent-reverse"+ size="icon-sm"+ draggable={false}+ aria-label={local['aria-label'] ?? 'Send'}+ tooltip={local.tooltip ?? 'Send'}+ class={cn(+ 'rounded-[11px] size-7.5 text-ink-extra-muted [&_svg]:stroke-[4px]',+ 'transition-transform ease duration-150',+ 'not-disabled:bg-accent not-disabled:text-surface not-disabled:hover:bg-accent/90 not-disabled:hover:text-surface',+ 'data-disabled:opacity-100 data-disabled:text-ink-extra-muted data-disabled:bg-ink-muted/5',+ 'active:not-disabled:scale-95',+ local.hidden && 'opacity-0!',+ local.class+ )}+ {...rest}+ >+ <Show when={!local.pending} fallback={<SpinnerIcon class="animate-spin" />}>+ {resolved() ?? <ArrowUp />}+ </Show>+ </Button>+ );+}diff --git a/js/app/packages/ui/index.ts b/js/app/packages/ui/index.tsindex f1dd03c463..7b0d82dbaf 100644--- a/js/app/packages/ui/index.ts+++ b/js/app/packages/ui/index.ts@@ -11,6 +11,7 @@ export { Surface } from './components/Surface';export { Tooltip } from './components/Tooltip';export { Dialog } from './components/Dialog';export { Button } from './components/Button';+export { SendButton } from './components/SendButton';export { Hotkey } from './components/Hotkey';export { Scroll } from './components/Scroll';export { Panel } from './components/Panel';@@ -21,6 +22,7 @@ export { Layer } from './components/Layer';export type { AvatarSize, AvatarProps, AvatarGroupSize, AvatarGroupProps } from './components/Avatar';export type { ToggleSwitchProps } from './components/ToggleSwitch';export type { ButtonProps } from './components/Button';+export type { SendButtonProps } from './components/SendButton';export type { DialogProps } from './components/Dialog';export type { ChatInputRows, ChatInputProps } from './components/ChatInput';