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(channels): prevent Recent agent preview remount loop (#7872)
Peter Chinman4bd03d886234
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.test.tsxindex b5496a0f45..60aae002ec 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.test.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.test.tsx@@ -1,8 +1,21 @@import { ChatMessageMarkdown } from '@core/component/AI/component/message/ChatMessageMarkdown';import { render, waitFor } from '@solidjs/testing-library';-import type { JSX } from 'solid-js';+import { createSignal, type JSX } from 'solid-js';import { describe, expect, it, vi } from 'vitest';-import { StaticMarkdownContext } from './StaticMarkdown';+import { StaticMarkdown, StaticMarkdownContext } from './StaticMarkdown';++const agentPreview = vi.hoisted(() => ({+ label: (): string => 'Loading session',+ mounted: vi.fn(),+}));++vi.mock('../decorator/AgentSessionMention', () => ({+ AgentSessionMention: () => {+ // Query setup can synchronously read its current reactive snapshot.+ agentPreview.mounted(agentPreview.label());+ return <span data-session-preview>{agentPreview.label()}</span>;+ },+}));vi.mock('@service-connection/websocket', () => ({ws: { send() {}, addEventListener() {}, removeEventListener() {} },@@ -120,3 +133,33 @@ describe('sent message document cards', () => {rendered.unmount();});});++describe('static agent session previews', () => {+ it('updates a preview without remounting its query on every result', async () => {+ const [label, setLabel] = createSignal('Loading session');+ agentPreview.label = label;+ agentPreview.mounted.mockClear();+ const rendered = render(() => (+ <StaticMarkdownContext>+ <StaticMarkdown+ markdown='<m-agent-session-mention>{"id":"session-1","label":"Session"}</m-agent-session-mention>'+ singleLine+ />+ </StaticMarkdownContext>+ ));+ // Let the asynchronous citation pass finish its initial render too.+ await waitFor(() => {+ expect(rendered.container.textContent).toContain('Loading session');+ });+ const preview = rendered.container.querySelector('[data-session-preview]');+ const mounts = agentPreview.mounted.mock.calls.length;++ setLabel('Loaded session');+ expect(rendered.container.textContent).toContain('Loaded session');+ expect(rendered.container.querySelector('[data-session-preview]')).toBe(+ preview+ );+ expect(agentPreview.mounted).toHaveBeenCalledTimes(mounts);+ rendered.unmount();+ });+});diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.tsxindex 3a35970fa8..952442e0d6 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.tsx@@ -411,11 +411,11 @@ const AgentSessionMention: TypedRenderableEntity<AgentSessionMentionNode> = {node.__type === 'agent-session-mention',render: (props) => (<span class={getTextClassName(props.node, props.theme)}>- {AgentSessionMentionDecorator({- ...props.node.exportComponentProps(),- key: props.node.getKey(),- theme: props.theme,- })}+ <AgentSessionMentionDecorator+ {...props.node.exportComponentProps()}+ key={props.node.getKey()}+ theme={props.theme}+ /></span>),};diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.mdindex 8127101241..2d333b361d 100644--- a/docs/AGENT_GUIDE/channels.md+++ b/docs/AGENT_GUIDE/channels.md@@ -741,6 +741,11 @@ list errors do not affect an active search.Collapsing a section does not discard its loaded pages. Recent has its ownpagination cursor. Each list is virtualized, so offscreen conversations may notexist in the DOM.+Verify Recent in a visible browser with a latest-message preview containing an+agent-session mention. Let its title resolve, scroll the preview out of view and+back, then switch to All. The title should update without repeatedly remounting+the mention, and scrolling and navigation must remain responsive; a headless+browser alone can miss this regression.Channels and DMs each have a sort action before their create action. They can besorted by last viewed, last updated, or date created, and each choice persistsindependently as a user preference.