diff --git a/webview-ui/src/components/chat/BrowserSessionRow.tsx b/webview-ui/src/components/chat/BrowserSessionRow.tsx index 46e715c..44f655d 100644 --- a/webview-ui/src/components/chat/BrowserSessionRow.tsx +++ b/webview-ui/src/components/chat/BrowserSessionRow.tsx @@ -5,13 +5,13 @@ import { BrowserActionResult, ClineMessage, ClineSayBrowserAction } from "../../ import { vscode } from "../../utils/vscode" import CodeAccordian from "../common/CodeAccordian" import CodeBlock, { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock" -import { ChatRowContent } from "./ChatRow" +import { ChatRowContent, ProgressIndicator } from "./ChatRow" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" interface BrowserSessionRowProps { messages: ClineMessage[] - isExpanded: boolean - onToggleExpand: () => void + isExpanded: (messageTs: number) => boolean + onToggleExpand: (messageTs: number) => void lastModifiedMessage?: ClineMessage isLast: boolean onHeightChange: (isTaller: boolean) => void @@ -20,12 +20,20 @@ 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 */ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { - const { messages, isLast, onHeightChange } = props + const { messages, isLast, onHeightChange, lastModifiedMessage, isExpanded } = props const prevHeightRef = useRef(0) - const maxActionHeightRef = useRef(0) // Track max height of action section + const [maxActionHeight, setMaxActionHeight] = useState(0) + const [consoleLogsExpanded, setConsoleLogsExpanded] = useState(false) + + const isBrowsing = useMemo(() => { + return ( + isLast && lastModifiedMessage?.ask !== "resume_task" && lastModifiedMessage?.ask !== "resume_completed_task" + ) + }, [isLast, lastModifiedMessage]) // Organize messages into pages with current state and next action const pages = useMemo(() => { @@ -33,6 +41,8 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { currentState: { url?: string screenshot?: string + mousePosition?: string + consoleLogs?: string messages: ClineMessage[] // messages up to and including the result } nextAction?: { @@ -57,6 +67,8 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { currentState: { url: resultData.currentUrl, screenshot: resultData.screenshot, + mousePosition: resultData.currentMousePosition, + consoleLogs: resultData.logs, messages: [...currentStateMessages], }, nextAction: @@ -120,11 +132,13 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { if (page.currentState.url || page.currentState.screenshot) { return { url: page.currentState.url, + mousePosition: page.currentState.mousePosition, + consoleLogs: page.currentState.consoleLogs, screenshot: page.currentState.screenshot, } } } - return { url: undefined, screenshot: undefined } + return { url: undefined, mousePosition: undefined, consoleLogs: undefined, screenshot: undefined } }, [pages]) const currentPage = pages[currentPageIndex] @@ -134,17 +148,26 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => { const displayState = isLastPage ? { url: currentPage?.currentState.url || latestState.url || initialUrl, + mousePosition: currentPage?.currentState.mousePosition || latestState.mousePosition || "400,300", + consoleLogs: currentPage?.currentState.consoleLogs, screenshot: currentPage?.currentState.screenshot || latestState.screenshot, } : { url: currentPage?.currentState.url || initialUrl, + mousePosition: currentPage?.currentState.mousePosition || "400,300", + consoleLogs: currentPage?.currentState.consoleLogs, screenshot: currentPage?.currentState.screenshot, } const [actionContent, { height: actionHeight }] = useSize(