Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,37 @@ export const ChatRowContent = ({
return <CodebaseSearchResultsDisplay results={results} />
case "user_edit_todos":
return <UpdateTodoListToolBlock userEdited onChange={() => {}} />
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 && (
<div style={headerStyle}>
{icon}
{title}
</div>
)}
<div style={{ paddingTop: 10 }}>
<div
style={{
color: "var(--vscode-errorForeground)",
fontFamily: "monospace",
fontSize: "12px",
padding: "8px",
backgroundColor: "var(--vscode-editor-background)",
border: "1px solid var(--vscode-editorError-border)",
borderRadius: "4px",
marginBottom: "8px",
}}>
⚠️ Browser action result not properly grouped - this is a bug in the message
grouping logic
</div>
<Markdown markdown={message.text} partial={message.partial} />
</div>
</>
)
default:
return (
<>
Expand Down
26 changes: 20 additions & 6 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,18 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
}

visibleMessages.forEach((message: ClineMessage) => {
// 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()
Expand Down Expand Up @@ -1294,12 +1306,14 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro

if (isBrowserSessionMessage(message)) {
currentGroup.push(message)

// Check if this is a close action
if (message.say === "browser_action") {
const browserAction = JSON.parse(message.text || "{}") as ClineSayBrowserAction
if (browserAction.action === "close") {
endBrowserSession()
if (message.say === "browser_action_result") {
// Check if the previous browser_action was a close action
const lastBrowserAction = [...currentGroup].reverse().find((m) => m.say === "browser_action")
if (lastBrowserAction) {
const browserAction = JSON.parse(lastBrowserAction.text || "{}") as ClineSayBrowserAction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse is used here on lastBrowserAction.text without error handling. To avoid runtime exceptions on malformed JSON, consider wrapping this call in a try/catch (or use safeJsonParse).

This comment was generated because it violated a code review rule: irule_PTI8rjtnhwrWq6jS.

if (browserAction.action === "close") {
endBrowserSession()
}
}
}
} else {
Expand Down
Loading