fix: Improve inline code sanitization in AgentStreamDisplay component

- Enhanced the `sanitizeForDisplay` function to correctly remove empty inline code snippets (`` or ` `) while preserving triple-backtick fenced code blocks.
- This change ensures better rendering of code blocks in the chat interface, improving overall display accuracy.
This commit is contained in:
wizardchen
2026-04-22 20:25:28 +08:00
parent da8ba98622
commit 623add89f1
@@ -521,7 +521,10 @@ const sanitizeForDisplay = (text: string): string => {
}); });
result = result.replace(ID_LABEL_RE, ''); result = result.replace(ID_LABEL_RE, '');
result = result.replace(UUID_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, ''); result = result.replace(/\(\s*\)/g, '');
return result; return result;
}; };