From e77dc0012fdbc6d824107d5ac59eaa1ba2418532 Mon Sep 17 00:00:00 2001 From: Stable Genius <259448942+stablegenius49@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:49:51 -0700 Subject: [PATCH] fix(webchat): render standalone HTML replies as code --- .../MessagePartsRenderer.vue | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue b/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue index 5fd7f59bed..8b3429cbf3 100644 --- a/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue +++ b/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue @@ -63,7 +63,8 @@ @@ -151,6 +152,21 @@ const emitDownloadFile = (file) => { emit('download-file', file); }; +const isMarkdownCodeFence = (text) => /^(```|~~~)/.test(text.trim()); + +const looksLikeStandaloneHtml = (text) => { + const normalized = text.trim(); + if (!normalized) return false; + if (!/(|<\/body>|<\/head>| { + if (typeof text !== 'string') return text; + if (isMarkdownCodeFence(text) || !looksLikeStandaloneHtml(text)) return text; + return `\`\`\`\`html\n${text}\n\`\`\`\``; +}; + const formatDuration = (seconds) => { if (seconds < 1) { return `${Math.round(seconds * 1000)}ms`;