Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(web): hide divider-only Markdown content (#42860)
Joel570317ecdeea
diff --git a/web/app/components/base/markdown/__tests__/index.spec.tsx b/web/app/components/base/markdown/__tests__/index.spec.tsxindex e313a32e748..2a0172589b9 100644--- a/web/app/components/base/markdown/__tests__/index.spec.tsx+++ b/web/app/components/base/markdown/__tests__/index.spec.tsx@@ -45,6 +45,26 @@ describe('Markdown', () => {expect(screen.getByTestId('react-markdown-wrapper'))!.toHaveTextContent('Hello World')})+ it.each(['', ' \n ', '---', ' *** ', '___', '- - -'])(+ 'should leave empty or divider-only Markdown unrendered (%s)',+ (content) => {+ render(<Markdown content={content} />)++ expect(screen.getByTestId('markdown-body')).toBeEmptyDOMElement()+ expect(screen.queryByTestId('react-markdown-wrapper')).not.toBeInTheDocument()+ },+ )++ it.each(['First\n\n---\n\nSecond', ' ---'])(+ 'should preserve meaningful Markdown containing divider characters (%s)',+ (content) => {+ render(<Markdown content={content} />)++ expect(screen.getByTestId('react-markdown-wrapper')).toBeInTheDocument()+ expect(getLastWrapperProps().latexContent).toBe(content)+ },+ )+it('should preprocess think tags', () => {render(<Markdown content="<think>Thought</think>" />)const props = getLastWrapperProps()diff --git a/web/app/components/base/markdown/index.tsx b/web/app/components/base/markdown/index.tsxindex 6a2628d14e1..3641a1894b2 100644--- a/web/app/components/base/markdown/index.tsx+++ b/web/app/components/base/markdown/index.tsx@@ -10,6 +10,8 @@ const StreamdownWrapper = dynamic(() => import('./streamdown-wrapper'), { ssr: fconst preprocess = flow([preprocessThinkTag, preprocessLaTeX])const EMPTY_COMPONENTS = {} as const+const MARKDOWN_DIVIDER_ONLY_RE =+ /^(?:[ \t]*\r?\n)*[ \t]{0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})(?:\r?\n[ \t]*)*$//*** @fileoverview Main Markdown rendering component.@@ -45,22 +47,25 @@ export const Markdown = memo((props: MarkdownProps) => {className,} = propsconst latexContent = useMemo(() => preprocess(content), [content])+ const hasContent = !!latexContent.trim() && !MARKDOWN_DIVIDER_ONLY_RE.test(latexContent)return (<divclassName={cn('markdown-body', 'text-text-primary!', className)}data-testid="markdown-body">- <StreamdownWrapper- pluginInfo={pluginInfo}- latexContent={latexContent}- customComponents={customComponents}- customDisallowedElements={customDisallowedElements}- remarkPlugins={remarkPlugins}- rehypePlugins={rehypePlugins}- isAnimating={isAnimating}- mode={mode}- />+ {hasContent && (+ <StreamdownWrapper+ pluginInfo={pluginInfo}+ latexContent={latexContent}+ customComponents={customComponents}+ customDisallowedElements={customDisallowedElements}+ remarkPlugins={remarkPlugins}+ rehypePlugins={rehypePlugins}+ isAnimating={isAnimating}+ mode={mode}+ />+ )}</div>)})