From 04653e2cae08092cae8d6c20d040db70ba6d54ec Mon Sep 17 00:00:00 2001 From: Isaac S Date: Fri, 29 May 2026 15:21:02 -0400 Subject: [PATCH] Strip leaked tags from chat output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assistant grounds answers with inline source markup like . react-markdown has no raw-HTML plugin, so these tags rendered as literal text in the chat. Strip the tags (keeping the cited prose) before rendering assistant messages. Co-Authored-By: Claude Opus 4.8 (1M context) --- v5/src/components/ChatFab.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/v5/src/components/ChatFab.tsx b/v5/src/components/ChatFab.tsx index 18de337..f650ff1 100644 --- a/v5/src/components/ChatFab.tsx +++ b/v5/src/components/ChatFab.tsx @@ -28,6 +28,14 @@ function toolStatusLabel(partType: string, t: ChatT): string { return t("working"); } +// The assistant can wrap grounded text in inline source markup such as +// . react-markdown has no raw-HTML plugin, so those +// tags would render as literal text. Strip the tags while keeping the cited +// prose intact. +function stripCitations(text: string): string { + return text.replace(/]*>/gi, "").replace(/<\/cite>/gi, ""); +} + function Icon({ name, }: { @@ -419,7 +427,7 @@ export function ChatFab() { remarkPlugins={[remarkGfm]} components={markdownComponents} > - {part.text} + {stripCitations(part.text)} ) : (