Skip to content
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
49bd122
feat(browser): bridge port + main-process window resolver for agent a…
Astro-Han Jun 10, 2026
6cb7e6d
feat(browser): BrowserSession over opencli CDPBridge with stealth tak…
Astro-Han Jun 10, 2026
1d59a3a
feat(tool): seven generic browser_* tools + browser permission key
Astro-Han Jun 10, 2026
085798f
feat(tool): deferred 'browser' tool-group activation
Astro-Han Jun 10, 2026
f93b624
feat(ui): browser tool cards, i18n, and trow grouping
Astro-Han Jun 10, 2026
d34a73c
fix(browser): extract via serialized selector, not evaluateWithArgs
Astro-Han Jun 10, 2026
e840e65
fix(browser): scope page-action permission to the current URL
Astro-Han Jun 10, 2026
98f542d
fix(tool): gate deferred-tool activation by client
Astro-Han Jun 10, 2026
4363ec2
test(ci): cover test/browser in the Windows opencode shard
Astro-Han Jun 10, 2026
c54edb3
fix(browser): probe the permission URL without touching the page
Astro-Han Jun 10, 2026
67f2ae8
test(permission): pin the browser default-allow ruling
Astro-Han Jun 10, 2026
d9a5331
fix(browser): single-flight concurrent first acquires
Astro-Han Jun 10, 2026
ae86f51
fix(browser): release host attachments when a lost connection invalid…
Astro-Han Jun 10, 2026
19048df
fix(browser): never orphan a host attachment around a pending acquire
Astro-Han Jun 10, 2026
dc5905b
fix(tool): reject blank browser_wait conditions
Astro-Han Jun 10, 2026
aca4bb4
fix(browser): lease the probed window from permission ask to attach
Astro-Han Jun 10, 2026
a607d54
fix(browser): every action takes a lease, or fails before the ask
Astro-Han Jun 10, 2026
54ea472
fix(browser): reject a reused connection whose window lease mismatches
Astro-Han Jun 10, 2026
5534a4c
fix(browser): drop the cached connection on a lease mismatch
Astro-Han Jun 10, 2026
8e7c0b0
fix(browser): scope the 'always allow' grant to the asked site's origin
Astro-Han Jun 10, 2026
c924352
fix(browser): cap browser_extract's page-side HTML read
Astro-Han Jun 10, 2026
558fd2b
fix(browser): surface the takeover-reload note in browser_wait
Astro-Han Jun 10, 2026
e3a7aef
fix(permission): a configured deny is never overridden by an approval
Astro-Han Jun 10, 2026
7c15763
feat(browser): route web-task intents to the browser tools
Astro-Han Jun 10, 2026
711429b
fix(browser): re-judge the landed URL when a navigate redirects
Astro-Han Jun 10, 2026
ceb1bf2
fix(tool): group activation announces only the available members
Astro-Han Jun 10, 2026
1c275fb
test(browser): compare the denied host exactly, not as a URL prefix
Astro-Han Jun 10, 2026
63f88ea
fix(tools): repair hint requires the called group member itself to be…
Astro-Han Jun 10, 2026
64002f0
test(tools): pin per-step availability gating for an activated browse…
Astro-Han Jun 10, 2026
2fe48d0
test(browser): pin the redirect deny as a soft contract — page loads,…
Astro-Han Jun 10, 2026
46c56c9
fix(browser): abort and timeout sever the connection so a stopped act…
Astro-Han Jun 10, 2026
14ffb58
fix(desktop): commit about:blank before attaching automation to a nev…
Astro-Han Jun 10, 2026
c77b9c4
feat(desktop): surface the browser tab when the agent attaches automa…
Astro-Han Jun 10, 2026
dbc2f81
fix(browser): accept the snapshot's "[12]" ref spelling in click and …
Astro-Han Jun 10, 2026
a2ab1a2
refactor(browser): own embedded browser views per conversation
Astro-Han Jun 10, 2026
fd339ea
feat(browser): adopt the Home draft view into the session it creates
Astro-Han Jun 10, 2026
fa3c67c
refactor(browser): retire the window lease from the bridge contract
Astro-Han Jun 10, 2026
9272fba
feat(ui): render the captured image on the browser_screenshot card
Astro-Han Jun 10, 2026
6e0429b
fix(browser): cover connect with the tool timeout and stop signal
Astro-Han Jun 10, 2026
f114950
fix(browser): key the automation layout write by the session's own di…
Astro-Han Jun 10, 2026
086dff8
refactor(tool): drop the dead deferredAvailable closure in llm.ts
Astro-Han Jun 10, 2026
8cb0a88
refactor(tool): retire the clients field — registration is the client…
Astro-Han Jun 10, 2026
f901b03
refactor(tool): drop canonicalisation retries canonicalDeferredId alr…
Astro-Han Jun 10, 2026
6ae8b2c
refactor(browser): delete the unused displayWindowID accessor
Astro-Han Jun 10, 2026
d1e8122
refactor(ui): one subtitle rule for browser tools across both surfaces
Astro-Han Jun 10, 2026
1474d05
refactor(browser): extract the controller registry behind a pure, tes…
Astro-Han Jun 11, 2026
6213164
fix(browser): dispose the conversation's view when its session is del…
Astro-Han Jun 11, 2026
07e8862
fix(browser): gate draft IPC on the window actually being on Home
Astro-Han Jun 11, 2026
e11816c
fix(browser): drop an in-progress address edit when the panel swaps t…
Astro-Han Jun 11, 2026
474c871
fix(browser): only a claiming layout push may take the display over
Astro-Han Jun 11, 2026
d6d7dec
fix(browser): re-judge the page after the ask so an approval is never…
Astro-Han Jun 11, 2026
8430e2e
test(app): give the browser-tools snap fixture the DialogProvider the…
Astro-Han Jun 11, 2026
ec1463f
fix(browser): re-judge a moved page with a second ask, at full-URL gr…
Astro-Han Jun 11, 2026
0a37063
fix(browser): an acquire racing the session's delete unwinds itself
Astro-Han Jun 11, 2026
4804ee2
fix(browser): set-view never resurrects a disposed view; adopt-draft …
Astro-Han Jun 11, 2026
2b096de
fix(browser): repeat the claim until main confirms it applied
Astro-Han Jun 11, 2026
6207468
test(ui): pin the unified browser subtitle rule and the safeHttpUrl s…
Astro-Han Jun 11, 2026
4b531a9
fix(browser): surface a wait timeout as guidance, not the raw page ex…
Astro-Han Jun 11, 2026
f7d85f8
test(browser): close the fake CDP server when connect fails in the co…
Astro-Han Jun 11, 2026
5f6f9f1
test(tool): restore a pre-existing OPENCODE_CLIENT instead of deletin…
Astro-Han Jun 11, 2026
7ccb036
feat(browser): closing the browser tab destroys the page
Astro-Han Jun 11, 2026
7e15d56
fix(browser): snapshot the close target at gesture time and fail-safe…
Astro-Han Jun 11, 2026
9bcaeef
fix(opencode): re-filter activation reminder members through current …
Astro-Han Jun 11, 2026
9113e7d
test(app): cover the screenshot card's image area in the browser snap…
Astro-Han Jun 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/windows-advisory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ jobs:
test/server
test/snapshot
test/tool
test/browser
test/mcp
test/question
test/effect
Expand Down
25 changes: 25 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions packages/app/e2e/snap/browser-tools.snap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { expect, type Locator } from "@playwright/test"
import { fileURLToPath } from "node:url"
import { test } from "../fixtures"
import { composeGrid, snapOutputPath, type Shot } from "./_compose"

