Skip to content

[v4]: add method arg to /click route stub#1884

Merged
seanmcguire12 merged 4 commits intomainfrom
seanmcguire/stg-1659-add-optional-synthetic-bool-to-click
Mar 27, 2026
Merged

[v4]: add method arg to /click route stub#1884
seanmcguire12 merged 4 commits intomainfrom
seanmcguire/stg-1659-add-optional-synthetic-bool-to-click

Conversation

@seanmcguire12
Copy link
Copy Markdown
Member

@seanmcguire12 seanmcguire12 commented Mar 24, 2026

why

  • to group two types of clicking into a single route. ie, we don't need to add a separate /sendClickEvent route

what changed

  • added an optional synthetic parameter to the /click schema, which we will internally route to .sendClickEvent()

screenshot:

Screenshot 2026-03-24 at 3 58 50 PM

test plan

  • added a test to verify passing synthetic: true passes validation

Summary by cubic

Add a method param to the v4 /click route to support both coordinate-based and JS event clicks in one endpoint, defaulting to xy for backward compatibility. Caps clickCount at 3 and updates the OpenAPI/action output. Addresses Linear STG-1659.

  • New Features
    • Adds method: 'xy' | 'jsevent' (default xy) to /click params; action output now includes and requires method via PageClickParamsOutput.
    • Limits clickCount to 1–3 in schema and OpenAPI in packages/server-v4.
    • Adds integration tests for coordinate clicks and method: "jsevent" selector clicks.

Written for commit c02c521. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 24, 2026

⚠️ No Changeset found

Latest commit: c02c521

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@seanmcguire12 seanmcguire12 changed the title [v4]: add synthetic arg to /click route [v4]: add synthetic arg to /click route stub Mar 24, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Client
    participant API as API Route (/v4/page/click)
    participant Schema as Zod / OpenAPI Validation
    participant Service as Page Service

    Client->>API: POST /v4/page/click { selector, synthetic? }
    
    API->>Schema: Validate request body
    Note over Schema: NEW: Schema now includes "synthetic" (boolean, default false)
    
    alt Invalid Payload
        Schema-->>API: Validation Error
        API-->>Client: 400 Bad Request
    else Valid Payload
        Schema-->>API: Parsed Params
        API->>Service: click(params)

        alt NEW: params.synthetic == true
            Service->>Service: INTERNAL: route to sendClickEvent()
            Note over Service: Dispatches a synthetic JS click event
        else params.synthetic == false (default)
            Service->>Service: Standard click() logic
            Note over Service: Simulates trusted physical mouse interaction
        end

        Service-->>API: Action Result
        
        API->>Schema: NEW: Map to PageClickActionOutput
        Note over Schema: Output now includes synthetic flag in params metadata
        Schema-->>API: Formatted Response
        
        API-->>Client: 200 OK + Result
    end
Loading

button: MouseButtonSchema.optional(),
clickCount: z.number().int().min(1).optional(),
returnSelector: z.boolean().optional(),
synthetic: z.boolean().default(false),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
synthetic: z.boolean().default(false),
method: z.enum(['jsevent', 'xy']).default('jsevent'),

@@ -271,6 +271,7 @@ export const PageClickParamsSchema = PageWithPageIdSchema.extend({
button: MouseButtonSchema.optional(),
clickCount: z.number().int().min(1).optional(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
clickCount: z.number().int().min(1).optional(),
clickCount: z.number().int().lte(3).gte(1).optional(),

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/server-v4/openapi.v4.yaml">

<violation number="1" location="packages/server-v4/openapi.v4.yaml:2494">
P1: The schema replaces `synthetic` with `method`, which breaks the intended `/click` API contract and rejects `synthetic` requests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

maximum: 3
returnSelector:
type: boolean
method:
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 27, 2026

Choose a reason for hiding this comment

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

P1: The schema replaces synthetic with method, which breaks the intended /click API contract and rejects synthetic requests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/server-v4/openapi.v4.yaml, line 2494:

<comment>The schema replaces `synthetic` with `method`, which breaks the intended `/click` API contract and rejects `synthetic` requests.</comment>

<file context>
@@ -2488,12 +2488,15 @@ components:
-        synthetic:
-          default: false
-          type: boolean
+        method:
+          default: xy
+          type: string
</file context>
Fix with Cubic

@seanmcguire12 seanmcguire12 changed the title [v4]: add synthetic arg to /click route stub [v4]: add method arg to /click route stub Mar 27, 2026
Co-authored-by: Nick Sweeting <github@sweeting.me>
@seanmcguire12 seanmcguire12 merged commit 28f40be into main Mar 27, 2026
28 checks passed
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