Skip to content

Commit eee8d51

Browse files
committed
Browser Use 2.0: backend emits executedCoordinate for click/hover; FE consumes it; remove fragile session-status parsing; ensure ResizeObserver cleanup; all tests passing (#8941)
1 parent 5a581b9 commit eee8d51

File tree

6 files changed

+26
-30
lines changed

6 files changed

+26
-30
lines changed

src/core/tools/browserActionTool.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ export async function browserActionTool(
183183

184184
cline.consecutiveMistakeCount = 0
185185

186-
await cline.say(
187-
"browser_action",
188-
JSON.stringify({
189-
action: action as BrowserAction,
190-
coordinate,
191-
text,
192-
size,
193-
} satisfies ClineSayBrowserAction),
194-
undefined,
195-
false,
196-
)
186+
// Prepare say payload; include executedCoordinate for pointer actions
187+
const sayPayload: ClineSayBrowserAction & { executedCoordinate?: string } = {
188+
action: action as BrowserAction,
189+
coordinate,
190+
text,
191+
size,
192+
}
193+
if ((action === "click" || action === "hover") && processedCoordinate) {
194+
sayPayload.executedCoordinate = processedCoordinate
195+
}
196+
await cline.say("browser_action", JSON.stringify(sayPayload), undefined, false)
197197

198198
switch (action) {
199199
case "click":

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ export interface ClineSayBrowserAction {
439439
coordinate?: string
440440
size?: string
441441
text?: string
442+
executedCoordinate?: string
442443
}
443444

444445
export type BrowserActionResult = {

webview-ui/src/components/chat/BrowserActionRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ const BrowserActionRow = memo(({ message, nextMessage, actionIndex, totalActions
151151
case "launch":
152152
return `Launched browser`
153153
case "click":
154-
return `Clicked at: ${getViewportCoordinate(browserAction.coordinate)}`
154+
return `Clicked at: ${browserAction.executedCoordinate || getViewportCoordinate(browserAction.coordinate)}`
155155
case "type":
156156
return `Typed: ${browserAction.text}`
157157
case "press":
158158
return `Pressed key: ${prettyKey(browserAction.text)}`
159159
case "hover":
160-
return `Hovered at: ${getViewportCoordinate(browserAction.coordinate)}`
160+
return `Hovered at: ${browserAction.executedCoordinate || getViewportCoordinate(browserAction.coordinate)}`
161161
case "scroll_down":
162162
return "Scrolled down"
163163
case "scroll_up":

webview-ui/src/components/chat/BrowserSessionRow.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const prettyKey = (k?: string): string => {
7373

7474
const getBrowserActionText = (
7575
action: BrowserAction,
76+
executedCoordinate?: string,
7677
coordinate?: string,
7778
text?: string,
7879
size?: string,
@@ -113,7 +114,7 @@ const getBrowserActionText = (
113114
case "launch":
114115
return `Launched browser`
115116
case "click":
116-
return `Clicked at: ${getViewportCoordinate(coordinate)}`
117+
return `Clicked at: ${executedCoordinate || getViewportCoordinate(coordinate)}`
117118
case "type":
118119
return `Typed: ${text}`
119120
case "press":
@@ -123,7 +124,7 @@ const getBrowserActionText = (
123124
case "scroll_up":
124125
return "Scrolled up"
125126
case "hover":
126-
return `Hovered at: ${getViewportCoordinate(coordinate)}`
127+
return `Hovered at: ${executedCoordinate || getViewportCoordinate(coordinate)}`
127128
case "resize":
128129
return `Resized to: ${size?.split(/[x,]/).join(" x ")}`
129130
case "close":
@@ -623,6 +624,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
623624
<span>
624625
{getBrowserActionText(
625626
action.action,
627+
pages[currentPageIndex]?.mousePosition,
626628
action.coordinate,
627629
action.text,
628630
pageSize,

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
972972
if (messages[i].ask === "browser_action_launch") {
973973
return i
974974
}
975-
// Also check for browser_session_status as a fallback indicator
976-
if (messages[i].say === "browser_session_status" && messages[i].text?.includes("opened")) {
977-
return i
978-
}
979975
}
980976
return -1
981977
}, [messages])

webview-ui/src/components/chat/TaskHeader.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,20 @@ const TaskHeader = ({
103103
for (let i = 0; i < msgs.length; i++) {
104104
const m = msgs[i] as any
105105
if (m?.ask === "browser_action_launch") return i
106-
if (m?.say === "browser_session_status" && typeof m.text === "string" && m.text.includes("opened")) {
107-
return i
108-
}
109106
}
110107
return -1
111108
}, [clineMessages])
112109

113110
const showBrowserGlobe = browserSessionStartIndex !== -1 || !!isBrowserSessionActive
114111

115112
const condenseButton = (
116-
<LucideIconButton
117-
title={t("chat:task.condenseContext")}
118-
icon={FoldVertical}
119-
disabled={buttonsDisabled}
120-
onClick={() => currentTaskItem && handleCondenseContext(currentTaskItem.id)}
121-
/>
122-
)
113+
<LucideIconButton
114+
title={t("chat:task.condenseContext")}
115+
icon={FoldVertical}
116+
disabled={buttonsDisabled}
117+
onClick={() => currentTaskItem && handleCondenseContext(currentTaskItem.id)}
118+
/>
119+
)
123120

124121
const hasTodos = todos && Array.isArray(todos) && todos.length > 0
125122

@@ -282,7 +279,7 @@ const TaskHeader = ({
282279
{t("chat:task.contextWindow")}
283280
</th>
284281
<td className="font-light align-top">
285-
<div className={`max-w-md -mt-1.5 flex flex-nowrap gap-1`}>
282+
<div className={`max-w-md -mt-1.5 flex flex-nowrap gap-1`}>
286283
<ContextWindowProgress
287284
contextWindow={contextWindow}
288285
contextTokens={contextTokens || 0}

0 commit comments

Comments
 (0)