From 4b85eb5d32260bce09374c707049fc63cf6987e8 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 15 Apr 2026 07:59:16 -0300 Subject: [PATCH] fix: Hide raw HTML during streaming - show loading until complete --- ui/suite/partials/chat.html | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/ui/suite/partials/chat.html b/ui/suite/partials/chat.html index 32b5581..782eb19 100644 --- a/ui/suite/partials/chat.html +++ b/ui/suite/partials/chat.html @@ -309,17 +309,16 @@ function addMessage(sender, content, msgId) { ""; } else { var cleanContent = stripMarkdownBlocks(content); - // Check if content has HTML (any tag, including comments) var hasHtmlTags = /<\/?[a-zA-Z][^>]*>|/i.test(cleanContent); console.log("Bot message - hasHtmlTags:", hasHtmlTags, "content length:", cleanContent.length, "msgId:", msgId); var parsed; - if (hasHtmlTags && msgId) { - // Streaming HTML content - don't show raw HTML, show loading indicator - // Content will be rendered at finalizeStreaming + // When msgId is present, we're in streaming mode - show loading until complete + // This prevents raw HTML from flashing during streaming + if (msgId) { parsed = '
...
'; } else if (hasHtmlTags) { - // Complete HTML content - render directly + // Complete HTML content (not streaming) - render directly parsed = cleanContent; } else { // Markdown content @@ -791,15 +790,8 @@ function updateStreaming(content) { msgContent.innerHTML = renderMentionInMessage(cleanContent); lastRenderTime = Date.now(); if (!isUserScrolling) scrollToBottom(true); - } else { - // Tags not balanced yet - show escaped HTML to avoid showing raw tags - // This prevents HTML from appearing as raw text before it's ready - var escapedContent = escapeHtml(cleanContent); - // Only update if content changed to avoid flickering - if (msgContent.textContent !== cleanContent) { - msgContent.textContent = cleanContent; - } } + // If not balanced, keep showing loading - don't show raw HTML text! } else { // Standard markdown/text rendering var parsed = typeof marked !== "undefined" && marked.parse