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(agents): stop images in the last agent reply flashing on send (#7100)
Wolf Mermelstein91e6495e1a84
diff --git a/apps/web/src/features/block-agent/component/parts/TextPart.test.tsx b/apps/web/src/features/block-agent/component/parts/TextPart.test.tsxnew file mode 100644index 0000000000..3632d8cff0--- /dev/null+++ b/apps/web/src/features/block-agent/component/parts/TextPart.test.tsx@@ -0,0 +1,52 @@+/**+ * @vitest-environment jsdom+ *+ * A settled message's markdown must not re-render when only `inFlight`+ * flips: sending a prompt briefly marks the previous agent message live, and+ * each re-render rebuilds its DOM, reloading every image in it.+ */++import { render } from '@solidjs/testing-library';+import { createEffect, createSignal } from 'solid-js';+import { describe, expect, it, vi } from 'vitest';+import { TextPart } from './TextPart';++const parses = vi.hoisted((): string[] => []);++vi.mock(+ '@core/component/LexicalMarkdown/component/core/StaticMarkdown',+ () => ({+ StaticMarkdown: (props: { markdown: string }) => {+ createEffect(() => {+ parses.push(props.markdown);+ });+ return null;+ },+ })+);+vi.mock('@core/component/LexicalMarkdown/theme', () => ({+ channelTheme: {},+}));++describe('TextPart', () => {+ it('does not re-render unchanged markdown when inFlight flips', () => {+ parses.length = 0;+ const [inFlight, setInFlight] = createSignal(false);+ render(() => <TextPart text="" inFlight={inFlight()} />);++ setInFlight(true);+ setInFlight(false);++ expect(parses).toEqual(['']);+ });++ it('re-renders when the in-flight text hides an unclosed tag', () => {+ parses.length = 0;+ const [inFlight, setInFlight] = createSignal(false);+ render(() => <TextPart text="hi <m-document" inFlight={inFlight()} />);++ setInFlight(true);++ expect(parses).toEqual(['hi <m-document', 'hi ']);+ });+});diff --git a/apps/web/src/features/block-agent/component/parts/TextPart.tsx b/apps/web/src/features/block-agent/component/parts/TextPart.tsxindex 586cb2254e..b1c5509673 100644--- a/apps/web/src/features/block-agent/component/parts/TextPart.tsx+++ b/apps/web/src/features/block-agent/component/parts/TextPart.tsx@@ -2,11 +2,15 @@import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import { channelTheme } from '@core/component/LexicalMarkdown/theme';+import { createMemo } from 'solid-js';import { hideIncompleteMacroXml } from './hideIncompleteMacroXml';export function TextPart(props: { text: string; inFlight?: boolean }) {- const markdown = () =>- props.inFlight ? hideIncompleteMacroXml(props.text) : props.text;+ // Memoized so an `inFlight` flip that leaves the text unchanged does not+ // rebuild the markdown DOM and reload its images.+ const markdown = createMemo(() =>+ props.inFlight ? hideIncompleteMacroXml(props.text) : props.text+ );return (// `chat-markdown-container` is the overflow host for KaTeX display math