test.use({ viewport: { width: 900, height: 720 }, deviceScaleFactor: 2 })

const LANGUAGE_KEY = "pawwork.global.dat:language"
const TITLE_SHIMMER = '[data-slot="basic-tool-tool-title"] [data-component="text-shimmer"]'
const fixturePath = fileURLToPath(new URL("./fixtures/browser-tools-snap-fixture.tsx", import.meta.url))

async function captureBlock(name: string, block: Locator): Promise<Shot> {
await expect(block).toBeVisible({ timeout: 30_000 })
return { name, buf: await block.screenshot() }
}

test("browser-tools", async ({ page }) => {
test.setTimeout(180_000)

await page.addInitScript((key) => {
localStorage.setItem(key, JSON.stringify({ locale: "zh" }))
}, LANGUAGE_KEY)

await page.goto("/")
await page.waitForFunction(
() => getComputedStyle(document.documentElement).getPropertyValue("--bg-base").trim().length > 0,
null,
{ timeout: 30_000 },
)
await page.evaluate(async (path) => {
const mod = await import(path)
mod.mountBrowserToolsSnapFixture(document.body)
}, `/@fs/${fixturePath}`)

const shots: Shot[] = []

const cards = page.locator('[data-snap="browser-cards"]')
for (const title of ["打开页面", "读取页面结构", "点击", "输入", "等待页面", "截图", "提取页面内容"]) {
await expect(cards).toContainText(title, { timeout: 30_000 })
}

// navigate renders a clickable link, like webfetch.
const navigateLink = cards.locator('[data-card="browser-navigate"] a[data-slot="basic-tool-tool-subtitle"]')
await expect(navigateLink).toHaveAttribute("href", "https://example.com/pricing", { timeout: 30_000 })

// click/type/wait show the literal target as subtitle.
await expect(cards.locator('[data-card="browser-click"]')).toContainText("e12", { timeout: 30_000 })
await expect(cards.locator('[data-card="browser-type"]')).toContainText("e7", { timeout: 30_000 })
await expect(cards.locator('[data-card="browser-wait"]')).toContainText("Thanks for signing up", {
timeout: 30_000,
})

// snapshot/extract expand to the text the agent read.
await expect(cards.locator('[data-card="browser-snapshot"] [data-component="bash-output"]')).toContainText(
"[ref=e12]",
{ timeout: 30_000 },
)
await expect(cards.locator('[data-card="browser-extract"] [data-component="bash-output"]')).toContainText(
"Simple plans for every team",
{ timeout: 30_000 },
)
shots.push(await captureBlock("browser-cards", cards))

// running navigate shimmers and must not render a link yet.
const running = page.locator('[data-snap="browser-running"]')
await expect(running.locator(`${TITLE_SHIMMER}[data-active="true"]`)).toBeVisible({ timeout: 30_000 })
await expect(running.locator("a")).toHaveCount(0)
shots.push(await captureBlock("browser-running", running))

// collapsed trow groups browser steps under one summary line.
const trow = page.locator('[data-snap="browser-trow-collapsed"]')
await expect(trow).toContainText("浏览器操作 7 步", { timeout: 30_000 })
shots.push(await captureBlock("browser-trow-collapsed", trow))

const out = snapOutputPath("browser-tools")
await composeGrid(shots, out, { cols: 1 })
process.stdout.write(`\n[snap] browser-tools grid -> ${out}\n\n`)
})
164 changes: 164 additions & 0 deletions packages/app/e2e/snap/fixtures/browser-tools-snap-fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { Dynamic, render } from "solid-js/web"
import { Show, type Accessor } from "solid-js"
import type { ToolPart, ToolState } from "@opencode-ai/sdk/v2"
import type { UiI18nKey } from "@opencode-ai/ui/context"
import { DataProvider, I18nProvider } from "@opencode-ai/ui/context"
import { DialogProvider } from "@opencode-ai/ui/context/dialog"
import { MarkedProvider } from "@opencode-ai/ui/context/marked"
import { ToolRegistry } from "@opencode-ai/ui/message-part"
import { TrowBlock, type TrowPart } from "@opencode-ai/ui/session-turn-trow-block"
import { fixtureData, labels, zhI18n } from "./trow-snap-fixture-data"

