Draft
Conversation
Contributor
There was a problem hiding this comment.
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_coordinatestool data + implementation (ClickCoordinateBrowserTool) usingpage.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/ywithminimum: 0, butinvokeonly checksNumber.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 anerrorResult) 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)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.