diff --git a/ui/src/ui/chat/grouped-render.ts b/ui/src/ui/chat/grouped-render.ts index 4a9ccec14..933f9b4ac 100644 --- a/ui/src/ui/chat/grouped-render.ts +++ b/ui/src/ui/chat/grouped-render.ts @@ -282,7 +282,14 @@ function renderGroupedMessage( )}` : nothing} ${markdown - ? html`
${unsafeHTML(toSanitizedMarkdownHtml(markdown))}
` + ? html` +
+ ${unsafeHTML(toSanitizedMarkdownHtml( + // Ensure horizontal rules (---) are padded with newlines + // so the markdown parser recognizes them correctly. + markdown.replace(/^(---|\*\*\*|___)$/gm, '\n$1\n') + ))} +
` : nothing} ${toolCards.map((card) => renderToolCardSidebar(card, onOpenSidebar))} diff --git a/ui/src/ui/markdown.test.ts b/ui/src/ui/markdown.test.ts index 396ff0fa5..c20eb63fb 100644 --- a/ui/src/ui/markdown.test.ts +++ b/ui/src/ui/markdown.test.ts @@ -29,4 +29,9 @@ describe("toSanitizedMarkdownHtml", () => { expect(html).toContain(" { + const html = toSanitizedMarkdownHtml("Line 1\n\n---\n\nLine 2"); + expect(html).toContain("