Add right/middle click support on act and observe#1631
Conversation
🦋 Changeset detectedLatest commit: 10a9866 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 SummaryAdded support for right and middle click actions in the Changes:
Minor concern:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Act/Observe
participant LLM
participant actHandlerUtils
participant Locator
participant Browser
User->>Act/Observe: Request action (e.g., "right click button")
Act/Observe->>LLM: Send instruction + DOM snapshot
Note over LLM: Prompt includes instruction:<br/>"provide right or middle as argument"
LLM-->>Act/Observe: Returns element + method="click" + args=["right"|"middle"]
Act/Observe->>actHandlerUtils: performUnderstudyMethod(method, xpath, args)
actHandlerUtils->>actHandlerUtils: clickElement(ctx)
Note over actHandlerUtils: Reads args[0] as MouseButton
actHandlerUtils->>Locator: locator.click({ button: args[0] })
Note over Locator: Defaults to "left" if button undefined
Locator->>Browser: Input.dispatchMouseEvent(button)
Browser-->>Locator: Click executed
Locator-->>actHandlerUtils: Success
actHandlerUtils-->>Act/Observe: Action completed
Act/Observe-->>User: Result
|
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 4/5
- Only a minor concern about exposing an internal helper type as public API in
packages/core/lib/v3/understudy/locator.ts, which could reduce refactoring flexibility but is unlikely to break behavior now - Overall risk seems low; this looks more like an API hygiene consideration than a functional regression
- Pay close attention to
packages/core/lib/v3/understudy/locator.ts- internal helper type exposure and intended stability
Prompt for AI agents (all 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/locator.ts">
<violation number="1" location="packages/core/lib/v3/understudy/locator.ts:20">
P2: Avoid exposing this internal helper type as a public API unless it’s intentionally stable and user‑facing; keep it module‑private to preserve refactoring flexibility.
(Based on your team's feedback about avoiding exposing internal types as public APIs.) [FEEDBACK_USED]</violation>
</file>
Architecture diagram
sequenceDiagram
* participant LLM as LLM (Reasoning Engine)
* participant Prompt as prompt.ts
* participant Handler as actHandlerUtils (clickElement)
* participant Locator as Locator (Understudy)
* participant Browser as Browser Instance
Note over LLM, Browser: Execution Flow for Act/Observe
Prompt->>LLM: CHANGED: System prompt now instructs LLM to provide "right" or "middle" for non-left clicks
LLM-->>Handler: Returns action (click) + args (e.g., ["right"])
rect rgb(23, 37, 84)
Note right of Handler: NEW: Action Context Handling
Handler->>Handler: Extract args[0] as MouseButton
Handler->>Locator: CHANGED: click({ button: args[0] })
end
Locator->>Browser: Trigger mouse click (button: left|right|middle)
Browser-->>Locator: Click event completed
Locator-->>Handler: Success/Failure
Handler-->>LLM: Result of interaction
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const MAX_REMOTE_UPLOAD_BYTES = 50 * 1024 * 1024; // 50MB guard copied from Playwright | ||
|
|
||
| type MouseButton = "left" | "right" | "middle"; | ||
| export type MouseButton = "left" | "right" | "middle"; |
There was a problem hiding this comment.
P2: Avoid exposing this internal helper type as a public API unless it’s intentionally stable and user‑facing; keep it module‑private to preserve refactoring flexibility.
(Based on your team's feedback about avoiding exposing internal types as public APIs.)
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/locator.ts, line 20:
<comment>Avoid exposing this internal helper type as a public API unless it’s intentionally stable and user‑facing; keep it module‑private to preserve refactoring flexibility.
(Based on your team's feedback about avoiding exposing internal types as public APIs.) </comment>
<file context>
@@ -17,7 +17,7 @@ import { NormalizedFilePayload } from "../types/private/locator";
const MAX_REMOTE_UPLOAD_BYTES = 50 * 1024 * 1024; // 50MB guard copied from Playwright
-type MouseButton = "left" | "right" | "middle";
+export type MouseButton = "left" | "right" | "middle";
/**
</file context>
| export type MouseButton = "left" | "right" | "middle"; | |
| type MouseButton = "left" | "right" | "middle"; |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| const MAX_REMOTE_UPLOAD_BYTES = 50 * 1024 * 1024; // 50MB guard copied from Playwright | ||
|
|
||
| type MouseButton = "left" | "right" | "middle"; | ||
| export type MouseButton = "left" | "right" | "middle"; |
There was a problem hiding this comment.
exporting is fine but maybe move to types/public/locator.ts
why
Locator.click has support for both right and middle clicks, but these are not properly piped or prompted for
actorobservewhat changed
test plan
Summary by cubic
Added right and right middle click support to act/observe so flows can trigger context menus and middle-click behaviors. Handlers now pass the mouse button to Locator.click.
Written for commit 10a9866. Summary will update on new commits. Review in cubic