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): keep expanded comments and Open Session inside the card (#9551)
gbirman9bce13dcd69d
diff --git a/apps/web/src/features/channel/Message/ChannelMessage.tsx b/apps/web/src/features/channel/Message/ChannelMessage.tsxindex 803e159940..03e38d7b7a 100644--- a/apps/web/src/features/channel/Message/ChannelMessage.tsx+++ b/apps/web/src/features/channel/Message/ChannelMessage.tsx@@ -139,17 +139,21 @@ function RegularMessageLayout(props: {<Message.SenderIcon /></Message.Slot><Message.Slot placement="header" class="flex flex-col gap-0.5 min-w-0">- <div class="flex items-baseline gap-1 min-w-0">- <Message.SenderName />- <Message.AgentBadge />- <Message.Timestamp- class="shrink-0"- format={- props.timestampFormat ??- (props.parent?.type === 'channel' ? 'time' : 'dateAndTime')- }- />- <Message.EditedIndicator class="shrink-0" />+ {/* In a narrow card (a document comment) the session link wraps to+ its own line rather than running past the card's edge. */}+ <div class="flex flex-wrap items-baseline gap-x-1 gap-y-0.5 min-w-0">+ <div class="flex items-baseline gap-1 min-w-0">+ <Message.SenderName />+ <Message.AgentBadge />+ <Message.Timestamp+ class="shrink-0"+ format={+ props.timestampFormat ??+ (props.parent?.type === 'channel' ? 'time' : 'dateAndTime')+ }+ />+ <Message.EditedIndicator class="shrink-0" />+ </div><Message.AgentSessionLink class="ml-auto" /></div><Show when={!props.hideTriggeredBy}>diff --git a/apps/web/src/features/channel/Message/Content.tsx b/apps/web/src/features/channel/Message/Content.tsxindex 01f4e786e5..205f718a51 100644--- a/apps/web/src/features/channel/Message/Content.tsx+++ b/apps/web/src/features/channel/Message/Content.tsx@@ -100,13 +100,30 @@ function CollapsibleBody(props: { children: JSX.Element }) {onCleanup(() => observer.disconnect());});+ let bodyRef!: HTMLDivElement;+const collapsed = () => overflowing() && !expanded();+ const toggleExpanded = () => {+ // The preview starts at the top, wherever the expanded body was scrolled.+ if (expanded()) bodyRef.scrollTop = 0;+ setExpanded((prev) => !prev);+ };+return (<><div+ ref={bodyRef}data-collapsed={collapsed() ? '' : undefined}- class={cn(collapsed() && 'overflow-hidden')}+ // Expanded, the body scrolls inside the card, which would otherwise+ // grow past the document it sits beside.+ class={cn(+ collapsed() && 'overflow-hidden',+ expanded() && 'max-h-[50vh] overflow-y-auto'+ )}+ // Safari never focuses a scroll box on its own, so without this a+ // keyboard could not scroll a comment that has no links.+ tabIndex={expanded() ? 0 : undefined}// Tabbing to a link under the cut (or in the fade) reveals it// instead of focusing something hidden.onFocusIn={(event) => {@@ -134,7 +151,7 @@ function CollapsibleBody(props: { children: JSX.Element }) {size="xs"class="mt-1 -ml-1.5 text-ink-muted"aria-expanded={expanded()}- onClick={() => setExpanded((prev) => !prev)}+ onClick={toggleExpanded}><CaretRightaria-hidden="true"diff --git a/apps/web/src/features/channel/Message/tests/collapsible-content.test.tsx b/apps/web/src/features/channel/Message/tests/collapsible-content.test.tsxindex 9d601bd613..fcc95fc281 100644--- a/apps/web/src/features/channel/Message/tests/collapsible-content.test.tsx+++ b/apps/web/src/features/channel/Message/tests/collapsible-content.test.tsx@@ -76,6 +76,22 @@ describe('long message content', () => {expect(screen.getByRole('button', { name: 'Show more' })).toBeTruthy();});+ it('starts the preview at the top again after reading down the expanded body', () => {+ setBodyHeight(800);+ const view = renderContent(true);+ const body = view.container.querySelector<HTMLElement>(+ '[data-message-content] > div'+ )!;++ fireEvent.click(screen.getByRole('button', { name: 'Show more' }));+ body.scrollTop = 500;+ expect(body.scrollTop).toBe(500);++ fireEvent.click(screen.getByRole('button', { name: 'Show less' }));+ expect(body.hasAttribute('data-collapsed')).toBe(true);+ expect(body.scrollTop).toBe(0);+ });+it('reveals a hidden link when focus moves into it', () => {setBodyHeight(800);const view = renderContent(true);