Skip to content

Commit 74219c5

Browse files
committed
feat: display latest browser action below screenshot
1 parent c3bf7fb commit 74219c5

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,26 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
8787
consoleLogs: latestState.consoleLogs,
8888
}
8989

90-
// Find latest click position for cursor display
91-
const latestClickPosition = useMemo(() => {
92-
if (!isBrowsing) return undefined
93-
94-
// Look through messages backwards for the latest browser_action with click
90+
// Find latest browser action and click position
91+
const latestBrowserAction = useMemo(() => {
92+
// Look through messages backwards for the latest browser_action
9593
for (let i = messages.length - 1; i >= 0; i--) {
9694
const message = messages[i]
9795
if (message.say === "browser_action" && message.text) {
9896
const browserAction = JSON.parse(message.text) as ClineSayBrowserAction
99-
if (browserAction.action === "click" && browserAction.coordinate) {
100-
return browserAction.coordinate
101-
}
97+
return browserAction
10298
}
10399
}
104100
return undefined
105-
}, [isBrowsing, messages])
101+
}, [messages])
102+
103+
const latestClickPosition = useMemo(() => {
104+
if (!isBrowsing || !latestBrowserAction) return undefined
105+
if (latestBrowserAction.action === "click" && latestBrowserAction.coordinate) {
106+
return latestBrowserAction.coordinate
107+
}
108+
return undefined
109+
}, [isBrowsing, latestBrowserAction])
106110

107111
const mousePosition = isBrowsing
108112
? latestClickPosition || displayState.mousePosition
@@ -226,6 +230,15 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
226230
<CodeBlock source={displayState.consoleLogs || t("chat:browser.noNewLogs")} language="shell" />
227231
)}
228232
</div>
233+
234+
{/* Show latest browser action */}
235+
{latestBrowserAction && (
236+
<BrowserActionBox
237+
action={latestBrowserAction.action}
238+
coordinate={latestBrowserAction.coordinate}
239+
text={latestBrowserAction.text}
240+
/>
241+
)}
229242
</div>,
230243
)
231244

@@ -272,7 +285,7 @@ const BrowserActionBox = ({
272285
}
273286
}
274287
return (
275-
<div style={{ padding: "10px 0 0 0" }}>
288+
<div className="ml-6 mr-1.5 mb-4">
276289
<div
277290
style={{
278291
borderRadius: 3,

0 commit comments

Comments
 (0)