perf: streaming a reply in a long chat no longer rescans every message for artifacts with full regex passes (#35209)

This commit is contained in:
G30 authored and GitHub committed 2026-12-01 00:26:53 +04:00
1 parent 636dd45c30
commit a42c14892f
2 files changed
+2 -1

No files matched your search

+1 -1
View File
@@ -3041,7 +3041,7 @@
if (message?.role !== 'user') {
const messageContent =
getOutputText(message?.output) || removeAllDetails(message?.content ?? '');
if (!messageContent.trim()) {
if (!messageContent.includes('```') && !messageContent.includes('<')) {
return;
}
+1
View File
@@ -1146,6 +1146,7 @@ export const removeDetails = (content, types) => {
};
export const removeAllDetails = (content) => {
if (!/<details/i.test(content)) return content.trim();
// Strip details before splitting code fences, which can separate opening and closing tags.
content = content.replace(/<details[^>]*>[\s\S]*?<\/details>/gi, '');
// Second pass: catch any remaining blocks that live outside code fences