From 4924668d8507cb6113db588312f42b6026096130 Mon Sep 17 00:00:00 2001 From: Philip Vasilevski Date: Mon, 7 Jul 2025 21:12:33 +0200 Subject: [PATCH] Fix browser mode JSON snippets appearing in chat --- webview-ui/src/components/chat/ChatRow.tsx | 31 +++++++++++++++++++++ webview-ui/src/components/chat/ChatView.tsx | 26 +++++++++++++---- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 9c90da503f..93ac5284fa 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -1109,6 +1109,37 @@ export const ChatRowContent = ({ return case "user_edit_todos": return {}} /> + case "browser_action_result": + // This should not normally be rendered here as browser_action_result messages + // should be grouped into browser sessions and rendered by BrowserSessionRow. + // If we see this, it means the message grouping logic has a bug. + return ( + <> + {title && ( +
+ {icon} + {title} +
+ )} +
+
+ ⚠️ Browser action result not properly grouped - this is a bug in the message + grouping logic +
+ +
+ + ) default: return ( <> diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 84bb7b89a2..8de672fed4 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1034,6 +1034,18 @@ const ChatViewComponent: React.ForwardRefRenderFunction { + // Special handling for browser_action_result - ensure it's always in a browser session + if (message.say === "browser_action_result" && !isInBrowserSession) { + isInBrowserSession = true + currentGroup = [] + } + + // Special handling for browser_action - ensure it's always in a browser session + if (message.say === "browser_action" && !isInBrowserSession) { + isInBrowserSession = true + currentGroup = [] + } + if (message.ask === "browser_action_launch") { // Complete existing browser session if any. endBrowserSession() @@ -1063,12 +1075,14 @@ const ChatViewComponent: React.ForwardRefRenderFunction m.say === "browser_action") + if (lastBrowserAction) { + const browserAction = JSON.parse(lastBrowserAction.text || "{}") as ClineSayBrowserAction + if (browserAction.action === "close") { + endBrowserSession() + } } } } else {