From 16e155fd8602450c14a5bb3c95cd6d6a9c4222eb Mon Sep 17 00:00:00 2001 From: FantWu2024 Date: Thu, 7 May 2026 12:26:41 +0800 Subject: [PATCH] Strip all leading system-reminder wrappers in conversation view When a user message contains multiple consecutive system-reminder blocks, the lazy regex only consumed the first one, leaving later wrappers in the visible body. Loop until no leading wrapper remains so the SHOW REMINDER toggle hides all of them. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/components/conversation/MessageBubble.tsx | 12 +++++------- .../src/components/conversation/TerminalView.tsx | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/frontend/dashboard/src/components/conversation/MessageBubble.tsx b/frontend/dashboard/src/components/conversation/MessageBubble.tsx index 228cf76..01894ec 100644 --- a/frontend/dashboard/src/components/conversation/MessageBubble.tsx +++ b/frontend/dashboard/src/components/conversation/MessageBubble.tsx @@ -92,15 +92,13 @@ export default function MessageBubble({ function UserBubble({ message }: { message: ConversationMessage }) { const [showWrapper, setShowWrapper] = useState(false); - const hasWrapper = SYSTEM_REMINDER_PATTERN.test(message.text); let displayText = message.text; let wrapperText = ""; - if (hasWrapper) { - const m = message.text.match(/^([\s\S]*?<\/(system-reminder|command-name|local-command-stdout|command-message|command-args)>\s*)/i); - if (m) { - wrapperText = m[1]; - displayText = message.text.slice(m[1].length); - } + while (SYSTEM_REMINDER_PATTERN.test(displayText)) { + const m = displayText.match(/^([\s\S]*?<\/(system-reminder|command-name|local-command-stdout|command-message|command-args)>\s*)/i); + if (!m) break; + wrapperText += m[1]; + displayText = displayText.slice(m[1].length); } return ( diff --git a/frontend/dashboard/src/components/conversation/TerminalView.tsx b/frontend/dashboard/src/components/conversation/TerminalView.tsx index dbce905..9f50558 100644 --- a/frontend/dashboard/src/components/conversation/TerminalView.tsx +++ b/frontend/dashboard/src/components/conversation/TerminalView.tsx @@ -88,17 +88,15 @@ function ContinuationRow({ children }: { children: ReactNode }) { function UserRow({ message }: { message: ConversationMessage }) { const [showWrapper, setShowWrapper] = useState(false); - const hasWrapper = SYSTEM_REMINDER_PATTERN.test(message.text); let displayText = message.text; let wrapperText = ""; - if (hasWrapper) { - const m = message.text.match( + while (SYSTEM_REMINDER_PATTERN.test(displayText)) { + const m = displayText.match( /^([\s\S]*?<\/(system-reminder|command-name|local-command-stdout|command-message|command-args)>\s*)/i, ); - if (m) { - wrapperText = m[1]; - displayText = message.text.slice(m[1].length); - } + if (!m) break; + wrapperText += m[1]; + displayText = displayText.slice(m[1].length); } return (