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(comments): stack floating comment replies on a single rail (#6866)
gbirman275f31104ad8
diff --git a/apps/web/src/features/channel/Thread/ChannelThread.tsx b/apps/web/src/features/channel/Thread/ChannelThread.tsxindex 3210142964..0c5c3329bd 100644--- a/apps/web/src/features/channel/Thread/ChannelThread.tsx+++ b/apps/web/src/features/channel/Thread/ChannelThread.tsx@@ -338,12 +338,15 @@ export function ChannelThread(props: ThreadProps) {button's left edge. Its vertical part starts exactly at thelast reply row's bottom (button h-8 + mb-2 + container pb). */}<Show- when={shouldShowCollapsedIndicator() || shouldShowReplyButton()}+ when={+ !props.monorail &&+ (shouldShowCollapsedIndicator() || shouldShowReplyButton())+ }><Thread.TerminalRail /></Show><DebugSuspense name="ChannelThread.replies">- <Thread.RepliesContainer>+ <Thread.RepliesContainer flat={props.monorail}><DebugSuspense name="ChannelThread.ReplyList"><Thread.ReplyListparent={props.parent()}@@ -362,6 +365,7 @@ export function ChannelThread(props: ThreadProps) {}isThreadFocused={isThreadFocused}onSelectReply={selectReply}+ monorail={props.monorail}/></DebugSuspense>@@ -379,20 +383,22 @@ export function ChannelThread(props: ThreadProps) {composer, so this branch turns at the avatar'scenter. Once replies exist, it instead joins thecomposer at its vertical center. */}- <div- class="pointer-events-none absolute top-0 -z-1 channel-rail-left channel-rail-bottom border-thread-rail rounded-bl-[14px]"- style={{- left: 'calc(var(--user-icon-width) / 2 + var(--message-padding-x) - var(--thread-shift) - var(--channel-rail-width) / 2)',- width:- 'calc(var(--thread-shift) - var(--user-icon-width) / 2 - var(--channel-rail-clearance))',- ...(hasReplies()- ? { bottom: '50%' }- : {- height:- 'calc(var(--message-padding-x) + var(--user-icon-width) / 2)',- }),- }}- />+ <Show when={!props.monorail}>+ <div+ class="pointer-events-none absolute top-0 -z-1 channel-rail-left channel-rail-bottom border-thread-rail rounded-bl-[14px]"+ style={{+ left: 'calc(var(--user-icon-width) / 2 + var(--message-padding-x) - var(--thread-shift) - var(--channel-rail-width) / 2)',+ width:+ 'calc(var(--thread-shift) - var(--user-icon-width) / 2 - var(--channel-rail-clearance))',+ ...(hasReplies()+ ? { bottom: '50%' }+ : {+ height:+ 'calc(var(--message-padding-x) + var(--user-icon-width) / 2)',+ }),+ }}+ />+ </Show><Show when={!hasReplies()}><Thread.ReplyAuthoruserId={replyUserId()}diff --git a/apps/web/src/features/channel/Thread/ThreadRepliesContainer.tsx b/apps/web/src/features/channel/Thread/ThreadRepliesContainer.tsxindex 0f9ff8205a..56ed41a7b8 100644--- a/apps/web/src/features/channel/Thread/ThreadRepliesContainer.tsx+++ b/apps/web/src/features/channel/Thread/ThreadRepliesContainer.tsx@@ -1,12 +1,17 @@import type { ParentProps } from 'solid-js';import { threadOffsetX } from './utils/thread-rail-geometry';-export function ThreadRepliesContainer(props: ParentProps) {+export function ThreadRepliesContainer(+ props: ParentProps<{+ /** Keep replies in the root's avatar column instead of indenting them. */+ flat?: boolean;+ }>+) {return (<divclass="flex flex-col w-full py-(--thread-padding-y)"style={{- 'padding-left': threadOffsetX,+ 'padding-left': props.flat ? undefined : threadOffsetX,}}>{props.children}diff --git a/apps/web/src/features/channel/Thread/ThreadReplyList.tsx b/apps/web/src/features/channel/Thread/ThreadReplyList.tsxindex 59d053902e..bf3d972f10 100644--- a/apps/web/src/features/channel/Thread/ThreadReplyList.tsx+++ b/apps/web/src/features/channel/Thread/ThreadReplyList.tsx@@ -3,7 +3,14 @@ import type {Message as EntityMessage,MessageParent,} from '@service-storage/messages';-import { type Accessor, createMemo, For, onCleanup, onMount } from 'solid-js';+import {+ type Accessor,+ createMemo,+ For,+ onCleanup,+ onMount,+ Show,+} from 'solid-js';import type { MessageEditor } from '../Channel/create-message-editor';import type { NewMessageCheckable } from '../Channel/util';import {@@ -13,6 +20,7 @@ import {} from '../Message';import { createTargetReplyScroller } from './create-target-reply-scroller';import { buildThreadReplyListMeta } from './reply-list-meta';+import { ThreadReplyMonorail } from './ThreadReplyMonorail';import { ThreadReplyRail } from './ThreadReplyRail';export type ThreadReplyListHandle = {@@ -40,6 +48,8 @@ export function ThreadReplyList(props: {targetedReplyId?: Accessor<string | undefined>;isThreadFocused?: Accessor<boolean>;onSelectReply?: (replyId: string) => void;+ /** Keep replies on the root's rail instead of branching each one off it. */+ monorail?: boolean;}) {const listMetaByReplyId = createMemo(() =>buildThreadReplyListMeta(props.replies, props.isNewMessage)@@ -47,6 +57,11 @@ export function ThreadReplyList(props: {const repliesById = createMemo(() => new Map(props.replies.map((reply) => [reply.id, reply])));+ const lastAvatarIndex = createMemo(() =>+ props.replies.findLastIndex(+ (reply) => !listMetaByReplyId()[reply.id]?.isGroupedWithPrevious+ )+ );const replyElements = new Map<string, HTMLElement>();const targetReplyScroller = createTargetReplyScroller({getTarget: (index) => replyElements.get(props.replies[index]?.id),@@ -81,9 +96,21 @@ export function ThreadReplyList(props: {}}class="relative">- <ThreadReplyRail- grouped={listMetaByReplyId()[id].isGroupedWithPrevious}- />+ <Show+ when={props.monorail}+ fallback={+ <ThreadReplyRail+ grouped={listMetaByReplyId()[id].isGroupedWithPrevious}+ />+ }+ >+ <Show when={listMetaByReplyId()[id].index <= lastAvatarIndex()}>+ <ThreadReplyMonorail+ grouped={listMetaByReplyId()[id].isGroupedWithPrevious}+ terminal={listMetaByReplyId()[id].index === lastAvatarIndex()}+ />+ </Show>+ </Show><MarkMessageNotifications messageId={id} parent={props.parent}><ChannelMessageparent={props.parent}diff --git a/apps/web/src/features/channel/Thread/ThreadReplyMonorail.tsx b/apps/web/src/features/channel/Thread/ThreadReplyMonorail.tsxnew file mode 100644index 0000000000..9b3abd6efc--- /dev/null+++ b/apps/web/src/features/channel/Thread/ThreadReplyMonorail.tsx@@ -0,0 +1,48 @@+import { cn } from '@ui';+import { type JSX, Show } from 'solid-js';++type ThreadReplyMonorailProps = {+ /** Grouped replies have no avatar; the rail runs straight through them. */+ grouped?: boolean;+ /** The last reply with an avatar: the rail ends above that avatar. */+ terminal?: boolean;+};++function RailSegment(props: { class: string; style?: JSX.CSSProperties }) {+ return (+ <div+ class={cn(+ 'pointer-events-none absolute -z-1 channel-rail-left border-thread-rail left-(--left-of-channel-rail)',+ props.class+ )}+ style={props.style}+ />+ );+}++/**+ * The rail for one reply row of an unindented thread. Replies sit in the+ * root's avatar column, so a single straight rail joins the avatars, broken+ * by the shared clearance around each one.+ */+export function ThreadReplyMonorail(props: ThreadReplyMonorailProps) {+ return (+ <Show when={!props.grouped} fallback={<RailSegment class="inset-y-0" />}>+ <RailSegment+ class="top-0"+ style={{+ height:+ 'calc(var(--regular-message-padding-t) - var(--channel-rail-clearance))',+ }}+ />+ <Show when={!props.terminal}>+ <RailSegment+ class="bottom-0"+ style={{+ top: 'calc(var(--regular-message-padding-t) + var(--user-icon-width) + var(--channel-rail-clearance))',+ }}+ />+ </Show>+ </Show>+ );+}diff --git a/apps/web/src/features/channel/Thread/types.ts b/apps/web/src/features/channel/Thread/types.tsindex 2aade377c1..c5596e5ed4 100644--- a/apps/web/src/features/channel/Thread/types.ts+++ b/apps/web/src/features/channel/Thread/types.ts@@ -70,4 +70,9 @@ export type ThreadProps = {onClearSelection?: () => void;messageListScopeId?: string;isNewestThread?: boolean;+ /**+ * A single-root thread (a document's floating comment) stacks replies under+ * the root on one straight rail instead of indenting and branching them.+ */+ monorail?: boolean;} & ThreadState;diff --git a/apps/web/src/lib/core/comments/Thread.tsx b/apps/web/src/lib/core/comments/Thread.tsxindex 5cf0f137bd..f3d1a18cb9 100644--- a/apps/web/src/lib/core/comments/Thread.tsx+++ b/apps/web/src/lib/core/comments/Thread.tsx@@ -225,6 +225,7 @@ function MessageThreadBody(props: ThreadBodyProps) {parent={parent()}rootId={String(props.comment.threadId)}canWrite={context.canComment()}+ monorailhideReplyInput={props.hideReplyInput}onEditingChange={context.setMessageEditing}targetId={targetId()}diff --git a/apps/web/src/lib/core/messages/MessageThread.tsx b/apps/web/src/lib/core/messages/MessageThread.tsxindex 6b8542293a..3843835470 100644--- a/apps/web/src/lib/core/messages/MessageThread.tsx+++ b/apps/web/src/lib/core/messages/MessageThread.tsx@@ -45,6 +45,7 @@ type ThreadOptions = {expanded?: boolean;hideReplyInput?: boolean;onEditingChange?: (id: string, editing: boolean) => void;+ monorail?: boolean;};/** Document and source-channel threads compose the existing channel thread and message controls. */@@ -117,6 +118,7 @@ export function MessageThread(setReplyInputHandle={setHandle}replyInputFocusRequest={focus}isFindBarOpen={() => false}+ monorail={props.monorail}messageListScopeId={scopeId}selectedMessageId={() => (props.targetId ? props.data.id : undefined)}targetNavigation={{