Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix: Improve inline code sanitization in AgentStreamDisplay component

wizardchen623add89f1b8
diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue
index 7e157b778..634bcfb19 100644
--- a/frontend/src/views/chat/components/AgentStreamDisplay.vue
+++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue
@@ -521,7 +521,10 @@ const sanitizeForDisplay = (text: string): string => {
});
result = result.replace(ID_LABEL_RE, '');
result = result.replace(UUID_RE, '');
- result = result.replace(/`\s*`/g, '');
+ // Remove empty inline code like `` or ` ` while preserving triple-backtick
+ // fenced code blocks (```). Without the lookaround the greedy pair match
+ // would eat two of the three fence backticks and break code block rendering.
+ result = result.replace(/(?<!`)`[ \t]*`(?!`)/g, '');
result = result.replace(/\(\s*\)/g, '');
return result;
};