Skip to content

Commit 8c41675

Browse files
committed
fix(browser): make page.keyboard.press type-safe via KeyInput; UI: show action icon/text and remove unused vars to satisfy lint
1 parent 82ee0f5 commit 8c41675

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/services/browser/BrowserSession.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from "vscode"
22
import * as fs from "fs/promises"
33
import * as path from "path"
44
import { Browser, Page, ScreenshotOptions, TimeoutError, launch, connect } from "puppeteer-core"
5+
import type { KeyInput } from "puppeteer-core"
56
// @ts-ignore
67
import PCR from "puppeteer-chromium-resolver"
78
import pWaitFor from "p-wait-for"
@@ -570,7 +571,7 @@ export class BrowserSession {
570571
async press(key: string): Promise<BrowserActionResult> {
571572
return this.doAction(async (page) => {
572573
// Allow common aliases
573-
const mapping: Record<string, string> = {
574+
const mapping: Partial<Record<string, KeyInput>> = {
574575
esc: "Escape",
575576
return: "Enter",
576577
escape: "Escape",
@@ -583,7 +584,7 @@ export class BrowserSession {
583584
arrowright: "ArrowRight",
584585
}
585586
const normalized = key.trim()
586-
const mapped = mapping[normalized.toLowerCase()] ?? key
587+
const mapped = (mapping[normalized.toLowerCase()] ?? (normalized as KeyInput)) as KeyInput
587588
await page.keyboard.press(mapped)
588589
})
589590
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ interface BrowserSessionRowProps {
3838
}
3939

4040
const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
41-
const { messages, isLast, onHeightChange, lastModifiedMessage, isStreaming } = props
41+
const { messages, isLast, onHeightChange, lastModifiedMessage } = props
4242
const { t } = useTranslation()
4343
const prevHeightRef = useRef(0)
44-
const [maxActionHeight, setMaxActionHeight] = useState(0)
45-
const [consoleLogsExpanded, setConsoleLogsExpanded] = useState(false)
44+
const [, setMaxActionHeight] = useState(0)
4645
// Collapse the pre-action details (reasoning, api request, text) by default
4746
const [nextActionsExpanded, setNextActionsExpanded] = useState(false)
4847

@@ -202,7 +201,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
202201
}
203202

204203
// Separate "pre-action details" from the final browser_action so we can collapse details by default
205-
const nextActions = currentPage?.nextAction?.messages || []
204+
const nextActions = useMemo(() => currentPage?.nextAction?.messages ?? [], [currentPage])
206205
const lastIsBrowserAction = nextActions.length > 0 && nextActions[nextActions.length - 1].say === "browser_action"
207206
const preActionMessages = lastIsBrowserAction ? nextActions.slice(0, -1) : nextActions
208207
const lastActionMessage = lastIsBrowserAction ? nextActions[nextActions.length - 1] : undefined
@@ -512,6 +511,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
512511
)}
513512
</div>
514513

514+
{actionContent}
515515
{/* Combined Details Accordion (Console Logs + Action Details) */}
516516
<div
517517
onClick={() => {
@@ -778,6 +778,7 @@ const BrowserActionBox = ({
778778
justifyContent: "space-between",
779779
flexWrap: "wrap",
780780
padding: "9px 10px",
781+
opacity: isActive ? 1 : 0.9,
781782
}}>
782783
<div
783784
style={{
@@ -788,7 +789,10 @@ const BrowserActionBox = ({
788789
minHeight: 20,
789790
}}>
790791
<span style={{ display: "inline-flex", alignItems: "center", justifyContent: "center" }}>
791-
<MousePointerIcon className="w-4 h-4 opacity-80" />
792+
{getActionIcon(action)}
793+
</span>
794+
<span style={{ fontSize: "12px", color: "var(--vscode-descriptionForeground)" }}>
795+
{customText ?? getBrowserActionText(action, coordinate, text)}
792796
</span>
793797
</div>
794798
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>

0 commit comments

Comments
 (0)