Skip to content

[POC] Browser click coordinates tool#313811

Draft
jruales wants to merge 1 commit intomainfrom
jruales/coordinate-click-tool
Draft

[POC] Browser click coordinates tool#313811
jruales wants to merge 1 commit intomainfrom
jruales/coordinate-click-tool

Conversation

@jruales
Copy link
Copy Markdown
Contributor

@jruales jruales commented May 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 1, 2026 22:46
@jruales jruales changed the title POC of click_coordinates tool [POC] Browser click coordinates tool May 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new internal BrowserView chat tool that lets agents click at viewport-relative (x, y) coordinates on a tracked Playwright page, and wires it into the existing browser tool registration/toolset.

Changes:

  • Introduce click_coordinates tool data + implementation (ClickCoordinateBrowserTool) using page.mouse.click.
  • Register the new tool in the BrowserView chat tools contribution so it becomes available alongside existing browser tools.
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/electron-browser/tools/clickCoordinateBrowserTool.ts New tool definition + invocation/prepare logic for coordinate-based mouse clicks.
src/vs/workbench/contrib/browserView/electron-browser/tools/browserTools.contribution.ts Registers the new tool implementation and adds it to the browser tool set.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/browserView/electron-browser/tools/clickCoordinateBrowserTool.ts:98

  • The input schema declares x/y with minimum: 0, but invoke only checks Number.isFinite. Negative coordinates can still be passed (e.g., from an extension/tool hook) and will likely cause Playwright to throw. Please enforce the non-negative constraint at runtime (and return an errorResult) to keep behavior consistent with the schema.
		if (!Number.isFinite(params.x) || !Number.isFinite(params.y)) {
			return errorResult('Both "x" and "y" must be finite viewport coordinates.');
		}
  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines +62 to +96
export class ClickCoordinateBrowserTool implements IToolImpl {
constructor(
@IPlaywrightService private readonly playwrightService: IPlaywrightService,
) { }

async prepareToolInvocation(_context: IToolInvocationPreparationContext, _token: CancellationToken): Promise<IPreparedToolInvocation | undefined> {
const params = _context.parameters as IClickCoordinateBrowserToolParams;
const link = createBrowserPageLink(params.pageId);
const coordinateLabel = `(${params.x}, ${params.y})`;
return {
invocationMessage: params.button === 'right'
? new MarkdownString(localize('browser.clickCoordinates.invocation.right', 'Right-clicking {0} in {1}', coordinateLabel, link))
: params.button === 'middle'
? new MarkdownString(localize('browser.clickCoordinates.invocation.middle', 'Middle-clicking {0} in {1}', coordinateLabel, link))
: params.dblClick
? new MarkdownString(localize('browser.clickCoordinates.invocation.double', 'Double-clicking {0} in {1}', coordinateLabel, link))
: new MarkdownString(localize('browser.clickCoordinates.invocation', 'Clicking {0} in {1}', coordinateLabel, link)),
pastTenseMessage: params.button === 'right'
? new MarkdownString(localize('browser.clickCoordinates.past.right', 'Right-clicked {0} in {1}', coordinateLabel, link))
: params.button === 'middle'
? new MarkdownString(localize('browser.clickCoordinates.past.middle', 'Middle-clicked {0} in {1}', coordinateLabel, link))
: params.dblClick
? new MarkdownString(localize('browser.clickCoordinates.past.double', 'Double-clicked {0} in {1}', coordinateLabel, link))
: new MarkdownString(localize('browser.clickCoordinates.past', 'Clicked {0} in {1}', coordinateLabel, link)),
};
}

async invoke(invocation: IToolInvocation, _countTokens: CountTokensCallback, _progress: ToolProgress, _token: CancellationToken): Promise<IToolResult> {
const params = invocation.parameters as IClickCoordinateBrowserToolParams;

if (!params.pageId) {
return errorResult(`No page ID provided. Use '${OpenPageToolId}' first.`);
}

if (!Number.isFinite(params.x) || !Number.isFinite(params.y)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants