-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix multiple click dispatch on CDP and Anthropic CUA handling #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multiple click dispatch on CDP and Anthropic CUA handling #1388
Conversation
🦋 Changeset detectedLatest commit: e6d079c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Greptile OverviewGreptile SummaryFixes multiple-click behavior by correctly dispatching individual
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant Locator as Locator/Page
participant CDP as Chrome DevTools Protocol
participant Browser as Browser Engine
Client->>Locator: click(clickCount=2)
Locator->>CDP: dispatchMouseEvent(type="mouseMoved")
CDP->>Browser: Move cursor to position
loop For each click (i=1 to clickCount)
Locator->>CDP: dispatchMouseEvent(type="mousePressed", clickCount=i)
CDP->>Browser: Press mouse button (click count: i)
Locator->>CDP: dispatchMouseEvent(type="mouseReleased", clickCount=i)
CDP->>Browser: Release mouse button (click count: i)
end
Browser->>Browser: Trigger click/dblclick events
Locator-->>Client: Click complete
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
| x, | ||
| y, | ||
| button, | ||
| clickCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: should be i not clickCount - the loop increments i to send individual events
| clickCount, | |
| clickCount: i, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/understudy/page.ts
Line: 1360:1360
Comment:
**logic:** should be `i` not `clickCount` - the loop increments `i` to send individual events
```suggestion
clickCount: i,
```
How can I resolve this? If you propose a fix, please make it concise.| x, | ||
| y, | ||
| button, | ||
| clickCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: should be i not clickCount - matches the pattern in locator.ts:417,425
| clickCount, | |
| clickCount: i, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/understudy/page.ts
Line: 1368:1368
Comment:
**logic:** should be `i` not `clickCount` - matches the pattern in locator.ts:417,425
```suggestion
clickCount: i,
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 4 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/core/lib/v3/understudy/page.ts">
<violation number="1" location="packages/core/lib/v3/understudy/page.ts:1360">
P2: The `clickCount` parameter in each iteration should be `i` (the iteration index), not the total `clickCount`. For proper double-click/triple-click simulation, browsers expect clickCount to increment with each successive click in the sequence (1 for first click, 2 for second click, etc.). This is how `event.detail` is set and how JavaScript double-click detection works.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| x, | ||
| y, | ||
| button, | ||
| clickCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The clickCount parameter in each iteration should be i (the iteration index), not the total clickCount. For proper double-click/triple-click simulation, browsers expect clickCount to increment with each successive click in the sequence (1 for first click, 2 for second click, etc.). This is how event.detail is set and how JavaScript double-click detection works.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/lib/v3/understudy/page.ts, line 1360:
<comment>The `clickCount` parameter in each iteration should be `i` (the iteration index), not the total `clickCount`. For proper double-click/triple-click simulation, browsers expect clickCount to increment with each successive click in the sequence (1 for first click, 2 for second click, etc.). This is how `event.detail` is set and how JavaScript double-click detection works.</comment>
<file context>
@@ -1350,22 +1350,24 @@ export class Page {
+ x,
+ y,
+ button,
+ clickCount,
+ } as Protocol.Input.DispatchMouseEventRequest);
</file context>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too slow, Greptile beat you mate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
why
Click count in CDP's Input.dispatchMouseEvent does not issue multiple click events, is mainly kept for tracking. Individual
mousePressed/mouseReleasedevents must be sentwhat changed
Added a for loop for the
clickCountnumber provided in bothlocator.click()andpage.click(). Also built redundancy aroundAnthropicCUAClientdouble_click coordinate parsing.test plan
click-count.spec.tsSummary by cubic
Fixes multiple-click behavior by dispatching individual mousePressed/mouseReleased events per click and normalizes Anthropic CUA doubleClick coordinates. Double-clicks and multi-clicks now work reliably via CDP and CUA.
Written for commit 26b784d. Summary will update automatically on new commits.