Compare commits

...
Author SHA1 Message Date
0xtoshii f4c59a1cb6 browser 2 2025-06-28 00:49:19 -07:00
0xtoshii 2c92ccde9f base 2025-06-28 00:22:44 -07:00
2 changed files with 77 additions and 74 deletions
@@ -9,13 +9,13 @@ import { BrowserAction, BrowserActionResult, ClineMessage, ClineSayBrowserAction
import { StringRequest } from "@shared/proto/common" import { StringRequest } from "@shared/proto/common"
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
import deepEqual from "fast-deep-equal" import deepEqual from "fast-deep-equal"
import React, { CSSProperties, memo, useEffect, useMemo, useRef, useState } from "react" import React, { CSSProperties, memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useSize } from "react-use" import { useSize } from "react-use"
import styled from "styled-components" import styled from "styled-components"
interface BrowserSessionRowProps { interface BrowserSessionRowProps {
messages: ClineMessage[] messages: ClineMessage[]
isExpanded: (messageTs: number) => boolean expandedRows: Record<number, boolean>
onToggleExpand: (messageTs: number) => void onToggleExpand: (messageTs: number) => void
lastModifiedMessage?: ClineMessage lastModifiedMessage?: ClineMessage
isLast: boolean isLast: boolean
@@ -294,10 +294,13 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
{currentPage?.nextAction?.messages.map((message) => ( {currentPage?.nextAction?.messages.map((message) => (
<BrowserSessionRowContent <BrowserSessionRowContent
key={message.ts} key={message.ts}
{...props}
message={message} message={message}
expandedRows={props.expandedRows}
onToggleExpand={props.onToggleExpand}
lastModifiedMessage={props.lastModifiedMessage}
isLast={props.isLast}
onSetQuote={props.onSetQuote}
setMaxActionHeight={setMaxActionHeight} setMaxActionHeight={setMaxActionHeight}
onSetQuote={onSetQuote}
/> />
))} ))}
{!isBrowsing && messages.some((m) => m.say === "browser_action_result") && currentPageIndex === 0 && ( {!isBrowsing && messages.some((m) => m.say === "browser_action_result") && currentPageIndex === 0 && (
@@ -498,73 +501,78 @@ interface BrowserSessionRowContentProps extends Omit<BrowserSessionRowProps, "me
onSetQuote: (text: string) => void onSetQuote: (text: string) => void
} }
const BrowserSessionRowContent = ({ const BrowserSessionRowContent = memo(
message, ({
isExpanded, message,
onToggleExpand, expandedRows,
lastModifiedMessage, onToggleExpand,
isLast, lastModifiedMessage,
setMaxActionHeight, isLast,
onSetQuote, setMaxActionHeight,
}: BrowserSessionRowContentProps) => { onSetQuote,
if (message.ask === "browser_action_launch" || message.say === "browser_action_launch") { }: BrowserSessionRowContentProps) => {
return ( const handleToggle = useCallback(() => {
<> if (message.say === "api_req_started") {
<div style={headerStyle}> setMaxActionHeight(0)
<span style={browserSessionStartedTextStyle}>Browser Session Started</span> }
</div> onToggleExpand(message.ts)
<div style={codeBlockContainerStyle}> }, [onToggleExpand, message.ts, setMaxActionHeight])
<CodeBlock source={`${"```"}shell\n${message.text}\n${"```"}`} forceWrap={true} />
</div>
</>
)
}
switch (message.type) { if (message.ask === "browser_action_launch" || message.say === "browser_action_launch") {
case "say": return (
switch (message.say) { <>
case "api_req_started": <div style={headerStyle}>
case "text": <span style={browserSessionStartedTextStyle}>Browser Session Started</span>
case "reasoning": </div>
return ( <div style={codeBlockContainerStyle}>
<div style={chatRowContentContainerStyle}> <CodeBlock source={`${"```"}shell\n${message.text}\n${"```"}`} forceWrap={true} />
<ChatRowContent </div>
message={message} </>
isExpanded={isExpanded(message.ts)} )
onToggleExpand={() => { }
if (message.say === "api_req_started") {
setMaxActionHeight(0) switch (message.type) {
} case "say":
onToggleExpand(message.ts) switch (message.say) {
}} case "api_req_started":
lastModifiedMessage={lastModifiedMessage} case "text":
isLast={isLast} case "reasoning":
onSetQuote={onSetQuote} return (
<div style={chatRowContentContainerStyle}>
<ChatRowContent
message={message}
isExpanded={expandedRows[message.ts] ?? false}
onToggleExpand={handleToggle}
lastModifiedMessage={lastModifiedMessage}
isLast={isLast}
onSetQuote={onSetQuote}
/>
</div>
)
case "browser_action":
const browserAction = JSON.parse(message.text || "{}") as ClineSayBrowserAction
return (
<BrowserActionBox
action={browserAction.action}
coordinate={browserAction.coordinate}
text={browserAction.text}
/> />
</div> )
)
case "browser_action": default:
const browserAction = JSON.parse(message.text || "{}") as ClineSayBrowserAction return null
return ( }
<BrowserActionBox
action={browserAction.action}
coordinate={browserAction.coordinate}
text={browserAction.text}
/>
)
default: case "ask":
return null switch (message.ask) {
} default:
return null
case "ask": }
switch (message.ask) { }
default: },
return null deepEqual,
} )
}
}
const BrowserActionBox = ({ action, coordinate, text }: { action: BrowserAction; coordinate?: string; text?: string }) => { const BrowserActionBox = ({ action, coordinate, text }: { action: BrowserAction; coordinate?: string; text?: string }) => {
const getBrowserActionText = (action: BrowserAction, coordinate?: string, text?: string) => { const getBrowserActionText = (action: BrowserAction, coordinate?: string, text?: string) => {
+2 -7
View File
@@ -1048,13 +1048,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
lastModifiedMessage={modifiedMessages.at(-1)} lastModifiedMessage={modifiedMessages.at(-1)}
onHeightChange={handleRowHeightChange} onHeightChange={handleRowHeightChange}
// Pass handlers for each message in the group // Pass handlers for each message in the group
isExpanded={(messageTs: number) => expandedRows[messageTs] ?? false} expandedRows={expandedRows}
onToggleExpand={(messageTs: number) => { onToggleExpand={toggleRowExpansion}
setExpandedRows((prev) => ({
...prev,
[messageTs]: !prev[messageTs],
}))
}}
onSetQuote={setActiveQuote} onSetQuote={setActiveQuote}
/> />
) )