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.

feat(fe): create task button with pre-populated title for emails and channels (#2569)

Evan Hutnik3028e0d54fac
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index b9de5f9285..a5a4426fd0 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -267,7 +267,12 @@ registerComponent('email-compose', (params) => {
});
registerComponent('task-compose', (params) => {
usePageViewTracking('task-compose');
- return <ComposeTask initialContent={params?.initialContent} />;
+ return (
+ <ComposeTask
+ initialContent={params?.initialContent}
+ initialTitle={params?.initialTitle}
+ />
+ );
});
registerComponent(
'import-linear',
diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsx
index 526af3f30b..fcbf480d81 100644
--- a/js/app/packages/block-email/component/TopBar.tsx
+++ b/js/app/packages/block-email/component/TopBar.tsx
@@ -107,10 +107,13 @@ export function TopBar(props: {
const openTaskCompose = () => {
const threadId = emailCtx.thread()?.db_id;
if (!threadId) return;
+ const title =
+ props.title.length > 70 ? `${props.title.slice(0, 70)}...` : props.title;
popoverSplit({
type: 'component',
id: 'task-compose',
params: {
+ initialTitle: title,
initialContent: buildMentionMarkdownString({
type: 'document',
documentId: threadId,
@@ -160,17 +163,19 @@ export function TopBar(props: {
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>
+ <div class="border-1 border-edge-muted flex items-stretch rounded-xs">
+ <button
+ class="h-7 px-2 flex items-center gap-1 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>
+ </div>
);
},
},
diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsx
index bd35823273..6516e3c52c 100644
--- a/js/app/packages/channel/Channel/Channel.tsx
+++ b/js/app/packages/channel/Channel/Channel.tsx
@@ -43,7 +43,7 @@ import { ChannelInputContainer } from '../Input/ChannelInputContainer';
import { createChannelMessageActions } from './create-channel-message-actions';
import { useSplitLayout } from '@app/component/split-layout/layout';
import { useChannelName, useChannelActivity } from '@core/context/channels';
-import { buildMentionMarkdownString } from '@lexical-core';
+import { buildMentionMarkdownString, markdownToPlainText } from '@lexical-core';
import { createActivityTracker } from '@channel/activity-tracker';
import {
invalidateChannelsActivity,
@@ -223,16 +223,25 @@ export function Channel(props: ChannelProps) {
messageEditor.start(message);
},
onCreateTask: (ctx) => {
+ const plainText = markdownToPlainText(ctx.message.content).trim();
+ const title =
+ plainText.length > 70 ? `${plainText.slice(0, 70)}...` : plainText;
popoverSplit({
type: 'component',
id: 'task-compose',
params: {
+ initialTitle: title,
initialContent: buildMentionMarkdownString({
type: 'document',
documentId: props.channelId,
documentName: channelName() ?? '',
blockName: 'channel',
- blockParams: { channel_message_id: ctx.message.id },
+ blockParams: {
+ channel_message_id: ctx.message.id,
+ ...(ctx.message.thread_id && {
+ channel_thread_id: ctx.message.thread_id,
+ }),
+ },
}),
},
});
diff --git a/js/app/packages/channel/Thread/ThreadReplyList.tsx b/js/app/packages/channel/Thread/ThreadReplyList.tsx
index f53c7fdca7..1e63bbb89b 100644
--- a/js/app/packages/channel/Thread/ThreadReplyList.tsx
+++ b/js/app/packages/channel/Thread/ThreadReplyList.tsx
@@ -80,7 +80,7 @@ export function ThreadReplyList(props: {
>
<ChannelMessage
channelId={props.channelId}
- message={reply}
+ message={replyMessage()}
actions={props.getMessageActions?.(replyMessage())}
listMeta={listMetaByReplyId()[reply.id]}
messageEditor={props.messageEditor}