Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(fe): create task button for email threads and channel messages (#2426)
Evan Hutnik262c78f2d52b
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsxindex 9887d8214e..c82fe009e1 100644--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx@@ -250,9 +250,9 @@ registerComponent('email-compose', (params) => {usePageViewTracking('email-compose');return <EmailCompose draftID={params?.draftID} />;});-registerComponent('task-compose', () => {+registerComponent('task-compose', (params) => {usePageViewTracking('task-compose');- return <ComposeTask />;+ return <ComposeTask initialContent={params?.initialContent} />;});registerComponent('import-linear',diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsxindex 362d5a1e3b..526af3f30b 100644--- a/js/app/packages/block-email/component/TopBar.tsx+++ b/js/app/packages/block-email/component/TopBar.tsx@@ -4,6 +4,7 @@ import {trashEmails,} from '@app/component/next-soup/utils';import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext';+import { useSplitLayout } from '@app/component/split-layout/layout';import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';import { ResponsiveBlockToolbar } from '@app/component/ResponsiveBlockToolbar';import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';@@ -21,6 +22,7 @@ import { ENABLE_EMAIL_SHARING } from '@core/constant/featureFlags';import { TOKENS } from '@core/hotkey/tokens';import { getActiveCommandByToken, runCommand } from '@core/hotkey/utils';import CheckIcon from '@icon/regular/check.svg';+import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';import IconShared from '@macro-icons/wide/share.svg';import TagIcon from '@icon/regular/tag.svg';import ProhibitIcon from '@icon/regular/prohibit.svg';@@ -29,7 +31,9 @@ import {EmailPropertiesButton,PROPERTIES_DRAWER_ID,} from './EmailPropertiesModal';+import { createSignal } from 'solid-js';import { useEmailContext } from './EmailContext';+import { buildMentionMarkdownString } from '@lexical-core';import { useEmailLinksQuery } from '@queries/email/link';import { isMobile } from '@core/mobile/isMobile';@@ -39,6 +43,7 @@ export function TopBar(props: {isDraft?: boolean;}) {const propertiesControl = useDrawerControl(PROPERTIES_DRAWER_ID);+ const { popoverSplit } = useSplitLayout();const shareCtx = useShareDialogContext();const emailCtx = useEmailContext();const soup = useMaybeSoup();@@ -99,6 +104,23 @@ export function TopBar(props: {});};+ const openTaskCompose = () => {+ const threadId = emailCtx.thread()?.db_id;+ if (!threadId) return;+ popoverSplit({+ type: 'component',+ id: 'task-compose',+ params: {+ initialContent: buildMentionMarkdownString({+ type: 'document',+ documentId: threadId,+ documentName: props.title,+ blockName: 'email',+ }),+ },+ });+ };+const tools: BlockTool[] = [{label: 'Done',@@ -131,11 +153,31 @@ export function TopBar(props: {action: propertiesControl.toggle,buttonComponent: () => <EmailPropertiesButton buttonSize="sm" />,},+ {+ label: 'Create Task',+ icon: AnimatedTaskIcon,+ action: openTaskCompose,+ buttonComponent: () => {+ const [hovering, setHovering] = createSignal(false);+ return (+ <button+ class="h-7 px-2 flex items-center gap-1 rounded-xs text-xs hover:bg-hover hover-transition-bg"+ onMouseEnter={() => setHovering(true)}+ onMouseLeave={() => setHovering(false)}+ onClick={openTaskCompose}+ >+ <div class="size-4 text-task">+ <AnimatedTaskIcon triggerAnimation={hovering()} />+ </div>+ <span class="text-ink">Task</span>+ </button>+ );+ },+ },{label: 'Share',icon: IconShared,action: () => shareCtx.open(),- divideAbove: true,condition: () => ENABLE_EMAIL_SHARING,buttonComponent: () => <ShareTrigger />,},diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsxindex 08f3c87873..dd1ecc4fea 100644--- a/js/app/packages/block-md/component/ComposeTask.tsx+++ b/js/app/packages/block-md/component/ComposeTask.tsx@@ -621,6 +621,11 @@ export function ComposeTask(props: ComposeTaskProps) {<MarkdownShellconfig={editorConfig}initialState={initialState.editorState}+ initialValue={+ initialState.editorState+ ? undefined+ : initialState.content || undefined+ }placeholder={props.placeholder ?? 'Add description...'}portalScope={splitPanel.handle.isPopover() ? 'local' : 'block'}class="shrink-1 min-h-0 h-[unset] text-base m-2 overflow-y-auto"diff --git a/js/app/packages/channel/Message/ActionMenu.tsx b/js/app/packages/channel/Message/ActionMenu.tsxindex 023ce2f3b2..ac1d308635 100644--- a/js/app/packages/channel/Message/ActionMenu.tsx+++ b/js/app/packages/channel/Message/ActionMenu.tsx@@ -1,5 +1,10 @@+import { useBlockId } from '@core/block';+import { useSplitLayout } from '@app/component/split-layout/layout';+import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';+import { buildMentionMarkdownString } from '@lexical-core';import ReplyIcon from '@icon/regular/arrow-bend-up-left.svg';import LinkIcon from '@icon/regular/link.svg';+import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';import PencilIcon from '@icon/regular/pencil.svg';import PlusIcon from '@icon/regular/plus.svg';import TrashIcon from '@icon/regular/trash.svg';@@ -55,6 +60,9 @@ export function ActionMenu(props: ActionMenuProps) {const actions = useMessageActions();const selection = useMessageSelection();const [emojiMenuOpen, setEmojiMenuOpen] = createSignal(false);+ const channelId = useBlockId();+ const channelName = useBlockDocumentName();+ const { popoverSplit } = useSplitLayout();const handleReaction = (emoji: string, event?: MessageActionEvent) => {void actions?.onReact?.({@@ -102,7 +110,7 @@ export function ActionMenu(props: ActionMenuProps) {class={props.class}persistentVisible={emojiMenuOpen() || !!selection?.isSelected}>- <div class="flex flex-row bg-menu border border-edge-muted items-center allow-css-brackets">+ <div class="flex flex-row bg-menu border border-edge-muted items-center allow-css-brackets -space-x-1"><Show when={hasReactAction()}><For each={QUICK_REACTION_EMOJIS}>{(emoji) => (@@ -140,6 +148,31 @@ export function ActionMenu(props: ActionMenuProps) {/></Show>+ <button+ type="button"+ title="Task"+ aria-label="Task"+ data-message-action="create-task"+ class="size-8 flex items-center justify-center text-task hover:bg-hover hover-transition-bg"+ onClick={() => {+ popoverSplit({+ type: 'component',+ id: 'task-compose',+ params: {+ initialContent: buildMentionMarkdownString({+ type: 'document',+ documentId: channelId,+ documentName: channelName() ?? '',+ blockName: 'channel',+ blockParams: { channel_message_id: message().id },+ }),+ },+ });+ }}+ >+ <AnimatedTaskIcon class="size-4 opacity-60" />+ </button>+<For each={visibleActions}>{(action) => (<ActionButton