diff --git a/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue b/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue index fde69aabf9..cadd5fb564 100644 --- a/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue +++ b/dashboard/src/components/chat/message_list_comps/MessagePartsRenderer.vue @@ -63,9 +63,10 @@ + custom-id="message-list" :custom-html-tags="['ref']" + :content="normalizeMarkdownContent(renderPart.part.text)" :typewriter="false" + class="markdown-content" :is-dark="isDark" :monacoOptions="{ theme: isDark ? 'vs-dark' : 'vs-light' }" + :key="`${renderPart.key}-${isDark ? 'dark' : 'light'}`"/>
@@ -152,6 +153,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`;