cua icon indicating copy to clipboard operation
cua copied to clipboard

[Bug]: element clicks on a second display take about 9 s each, even with the agent cursor disabled

Open FredAmartey opened this issue 2 months ago • 2 comments

Primary area

Cua Driver

Summary

Every element click on a Calculator window on a second display takes about 9 seconds, including consecutive clicks on neighbouring buttons, and turning the agent cursor off with set_agent_cursor_enabled does not change that. Setting glide_duration_ms to 150 brings each click down to about 1.4 s.

Reproduction

  1. Put Calculator's window on a second display. Here it is a CGVirtualDisplay placed left of and below the main display.
  2. Start cua-driver mcp, call get_window_state for Calculator, then click the element tokens for Add, Equals and Add again, timing each call.
  3. In a new connection, call set_agent_cursor_enabled {"enabled": false}, confirm it with get_agent_cursor_state, and repeat step 2.

It happens on every click.

Expected behavior

With the cursor disabled, a click does not wait for a cursor animation (animate_cursor_to says a disabled cursor never animates), and an element click on this window finishes in well under a second.

Actual behavior

Connection Add Equals Add
default cursor 9.18 s 9.45 s 9.02 s
set_agent_cursor_enabled {"enabled": false} first 9.25 s 9.13 s 9.09 s

get_agent_cursor_state in the second connection reports "enabled": false and "glide_duration_ms": 0.0. With set_agent_cursor_motion {"glide_duration_ms": 150} instead, the same clicks take about 1.4 s. The buttons are pressed every time, and an AXPress sent to the same button directly takes about 0.01 s. I don't know where the wait comes from while the cursor is disabled.

Environment

Cua Driver 0.30.1, MCP over stdio against the LaunchAgent daemon in unrestricted mode. macOS 27.0 (26A428), Apple silicon, Stage Manager on. Calculator. main at 1fadc40 has the same click path.

Evidence

animate_cursor_to returns early for a disabled cursor: https://github.com/trycua/cua/blob/1fadc40b3e40e042590c9f63cf8ef837a6263258/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs#L346-L387

The element click path awaits it before pressing: https://github.com/trycua/cua/blob/1fadc40b3e40e042590c9f63cf8ef837a6263258/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs#L598-L604

Workaround and additional context

set_agent_cursor_motion {"glide_duration_ms": 150} on each session: about 1.4 s a click.

Submission checks

  • [x] I searched for duplicate issues and active pull requests.
  • [x] This issue describes a single problem.
  • [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.

FredAmartey avatar Sep 28 '26 00:09 FredAmartey

Hello, I’d like to take this up. Could you please assign this issue to me?

Approach:

  1. Update seed_start_in_map and animate_cursor_to across the platform overlay modules (platform-macos, platform-windows, platform-linux) to check runtime cursor visibility (rs.core.visible / set_agent_cursor_enabled), not just the launch-time rs.core.cfg.enabled flag, so disabled cursors return immediately without seeding or waiting on a glide animation.
  2. Replace the pos.0 < -50.0 / pos.0 < -100.0 coordinate threshold checks in cursor-overlay (RenderStateCore) and the platform overlays with explicit placement tracking so valid negative coordinates on a secondary display (placed left of or above the primary display) are not mistaken for the initial unplaced (-200, -200) sentinel and re-clamped to the main screen on every click.

Validation / Testing:

  • Unit tests: Add tests in cursor-overlay and the platform overlay modules covering runtime-disabled cursor short-circuiting (set_agent_cursor_enabled {"enabled": false}) and consecutive clicks/glides at negative display coordinates (x < -50.0, y < -50.0) without re-seeding to the primary screen.
  • Multi-monitor desktop testing: Test locally on Windows connected to an external second monitor positioned at negative coordinates (left of the primary display) by running consecutive element clicks with the agent cursor both enabled and disabled (set_agent_cursor_enabled {"enabled": false}) to verify click latency and cursor state, alongside the macOS/Linux CI checks.

Mohit20057 avatar Sep 28 '26 19:09 Mohit20057

PR #4695 addresses the disabled-cursor delay reported here. We reproduced it on Cua Driver 0.34.0: after disabling the cursor and setting a five-second animation, an exact button click still took 5.557 seconds. The button received the click.

The fix checks whether the cursor is currently visible before waiting for its animation. The public MCP regression fails on the release and passes on the PR's final commit. With the cursor disabled, the measured native form took 23% less time and the embedded-browser form took 18% less time.

This PR covers the disabled-cursor wait only. It does not resolve the separate negative-coordinate placement problem described in the proposed scope above. Windows desktop confirmation and the full canonical matrix are pending.

muness avatar Oct 06 '26 00:10 muness