Repository navigation
Studio: browser agent can click at a point, move the mouse, drag, and run approved scripts - #13505
Conversation
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…endpoints and script prompts current
…hat a point or drop really hits
… and recheck points after the user answers
…hrough shadow roots, and tie screenshot points to scroll and document
The browser pointer and script tools (unslothai#13505) use AgentAnswer.pending as a boolean for a script still running; a numeric pending here would merge into the same type.
|
pre-commit.ci run |
Stop a drag whose page navigates mid-drag before it touches the new page, land the last step on the end point exactly, refuse to press a disabled control, and recheck the release target after the page's hover and dragover handlers, as the press already does.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77108248ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const status = await pageCall(tab, { op: "status" }); | ||
| const keys = ["width", "height", "scrollX", "scrollY", "scrolls", "doc"] as const; | ||
| if (keys.some((key) => status[key] !== shot[key])) return STALE_SHOT; | ||
| return { x: x * shot.scale, y: y * shot.scale }; |
There was a problem hiding this comment.
Invalidate screenshot points after layout mutations
When the DOM changes without a resize or scroll—for example, a carousel advances or an ad inserts content between the screenshot and the click—every key checked here remains unchanged, so the screenshot coordinates are accepted even though they may now point at a different control. The subsequent description and signature checks only bind the action to the element currently at that point, not the element the model saw in the screenshot, allowing an unintended button or link to be clicked. Track a mutation/layout generation with the screenshot and reject coordinates when it changes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: the point is described and gated on what is there at click time, and the click and press refuse if that element changes after the check. A mutation counter would make point clicks refuse on any page with a clock, ticker or animation.
| mouse(el, "pointermove", at, buttons); | ||
| mouse(el, "mousemove", at, buttons); |
There was a problem hiding this comment.
Use real pointer movement for CSS hover interactions
browser_move_mouse only dispatches synthetic pointer and mouse events through dispatchEvent; these events can invoke JavaScript listeners but do not move the browser's pointing device or update the :hover pseudo-class. Consequently, common menus implemented purely with CSS such as .menu:hover .submenu never open even though this tool explicitly advertises hover menus as a use case. The movement path needs native/trusted pointer injection, or the tool must avoid claiming support for CSS-hover interactions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Known limit, stated in the PR: synthetic events cannot set :hover without trusted input injection. Menus driven by JavaScript hover handlers, the case the tool covers, open.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…he browser panel (#13532) * Studio: fix compressed pages, router paths and early empty reads in the browser panel * Keep a page's own base fixed when its router moves * Count an empty base href as the page's own base * Studio: name the page's open request count requests, not pending The browser pointer and script tools (#13505) use AgentAnswer.pending as a boolean for a script still running; a numeric pending here would merge into the same type. * Studio: shorten comments in the browser page wait * Studio: keep Forward on a routed reload and an XHR count through a refused send Reload at the router's address now swaps the entry in place instead of truncating the pages ahead, and a second send() the browser refuses no longer ends the count of the request still in flight. * Studio: give a changing page its DOM allowance from when its requests close * Studio: count a page's quiet from when its last request closed --------- Co-authored-by: Daniel Han <[email protected]>
What changes
The browser agent could only act on elements by ref. It had no way to click something without a ref (a canvas, a map, a custom widget), hover to open a menu, drag, or run JavaScript. This adds:
browser_clickat x, y.refis now optional: the model can passxandyinstead. The click lands on whatever is drawn at that point, as a real click would, with the rightclientX/clientY, so canvases and maps get correct offsets.browser_move_mouse(ref or x, y). Sends the full pointer/mouse over, enter, leave and move sequence, so menus that open onmouseenteropen.browser_dragfrom ref or x, y toto_reforto_x,to_y. Press, 5 to 25 moves paced one frame apart, release. Pages that listen ondocument(sliders, sortable lists) follow it. When the source isdraggable="true"it sends HTML drag and drop events instead, with a sharedDataTransfer, and reports when nothing took the drop.browser_evaluateruns a script (the body of an async function;returngives back a value as JSON,awaitworks). The result goes back to the model inside the untrusted-content fence.Coordinates are pixels of the latest
browser_screenshot. The panel scales the capture to the page's CSS size (within the server's 1024 px image edge) and keeps the scale, so a point read off the picture maps back exactly. The tool result states the picture's size. Without a screenshot, x and y are CSS pixels of the visible page.Security
The new tools reuse the existing gates and close the gaps that points and scripts open:
Cf, the Trojan Source trick) and long blank runs that could hide a tail. Scripts are capped at 8000 characters.browser_view_evalcommand. The script is spliced into source the same way as the agent and annotate code, so a page CSP without'unsafe-eval'can't block it. The id and document token are checked to plain characters before splicing. A syntax error fails the whole script, so the page never runs half of it. The command has the samerequire_mainand view checks asbrowser_view_agent. The proxied frame compiles the script in the page, where the proxy already strips the page's CSP.Performance
Each action costs about what a ref click does. Settling and the snapshot after it dominate, as before.
How it was verified
pytest tests/test_browser_agent.pypasses. New tests cover ref-or-point validation, script bounds and fencing, the hidden-text refusals, and the screenshot size note.ruffis clean.npm run typecheck,npm test(11766 passed, including the durable-gate list check) andnpm run buildpass.eval_code_is_spliced_once_and_ids_are_plainpasses along with the existing splice tests. The new test also checks rejection of bad ids and document tokens.DataTransferdata.Not covered here
:hoveror move native form controls such as<input type="range">. Menus driven by JS hover handlers, and custom sliders, work.Screenshots
A browser_evaluate request reaching the panel, merge base (left) against this branch (right), each a separate Studio built from its tree. On the merge base there is no script tool, so nothing is asked.
The script is shown in full and Allow stays disabled while its end is off screen:
Scrolled to its last line, Allow is enabled: