From e2e0fbf11442b9b5377e455fcddb499de77cce75 Mon Sep 17 00:00:00 2001 From: LofiSu Date: Thu, 29 Jan 2026 12:50:09 +0800 Subject: [PATCH] fix: hide incomplete citations block during streaming Improve UX by hiding citations block while it's being streamed: - Remove complete citations blocks (existing logic) - Also remove incomplete citations blocks during streaming - Prevents flickering of raw citations XML in the UI Co-authored-by: Cursor --- frontend/src/core/citations/utils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/core/citations/utils.ts b/frontend/src/core/citations/utils.ts index f83feba..aadd0e1 100644 --- a/frontend/src/core/citations/utils.ts +++ b/frontend/src/core/citations/utils.ts @@ -67,8 +67,14 @@ export function parseCitations(content: string): ParseCitationsResult { } } - // Remove ALL citations blocks from content + // Remove ALL citations blocks from content (both complete and incomplete) cleanContent = content.replace(/[\s\S]*?<\/citations>/g, "").trim(); + + // Also remove incomplete citations blocks (during streaming) + // Match without closing tag or followed by anything until end of string + if (cleanContent.includes("")) { + cleanContent = cleanContent.replace(/[\s\S]*$/g, "").trim(); + } return { citations, cleanContent }; }