From c65217ee7ee1cd959ecad603016ba0d63cde083c Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:52:54 -0400 Subject: [PATCH] Finalize UI for browser row --- .../src/components/chat/BrowserSessionRow.tsx | 104 ++++++++++-------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/webview-ui/src/components/chat/BrowserSessionRow.tsx b/webview-ui/src/components/chat/BrowserSessionRow.tsx index 44f655d..c4c6c2b 100644 --- a/webview-ui/src/components/chat/BrowserSessionRow.tsx +++ b/webview-ui/src/components/chat/BrowserSessionRow.tsx @@ -1,9 +1,13 @@ import deepEqual from "fast-deep-equal" import React, { memo, useEffect, useMemo, useRef, useState } from "react" import { useSize } from "react-use" -import { BrowserActionResult, ClineMessage, ClineSayBrowserAction } from "../../../../src/shared/ExtensionMessage" +import { + BrowserAction, + BrowserActionResult, + ClineMessage, + ClineSayBrowserAction, +} from "../../../../src/shared/ExtensionMessage" import { vscode } from "../../utils/vscode" -import CodeAccordian from "../common/CodeAccordian" import CodeBlock, { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock" import { ChatRowContent, ProgressIndicator } from "./ChatRow" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" @@ -21,10 +25,14 @@ interface BrowserSessionRowProps { - console logs will be aggregate up to that current page - while isbrowsing, disable next prev buttons and latest action if click use that as position instead of display state +- action rows ui +- pagination make look better +- test cancel/abort session +- test resume task */ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { - const { messages, isLast, onHeightChange, lastModifiedMessage, isExpanded } = props + const { messages, isLast, onHeightChange, lastModifiedMessage } = props const prevHeightRef = useRef(0) const [maxActionHeight, setMaxActionHeight] = useState(0) const [consoleLogsExpanded, setConsoleLogsExpanded] = useState(false) @@ -276,6 +284,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { position: "absolute", top: `${(parseInt(displayState.mousePosition.split(",")[1]) / 600) * 100}%`, left: `${(parseInt(displayState.mousePosition.split(",")[0]) / 800) * 100}%`, + transition: "top 0.3s ease-out, left 0.3s ease-out", }} /> )} @@ -315,7 +324,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { justifyContent: "space-between", alignItems: "center", padding: "8px", - marginTop: "10px", + marginTop: "15px", borderTop: "1px solid var(--vscode-editorGroup-border)", }}>
@@ -376,13 +385,30 @@ const BrowserSessionRowContent = ({ // This includes handling all message types: api_req_started, browser_action, text, etc. // The implementation would be identical to ChatRowContent + const getBrowserActionText = (action: BrowserAction, coordinate?: string, text?: string) => { + switch (action) { + case "click": + return `Click (${coordinate?.replace(",", ", ")})` + case "type": + return `Type "${text}"` + case "scroll_down": + return "Scroll down" + case "scroll_up": + return "Scroll up" + case "close": + return "Close browser" + default: + return action + } + } + switch (message.type) { case "say": switch (message.say) { case "api_req_started": case "text": return ( -
+
-
{browserAction.action}
- {browserAction.coordinate &&
{browserAction.coordinate}
} - {browserAction.text &&
{browserAction.text}
} -
- ) - - case "browser_action_result": - const { screenshot, logs, currentMousePosition, currentUrl } = JSON.parse( - message.text || "{}" - ) as BrowserActionResult - return ( -
- {currentMousePosition &&
{currentMousePosition}
} - {currentUrl &&
{currentUrl}
} - {screenshot && ( - Browser action screenshot +
+
vscode.postMessage({ type: "openImage", text: screenshot })} - /> - )} - {logs && ( - onToggleExpand(message.ts)} - /> - )} + display: "flex", + alignItems: "center", + padding: "9px 10px", + }}> + + Browse Action: + {getBrowserActionText( + browserAction.action, + browserAction.coordinate, + browserAction.text + )} + +
+
)