const PAGE_URL = "https://example.com/pricing"

const SNAPSHOT_OUTPUT = [
'- heading "Pricing" [ref=e1]',
'- link "Get started" [ref=e12]',
'- textbox "Work email" [ref=e7]',
'- button "Contact sales" [ref=e9]',
].join("\n")

const EXTRACT_OUTPUT = "# Pricing\n\nSimple plans for every team. Starter is free forever;\nPro adds unlimited projects and priority support."

const BROWSER_TITLE_KEYS: Record<string, UiI18nKey> = {
browser_navigate: "ui.tool.browser.navigate",
browser_snapshot: "ui.tool.browser.snapshot",
browser_click: "ui.tool.browser.click",
browser_type: "ui.tool.browser.type",
browser_wait: "ui.tool.browser.wait",
browser_screenshot: "ui.tool.browser.screenshot",
browser_extract: "ui.tool.browser.extract",
}

function browserTool(
id: string,
toolName: string,
input: Record<string, unknown>,
output = "",
metadata: Record<string, unknown> = {},
status: ToolState["status"] = "completed",
): ToolPart {
const state: ToolState =
status === "running"
? { status: "running", input, time: { start: 0 } }
: { status: "completed", input, output, title: toolName, metadata, time: { start: 0, end: 1 } }
return {
id,
sessionID: "snap-session",
messageID: "snap-message",
type: "tool",
callID: `call-${id}`,
tool: toolName,
state,
}
}

