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`;