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(tasks): rail chat bottom-matter comments in tasks (#2731)

Seamusd04cbc1a52bf
diff --git a/js/app/packages/block-md/comments/discussionAdapter.ts b/js/app/packages/block-md/comments/discussionAdapter.ts
new file mode 100644
index 0000000000..c59233cbc1
--- /dev/null
+++ b/js/app/packages/block-md/comments/discussionAdapter.ts
@@ -0,0 +1,45 @@
+import type { MessageData } from '@channel/Message/types';
+import type { ApiChannelMessage } from '@service-storage/generated/schemas/apiChannelMessage';
+import type { Comment } from '@service-storage/generated/schemas/comment';
+
+export function commentToMessageData(comment: Comment): MessageData {
+ return {
+ id: String(comment.commentId),
+ content: comment.text,
+ sender_id: comment.sender ?? comment.owner,
+ created_at: comment.createdAt ?? '',
+ updated_at: comment.updatedAt ?? comment.createdAt ?? '',
+ deleted_at: comment.deletedAt ?? null,
+ edited_at:
+ comment.updatedAt && comment.updatedAt !== comment.createdAt
+ ? comment.updatedAt
+ : null,
+ attachments: [],
+ reactions: [],
+ };
+}
+
+export function commentToApiChannelMessage(
+ comment: Comment
+): ApiChannelMessage {
+ return {
+ id: String(comment.commentId),
+ content: comment.text,
+ sender_id: comment.sender ?? comment.owner,
+ created_at: comment.createdAt ?? '',
+ updated_at: comment.updatedAt ?? comment.createdAt ?? '',
+ deleted_at: comment.deletedAt ?? null,
+ edited_at:
+ comment.updatedAt && comment.updatedAt !== comment.createdAt
+ ? comment.updatedAt
+ : null,
+ attachments: [],
+ reactions: [],
+ channel_id: '',
+ thread: {
+ reply_count: 0,
+ latest_reply_at: null,
+ preview: [],
+ },
+ };
+}
diff --git a/js/app/packages/block-md/comments/discussionResource.ts b/js/app/packages/block-md/comments/discussionResource.ts
new file mode 100644
index 0000000000..05bc5d6f6e
--- /dev/null
+++ b/js/app/packages/block-md/comments/discussionResource.ts
@@ -0,0 +1,59 @@
+import { createBlockMemo } from '@core/block';
+import { compareDateAsc } from '@core/util/date';
+import type { CommentThread } from '@service-storage/generated/schemas/commentThread';
+import type { CreateCommentRequestMentions } from '@service-storage/generated/schemas/createCommentRequestMentions';
+import {
+ commentThreadsResource,
+ sortComments,
+ useCreateHighlightCommentResource,
+ useCreateThreadReplyResource,
+ useDeleteCommentResource,
+ useEditCommentResource,
+} from './commentsResource';
+import type { ThreadMetadata } from './commentType';
+
+export const DISCUSSION_MARK_PREFIX = 'DISCUSSION:';
+
+function isDiscussionThread(ct: CommentThread): boolean {
+ const meta = ct.thread.metadata as ThreadMetadata | undefined;
+ return meta?.markId?.startsWith(DISCUSSION_MARK_PREFIX) ?? false;
+}
+
+export const discussionThreads = createBlockMemo(() => {
+ const [data] = commentThreadsResource;
+ const threads = data() ?? [];
+ return threads
+ .filter(isDiscussionThread)
+ .sort((a, b) => compareDateAsc(a.thread.createdAt, b.thread.createdAt));
+});
+
+export { sortComments };
+
+export function useCreateDiscussionThread() {
+ const createHighlight = useCreateHighlightCommentResource();
+
+ return async (text: string, mentions?: CreateCommentRequestMentions) => {
+ const markId = `${DISCUSSION_MARK_PREFIX}${crypto.randomUUID()}`;
+ return createHighlight(text, markId, mentions);
+ };
+}
+
+export function useCreateDiscussionReply() {
+ const createReply = useCreateThreadReplyResource();
+
+ return async (
+ text: string,
+ threadId: number,
+ mentions?: CreateCommentRequestMentions
+ ) => {
+ return createReply({ text, threadId, mentions });
+ };
+}
+
+export function useEditDiscussionComment() {
+ return useEditCommentResource();
+}
+
+export function useDeleteDiscussionComment() {
+ return useDeleteCommentResource();
+}
diff --git a/js/app/packages/block-md/component/DiscussionInput.tsx b/js/app/packages/block-md/component/DiscussionInput.tsx
new file mode 100644
index 0000000000..a345f79cb7
--- /dev/null
+++ b/js/app/packages/block-md/component/DiscussionInput.tsx
@@ -0,0 +1,243 @@
+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import { isMobile } from '@core/mobile/isMobile';
+import { isIOS } from '@solid-primitives/platform';
+import { createConfiguredDiscussionMarkdownEditor } from './configured-discussion-markdown-editor';
+import { addMediaFromFile } from '@core/component/LexicalMarkdown/plugins/media';
+import type {
+ InputCallbacks,
+ InputData,
+ InputHandle,
+ InputSnapshot,
+} from '@channel/Input/types';
+import {
+ createSignal,
+ type Accessor,
+ type JSX,
+ Show,
+ Match,
+ Switch,
+} from 'solid-js';
+import { Input } from '@channel/Input/Input';
+import { FormatButtons } from '@channel/Input/FormatButtons';
+import {
+ applyInlineFormat,
+ applyNodeFormat,
+} from '@channel/Input/utils/formatting';
+import { isReplyInput } from '@channel/Input/types';
+import type { ItemMention } from '@core/component/LexicalMarkdown/plugins';
+import type { IUser } from '@core/user/types';
+import { InputActionButton } from '@channel/Input/ActionButton';
+import { useInputCommands } from '@channel/Input/context';
+import PaperclipIcon from '@phosphor-icons/core/regular/paperclip.svg?component-solid';
+
+export type DiscussionInputProps = InputCallbacks & {
+ input: InputData;
+ markdownNamespace?: string;
+ participants?: Accessor<IUser[]>;
+ onReady?: (handle: InputHandle) => void;
+ children?: JSX.Element;
+ /** Whether to auto-focus the input on mount. Defaults to `!isMobile()`. */
+ autofocus?: boolean;
+};
+
+function AttachImagesAction() {
+ const commands = useInputCommands();
+ let fileInputRef: HTMLInputElement | undefined;
+
+ const onAttachImages: JSX.EventHandlerUnion<HTMLInputElement, Event> = (
+ event
+ ) => {
+ const files = Array.from(event.currentTarget.files ?? []);
+ event.currentTarget.value = '';
+ if (files.length === 0) return;
+ void commands.attachFiles(files);
+ };
+
+ return (
+ <>
+ <input
+ ref={(element) => {
+ fileInputRef = element;
+ }}
+ type="file"
+ class="hidden"
+ multiple
+ accept="image/*"
+ onChange={onAttachImages}
+ />
+ <InputActionButton
+ label="Attach images"
+ onClick={() => fileInputRef?.click()}
+ >
+ <PaperclipIcon class="size-5" />
+ </InputActionButton>
+ </>
+ );
+}
+
+function DefaultActions(props: { input: InputData }) {
+ return (
+ <Input.Actions>
+ <Input.Actions.Left>
+ <AttachImagesAction />
+ <Input.ToggleFormatAction />
+ <Show when={isReplyInput(props.input)}>
+ <Input.CloseReplyAction />
+ </Show>
+ </Input.Actions.Left>
+ <Input.Actions.Right>
+ <Input.SendAction />
+ </Input.Actions.Right>
+ </Input.Actions>
+ );
+}
+
+export function DiscussionInput(props: DiscussionInputProps) {
+ const [scrollContainer, setScrollContainer] = createSignal<HTMLElement>();
+ const [value, setValue] = createSignal(props.input.value ?? '');
+ const [mentions, setMentions] = createSignal<ItemMention[]>([]);
+ const [showFormatRibbon, setShowFormatRibbon] = createSignal(false);
+
+ const inputView = () => ({
+ ...props.input,
+ value: value(),
+ isEmpty: !value().trim(),
+ attachments: [],
+ showFormatRibbon: showFormatRibbon(),
+ });
+
+ const createSnapshot = (): InputSnapshot => ({
+ value: value(),
+ attachments: [],
+ mentions: mentions(),
+ });
+
+ const markdownEditor = createConfiguredDiscussionMarkdownEditor({
+ type: 'markdown',
+ namespace: props.markdownNamespace ?? 'discussion-input-markdown',
+ enableMentions: true,
+ users: props.participants,
+ scrollContainer,
+ onMentionCreate: (mention) => {
+ setMentions((prev) => [...prev, mention]);
+ },
+ onMentionRemove: (mention) => {
+ setMentions((prev) =>
+ prev.filter(
+ (m) =>
+ !(m.itemId === mention.itemId && m.itemType === mention.itemType)
+ )
+ );
+ },
+ onChange: (markdown) => {
+ setValue(markdown);
+ props.onChange?.(createSnapshot());
+ },
+ onEnter: () => {
+ if (isMobile()) return false;
+ void commands.send();
+ return true;
+ },
+ });
+
+ // Build the editor handle immediately to ensure lexical is available for commands
+ markdownEditor.buildHandle();
+
+ const commands = {
+ send: async () => {
+ const snapshot = createSnapshot();
+ if (!snapshot.value.trim()) return false;
+ await props.onSend?.(snapshot);
+ return true;
+ },
+ close: () => {
+ props.onClose?.(createSnapshot());
+ },
+ toggleFormatRibbon: () => {
+ setShowFormatRibbon(!showFormatRibbon());
+ props.onToggleFormatRibbon?.(!showFormatRibbon());
+ },
+ attachFiles: async (files: File[]) => {
+ // Insert images into the editor
+ for (const file of files) {
+ await addMediaFromFile(markdownEditor.lexical, file, 'image');
+ }
+ },
+ removeAttachment: () => {
+ // No-op for discussion input - no attachments to remove
+ },
+ };
+
+ props.onReady?.({
+ clear: () => {
+ // On iOS, blur before clearing so dictation finalizes and discards its buffer
+ if (isIOS) {
+ markdownEditor.controls.blur();
+ markdownEditor.controls.clear();
+ requestAnimationFrame(() => markdownEditor.controls.focus());
+ } else {
+ markdownEditor.controls.clear();
+ }
+ setValue('');
+ setMentions([]);
+ },
+ focus: () => markdownEditor.controls.focus(),
+ attachFiles: async (files: File[]) => {
+ // Insert images into the editor
+ for (const file of files) {
+ await addMediaFromFile(markdownEditor.lexical, file, 'image');
+ }
+ },
+ restoreSnapshot: (snapshot) => {
+ markdownEditor.controls.setMarkdown(snapshot.value);
+ setMentions(snapshot.mentions);
+ setValue(snapshot.value);
+ markdownEditor.controls.focus();
+ },
+ });
+
+ return (
+ <Input.Root input={inputView()} commands={commands}>
+ <Input.Layout>
+ <Input.FormatRibbon>
+ <FormatButtons
+ selectionState={() => markdownEditor.selection}
+ onInlineFormat={(format) =>
+ applyInlineFormat(markdownEditor.lexical, format)
+ }
+ onNodeFormat={(format) =>
+ applyNodeFormat(markdownEditor.lexical, format)
+ }
+ />
+ </Input.FormatRibbon>
+ <Input.EditorShell
+ ref={setScrollContainer}
+ onClick={(event) => {
+ if (!isMobile()) {
+ event.stopPropagation();
+ markdownEditor.controls.focus();
+ }
+ }}
+ >
+ <Input.Editor>
+ <MarkdownShell
+ config={markdownEditor}
+ placeholder={inputView().placeholder}
+ initialValue={inputView().value}
+ autofocus={!isMobile() && (props.autofocus ?? true)}
+ class="text-sm"
+ />
+ </Input.Editor>
+ </Input.EditorShell>
+ <Input.Footer>
+ <Switch>
+ <Match when={props.children}>{props.children}</Match>
+ <Match when>
+ <DefaultActions input={inputView()} />
+ </Match>
+ </Switch>
+ </Input.Footer>
+ </Input.Layout>
+ </Input.Root>
+ );
+}
diff --git a/js/app/packages/block-md/component/MarkdownEditor.tsx b/js/app/packages/block-md/component/MarkdownEditor.tsx
index 6583c74e70..0406602379 100644
--- a/js/app/packages/block-md/component/MarkdownEditor.tsx
+++ b/js/app/packages/block-md/component/MarkdownEditor.tsx
@@ -193,6 +193,8 @@ const DEBUG = LOCAL_ONLY;
// and add a new line. This constant is the minimum height of that element (in pixels)
// once the editor has at least one full page of content.
const EDITOR_PADDING_BOTTOM = 200;
+// For tasks, the click target is a small fixed pad so the activity section stays visible.
+const TASK_EDITOR_PADDING_BOTTOM = 48;
export function MarkdownEditor(props: { autoFocusOnMount?: boolean } = {}) {
const blockData = blockDataSignal.get;
@@ -651,7 +653,13 @@ export function MarkdownEditor(props: { autoFocusOnMount?: boolean } = {}) {
})
);
+ const isTask = blockName === 'task';
+
const observeClickTargetHeight = () => {
+ if (isTask) {
+ setClickTargetHeight(TASK_EDITOR_PADDING_BOTTOM);
+ return;
+ }
const blockEl = blockElement();
const rootEl = editor.getRootElement();
if (!blockEl || !rootEl) {
@@ -941,6 +949,7 @@ export function MarkdownEditor(props: { autoFocusOnMount?: boolean } = {}) {
classList={{
'select-auto': !canEdit(),
'md-no-comments': !ENABLE_MARKDOWN_COMMENTS,
+ 'min-h-52': isTask,
}}
/>
diff --git a/js/app/packages/block-md/component/Notebook.tsx b/js/app/packages/block-md/component/Notebook.tsx
index d3bd160ba8..469ff588e8 100644
--- a/js/app/packages/block-md/component/Notebook.tsx
+++ b/js/app/packages/block-md/component/Notebook.tsx
@@ -7,12 +7,14 @@ import {
} from '@block-md/comments/commentStore';
import { useGoToTempRedirect } from '@block-md/signal/location';
import { mdStore } from '@block-md/signal/markdownBlockData';
-import { useBlockId } from '@core/block';
-import { ENABLE_MARKDOWN_COMMENTS } from '@core/constant/featureFlags';
+import { useBlockAliasedName, useBlockId } from '@core/block';
+import { editorFocusSignal } from '@core/component/LexicalMarkdown/utils';
+import {
+ ENABLE_MARKDOWN_COMMENTS,
+ ENABLE_RAIL_CHAT_TASK_COMMENTS,
+} from '@core/constant/featureFlags';
import { registerHotkey } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
-import { editorFocusSignal } from '@core/component/LexicalMarkdown/utils';
-import { registerMarkdownCommands } from './useMarkdownCommands';
import {
blockElementSignal,
blockHotkeyScopeSignal,
@@ -27,12 +29,15 @@ import {
createSignal,
onCleanup,
onMount,
+ Show,
untrack,
} from 'solid-js';
import { FrontMatterProperties } from './FrontMatterProperties';
import { InstructionsEditor } from './InstructionsEditor';
import { MarkdownEditor } from './MarkdownEditor';
+import { TaskDiscussion } from './TaskDiscussion';
import { TitleEditor } from './TitleEditor';
+import { registerMarkdownCommands } from './useMarkdownCommands';
const NoteTargetWidth = 768;
const CommentTargetWidth = 320;
@@ -70,6 +75,7 @@ export function Notebook() {
const canEdit = useCanEdit();
const documentName = useBlockDocumentName();
const scopeId = blockHotkeyScopeSignal.get;
+ const isTask = useBlockAliasedName() === 'task';
const md = mdStore.get;
let notebookRef!: HTMLDivElement;
@@ -283,6 +289,9 @@ export function Notebook() {
fallback={<div class="h-6 w-full" />}
/>
<MarkdownEditor autoFocusOnMount={!navigatedFromJK()} />
+ <Show when={ENABLE_RAIL_CHAT_TASK_COMMENTS && isTask}>
+ <TaskDiscussion />
+ </Show>
</div>
<div
class={commentPositioning().classes}
diff --git a/js/app/packages/block-md/component/TaskDiscussion.tsx b/js/app/packages/block-md/component/TaskDiscussion.tsx
new file mode 100644
index 0000000000..c1b4ae9d37
--- /dev/null
+++ b/js/app/packages/block-md/component/TaskDiscussion.tsx
@@ -0,0 +1,327 @@
+import { DiscussionInput } from './DiscussionInput';
+import type { InputSnapshot } from '@channel/Input/types';
+import { Message } from '@channel/Message/Message';
+import type { MessageActions } from '@channel/Message/types';
+import { Thread } from '@channel/Thread/Thread';
+import { ThreadRail } from '@channel/Thread/ThreadRail';
+import { ThreadReplyInputConnector } from '@channel/Thread/ThreadReplyInputConnector';
+import { replyInputOffsetX } from '@channel/Thread/utils/thread-rail-geometry';
+import type { ItemMention } from '@core/component/LexicalMarkdown/plugins';
+import { useUserId } from '@core/context/user';
+import { useCanEdit } from '@core/signal/permissions';
+import { tryMacroId, useDisplayName } from '@core/user';
+import CaretDown from '@icon/bold/caret-down-bold.svg';
+import CaretRight from '@icon/bold/caret-right-bold.svg';
+import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
+import type { Comment } from '@service-storage/generated/schemas/comment';
+import type { CommentThread } from '@service-storage/generated/schemas/commentThread';
+import type { CreateCommentRequestMentions } from '@service-storage/generated/schemas/createCommentRequestMentions';
+import { createSignal, For, Show } from 'solid-js';
+import {
+ commentToApiChannelMessage,
+ commentToMessageData,
+} from '../comments/discussionAdapter';
+import {
+ discussionThreads,
+ sortComments,
+ useCreateDiscussionReply,
+ useCreateDiscussionThread,
+ useDeleteDiscussionComment,
+ useEditDiscussionComment,
+} from '../comments/discussionResource';
+
+function buildCommentMentions(
+ mentions: ItemMention[]
+): CreateCommentRequestMentions | undefined {
+ const userIds = mentions
+ .filter((m) => m.itemType === 'user')
+ .map((m) => m.itemId);
+
+ if (userIds.length === 0) {
+ return undefined;
+ }
+
+ return {
+ mentionId: crypto.randomUUID(),
+ users: userIds,
+ };
+}
+
+export function TaskDiscussion() {
+ const canEdit = useCanEdit();
+ const createThread = useCreateDiscussionThread();
+ const [isExpanded, setIsExpanded] = createSignal(true);
+
+ let newThreadInputHandle: { clear: () => void } | undefined;
+
+ const toggleExpanded = () => {
+ setIsExpanded(!isExpanded());
+ };
+
+ const handleCreateThread = async (snapshot: InputSnapshot) => {
+ const text = snapshot.value.trim();
+ if (!text) return;
+ const mentions = buildCommentMentions(snapshot.mentions);
+ await createThread(text, mentions);
+ newThreadInputHandle?.clear();
+ };
+
+ return (
+ <section class="mt-8 pb-12">
+ <div class="flex items-center gap-2 pt-2">
+ <div class="w-6 border-t border-edge-muted" />
+ <button
+ type="button"
+ class="flex items-center gap-1 px-2 hover:opacity-70 transition-opacity"
+ onClick={toggleExpanded}
+ >
+ {isExpanded() ? (
+ <CaretDown class="w-3 h-3" />
+ ) : (
+ <CaretRight class="w-3 h-3" />
+ )}
+ <span class="text-xs">Discussion</span>
+ </button>
+ <div class="flex-1 border-t border-edge-muted" />
+ </div>
+
+ <Show when={isExpanded()}>
+ <StaticMarkdownContext>
+ <div class="py-2 text-xs">
+ <div>
+ <For each={discussionThreads() ?? []}>
+ {(thread) => <DiscussionThread thread={thread} />}
+ </For>
+ </div>
+
+ <Show when={canEdit()}>
+ <div>
+ <DiscussionInput
+ input={{ mode: 'channel', placeholder: 'Leave a comment...' }}
+ onSend={handleCreateThread}
+ onReady={(handle) => {
+ newThreadInputHandle = handle;
+ }}
+ autofocus={false}
+ />
+ </div>
+ </Show>
+ </div>
+ </StaticMarkdownContext>
+ </Show>
+ </section>
+ );
+}
+
+function DiscussionThread(props: { thread: CommentThread }) {
+ const userId = useUserId();
+ const canEdit = useCanEdit();
+ const createReply = useCreateDiscussionReply();
+ const editComment = useEditDiscussionComment();
+ const deleteComment = useDeleteDiscussionComment();
+
+ const [isReplying, setIsReplying] = createSignal(false);
+ const [editingId, setEditingId] = createSignal<number | null>(null);
+ let replyInputHandle: { clear: () => void } | undefined;
+ let replyInputContainerRef: HTMLDivElement | undefined;
+
+ const sorted = () => [...props.thread.comments].sort(sortComments);
+ const root = () => sorted()[0];
+ const replies = () => sorted().slice(1);
+ const hasReplies = () => replies().length > 0;
+
+ const threadId = () => props.thread.thread.threadId;
+
+ const replyUserId = () => userId() ?? root()?.sender ?? root()?.owner ?? '';
+ const macroId = () => tryMacroId(replyUserId());
+ const [displayName] = useDisplayName(macroId());
+
+ const isOwn = (comment: Comment) =>
+ (comment.sender ?? comment.owner) === userId();
+
+ const makeActions = (comment: Comment, isRoot: boolean): MessageActions => {
+ const own = isOwn(comment);
+ return {
+ onReply: isRoot
+ ? () => {
+ setIsReplying(true);
+ }
+ : undefined,
+ onEdit: own
+ ? () => {
+ setEditingId(comment.commentId);
+ }
+ : undefined,
+ onDelete:
+ own && canEdit()
+ ? async () => {
+ await deleteComment(comment.commentId, {});
+ }
+ : undefined,
+ };
+ };
+
+ const handleReply = async (snapshot: InputSnapshot) => {
+ const text = snapshot.value.trim();
+ if (!text) return;
+ const mentions = buildCommentMentions(snapshot.mentions);
+ await createReply(text, threadId(), mentions);
+ replyInputHandle?.clear();
+ setIsReplying(false);
+ };
+
+ const handleEdit = async (comment: Comment, snapshot: InputSnapshot) => {
+ const text = snapshot.value.trim();
+ if (!text) return;
+ await editComment(comment.commentId, {
+ text,
+ threadId: threadId(),
+ });
+ setEditingId(null);
+ };
+
+ return (
+ <Show when={root()}>
+ {(rootComment) => {
+ const rootMessageData = () => commentToApiChannelMessage(rootComment());
+ return (
+ <div class="flex flex-col w-full gap-0">
+ <Thread.Row message={rootMessageData()}>
+ <DiscussionMessage
+ comment={rootComment()}
+ actions={makeActions(rootComment(), true)}
+ editingId={editingId()}
+ onEditSave={(snapshot) => handleEdit(rootComment(), snapshot)}
+ onEditCancel={() => setEditingId(null)}
+ />
+
+ <Show when={hasReplies() || isReplying()}>
+ <div class="relative w-full">
+ <Thread.ReplyRailDecorations
+ isReplying={isReplying}
+ firstThreadReplyNewMessage={false}
+ />
+ <Thread.RepliesContainer>
+ <For each={replies()}>
+ {(reply) => (
+ <div class="relative">
+ <ThreadRail />
+ <DiscussionMessage
+ comment={reply}
+ actions={makeActions(reply, false)}
+ editingId={editingId()}
+ onEditSave={(snapshot) =>
+ handleEdit(reply, snapshot)
+ }
+ onEditCancel={() => setEditingId(null)}
+ />
+ </div>
+ )}
+ </For>
+
+ <Show when={isReplying() && canEdit()}>
+ <div class="ph-no-capture">
+ <Show when={!hasReplies()}>
+ <Thread.ReplyAuthor
+ userId={replyUserId()}
+ displayName={displayName()}
+ />
+ </Show>
+ <div
+ ref={replyInputContainerRef}
+ class="relative pt-2"
+ style={{ 'margin-left': replyInputOffsetX }}
+ >
+ <ThreadReplyInputConnector />
+ <DiscussionInput
+ input={{ mode: 'reply', placeholder: 'Reply...' }}
+ onSend={handleReply}
+ onClose={() => {
+ setIsReplying(false);
+ }}
+ onReady={(handle) => {
+ replyInputHandle = handle;
+ }}
+ />
+ </div>
+ </div>
+ </Show>
+
+ <Show when={!isReplying() && canEdit()}>
+ <Thread.ActionsFooter>
+ <Thread.ReplyButton
+ getFocusTarget={() =>
+ replyInputContainerRef?.querySelector<HTMLElement>(
+ '[contenteditable]'
+ ) ?? null
+ }
+ onClick={() => setIsReplying(true)}
+ aria-label="Reply"
+ />
+ </Thread.ActionsFooter>
+ </Show>
+ </Thread.RepliesContainer>
+ </div>
+ </Show>
+ </Thread.Row>
+ </div>
+ );
+ }}
+ </Show>
+ );
+}
+
+function DiscussionMessage(props: {
+ comment: Comment;
+ actions: MessageActions;
+ editingId: number | null;
+ onEditSave: (snapshot: InputSnapshot) => void;
+ onEditCancel: () => void;
+}) {
+ const isEditing = () => props.editingId === props.comment.commentId;
+ const messageData = () => commentToMessageData(props.comment);
+
+ return (
+ <Show
+ when={!isEditing()}
+ fallback={
+ <DiscussionInput
+ input={{
+ mode: 'reply',
+ placeholder: 'Edit comment...',
+ value: props.comment.text,
+ }}
+ onSend={props.onEditSave}
+ onClose={() => {
+ props.onEditCancel();
+ }}
+ />
+ }
+ >
+ <Message.Root message={messageData()} actions={props.actions}>
+ <Message.Layout class="pt-(--regular-message-padding-t)">
+ <Message.Slot placement="icon">
+ <Message.SenderIcon />
+ </Message.Slot>
+ <Message.Slot
+ placement="header"
+ class="flex items-center gap-1 min-w-0 w-full"
+ >
+ <Message.SenderName />
+ <Message.EditedIndicator />
+ <div class="grow-1 shrink-0 min-w-0 flex justify-end group-hover/message:absolute group-hover/message:right-1 group-hover/message:-top-9 group-hover/message:p-1">
+ <Message.Timestamp
+ class="ml-auto shrink-0"
+ format="dateAndTime"
+ />
+ </div>
+ </Message.Slot>
+ <Message.Slot placement="content" class="ph-no-capture">
+ <Message.Content />
+ </Message.Slot>
+ <Message.ActionMenu />
+ </Message.Layout>
+ </Message.Root>
+ </Show>
+ );
+}
diff --git a/js/app/packages/block-md/component/configured-discussion-markdown-editor.ts b/js/app/packages/block-md/component/configured-discussion-markdown-editor.ts
new file mode 100644
index 0000000000..bee8d6ed10
--- /dev/null
+++ b/js/app/packages/block-md/component/configured-discussion-markdown-editor.ts
@@ -0,0 +1,78 @@
+import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
+import {
+ DefaultShortcuts,
+ type ItemMention,
+ keyboardShortcutsPlugin,
+} from '@core/component/LexicalMarkdown/plugins';
+import { iosCursorScrollPlugin } from '@core/component/LexicalMarkdown/plugins/ios-cursor-scroll';
+import { tableCellResizerPlugin } from '@core/component/LexicalMarkdown/plugins/tables/tableCellResizerPlugin';
+import { tablePlugin } from '@core/component/LexicalMarkdown/plugins/tables/tablePlugin';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import type { IUser } from '@core/user/types';
+import type { EditorType } from '@lexical-core';
+import { isIOS } from '@solid-primitives/platform';
+import type { Accessor } from 'solid-js';
+
+type CreateConfiguredDiscussionMarkdownEditorOptions = {
+ namespace: string;
+ enableMentions?: boolean;
+ onMentionCreate?: (mention: ItemMention) => void;
+ onMentionRemove?: (mention: ItemMention) => void;
+ users?: () => IUser[];
+ onChange?: (markdown: string) => void;
+ onEnter?: (event: KeyboardEvent, markdown: string) => boolean;
+ scrollContainer?: Accessor<HTMLElement | undefined>;
+ type?: EditorType;
+};
+
+export function createConfiguredDiscussionMarkdownEditor(
+ options: CreateConfiguredDiscussionMarkdownEditorOptions
+) {
+ const editor = buildConfig(options.type ?? 'chat');
+ editor.namespace(options.namespace);
+
+ if (options.enableMentions !== false) {
+ editor.withMentions({
+ onCreate: options.onMentionCreate,
+ onRemove: options.onMentionRemove,
+ users: options.users,
+ block: 'channel',
+ });
+ }
+
+ editor
+ .withMedia({ fileDrop: true })
+ .withEmojis()
+ .withActions({ ignoreActionIds: ['hr', 'table', 'latex'] })
+ .withLinks({ floatingMenu: true })
+ .withHistory({ timeGap: 400 })
+ .withCode()
+ .withRestoreFocus()
+ .withSelectionData();
+
+ editor
+ .use(
+ tablePlugin({
+ hasCellMerge: true,
+ hasCellBackgroundColor: false,
+ hasTabHandler: true,
+ hasHorizontalScroll: true,
+ })
+ )
+ .use(tableCellResizerPlugin())
+ .use(
+ keyboardShortcutsPlugin({
+ shortcuts: DefaultShortcuts,
+ })
+ )
+ .onChange(options.onChange)
+ .onEnter(options.onEnter);
+
+ if ((isIOS || isNativeMobilePlatform()) && options.scrollContainer) {
+ editor.use(
+ iosCursorScrollPlugin({ scrollContainer: options.scrollContainer })
+ );
+ }
+
+ return editor;
+}
diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsx
index 7f1c831071..f8d173090d 100644
--- a/js/app/packages/channel/Message/ChannelMessage.tsx
+++ b/js/app/packages/channel/Message/ChannelMessage.tsx
@@ -1,15 +1,15 @@
-import { Match, Show, Switch, type JSX } from 'solid-js';
-import { cn } from '@ui/utils/classname';
-import type { MessageActions, MessageData } from './types';
-import { Message } from './Message';
-import type { ChannelMessageListMeta } from './list-meta';
-import { useMessage, MessageSelectionProvider } from './context';
-import type { MessageSelectionState } from './context';
import { useMessageActionDrawer } from '@channel/Mobile/message-action-drawer-context';
-import type { MessageEditor } from '../Channel/create-message-editor';
-import { MessageEditorContent } from '../Channel/InlineMessageEditor';
import { longPressHighlight } from '@core/directive/longPressHighlight';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { cn } from '@ui/utils/classname';
+import { type JSX, Match, Show, Switch } from 'solid-js';
+import type { MessageEditor } from '../Channel/create-message-editor';
+import { MessageEditorContent } from '../Channel/InlineMessageEditor';
+import type { MessageSelectionState } from './context';
+import { MessageSelectionProvider, useMessage } from './context';
+import type { ChannelMessageListMeta } from './list-meta';
+import { Message } from './Message';
+import type { MessageActions, MessageData } from './types';
type ChannelMessageProps = {
channelId: string;
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/core/BlockLink.tsx b/js/app/packages/core/component/LexicalMarkdown/component/core/BlockLink.tsx
index 919999be31..0f0f152680 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/core/BlockLink.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/core/BlockLink.tsx
@@ -11,6 +11,7 @@ export const blockNamesWithLocations = [
'canvas',
'channel',
'md',
+ 'task',
'email',
'chat',
'task',
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
index 86db01415c..974487d5b7 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
@@ -180,7 +180,7 @@ export function ActionMenu(props: {
});
const [escapeSpaceState, setEscapeSpaceState] = createSignal<
- 'start' | 'single' | 'double' | null
+ 'start' | 'single' | null
>('start');
createEffect(() => {
if (!isOpen()) {
@@ -229,13 +229,10 @@ export function ActionMenu(props: {
onClose: closeMenu,
onSpace: () => {
switch (escapeSpaceState()) {
- case 'double':
+ case 'single':
case 'start':
closeMenu();
return true;
- case 'single':
- setEscapeSpaceState('double');
- return false;
case null:
setEscapeSpaceState('single');
return false;
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/EmojiMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/EmojiMenu.tsx
index be9a9de427..3a51846f1a 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/EmojiMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/EmojiMenu.tsx
@@ -72,7 +72,7 @@ export function EmojiMenu(props: EmojiMenuProps) {
const [mountSelection, setMountSelection] = createSignal<Selection | null>();
const [selectedIndex, setSelectedIndex] = createSignal(0);
const [escapeSpaceState, setEscapeSpaceState] = createSignal<
- 'start' | 'single' | 'double' | null
+ 'start' | 'single' | null
>('start');
const [virtualHandle, setVirtualHandle] = createSignal<VirtualizerHandle>();
const [menuAvailableHeight, setMenuAvailableHeight] = createSignal<
@@ -193,13 +193,10 @@ export function EmojiMenu(props: EmojiMenuProps) {
onClose: closeMenu,
onSpace: () => {
switch (escapeSpaceState()) {
- case 'double':
+ case 'single':
case 'start':
closeMenu();
return true;
- case 'single':
- setEscapeSpaceState('double');
- return false;
case null:
setEscapeSpaceState('single');
return false;
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
index e4492da3c7..b24c4a192b 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
@@ -309,7 +309,7 @@ function MentionsMenuInner(props: MentionsMenuProps) {
});
const [escapeSpaceState, setEscapeSpaceState] = createSignal<
- 'start' | 'single' | 'double' | null
+ 'start' | 'single' | null
>('start');
createEffect(() => {
@@ -399,13 +399,10 @@ function MentionsMenuInner(props: MentionsMenuProps) {
},
onSpace: () => {
switch (escapeSpaceState()) {
- case 'double':
+ case 'single':
case 'start':
closeMenu();
return true;
- case 'single':
- setEscapeSpaceState('double');
- return false;
case null:
setEscapeSpaceState('single');
return false;
diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/draggable-block/draggableBlockPlugin.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/draggable-block/draggableBlockPlugin.ts
index f57956fdaf..2d47d86cff 100644
--- a/js/app/packages/core/component/LexicalMarkdown/plugins/draggable-block/draggableBlockPlugin.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/draggable-block/draggableBlockPlugin.ts
@@ -519,8 +519,6 @@ function registerDraggableBlock(
});
}
- // -- Listener management -------------------------------------------------
-
function attachDragListeners(elem: HTMLElement) {
elem.addEventListener('dragover', handleDragOver, true);
elem.addEventListener('drop', handleDrop, true);
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index 6adffff602..18c13bfd7c 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -310,6 +310,11 @@ export const ENABLE_CLIENT_EMAIL_SIGNAL_FILTER = resolveFeatureFlag(
false
);
+export const ENABLE_RAIL_CHAT_TASK_COMMENTS = resolveFeatureFlag(
+ 'RAIL_CHAT_TASK_COMMENTS',
+ DEV_MODE_ENV
+);
+
// skips over posthog and sets the ENABLE_CALLS feature to true if we are in dev mode
const ENABLE_CALLS_OVERRIDE = DEV_MODE_ENV ? true : undefined;