const completedBrowserParts = [
browserTool("browser-navigate", "browser_navigate", { url: PAGE_URL }, "", { url: PAGE_URL }),
browserTool("browser-snapshot", "browser_snapshot", {}, SNAPSHOT_OUTPUT, { url: PAGE_URL }),
browserTool("browser-click", "browser_click", { ref: "e12" }, "Clicked e12"),
browserTool("browser-type", "browser_type", { ref: "e7", text: "team@example.com" }, "Typed into e7"),
browserTool("browser-wait", "browser_wait", { text: "Thanks for signing up" }, "Condition met"),
browserTool("browser-screenshot", "browser_screenshot", {}, "Captured viewport", { url: PAGE_URL }),
browserTool("browser-extract", "browser_extract", { selector: "main" }, EXTRACT_OUTPUT, { url: PAGE_URL }),
]

const runningBrowserParts = [
browserTool("browser-navigate-running", "browser_navigate", { url: PAGE_URL }, "", {}, "running"),
]

const OPEN_CARDS = ["browser-snapshot", "browser-extract"]

function describeBrowserTool(part: ToolPart) {
const key = BROWSER_TITLE_KEYS[part.tool]
return key ? zhI18n.t(key) : part.tool
}

function renderBrowserCard(prefix: string) {
return (part: Accessor<TrowPart>) => {
const tool = () => {
const current = part()
return current.type === "tool" ? current : undefined
}
return (
<Show when={tool()}>
{(tool) => {
const input = () => tool().state.input ?? {}
const output = () => (tool().state.status === "completed" ? tool().state.output : undefined)
const metadata = () => (tool().state.status === "completed" ? (tool().state.metadata ?? {}) : {})
return (
<div data-slot="trow-result-body" data-card={tool().id} data-timeline-anchor={`tool:${tool().id}`}>
<Dynamic
component={ToolRegistry.render(tool().tool)}
input={input()}
tool={tool().tool}
metadata={metadata()}
output={output()}
status={tool().state.status}
defaultOpen={OPEN_CARDS.includes(tool().id)}
stateKey={`${prefix}:${tool().id}`}
/>
</div>
)
}}
</Show>
)
}
}

function BrowserToolsSnapFixture() {
return (
<div
style={{
display: "grid",
gap: "18px",
padding: "24px",
background: "var(--bg-base)",
color: "var(--fg-base)",
width: "760px",
}}
>
<div data-snap="browser-cards">
<TrowBlock
parts={completedBrowserParts}
defaultOpen
labels={labels}
describeTool={describeBrowserTool}
renderPart={renderBrowserCard("browser-cards")}
/>
</div>
<div data-snap="browser-running">
<TrowBlock
parts={runningBrowserParts}
working
labels={labels}
describeTool={describeBrowserTool}
renderPart={renderBrowserCard("browser-running")}
/>
</div>
<div data-snap="browser-trow-collapsed">
<TrowBlock parts={completedBrowserParts} labels={labels} />
</div>
</div>
)
}

export function mountBrowserToolsSnapFixture(root: HTMLElement) {
root.innerHTML = ""
render(
() => (
<I18nProvider value={zhI18n}>
<MarkedProvider>
{/* The real app wraps every surface in DialogProvider (app.tsx); the
screenshot card's click-to-preview needs it even to render. */}
<DialogProvider>
<DataProvider data={fixtureData} directory="/Users/yuhan/PawWork">
<BrowserToolsSnapFixture />
</DataProvider>
</DialogProvider>
</MarkedProvider>
</I18nProvider>
),
root,
)
}
Loading
Loading