From f3ae8127daa48743bcfa5426b710f8e6a74e1c36 Mon Sep 17 00:00:00 2001 From: kumarabhirup Date: Sat, 21 Feb 2026 12:32:10 -0800 Subject: [PATCH] web: filter leaked NO_REPLY tokens in chat message display --- apps/web/app/components/chat-message.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/web/app/components/chat-message.tsx b/apps/web/app/components/chat-message.tsx index b97a7158a27..e97999e91dd 100644 --- a/apps/web/app/components/chat-message.tsx +++ b/apps/web/app/components/chat-message.tsx @@ -31,6 +31,18 @@ const ReportCard = dynamic( }, ); +/* ─── Silent-reply leak filter ─── */ + +const _SILENT_TOKEN = "NO_REPLY"; + +function isLeakedSilentToken(text: string): boolean { + const t = text.trim(); + if (!t) {return false;} + if (new RegExp(`^${_SILENT_TOKEN}\\W*$`).test(t)) {return true;} + if (_SILENT_TOKEN.startsWith(t) && t.length >= 2 && t.length < _SILENT_TOKEN.length) {return true;} + return false; +} + /* ─── Part grouping ─── */ type MessageSegment = @@ -77,8 +89,9 @@ function groupParts(parts: UIMessage["parts"]): MessageSegment[] { for (const part of parts) { if (part.type === "text") { - flush(true); const text = (part as { type: "text"; text: string }).text; + if (isLeakedSilentToken(text)) { continue; } + flush(true); if (hasReportBlocks(text)) { segments.push( ...(splitReportBlocks(text) as MessageSegment[]),