Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(cua-driver): choose the cursor motion in start_session and a saved default (#4670)

Francesco Bonacci75ac6800d12d
diff --git a/docs/content/docs/cua-driver/guides/operate.mdx b/docs/content/docs/cua-driver/guides/operate.mdx
index 68f8be830b..ce968a5684 100644
--- a/docs/content/docs/cua-driver/guides/operate.mdx
+++ b/docs/content/docs/cua-driver/guides/operate.mdx
@@ -296,6 +296,53 @@ cua-driver cursor-theme list
cua-driver cursor-theme uninstall com.example.cursor.studio
```
+## Choose your cursor
+
+Six motion styles are built in. `signature_arc` is the default.
+
+| Style | Feel |
+| --- | --- |
+| `signature_arc` | One confident arc with a small follow-through. |
+| `spring_settle` | An arc that lands with one soft bounce. |
+| `magnetic` | Slows near the target, then is pulled in. |
+| `comet_swoop` | A wide arc with a short trail. |
+| `adaptive` | Careful for small targets, a swoop for long moves. |
+| `classic` | The original glide. |
+
+Pick one for every new session by saving it as the default:
+
+```bash test="cli-shape" id="cua-driver-choose-cursor-default"
+cua-driver config set cursor.motion.style magnetic
+cua-driver config set cursor.motion.timing fitts
+cua-driver config set cursor.motion.effects.trail true
+cua-driver config get cursor.motion.style
+```
+
+The default is saved in `~/.cua-driver/config.json` and applies to sessions
+started afterwards. Use `null` as the value to clear a key, or
+`cua-driver config set cursor.motion null` to clear them all. A bad value is
+rejected with the list of allowed styles.
+
+Or choose per run, before the cursor first appears, in `start_session`:
+
+```bash test="cli-shape" id="cua-driver-choose-cursor-session"
+cua-driver start_session '{"session":"research","cursor_motion":{"style":"spring_settle","timing":"fitts"}}'
+```
+
+`cursor_motion` takes the same fields as `set_agent_cursor_motion`, and
+`start_session` echoes it back. When several apply, the most specific wins:
+
+1. `set_agent_cursor_motion` on the session
+2. `cursor_motion` in `start_session`
+3. the saved default (`cursor.motion.*`)
+4. the built-in `signature_arc`
+
+Reduced motion always wins: when the theme or host asks for it, every move is a
+short straight glide with no effects, whatever you chose.
+
+Cua Driver has no settings window, so there is no cursor picker in the app. Use
+`cua-driver config set` or `start_session`.
+
## Telemetry
Cua Driver sends content-free, pseudonymous usage events to PostHog's EU
diff --git a/docs/content/docs/cua-driver/reference/cli/config.mdx b/docs/content/docs/cua-driver/reference/cli/config.mdx
index 1939dc2aa0..eeba586ab7 100644
--- a/docs/content/docs/cua-driver/reference/cli/config.mdx
+++ b/docs/content/docs/cua-driver/reference/cli/config.mdx
@@ -97,6 +97,8 @@ cua-driver config get max_image_dimension
Set one config key.
+Cursor motion defaults are saved keys that apply to sessions started afterwards: cursor.motion.style (signature_arc, spring_settle, magnetic, comet_swoop, adaptive, classic), cursor.motion.timing (native, fitts, fixed) and cursor.motion.effects.<trail|glow|magnet|ripple|squish> (true, false). Use null for a key to clear it, or cursor.motion null to clear all. A start_session cursor_motion or a set_agent_cursor_motion call overrides the saved default.
+
```text output
cua-driver config set <key> <value>
```
@@ -111,6 +113,15 @@ cua-driver config set <key> <value>
```bash test="cli-shape" id="ref-cua-driver-config-set"
# Downscale screenshots to at most 1568 px
cua-driver config set max_image_dimension 1568
+
+# Make magnetic the default cursor motion for new sessions
+cua-driver config set cursor.motion.style magnetic
+
+# Scale cursor move time with distance and target size
+cua-driver config set cursor.motion.timing fitts
+
+# Turn the cursor trail on by default
+cua-driver config set cursor.motion.effects.trail true
```
### `cua-driver config reset`
diff --git a/docs/content/docs/cua-driver/reference/mcp-tools/maintenance.mdx b/docs/content/docs/cua-driver/reference/mcp-tools/maintenance.mdx
index 9305d66b0d..00b959de82 100644
--- a/docs/content/docs/cua-driver/reference/mcp-tools/maintenance.mdx
+++ b/docs/content/docs/cua-driver/reference/mcp-tools/maintenance.mdx
@@ -77,6 +77,8 @@ Update cua-driver-rs configuration. Changes to max_image_dimension take effect i
Note: capture_mode is a per-call param (on get_window_state / click), not a stored setting. Capture modality is selected by each action's target; the old capture_scope config key is retired.
+Cursor motion defaults: cursor.motion.style, cursor.motion.timing and cursor.motion.effects.&lt;trail|glow|magnet|ripple|squish&gt; are saved to ~/.cua-driver/config.json and seed sessions started afterwards. start_session cursor_motion and set_agent_cursor_motion override them; reduced motion always wins.
+
**macOS parameters**
| Parameter | Type | Default | Description |
@@ -97,6 +99,8 @@ Two input shapes (both accepted, matching Windows/Swift):
The experimental_pip keys persist to ~/.cua-driver/config.json and apply on next daemon restart (the PiP backend is initialised once at startup; Linux ships only the trait stub today: see issue #1729).
+`cursor.motion.style`, `cursor.motion.timing` and `cursor.motion.effects.<name>` save the default cursor motion for sessions started afterwards.
+
**Linux parameters**
| Parameter | Type | Default | Description |
@@ -122,6 +126,8 @@ Known keys:
- `experimental_pip` (boolean; persisted to config.json, applies on next daemon restart: Windows backend stubbed today, see issue #1729)
- `experimental_pip_geometry` (string `WxH` or `WxH+X+Y`; persisted; applies on next daemon restart)
+- `cursor.motion.style`, `cursor.motion.timing`, `cursor.motion.effects.<name>`: saved default cursor motion for sessions started afterwards (see the cursor docs).
+
Returns the full updated config in the same shape as `get_config`.
**Windows parameters**
@@ -141,6 +147,14 @@ Returns the full updated config in the same shape as `get_config`.
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
+| <span id="set_config--cursor-motion"></span>`cursor.motion` | `any` | | Pass null (or `default`) to clear every saved cursor motion default. |
+| <span id="set_config--cursor-motion-effects-glow"></span>`cursor.motion.effects.glow` | `boolean` | | Saved default for the `glow` cursor effect. Unset follows the style. |
+| <span id="set_config--cursor-motion-effects-magnet"></span>`cursor.motion.effects.magnet` | `boolean` | | Saved default for the `magnet` cursor effect. Unset follows the style. |
+| <span id="set_config--cursor-motion-effects-ripple"></span>`cursor.motion.effects.ripple` | `boolean` | | Saved default for the `ripple` cursor effect. Unset follows the style. |
+| <span id="set_config--cursor-motion-effects-squish"></span>`cursor.motion.effects.squish` | `boolean` | | Saved default for the `squish` cursor effect. Unset follows the style. |
+| <span id="set_config--cursor-motion-effects-trail"></span>`cursor.motion.effects.trail` | `boolean` | | Saved default for the `trail` cursor effect. Unset follows the style. |
+| <span id="set_config--cursor-motion-style"></span>`cursor.motion.style` | `"signature_arc" \| "spring_settle" \| "magnetic" \| "comet_swoop" \| "adaptive" \| "classic"` | | Saved default cursor motion style for new sessions. Overridden by start_session cursor_motion and set_agent_cursor_motion; reduced motion always wins. Built-in default: signature_arc. |
+| <span id="set_config--cursor-motion-timing"></span>`cursor.motion.timing` | `"native" \| "fitts" \| "fixed"` | | Saved default cursor move timing for new sessions. |
| <span id="set_config--session"></span>`session` | `string` | | For multi-call work, prefer a short public session label and repeat it on every call that accepts it. Omit it to use the authenticated transport's implicit lifecycle session. |
| <span id="set_config--value"></span>`value` | `any` | | New value for `key`. JSON type depends on the key. |
diff --git a/docs/content/docs/cua-driver/reference/mcp-tools/sessions.mdx b/docs/content/docs/cua-driver/reference/mcp-tools/sessions.mdx
index cea60883a6..5751a89a89 100644
--- a/docs/content/docs/cua-driver/reference/mcp-tools/sessions.mdx
+++ b/docs/content/docs/cua-driver/reference/mcp-tools/sessions.mdx
@@ -30,6 +30,19 @@ Effect: mutating, idempotent. Platforms: macOS, Linux, Windows.
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| <span id="start_session--capture_scope"></span>`capture_scope` | `"auto" \| "window" \| "desktop"` | | Deprecated compatibility policy. New callers select window or desktop modality on each action instead of storing it on the session. |
+| <span id="start_session--cursor_motion"></span>`cursor_motion` | `object` | | Optional initial cursor motion (style, timing, effects and tuning). The host applies it before the cursor is first made visible. A later `set_agent_cursor_motion` call wins; this wins over the saved default (`cursor.motion.*` in the driver config) and the built-in `signature_arc`. Reduced motion always wins. |
+| <span id="start_session--cursor_motion-arc_flow"></span>`cursor_motion.arc_flow` | `number` | | Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`: positive moves the apex toward the destination. Clamped to -1..1 (default 0). |
+| <span id="start_session--cursor_motion-arc_size"></span>`cursor_motion.arc_size` | `number` | | Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default) keeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1. |
+| <span id="start_session--cursor_motion-dwell_after_click_ms"></span>`cursor_motion.dwell_after_click_ms` | `number` | | Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80). |
+| <span id="start_session--cursor_motion-effects"></span>`cursor_motion.effects` | `object` | | Turn single effects on or off. An omitted effect keeps its current setting; null restores the style's default. |
+| <span id="start_session--cursor_motion-end_handle"></span>`cursor_motion.end_handle` | `number` | | Arc control-point offset from the end, as a fraction of the distance, for `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3). |
+| <span id="start_session--cursor_motion-glide_duration_ms"></span>`cursor_motion.glide_duration_ms` | `number` | | Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A nonzero value with `native` timing also fixes the duration. Clamped to 0..5000. |
+| <span id="start_session--cursor_motion-idle_hide_ms"></span>`cursor_motion.idle_hide_ms` | `number` | | Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to 0..60000 (default 15000). |
+| <span id="start_session--cursor_motion-spring"></span>`cursor_motion.spring` | `number` | | Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped to 0.3..1 (default 0.72). |
+| <span id="start_session--cursor_motion-start_handle"></span>`cursor_motion.start_handle` | `number` | | Arc control-point offset from the start, as a fraction of the distance, for `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3). |
+| <span id="start_session--cursor_motion-style"></span>`cursor_motion.style` | `"signature_arc" \| "spring_settle" \| "magnetic" \| "comet_swoop" \| "adaptive" \| "classic"` | | Trajectory style. `signature_arc` (default) is one arc with a small follow-through; `spring_settle` lands with one soft bounce; `magnetic` is pulled into the target; `comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for small targets and a swoop for long moves; `classic` is the previous Dubins glide. When the theme's reduced motion is on, every move is a short straight glide with no effects. |
+| <span id="start_session--cursor_motion-timing"></span>`cursor_motion.timing` | `"native" \| "fitts" \| "fixed"` | | `native` uses the style's own timing; `fitts` scales the move time with distance and target size; `fixed` uses glide_duration_ms (1430 ms when 0). |
+| <span id="start_session--cursor_motion-turn_radius"></span>`cursor_motion.turn_radius` | `number` | | Minimum turning radius of the `classic` glide path, in points; smaller turns tighter. Clamped to 1..1000 (default 80). |
| <span id="start_session--cursor_theme"></span>`cursor_theme` | `object` | | Optional initial cursor theme. The host applies it before the cursor is first made visible, avoiding a flash of the default theme. |
| <span id="start_session--cursor_theme-reduced_motion"></span>`cursor_theme.reduced_motion` | `"auto" \| "on" \| "off"` | `"auto"` | |
| <span id="start_session--cursor_theme-theme_id"></span>`cursor_theme.theme_id` | `string` | | |
diff --git a/libs/cua-driver/contract/manifest.json b/libs/cua-driver/contract/manifest.json
index f82cae995d..6a668a2623 100644
--- a/libs/cua-driver/contract/manifest.json
+++ b/libs/cua-driver/contract/manifest.json
@@ -4750,6 +4750,145 @@
],
"type": "string"
},
+ "cursor_motion": {
+ "additionalProperties": false,
+ "description": "Optional initial cursor motion (style, timing, effects and tuning). The host applies it\nbefore the cursor is first made visible. A later `set_agent_cursor_motion` call wins;\nthis wins over the saved default (`cursor.motion.*` in the driver config) and the\nbuilt-in `signature_arc`. Reduced motion always wins.",
+ "properties": {
+ "arc_flow": {
+ "description": "Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:\npositive moves the apex toward the destination. Clamped to -1..1 (default 0).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "arc_size": {
+ "description": "Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)\nkeeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "dwell_after_click_ms": {
+ "description": "Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "effects": {
+ "additionalProperties": false,
+ "description": "Turn single effects on or off. An omitted effect keeps its current setting; null\nrestores the style's default.",
+ "properties": {
+ "glow": {
+ "description": "Soft glow around the cursor that grows with speed.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "magnet": {
+ "description": "Target glow when the `magnetic` style locks on.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ripple": {
+ "description": "Ring that expands from the hotspot on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "squish": {
+ "description": "Brief scale-down of the cursor on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "trail": {
+ "description": "Short fading trail behind the cursor.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "end_handle": {
+ "description": "Arc control-point offset from the end, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "glide_duration_ms": {
+ "description": "Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A\nnonzero value with `native` timing also fixes the duration. Clamped to 0..5000.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "idle_hide_ms": {
+ "description": "Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to\n0..60000 (default 15000).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "spring": {
+ "description": "Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped\nto 0.3..1 (default 0.72).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "start_handle": {
+ "description": "Arc control-point offset from the start, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "style": {
+ "description": "Trajectory style. `signature_arc` (default) is one arc with a small follow-through;\n`spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;\n`comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for\nsmall targets and a swoop for long moves; `classic` is the previous Dubins glide. When\nthe theme's reduced motion is on, every move is a short straight glide with no effects.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "timing": {
+ "description": "`native` uses the style's own timing; `fitts` scales the move time with distance and\ntarget size; `fixed` uses glide_duration_ms (1430 ms when 0).",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
+ "turn_radius": {
+ "description": "Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.\nClamped to 1..1000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
"cursor_theme": {
"description": "Optional initial cursor theme. The host applies it before the cursor is\nfirst made visible, avoiding a flash of the default theme.",
"properties": {
@@ -4796,6 +4935,127 @@
],
"type": "string"
},
+ "cursor_motion": {
+ "additionalProperties": false,
+ "properties": {
+ "arc_flow": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "arc_size": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "dwell_after_click_ms": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "effects": {
+ "additionalProperties": false,
+ "properties": {
+ "glow": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "magnet": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ripple": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "squish": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "trail": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "end_handle": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "glide_duration_ms": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "idle_hide_ms": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "spring": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "start_handle": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "style": {
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "timing": {
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
+ "turn_radius": {
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
"desktop_capture_authorized": {
"type": "boolean"
},
diff --git a/libs/cua-driver/docs/cursor-themes.md b/libs/cua-driver/docs/cursor-themes.md
index 14d88f7ba9..a6d5f30f3e 100644
--- a/libs/cua-driver/docs/cursor-themes.md
+++ b/libs/cua-driver/docs/cursor-themes.md
@@ -111,6 +111,14 @@ The same four typed operations are available on `CuaDriver` and
is created. `reduced_motion` is `auto`, `on`, or `off`. `auto` follows the host
accessibility preference where the platform exposes one.
+`StartSessionInput.cursor_motion` sets the session's motion (the fields of
+`set_agent_cursor_motion` without `session`) before the cursor is first shown,
+and `start_session` echoes it. A saved default comes from
+`cua-driver config set cursor.motion.style|timing|effects.<name>`. Precedence:
+`set_agent_cursor_motion`, then `start_session.cursor_motion`, then the saved
+default, then the built-in `signature_arc`. Reduced motion wins over all of
+them.
+
## Semantic profile
A full custom theme must provide all twelve action animations:
diff --git a/libs/cua-driver/python/src/cua_driver/_native_contract.py b/libs/cua-driver/python/src/cua_driver/_native_contract.py
index 6e53c6c78c..9a3c21e3b0 100644
--- a/libs/cua-driver/python/src/cua_driver/_native_contract.py
+++ b/libs/cua-driver/python/src/cua_driver/_native_contract.py
@@ -2860,6 +2860,132 @@ class _UniffiFfiConverterTypeCursorMotionOutput(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalTypeCursorMotionTiming.write(value.timing, buf)
_UniffiFfiConverterOptionalTypeCursorMotionEffectsOutput.write(value.effects, buf)
+class _UniffiFfiConverterOptionalTypeCursorMotionEffects(_UniffiConverterRustBuffer):
+ @classmethod
+ def check_lower(cls, value):
+ if value is not None:
+ _UniffiFfiConverterTypeCursorMotionEffects.check_lower(value)
+
+ @classmethod
+ def write(cls, value, buf):
+ if value is None:
+ buf.write_u8(0)
+ return
+
+ buf.write_u8(1)
+ _UniffiFfiConverterTypeCursorMotionEffects.write(value, buf)
+
+ @classmethod
+ def read(cls, buf):
+ flag = buf.read_u8()
+ if flag == 0:
+ return None
+ elif flag == 1:
+ return _UniffiFfiConverterTypeCursorMotionEffects.read(buf)
+ else:
+ raise InternalError("Unexpected flag byte for optional type")
+
+@dataclass
+class CursorMotionSelection:
+ """
+ Cursor motion for a session, with the fields of `set_agent_cursor_motion` minus `session`.
+ Omitted or null fields keep the saved default (`cursor.motion.*` in the driver config), then
+ the built-in `signature_arc`.
+"""
+ def __init__(self, *, style:typing.Optional[CursorMotionStyle], timing:typing.Optional[CursorMotionTiming], effects:typing.Optional[CursorMotionEffects], start_handle:typing.Optional[float], end_handle:typing.Optional[float], arc_size:typing.Optional[float], arc_flow:typing.Optional[float], spring:typing.Optional[float], glide_duration_ms:typing.Optional[float], dwell_after_click_ms:typing.Optional[float], idle_hide_ms:typing.Optional[float], turn_radius:typing.Optional[float]):
+ self.style = style
+ self.timing = timing
+ self.effects = effects
+ self.start_handle = start_handle
+ self.end_handle = end_handle
+ self.arc_size = arc_size
+ self.arc_flow = arc_flow
+ self.spring = spring
+ self.glide_duration_ms = glide_duration_ms
+ self.dwell_after_click_ms = dwell_after_click_ms
+ self.idle_hide_ms = idle_hide_ms
+ self.turn_radius = turn_radius
+
+
+
+
+ def __str__(self):
+ return "CursorMotionSelection(style={}, timing={}, effects={}, start_handle={}, end_handle={}, arc_size={}, arc_flow={}, spring={}, glide_duration_ms={}, dwell_after_click_ms={}, idle_hide_ms={}, turn_radius={})".format(self.style, self.timing, self.effects, self.start_handle, self.end_handle, self.arc_size, self.arc_flow, self.spring, self.glide_duration_ms, self.dwell_after_click_ms, self.idle_hide_ms, self.turn_radius)
+ def __eq__(self, other):
+ if self.style != other.style:
+ return False
+ if self.timing != other.timing:
+ return False
+ if self.effects != other.effects:
+ return False
+ if self.start_handle != other.start_handle:
+ return False
+ if self.end_handle != other.end_handle:
+ return False
+ if self.arc_size != other.arc_size:
+ return False
+ if self.arc_flow != other.arc_flow:
+ return False
+ if self.spring != other.spring:
+ return False
+ if self.glide_duration_ms != other.glide_duration_ms:
+ return False
+ if self.dwell_after_click_ms != other.dwell_after_click_ms:
+ return False
+ if self.idle_hide_ms != other.idle_hide_ms:
+ return False
+ if self.turn_radius != other.turn_radius:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeCursorMotionSelection(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return CursorMotionSelection(
+ style=_UniffiFfiConverterOptionalTypeCursorMotionStyle.read(buf),
+ timing=_UniffiFfiConverterOptionalTypeCursorMotionTiming.read(buf),
+ effects=_UniffiFfiConverterOptionalTypeCursorMotionEffects.read(buf),
+ start_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
+ end_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
+ arc_size=_UniffiFfiConverterOptionalFloat64.read(buf),
+ arc_flow=_UniffiFfiConverterOptionalFloat64.read(buf),
+ spring=_UniffiFfiConverterOptionalFloat64.read(buf),
+ glide_duration_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
+ dwell_after_click_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
+ idle_hide_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
+ turn_radius=_UniffiFfiConverterOptionalFloat64.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterOptionalTypeCursorMotionStyle.check_lower(value.style)
+ _UniffiFfiConverterOptionalTypeCursorMotionTiming.check_lower(value.timing)
+ _UniffiFfiConverterOptionalTypeCursorMotionEffects.check_lower(value.effects)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.start_handle)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.end_handle)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_size)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_flow)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.spring)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.glide_duration_ms)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.dwell_after_click_ms)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.idle_hide_ms)
+ _UniffiFfiConverterOptionalFloat64.check_lower(value.turn_radius)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterOptionalTypeCursorMotionStyle.write(value.style, buf)
+ _UniffiFfiConverterOptionalTypeCursorMotionTiming.write(value.timing, buf)
+ _UniffiFfiConverterOptionalTypeCursorMotionEffects.write(value.effects, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.start_handle, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.end_handle, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.arc_size, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.arc_flow, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.spring, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.glide_duration_ms, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.dwell_after_click_ms, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.idle_hide_ms, buf)
+ _UniffiFfiConverterOptionalFloat64.write(value.turn_radius, buf)
+
@dataclass
class CursorPointOutput:
def __init__(self, *, x:float, y:float):
@@ -6776,31 +6902,6 @@ class _UniffiFfiConverterTypeSetAgentCursorEnabledOutput(_UniffiConverterRustBuf
_UniffiFfiConverterString.write(value.session, buf)
_UniffiFfiConverterBoolean.write(value.enabled, buf)
-class _UniffiFfiConverterOptionalTypeCursorMotionEffects(_UniffiConverterRustBuffer):
- @classmethod
- def check_lower(cls, value):
- if value is not None:
- _UniffiFfiConverterTypeCursorMotionEffects.check_lower(value)
-
- @classmethod
- def write(cls, value, buf):
- if value is None:
- buf.write_u8(0)
- return
-
- buf.write_u8(1)
- _UniffiFfiConverterTypeCursorMotionEffects.write(value, buf)
-
- @classmethod
- def read(cls, buf):
- flag = buf.read_u8()
- if flag == 0:
- return None
- elif flag == 1:
- return _UniffiFfiConverterTypeCursorMotionEffects.read(buf)
- else:
- raise InternalError("Unexpected flag byte for optional type")
-
@dataclass
class SetAgentCursorMotionInput:
def __init__(self, *, session:str, style:typing.Optional[CursorMotionStyle], timing:typing.Optional[CursorMotionTiming], effects:typing.Optional[CursorMotionEffects], start_handle:typing.Optional[float], end_handle:typing.Optional[float], arc_size:typing.Optional[float], arc_flow:typing.Optional[float], spring:typing.Optional[float], glide_duration_ms:typing.Optional[float], dwell_after_click_ms:typing.Optional[float], idle_hide_ms:typing.Optional[float], turn_radius:typing.Optional[float]):
@@ -7169,18 +7270,44 @@ class _UniffiFfiConverterOptionalTypeCursorThemeSelection(_UniffiConverterRustBu
else:
raise InternalError("Unexpected flag byte for optional type")
+class _UniffiFfiConverterOptionalTypeCursorMotionSelection(_UniffiConverterRustBuffer):
+ @classmethod
+ def check_lower(cls, value):
+ if value is not None:
+ _UniffiFfiConverterTypeCursorMotionSelection.check_lower(value)
+
+ @classmethod
+ def write(cls, value, buf):
+ if value is None:
+ buf.write_u8(0)
+ return
+
+ buf.write_u8(1)
+ _UniffiFfiConverterTypeCursorMotionSelection.write(value, buf)
+
+ @classmethod
+ def read(cls, buf):
+ flag = buf.read_u8()
+ if flag == 0:
+ return None
+ elif flag == 1:
+ return _UniffiFfiConverterTypeCursorMotionSelection.read(buf)
+ else:
+ raise InternalError("Unexpected flag byte for optional type")
+
@dataclass
class StartSessionInput:
- def __init__(self, *, session:typing.Optional[str], capture_scope:typing.Optional[CaptureScope], cursor_theme:typing.Optional[CursorThemeSelection]):
+ def __init__(self, *, session:typing.Optional[str], capture_scope:typing.Optional[CaptureScope], cursor_theme:typing.Optional[CursorThemeSelection], cursor_motion:typing.Optional[CursorMotionSelection]):
self.session = session
self.capture_scope = capture_scope
self.cursor_theme = cursor_theme
+ self.cursor_motion = cursor_motion
def __str__(self):
- return "StartSessionInput(session={}, capture_scope={}, cursor_theme={})".format(self.session, self.capture_scope, self.cursor_theme)
+ return "StartSessionInput(session={}, capture_scope={}, cursor_theme={}, cursor_motion={})".format(self.session, self.capture_scope, self.cursor_theme, self.cursor_motion)
def __eq__(self, other):
if self.session != other.session:
return False
@@ -7188,6 +7315,8 @@ class StartSessionInput:
return False
if self.cursor_theme != other.cursor_theme:
return False
+ if self.cursor_motion != other.cursor_motion:
+ return False
return True
class _UniffiFfiConverterTypeStartSessionInput(_UniffiConverterRustBuffer):
@@ -7197,6 +7326,7 @@ class _UniffiFfiConverterTypeStartSessionInput(_UniffiConverterRustBuffer):
session=_UniffiFfiConverterOptionalString.read(buf),
capture_scope=_UniffiFfiConverterOptionalTypeCaptureScope.read(buf),
cursor_theme=_UniffiFfiConverterOptionalTypeCursorThemeSelection.read(buf),
+ cursor_motion=_UniffiFfiConverterOptionalTypeCursorMotionSelection.read(buf),
)
@staticmethod
@@ -7204,28 +7334,31 @@ class _UniffiFfiConverterTypeStartSessionInput(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalString.check_lower(value.session)
_UniffiFfiConverterOptionalTypeCaptureScope.check_lower(value.capture_scope)
_UniffiFfiConverterOptionalTypeCursorThemeSelection.check_lower(value.cursor_theme)
+ _UniffiFfiConverterOptionalTypeCursorMotionSelection.check_lower(value.cursor_motion)
@staticmethod
def write(value, buf):
_UniffiFfiConverterOptionalString.write(value.session, buf)
_UniffiFfiConverterOptionalTypeCaptureScope.write(value.capture_scope, buf)
_UniffiFfiConverterOptionalTypeCursorThemeSelection.write(value.cursor_theme, buf)
+ _UniffiFfiConverterOptionalTypeCursorMotionSelection.write(value.cursor_motion, buf)
@dataclass
class StartSessionOutput:
"""
Successful structured result returned by `start_session`.
"""
- def __init__(self, *, state:SessionStateOutput, active:bool, revived:bool):
+ def __init__(self, *, state:SessionStateOutput, active:bool, revived:bool, cursor_motion:typing.Optional[CursorMotionSelection]):
self.state = state
self.active = active
self.revived = revived
+ self.cursor_motion = cursor_motion
def __str__(self):
- return "StartSessionOutput(state={}, active={}, revived={})".format(self.state, self.active, self.revived)
+ return "StartSessionOutput(state={}, active={}, revived={}, cursor_motion={})".format(self.state, self.active, self.revived, self.cursor_motion)
def __eq__(self, other):
if self.state != other.state:
return False
@@ -7233,6 +7366,8 @@ class StartSessionOutput:
return False
if self.revived != other.revived:
return False
+ if self.cursor_motion != other.cursor_motion:
+ return False
return True
class _UniffiFfiConverterTypeStartSessionOutput(_UniffiConverterRustBuffer):
@@ -7242,6 +7377,7 @@ class _UniffiFfiConverterTypeStartSessionOutput(_UniffiConverterRustBuffer):
state=_UniffiFfiConverterTypeSessionStateOutput.read(buf),
active=_UniffiFfiConverterBoolean.read(buf),
revived=_UniffiFfiConverterBoolean.read(buf),
+ cursor_motion=_UniffiFfiConverterOptionalTypeCursorMotionSelection.read(buf),
)
@staticmethod
@@ -7249,12 +7385,14 @@ class _UniffiFfiConverterTypeStartSessionOutput(_UniffiConverterRustBuffer):
_UniffiFfiConverterTypeSessionStateOutput.check_lower(value.state)
_UniffiFfiConverterBoolean.check_lower(value.active)
_UniffiFfiConverterBoolean.check_lower(value.revived)
+ _UniffiFfiConverterOptionalTypeCursorMotionSelection.check_lower(value.cursor_motion)
@staticmethod
def write(value, buf):
_UniffiFfiConverterTypeSessionStateOutput.write(value.state, buf)
_UniffiFfiConverterBoolean.write(value.active, buf)
_UniffiFfiConverterBoolean.write(value.revived, buf)
+ _UniffiFfiConverterOptionalTypeCursorMotionSelection.write(value.cursor_motion, buf)
class _UniffiFfiConverterOptionalTypeBoundsExpectation(_UniffiConverterRustBuffer):
@classmethod
@@ -8331,6 +8469,7 @@ __all__ = [
"CursorMotionEffects",
"CursorMotionEffectsOutput",
"CursorMotionOutput",
+ "CursorMotionSelection",
"CursorPointOutput",
"CursorThemeOutput",
"CursorThemeSelection",
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/cursor.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/cursor.rs
index b82e3a7bc8..3c61383cc7 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/cursor.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/cursor.rs
@@ -219,6 +219,20 @@ impl CursorMotionStyle {
Self::Classic => "classic",
}
}
+
+ /// Parse a public name or one of its accepted aliases.
+ pub fn parse(value: &str) -> Option<Self> {
+ let aliased = match value {
+ "dc-signature-arc" => Self::SignatureArc,
+ "dc-spring-settle" => Self::SpringSettle,
+ "dc-magnetic" => Self::Magnetic,
+ "dc-comet-swoop" => Self::CometSwoop,
+ "adaptive-auto" => Self::Adaptive,
+ "dubins-glide" | "dubins" => Self::Classic,
+ _ => return Self::ALL.into_iter().find(|style| style.as_str() == value),
+ };
+ Some(aliased)
+ }
}
// How long each agent cursor move takes.
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
index 7c1459dfc6..d6ea439f7e 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
@@ -327,6 +327,12 @@ pub struct StartSessionInput {
/// first made visible, avoiding a flash of the default theme.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cursor_theme: Option<CursorThemeSelection>,
+ /// Optional initial cursor motion (style, timing, effects and tuning). The host applies it
+ /// before the cursor is first made visible. A later `set_agent_cursor_motion` call wins;
+ /// this wins over the saved default (`cursor.motion.*` in the driver config) and the
+ /// built-in `signature_arc`. Reduced motion always wins.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub cursor_motion: Option<CursorMotionSelection>,
}
impl ToolInput for StartSessionInput {
@@ -413,6 +419,66 @@ impl ToolInput for SetAgentCursorEnabledInput {
const TOOL_NAME: &'static str = "set_agent_cursor_enabled";
}
+/// Cursor motion for a session, with the fields of `set_agent_cursor_motion` minus `session`.
+/// Omitted or null fields keep the saved default (`cursor.motion.*` in the driver config), then
+/// the built-in `signature_arc`.
+#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
+#[serde(deny_unknown_fields)]
+pub struct CursorMotionSelection {
+ /// Trajectory style. `signature_arc` (default) is one arc with a small follow-through;
+ /// `spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;
+ /// `comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for
+ /// small targets and a swoop for long moves; `classic` is the previous Dubins glide. When
+ /// the theme's reduced motion is on, every move is a short straight glide with no effects.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "cursor_motion_style_schema")]
+ pub style: Option<crate::CursorMotionStyle>,
+ /// `native` uses the style's own timing; `fitts` scales the move time with distance and
+ /// target size; `fixed` uses glide_duration_ms (1430 ms when 0).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "cursor_motion_timing_schema")]
+ pub timing: Option<crate::CursorMotionTiming>,
+ /// Turn single effects on or off. An omitted effect keeps its current setting; null
+ /// restores the style's default.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub effects: Option<crate::CursorMotionEffects>,
+ /// Arc control-point offset from the start, as a fraction of the distance, for
+ /// `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub start_handle: Option<f64>,
+ /// Arc control-point offset from the end, as a fraction of the distance, for
+ /// `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub end_handle: Option<f64>,
+ /// Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)
+ /// keeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub arc_size: Option<f64>,
+ /// Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:
+ /// positive moves the apex toward the destination. Clamped to -1..1 (default 0).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub arc_flow: Option<f64>,
+ /// Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped
+ /// to 0.3..1 (default 0.72).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub spring: Option<f64>,
+ /// Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A
+ /// nonzero value with `native` timing also fixes the duration. Clamped to 0..5000.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub glide_duration_ms: Option<f64>,
+ /// Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub dwell_after_click_ms: Option<f64>,
+ /// Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to
+ /// 0..60000 (default 15000).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub idle_hide_ms: Option<f64>,
+ /// Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.
+ /// Clamped to 1..1000 (default 80).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub turn_radius: Option<f64>,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
#[serde(deny_unknown_fields)]
pub struct SetAgentCursorMotionInput {
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
index 28c95a1b9d..5516b29339 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
@@ -51,13 +51,14 @@ pub use cursor::{
};
pub use inputs::{
action_target_schema, ActionTarget, CaptureScope, ClickButton, ClickInput, ClickPosition,
- ClipboardReadInput, ClipboardWriteInput, DesktopScope, DragInput, EndSessionInput,
- EscalateSessionInput, EscalationReason, GetAgentCursorStateInput, GetCursorPositionInput,
- GetDesktopStateInput, GetScreenSizeInput, GetSessionInput, GetSessionStateInput, HotkeyInput,
- InputDeliveryMode, InvokeMenuInput, LegacyClickInput, ListSessionsInput, MoveCursorInput,
- PressKeyInput, ScrollBy, ScrollDirection, ScrollInput, SetAgentCursorEnabledInput,
- SetAgentCursorMotionInput, SetAgentCursorThemeInput, SetWindowFrameInput, StartSessionInput,
- ToolInput, TypeTextInput, MULTI_CALL_SESSION_DESCRIPTION,
+ ClipboardReadInput, ClipboardWriteInput, CursorMotionSelection, DesktopScope, DragInput,
+ EndSessionInput, EscalateSessionInput, EscalationReason, GetAgentCursorStateInput,
+ GetCursorPositionInput, GetDesktopStateInput, GetScreenSizeInput, GetSessionInput,
+ GetSessionStateInput, HotkeyInput, InputDeliveryMode, InvokeMenuInput, LegacyClickInput,
+ ListSessionsInput, MoveCursorInput, PressKeyInput, ScrollBy, ScrollDirection, ScrollInput,
+ SetAgentCursorEnabledInput, SetAgentCursorMotionInput, SetAgentCursorThemeInput,
+ SetWindowFrameInput, StartSessionInput, ToolInput, TypeTextInput,
+ MULTI_CALL_SESSION_DESCRIPTION,
};
pub use outputs::{
advertised_output_schema, conforming_error_envelope, is_refusal_envelope,
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
index 22c6b01188..188eb07e95 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
@@ -253,12 +253,15 @@ pub struct ListSessionsOutput {
impl ToolOutput for ListSessionsOutput {}
/// Successful structured result returned by `start_session`.
-#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, uniffi::Record)]
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
pub struct StartSessionOutput {
#[serde(flatten)]
pub state: SessionStateOutput,
pub active: bool,
pub revived: bool,
+ /// The `cursor_motion` this call applied, echoed as sent. Absent when the call did not set one.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub cursor_motion: Option<crate::CursorMotionSelection>,
}
impl ToolOutput for StartSessionOutput {}
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/cursor_events.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/cursor_events.rs
index 2657f6269a..b05e8a9cf5 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/cursor_events.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/cursor_events.rs
@@ -8,7 +8,8 @@
//! subscribers are intentionally invisible to the tool result.
use cua_driver_contract::{
- classify_cursor_semantics, CursorAction, CursorSemantics, CursorThemeSelection,
+ classify_cursor_semantics, CursorAction, CursorMotionSelection, CursorSemantics,
+ CursorThemeSelection,
};
use serde_json::Value;
use std::sync::{Arc, OnceLock, RwLock};
@@ -34,6 +35,12 @@ pub enum CursorEvent {
session: String,
selection: CursorThemeSelection,
},
+ /// Initial motion from `start_session.cursor_motion`, in the field shape
+ /// of `set_agent_cursor_motion` without `session`.
+ SelectMotion {
+ session: String,
+ motion: Value,
+ },
}
pub trait CursorEventSink: Send + Sync + 'static {
@@ -101,6 +108,14 @@ pub fn begin_tool(name: &str, args: &Value) -> Option<(String, CursorAction)> {
selection,
});
}
+ if let Some(motion) = args.get("cursor_motion").filter(|value| value.is_object()) {
+ if serde_json::from_value::<CursorMotionSelection>(motion.clone()).is_ok() {
+ emit(CursorEvent::SelectMotion {
+ session: session.clone(),
+ motion: motion.clone(),
+ });
+ }
+ }
}
let semantics = classify_cursor_semantics(name, args)?;
emit(CursorEvent::Action {
@@ -186,6 +201,47 @@ mod tests {
));
}
+ #[test]
+ fn start_session_cursor_motion_is_emitted_before_the_cursor_is_shown() {
+ let _guard = test_sink_guard();
+ let events = Arc::new(Mutex::new(Vec::new()));
+ let captured = Arc::clone(&events);
+ install_cursor_event_sink(Arc::new(move |event| {
+ captured
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .push(event);
+ }));
+
+ begin_tool(
+ "start_session",
+ &json!({"session":"run","cursor_motion":{"style":"spring_settle"}}),
+ );
+ // An invalid selection never reaches the overlay.
+ begin_tool(
+ "start_session",
+ &json!({"session":"run","cursor_motion":{"style":7}}),
+ );
+
+ clear_cursor_event_sink();
+ let events = events
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner());
+ let selected: Vec<_> = events
+ .iter()
+ .filter(|event| matches!(event, CursorEvent::SelectMotion { .. }))
+ .collect();
+ assert_eq!(
+ selected,
+ vec![&CursorEvent::SelectMotion {
+ session: "run".into(),
+ motion: json!({"style":"spring_settle"}),
+ }]
+ );
+ // The motion is queued ahead of the action that first shows the cursor.
+ assert!(matches!(events[0], CursorEvent::SelectMotion { .. }));
+ }
+
#[test]
fn public_label_metadata_is_emitted_separately_from_private_cursor_key() {
let _guard = test_sink_guard();
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/session_tools.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/session_tools.rs
index f7d9979f53..45fee286cc 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/session_tools.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/session_tools.rs
@@ -16,9 +16,10 @@ use crate::tool::{Tool, ToolDef};
use crate::tool_args::parse_typed_input;
use async_trait::async_trait;
use cua_driver_contract::{
- CaptureScope, EndSessionInput, EscalateSessionInput, EscalationReason, GetSessionInput,
- GetSessionStateInput, ListSessionsInput, ListSessionsOutput, SessionClientKindOutput,
- SessionLifecycleState, SessionOutput, SessionTransportOutput, StartSessionInput,
+ CaptureScope, CursorMotionStyle, EndSessionInput, EscalateSessionInput, EscalationReason,
+ GetSessionInput, GetSessionStateInput, ListSessionsInput, ListSessionsOutput,
+ SessionClientKindOutput, SessionLifecycleState, SessionOutput, SessionTransportOutput,
+ StartSessionInput,
};
use serde_json::{json, Value};
use std::sync::OnceLock;
@@ -107,6 +108,42 @@ fn lifecycle_output(snapshot: crate::session::LifecycleSessionSnapshot) -> Sessi
}
}
+/// Reject an invalid `cursor_motion` with a message that lists the allowed
+/// values, before any session state changes.
+fn invalid_cursor_motion(args: &Value) -> Option<ToolResult> {
+ let motion = args.get("cursor_motion").filter(|value| !value.is_null())?;
+ let reject = |message: String| {
+ Some(ToolResult::error(message).with_structured(json!({ "code": "invalid_cursor_motion" })))
+ };
+ let Some(motion) = motion.as_object() else {
+ return reject("start_session.cursor_motion must be an object.".into());
+ };
+ if let Some(style) = motion.get("style").filter(|value| !value.is_null()) {
+ let valid = style
+ .as_str()
+ .is_some_and(|name| CursorMotionStyle::parse(name).is_some());
+ if !valid {
+ return reject(format!(
+ "invalid cursor_motion.style {style}; expected one of {}",
+ CursorMotionStyle::ALL
+ .map(CursorMotionStyle::as_str)
+ .join(", ")
+ ));
+ }
+ }
+ if let Some(timing) = motion.get("timing").filter(|value| !value.is_null()) {
+ let valid = timing
+ .as_str()
+ .is_some_and(|name| matches!(name, "native" | "fitts" | "fixed"));
+ if !valid {
+ return reject(format!(
+ "invalid cursor_motion.timing {timing}; expected native, fitts or fixed"
+ ));
+ }
+ }
+ None
+}
+
// ── start_session ─────────────────────────────────────────────────────────────
pub struct StartSessionTool;
@@ -140,6 +177,9 @@ impl Tool for StartSessionTool {
}));
}
}
+ if let Some(error) = invalid_cursor_motion(&args) {
+ return error;
+ }
let input = match parse_typed_input::<StartSessionInput>("start_session", args.clone()) {
Ok(input) => input,
Err(result) => return result,
@@ -218,6 +258,7 @@ impl Tool for StartSessionTool {
state: scope.output(&response_session_label(&args, &id)),
active: true,
revived,
+ cursor_motion: input.cursor_motion.clone(),
})
.expect("start_session output serializes");
ToolResult::text(format!(
@@ -546,6 +587,58 @@ mod tests {
assert_eq!(session_id_of(&json!({ "session": "default" })), None);
}
+ #[tokio::test]
+ async fn start_session_echoes_cursor_motion() {
+ let id = format!("session-tool-motion-{}", std::process::id());
+ let result = StartSessionTool
+ .invoke(json!({
+ "session": id,
+ "cursor_motion": {"style": "magnetic", "timing": "fitts", "effects": {"trail": true}}
+ }))
+ .await;
+ assert_ne!(result.is_error, Some(true));
+ let structured = result.structured_content.as_ref().unwrap();
+ assert_eq!(structured["cursor_motion"]["style"], "magnetic");
+ assert_eq!(structured["cursor_motion"]["timing"], "fitts");
+ assert_eq!(structured["cursor_motion"]["effects"]["trail"], true);
+ EndSessionTool.invoke(json!({"session": id})).await;
+
+ // Optional: absent unless the call set it.
+ let plain_id = format!("session-tool-no-motion-{}", std::process::id());
+ let plain = StartSessionTool.invoke(json!({"session": plain_id})).await;
+ assert!(plain
+ .structured_content
+ .as_ref()
+ .unwrap()
+ .get("cursor_motion")
+ .is_none());
+ EndSessionTool.invoke(json!({"session": plain_id})).await;
+ }
+
+ #[tokio::test]
+ async fn start_session_rejects_unknown_cursor_motion_with_allowed_values() {
+ let id = format!("session-tool-bad-motion-{}", std::process::id());
+ let bad_style = StartSessionTool
+ .invoke(json!({"session": id, "cursor_motion": {"style": "wobble"}}))
+ .await;
+ assert_eq!(bad_style.is_error, Some(true));
+ assert_eq!(result_code(&bad_style), Some("invalid_cursor_motion"));
+ let message = format!("{:?}", bad_style.content);
+ for style in CursorMotionStyle::ALL {
+ assert!(message.contains(style.as_str()), "{message}");
+ }
+ let bad_timing = StartSessionTool
+ .invoke(json!({"session": id, "cursor_motion": {"timing": "slow"}}))
+ .await;
+ assert_eq!(result_code(&bad_timing), Some("invalid_cursor_motion"));
+ let bad_effect = StartSessionTool
+ .invoke(json!({"session": id, "cursor_motion": {"effects": {"sparkle": true}}}))
+ .await;
+ assert_eq!(bad_effect.is_error, Some(true));
+ // Nothing was started by a rejected call.
+ assert!(get_session(&id).is_none());
+ }
+
#[tokio::test]
async fn implicit_start_does_not_expose_its_private_transport_identity() {
let id = format!("private-implicit-session-{}", std::process::id());
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
index 7acf1752a2..1aee34b717 100644
--- a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
@@ -2247,6 +2247,7 @@ mod tests {
session: Some(public.clone()),
capture_scope: None,
cursor_theme: None,
+ cursor_motion: None,
})
.await
.unwrap();
@@ -3082,6 +3083,7 @@ mod tests {
session: Some("run-2".into()),
capture_scope: Some(cua_driver_contract::CaptureScope::Auto),
cursor_theme: None,
+ cursor_motion: None,
})
.await
.unwrap();
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/cli.rs b/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
index b3dcd42f05..b439a1c2db 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
@@ -4408,7 +4408,7 @@ fn cli_docs_literal() -> serde_json::Value {
"subcommands": [
{"name":"show","abstract":"Print the full config.","discussion":"","arguments":[],"options":[],"flags":[],"subcommands":[]},
{"name":"get","abstract":"Print one config key.","discussion":"","arguments":[{"name":"key","help":"Config key to read.","type":"String","is_optional":false}],"options":[],"flags":[],"subcommands":[]},
- {"name":"set","abstract":"Set one config key.","discussion":"","arguments":[{"name":"key","help":"Config key to write.","type":"String","is_optional":false},{"name":"value","help":"Value to store.","type":"String","is_optional":false}],"options":[],"flags":[],"subcommands":[]},
+ {"name":"set","abstract":"Set one config key.","discussion":"Cursor motion defaults are saved keys that apply to sessions started afterwards: cursor.motion.style (signature_arc, spring_settle, magnetic, comet_swoop, adaptive, classic), cursor.motion.timing (native, fitts, fixed) and cursor.motion.effects.<trail|glow|magnet|ripple|squish> (true, false). Use null for a key to clear it, or cursor.motion null to clear all. A start_session cursor_motion or a set_agent_cursor_motion call overrides the saved default.","arguments":[{"name":"key","help":"Config key to write.","type":"String","is_optional":false},{"name":"value","help":"Value to store.","type":"String","is_optional":false}],"options":[],"flags":[],"subcommands":[]},
{"name":"reset","abstract":"Reset config to defaults.","discussion":"","arguments":[],"options":[],"flags":[],"subcommands":[]}
]
},
@@ -4641,7 +4641,12 @@ const CLI_EXAMPLES: &[(&str, &[(&str, &str)])] = &[
("config", &[("cua-driver config", "Print the full config")]),
("config show", &[("cua-driver config show", "Print the full config")]),
("config get", &[("cua-driver config get max_image_dimension", "Print one key")]),
- ("config set", &[("cua-driver config set max_image_dimension 1568", "Downscale screenshots to at most 1568 px")]),
+ ("config set", &[
+ ("cua-driver config set max_image_dimension 1568", "Downscale screenshots to at most 1568 px"),
+ ("cua-driver config set cursor.motion.style magnetic", "Make magnetic the default cursor motion for new sessions"),
+ ("cua-driver config set cursor.motion.timing fitts", "Scale cursor move time with distance and target size"),
+ ("cua-driver config set cursor.motion.effects.trail true", "Turn the cursor trail on by default"),
+ ]),
("config reset", &[("cua-driver config reset", "Restore the defaults")]),
("telemetry", &[("cua-driver telemetry status", "Show the effective telemetry setting")]),
("telemetry enable", &[("cua-driver telemetry enable", "Enable telemetry")]),
@@ -5031,6 +5036,25 @@ fn diagnose_config_paths_section() -> String {
lines.join("\n")
}
+/// Print a tool-level error (`isError` result) to stderr and exit 1, so a
+/// rejected `config set` never reports success.
+fn exit_on_tool_error(result: &serde_json::Value) {
+ if result.get("isError").and_then(serde_json::Value::as_bool) != Some(true) {
+ return;
+ }
+ let message = result
+ .get("content")
+ .and_then(serde_json::Value::as_array)
+ .and_then(|items| {
+ items
+ .iter()
+ .find_map(|item| item.get("text").and_then(serde_json::Value::as_str))
+ })
+ .unwrap_or("set_config failed");
+ eprintln!("{message}");
+ process::exit(1);
+}
+
/// `cua-driver config [show|get|set|reset] [key] [value]`
///
/// Thin daemon-only wrapper around the `get_config` / `set_config` tools.
@@ -5103,7 +5127,7 @@ pub fn run_config_cmd(
Some(k) => k,
None => {
eprintln!("Usage: cua-driver config get <key>");
- eprintln!("Keys: capture_mode, max_image_dimension, version, platform");
+ eprintln!("Keys: capture_mode, max_image_dimension, version, platform, cursor.motion.style, cursor.motion.timing");
process::exit(64);
}
};
@@ -5116,11 +5140,8 @@ pub fn run_config_cmd(
let config = get_config();
// Support dotted key paths like "agent_cursor.enabled".
let v = if key.contains('.') {
- let (parent, child) = key.split_once('.').unwrap();
-
- config
- .get(parent)
- .and_then(|object| object.get(child))
+ key.split('.')
+ .try_fold(&config, |node, part| node.get(part))
.cloned()
} else {
config.get(key).cloned()
@@ -5135,7 +5156,7 @@ pub fn run_config_cmd(
);
} else {
eprintln!("Unknown config key: {key}");
- eprintln!("Available keys: capture_mode, max_image_dimension, version, platform, agent_cursor.enabled");
+ eprintln!("Available keys: capture_mode, max_image_dimension, version, platform, agent_cursor.enabled, cursor.motion.style, cursor.motion.timing, cursor.motion.effects");
process::exit(64);
}
}
@@ -5164,7 +5185,14 @@ pub fn run_config_cmd(
// Parse value: try JSON, fall back to string.
let parsed_value: serde_json::Value = serde_json::from_str(value)
.unwrap_or_else(|_| serde_json::Value::String(value.to_owned()));
- call("set_config", serde_json::json!({ key: parsed_value }));
+ // Dotted keys (cursor.motion.style, ...) use the {key, value} shape.
+ let set_args = if key.contains('.') {
+ serde_json::json!({ "key": key, "value": parsed_value })
+ } else {
+ serde_json::json!({ key: parsed_value })
+ };
+ let result = call("set_config", set_args);
+ exit_on_tool_error(&result);
println!("Config updated.");
let config = get_config();
println!(
@@ -5182,6 +5210,11 @@ pub fn run_config_cmd(
"max_image_dimension": 0
});
call("set_config", defaults);
+ // Also clear the saved cursor motion defaults.
+ exit_on_tool_error(&call(
+ "set_config",
+ serde_json::json!({ "key": "cursor.motion", "value": null }),
+ ));
println!("Config reset to defaults.");
let config = get_config();
println!(
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
index 1420bd78b4..45d26fc728 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
@@ -191,6 +191,7 @@ async fn embedded_host_serves_sdk_and_mcp_with_one_contract() {
session: Some("embedded-sdk-window".into()),
capture_scope: Some(CaptureScope::Window),
cursor_theme: None,
+ cursor_motion: None,
})
.await
.expect("start SDK-owned session");
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs
index 0ea9c995bc..772693046f 100644
--- a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs
@@ -13,6 +13,7 @@ pub mod bezier;
pub mod capture_exclusion;
pub mod capture_utils;
pub mod motion;
+pub mod motion_defaults;
pub mod path_planner;
pub mod render_map;
pub mod render_state;
@@ -108,6 +109,9 @@ impl CursorConfig {
/// ```
pub fn from_args() -> Self {
let args: Vec<String> = std::env::args().collect();
+ // Load the saved `cursor.motion.*` defaults; the render map layers
+ // them under each cursor it creates.
+ motion_defaults::load_active();
Self::parse(&args[1..])
}
@@ -372,6 +376,10 @@ pub enum OverlayCommand {
SetEnabled(bool),
/// Update the motion/timing config live.
SetMotion(MotionConfig),
+ /// Apply `set_agent_cursor_motion`-shaped fields on top of the cursor's
+ /// current motion (the `cursor_motion` of `start_session`). Invalid
+ /// values are ignored; the tool boundary already rejected them.
+ ApplyMotion(serde_json::Value),
/// Pin the overlay above a specific window (by platform window id).
PinAbove(u64),
/// Begin a best-effort semantic cursor cue.
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/motion.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/motion.rs
index 743706937d..c784121734 100644
--- a/libs/cua-driver/rust/crates/cursor-overlay/src/motion.rs
+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/motion.rs
@@ -301,6 +301,27 @@ impl MotionConfig {
/// Apply the `style`, `timing` and `effects` fields of a
/// `set_agent_cursor_motion` call. Absent or null fields keep their
/// current value; inside `effects`, `null` restores the style default.
+ /// Apply the motion fields of `set_agent_cursor_motion` (also the
+ /// `cursor_motion` of `start_session`) on top of `self`. Omitted or null
+ /// fields keep their current value; an invalid style, timing or effect is
+ /// an error that names the allowed values.
+ pub fn with_motion_args(&self, args: &Value) -> Result<Self, String> {
+ let number = |name: &str| args.get(name).and_then(Value::as_f64);
+ self.with_overrides(
+ number("start_handle"),
+ number("end_handle"),
+ number("arc_size"),
+ number("arc_flow"),
+ number("spring"),
+ number("glide_duration_ms"),
+ number("dwell_after_click_ms"),
+ number("idle_hide_ms"),
+ None,
+ number("turn_radius"),
+ )
+ .with_style_args(args)
+ }
+
pub fn with_style_args(&self, args: &Value) -> Result<Self, String> {
let mut out = self.clone();
match args.get("style") {
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/motion_defaults.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/motion_defaults.rs
new file mode 100644
index 0000000000..d5fcb04b7a
--- /dev/null
+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/motion_defaults.rs
@@ -0,0 +1,540 @@
+//! Saved default cursor motion.
+//!
+//! `cursor.motion.style`, `cursor.motion.timing` and
+//! `cursor.motion.effects.<name>` live in `~/.cua-driver/config.json`
+//! (`{"cursor": {"motion": {...}}}`) next to the other persistent driver
+//! settings. They seed the motion of every session cursor created after the
+//! value is read. Precedence, highest first: a per-call
+//! `set_agent_cursor_motion`, the `cursor_motion` of `start_session`, this
+//! saved default, the built-in `signature_arc`. A reduced-motion theme or
+//! policy always wins at render time, so it overrides all of them.
+
+use crate::motion::{MotionConfig, MotionEffects, MotionStyle, MotionTiming};
+use serde_json::{json, Map, Value};
+use std::path::{Path, PathBuf};
+use std::sync::RwLock;
+
+/// Config keys this module owns.
+pub const KEY_PREFIX: &str = "cursor.motion";
+pub const STYLE_KEY: &str = "cursor.motion.style";
+pub const TIMING_KEY: &str = "cursor.motion.timing";
+pub const EFFECT_NAMES: [&str; 5] = ["trail", "glow", "magnet", "ripple", "squish"];
+
+/// Saved motion defaults. `None` means "not set": the built-in applies.
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
+pub struct SavedMotionDefaults {
+ pub style: Option<MotionStyle>,
+ pub timing: Option<MotionTiming>,
+ pub effects: MotionEffects,
+}
+
+impl SavedMotionDefaults {
+ pub fn is_empty(&self) -> bool {
+ *self == Self::default()
+ }
+
+ /// Layer these defaults over `motion` (used for a new cursor, before any
+ /// session or per-call override).
+ pub fn apply(&self, motion: &mut MotionConfig) {
+ if let Some(style) = self.style {
+ motion.style = style;
+ }
+ if let Some(timing) = self.timing {
+ motion.timing = timing;
+ }
+ let effects = &mut motion.effects;
+ effects.trail = self.effects.trail.or(effects.trail);
+ effects.glow = self.effects.glow.or(effects.glow);
+ effects.magnet = self.effects.magnet.or(effects.magnet);
+ effects.ripple = self.effects.ripple.or(effects.ripple);
+ effects.squish = self.effects.squish.or(effects.squish);
+ }
+
+ /// Value shown by `get_config` under `cursor.motion`: the effective style
+ /// and timing, plus only the effects that are explicitly saved.
+ pub fn config_json(&self) -> Value {
+ let mut effects = Map::new();
+ for (name, value) in [
+ ("trail", self.effects.trail),
+ ("glow", self.effects.glow),
+ ("magnet", self.effects.magnet),
+ ("ripple", self.effects.ripple),
+ ("squish", self.effects.squish),
+ ] {
+ if let Some(value) = value {
+ effects.insert(name.to_owned(), Value::Bool(value));
+ }
+ }
+ json!({
+ "style": self.style.unwrap_or_default().as_str(),
+ "timing": self.timing.unwrap_or_default().as_str(),
+ "effects": effects,
+ })
+ }
+}
+
+/// `~/.cua-driver/config.json`, the file `set_config` writes everywhere.
+pub fn default_config_path() -> Option<PathBuf> {
+ std::env::var_os("HOME")
+ .or_else(|| std::env::var_os("USERPROFILE"))
+ .map(|home| PathBuf::from(home).join(".cua-driver").join("config.json"))
+}
+
+fn allowed_styles() -> String {
+ MotionStyle::ALL.map(MotionStyle::as_str).join(", ")
+}
+
+fn effect_flag(key: &str, value: &Value) -> Result<Option<bool>, String> {
+ match value {
+ Value::Null => Ok(None),
+ Value::Bool(flag) => Ok(Some(*flag)),
+ Value::String(text) => match text.as_str() {
+ "true" | "on" => Ok(Some(true)),
+ "false" | "off" => Ok(Some(false)),
+ "default" => Ok(None),
+ _ => Err(format!(
+ "{key} must be true, false or default, got `{text}`"
+ )),
+ },
+ other => Err(format!("{key} must be true, false or default, got {other}")),
+ }
+}
+
+/// Validate one config write and fold it into `saved`.
+///
+/// Accepted keys: `cursor.motion.style`, `cursor.motion.timing`,
+/// `cursor.motion.effects.<trail|glow|magnet|ripple|squish>`, and
+/// `cursor.motion` itself with a null/`"default"` value to clear all of them.
+/// A null or `"default"` value clears a single key. Errors name the allowed
+/// values.
+pub fn apply_key(saved: &mut SavedMotionDefaults, key: &str, value: &Value) -> Result<(), String> {
+ let clear = value.is_null() || value.as_str() == Some("default");
+ match key {
+ KEY_PREFIX => {
+ if clear {
+ *saved = SavedMotionDefaults::default();
+ Ok(())
+ } else {
+ Err(format!(
+ "{KEY_PREFIX} can only be reset (null or `default`); set {STYLE_KEY}, {TIMING_KEY} or {KEY_PREFIX}.effects.<{}> instead",
+ EFFECT_NAMES.join("|")
+ ))
+ }
+ }
+ STYLE_KEY => {
+ saved.style = if clear {
+ None
+ } else {
+ let name = value
+ .as_str()
+ .ok_or_else(|| format!("{STYLE_KEY} must be a string, got {value}"))?;
+ Some(MotionStyle::parse(name).ok_or_else(|| {
+ format!(
+ "unknown cursor motion style `{name}`; expected one of {}",
+ allowed_styles()
+ )
+ })?)
+ };
+ Ok(())
+ }
+ TIMING_KEY => {
+ saved.timing = if clear {
+ None
+ } else {
+ let name = value
+ .as_str()
+ .ok_or_else(|| format!("{TIMING_KEY} must be a string, got {value}"))?;
+ Some(MotionTiming::parse(name).ok_or_else(|| {
+ format!(
+ "unknown cursor motion timing `{name}`; expected native, fitts or fixed"
+ )
+ })?)
+ };
+ Ok(())
+ }
+ other => {
+ let Some(effect) = other.strip_prefix("cursor.motion.effects.") else {
+ return Err(format!(
+ "unknown cursor motion key `{other}`; expected {STYLE_KEY}, {TIMING_KEY} or {KEY_PREFIX}.effects.<{}>",
+ EFFECT_NAMES.join("|")
+ ));
+ };
+ let flag = effect_flag(other, value)?;
+ match effect {
+ "trail" => saved.effects.trail = flag,
+ "glow" => saved.effects.glow = flag,
+ "magnet" => saved.effects.magnet = flag,
+ "ripple" => saved.effects.ripple = flag,
+ "squish" => saved.effects.squish = flag,
+ _ => {
+ return Err(format!(
+ "unknown cursor effect `{effect}`; expected {}",
+ EFFECT_NAMES.join(", ")
+ ))
+ }
+ }
+ Ok(())
+ }
+ }
+}
+
+/// Whether `key` belongs to the cursor motion defaults.
+pub fn is_motion_key(key: &str) -> bool {
+ key == KEY_PREFIX || key.starts_with("cursor.motion.")
+}
+
+/// Input-schema properties to merge into each platform's `set_config` tool.
+pub fn config_schema_properties() -> Map<String, Value> {
+ let mut properties = Map::new();
+ properties.insert(
+ STYLE_KEY.to_owned(),
+ json!({
+ "type": "string",
+ "enum": MotionStyle::ALL.map(MotionStyle::as_str),
+ "description": "Saved default cursor motion style for new sessions. Overridden by start_session cursor_motion and set_agent_cursor_motion; reduced motion always wins. Built-in default: signature_arc."
+ }),
+ );
+ properties.insert(
+ TIMING_KEY.to_owned(),
+ json!({
+ "type": "string",
+ "enum": ["native", "fitts", "fixed"],
+ "description": "Saved default cursor move timing for new sessions."
+ }),
+ );
+ for name in EFFECT_NAMES {
+ properties.insert(
+ format!("cursor.motion.effects.{name}"),
+ json!({
+ "type": "boolean",
+ "description": format!("Saved default for the `{name}` cursor effect. Unset follows the style.")
+ }),
+ );
+ }
+ properties.insert(
+ KEY_PREFIX.to_owned(),
+ json!({
+ "description": "Pass null (or `default`) to clear every saved cursor motion default."
+ }),
+ );
+ properties
+}
+
+/// Apply every cursor motion write in a `set_config` call, accepting both the
+/// `{key, value}` shape and direct dotted fields. Returns the keys written, or
+/// the first validation error (later keys are not written after an error).
+pub fn apply_config_args(args: &Value) -> Result<Vec<String>, String> {
+ let mut writes: Vec<(String, Value)> = Vec::new();
+ if let (Some(key), Some(value)) = (args.get("key").and_then(Value::as_str), args.get("value")) {
+ if is_motion_key(key) {
+ writes.push((key.to_owned(), value.clone()));
+ }
+ }
+ if let Some(object) = args.as_object() {
+ for (key, value) in object {
+ if is_motion_key(key) {
+ writes.push((key.clone(), value.clone()));
+ }
+ }
+ }
+ let mut applied = Vec::new();
+ for (key, value) in writes {
+ set_key(&key, &value)?;
+ applied.push(key);
+ }
+ Ok(applied)
+}
+
+/// Read the saved defaults from `path`. Missing files, malformed JSON and
+/// invalid values fall back to the built-ins; a bad value is logged, never
+/// fatal, so a hand-edited file cannot stop the daemon.
+pub fn load_from(path: &Path) -> SavedMotionDefaults {
+ let mut saved = SavedMotionDefaults::default();
+ let Ok(text) = std::fs::read_to_string(path) else {
+ return saved;
+ };
+ let Ok(json) = serde_json::from_str::<Value>(&text) else {
+ return saved;
+ };
+ let Some(motion) = json.get("cursor").and_then(|cursor| cursor.get("motion")) else {
+ return saved;
+ };
+ let mut apply = |key: String, value: Option<&Value>| {
+ if let Some(value) = value {
+ if let Err(error) = apply_key(&mut saved, &key, value) {
+ tracing::warn!("ignoring saved {key}: {error}");
+ }
+ }
+ };
+ apply(STYLE_KEY.to_owned(), motion.get("style"));
+ apply(TIMING_KEY.to_owned(), motion.get("timing"));
+ if let Some(effects) = motion.get("effects").and_then(Value::as_object) {
+ for name in EFFECT_NAMES {
+ apply(format!("cursor.motion.effects.{name}"), effects.get(name));
+ }
+ }
+ saved
+}
+
+fn to_json(saved: &SavedMotionDefaults) -> Value {
+ let mut motion = Map::new();
+ if let Some(style) = saved.style {
+ motion.insert("style".into(), json!(style.as_str()));
+ }
+ if let Some(timing) = saved.timing {
+ motion.insert("timing".into(), json!(timing.as_str()));
+ }
+ let effects = saved.config_json()["effects"].clone();
+ if effects.as_object().is_some_and(|map| !map.is_empty()) {
+ motion.insert("effects".into(), effects);
+ }
+ Value::Object(motion)
+}
+
+/// Validate and persist one write to `path`, keeping every other key in the
+/// file. Returns the new saved defaults. Nothing is written when validation
+/// fails.
+pub fn set_key_at(path: &Path, key: &str, value: &Value) -> Result<SavedMotionDefaults, String> {
+ let mut saved = load_from(path);
+ apply_key(&mut saved, key, value)?;
+ let mut root: Value = std::fs::read_to_string(path)
+ .ok()
+ .and_then(|text| serde_json::from_str(&text).ok())
+ .filter(Value::is_object)
+ .unwrap_or_else(|| json!({}));
+ let motion = to_json(&saved);
+ let cursor = root
+ .as_object_mut()
+ .expect("root is an object")
+ .entry("cursor")
+ .or_insert_with(|| json!({}));
+ if !cursor.is_object() {
+ *cursor = json!({});
+ }
+ let cursor = cursor.as_object_mut().expect("cursor is an object");
+ if motion.as_object().is_some_and(Map::is_empty) {
+ cursor.remove("motion");
+ } else {
+ cursor.insert("motion".into(), motion);
+ }
+ if cursor.is_empty() {
+ root.as_object_mut()
+ .expect("root is an object")
+ .remove("cursor");
+ }
+ if let Some(parent) = path.parent() {
+ std::fs::create_dir_all(parent).map_err(|error| error.to_string())?;
+ }
+ let body = serde_json::to_string_pretty(&root).map_err(|error| error.to_string())?;
+ std::fs::write(path, body).map_err(|error| format!("failed to persist {key}: {error}"))?;
+ Ok(saved)
+}
+
+// Process-wide copy applied to cursors created after it is set. It starts
+// empty so unit tests never read the user's file; the daemon fills it in at
+// startup (`CursorConfig::from_args`) and on every config write.
+static ACTIVE: RwLock<SavedMotionDefaults> = RwLock::new(SavedMotionDefaults {
+ style: None,
+ timing: None,
+ effects: MotionEffects {
+ trail: None,
+ glow: None,
+ magnet: None,
+ ripple: None,
+ squish: None,
+ },
+});
+
+/// Defaults new cursors currently start from.
+pub fn active() -> SavedMotionDefaults {
+ *ACTIVE
+ .read()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+}
+
+/// Replace the process-wide copy.
+pub fn set_active(saved: SavedMotionDefaults) {
+ *ACTIVE
+ .write()
+ .unwrap_or_else(|poisoned| poisoned.into_inner()) = saved;
+}
+
+/// Load `~/.cua-driver/config.json` into the process-wide copy.
+pub fn load_active() -> SavedMotionDefaults {
+ let saved = default_config_path()
+ .map(|path| load_from(&path))
+ .unwrap_or_default();
+ set_active(saved);
+ saved
+}
+
+/// Read what is saved on disk right now (for `get_config`).
+pub fn read_saved() -> SavedMotionDefaults {
+ default_config_path()
+ .map(|path| load_from(&path))
+ .unwrap_or_default()
+}
+
+/// Validate, persist to `~/.cua-driver/config.json`, and make the value the
+/// default for cursors created from now on.
+pub fn set_key(key: &str, value: &Value) -> Result<SavedMotionDefaults, String> {
+ let path = default_config_path().ok_or_else(|| "$HOME is not set".to_string())?;
+ let saved = set_key_at(&path, key, value)?;
+ set_active(saved);
+ Ok(saved)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn temp_path(name: &str) -> PathBuf {
+ let dir =
+ std::env::temp_dir().join(format!("cua-motion-defaults-{name}-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ dir.join("config.json")
+ }
+
+ #[test]
+ fn built_in_default_is_signature_arc() {
+ let mut motion = MotionConfig::default();
+ SavedMotionDefaults::default().apply(&mut motion);
+ assert_eq!(motion.style, MotionStyle::SignatureArc);
+ assert_eq!(motion.timing, MotionTiming::Native);
+ }
+
+ #[test]
+ fn saved_style_timing_and_effects_persist_and_reload() {
+ let path = temp_path("persist");
+ set_key_at(&path, STYLE_KEY, &json!("magnetic")).unwrap();
+ set_key_at(&path, TIMING_KEY, &json!("fitts")).unwrap();
+ set_key_at(&path, "cursor.motion.effects.trail", &json!(true)).unwrap();
+ set_key_at(&path, "cursor.motion.effects.glow", &json!("false")).unwrap();
+
+ let saved = load_from(&path);
+ assert_eq!(saved.style, Some(MotionStyle::Magnetic));
+ assert_eq!(saved.timing, Some(MotionTiming::Fitts));
+ assert_eq!(saved.effects.trail, Some(true));
+ assert_eq!(saved.effects.glow, Some(false));
+ assert_eq!(saved.effects.ripple, None);
+
+ let mut motion = MotionConfig::default();
+ saved.apply(&mut motion);
+ assert_eq!(motion.style, MotionStyle::Magnetic);
+ assert_eq!(motion.timing, MotionTiming::Fitts);
+ assert!(motion.resolved_effects().trail);
+ assert!(!motion.resolved_effects().glow);
+ // Untouched effects keep the style's defaults (magnetic: ripple on).
+ assert!(motion.resolved_effects().ripple);
+ let _ = std::fs::remove_dir_all(path.parent().unwrap());
+ }
+
+ #[test]
+ fn writes_keep_unrelated_keys_and_clear_cleanly() {
+ let path = temp_path("keep");
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(
+ &path,
+ r#"{"max_image_dimension": 800, "cursor": {"other": 1}}"#,
+ )
+ .unwrap();
+ set_key_at(&path, STYLE_KEY, &json!("classic")).unwrap();
+ let root: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();
+ assert_eq!(root["max_image_dimension"], 800);
+ assert_eq!(root["cursor"]["other"], 1);
+ assert_eq!(root["cursor"]["motion"]["style"], "classic");
+
+ set_key_at(&path, KEY_PREFIX, &Value::Null).unwrap();
+ let root: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();
+ assert_eq!(root["max_image_dimension"], 800);
+ assert!(root["cursor"].get("motion").is_none());
+ assert_eq!(load_from(&path), SavedMotionDefaults::default());
+ let _ = std::fs::remove_dir_all(path.parent().unwrap());
+ }
+
+ #[test]
+ fn validation_lists_allowed_values_and_writes_nothing() {
+ let path = temp_path("validate");
+ let error = set_key_at(&path, STYLE_KEY, &json!("wobble")).unwrap_err();
+ for style in MotionStyle::ALL {
+ assert!(error.contains(style.as_str()), "{error}");
+ }
+ assert!(set_key_at(&path, TIMING_KEY, &json!("slow"))
+ .unwrap_err()
+ .contains("native, fitts or fixed"));
+ assert!(set_key_at(&path, "cursor.motion.effects.sparkle", &json!(true)).is_err());
+ assert!(set_key_at(&path, "cursor.motion.effects.trail", &json!(3)).is_err());
+ assert!(set_key_at(&path, STYLE_KEY, &json!(7)).is_err());
+ assert!(!path.exists(), "a rejected write must not create the file");
+ }
+
+ #[test]
+ fn invalid_saved_values_fall_back_to_built_ins() {
+ let path = temp_path("invalid");
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(
+ &path,
+ r#"{"cursor":{"motion":{"style":"wobble","timing":"fixed"}}}"#,
+ )
+ .unwrap();
+ let saved = load_from(&path);
+ assert_eq!(saved.style, None);
+ assert_eq!(saved.timing, Some(MotionTiming::Fixed));
+ let _ = std::fs::remove_dir_all(path.parent().unwrap());
+ }
+
+ #[test]
+ fn precedence_per_call_beats_session_beats_saved_beats_built_in() {
+ // Saved default seeds a new cursor.
+ let mut motion = MotionConfig::default();
+ SavedMotionDefaults {
+ style: Some(MotionStyle::Magnetic),
+ ..Default::default()
+ }
+ .apply(&mut motion);
+ assert_eq!(motion.style, MotionStyle::Magnetic);
+ // start_session cursor_motion applies on top.
+ let motion = motion
+ .with_style_args(&json!({"style": "comet_swoop"}))
+ .unwrap();
+ assert_eq!(motion.style, MotionStyle::CometSwoop);
+ // A later set_agent_cursor_motion wins; omitted fields keep the session value.
+ let motion = motion.with_style_args(&json!({"timing": "fitts"})).unwrap();
+ assert_eq!(motion.style, MotionStyle::CometSwoop);
+ let motion = motion
+ .with_style_args(&json!({"style": "spring_settle"}))
+ .unwrap();
+ assert_eq!(motion.style, MotionStyle::SpringSettle);
+ }
+
+ #[test]
+ fn start_session_motion_args_apply_over_the_current_motion() {
+ let base = MotionConfig::default();
+ let motion = base
+ .with_motion_args(
+ &json!({"style": "magnetic", "effects": {"trail": true}, "glide_duration_ms": 900}),
+ )
+ .unwrap();
+ assert_eq!(motion.style, MotionStyle::Magnetic);
+ assert_eq!(motion.effects.trail, Some(true));
+ assert_eq!(motion.glide_duration_ms, 900.0);
+ let error = base
+ .with_motion_args(&json!({"style": "wobble"}))
+ .unwrap_err();
+ assert!(
+ error.contains("signature_arc") && error.contains("classic"),
+ "{error}"
+ );
+ }
+
+ #[test]
+ fn schema_exposes_every_key_a_write_accepts() {
+ let properties = config_schema_properties();
+ assert!(properties.contains_key(STYLE_KEY));
+ assert!(properties.contains_key(TIMING_KEY));
+ assert!(properties.contains_key(KEY_PREFIX));
+ for name in EFFECT_NAMES {
+ assert!(properties.contains_key(&format!("cursor.motion.effects.{name}")));
+ }
+ }
+}
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/render_map.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/render_map.rs
index b0aa654dfa..de95a55784 100644
--- a/libs/cua-driver/rust/crates/cursor-overlay/src/render_map.rs
+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/render_map.rs
@@ -181,6 +181,8 @@ pub fn seed_position(target_x: f64, target_y: f64, frame: Option<ScreenFrame>) -
pub fn keyed_config(template: &CursorConfig, key: &str) -> CursorConfig {
let mut config = template.clone();
config.cursor_id = key.to_owned();
+ // A saved default changed after launch reaches sessions created from now on.
+ crate::motion_defaults::active().apply(&mut config.motion);
config
}
@@ -206,9 +208,11 @@ impl<S: RenderEntry, P> RenderMap<S, P> {
/// own `cursor_id`.
pub fn new(template: CursorConfig, platform: P) -> Self {
let mut cursors = CursorMap::new();
+ let mut default_config = template.clone();
+ crate::motion_defaults::active().apply(&mut default_config.motion);
cursors.insert(
DEFAULT_CURSOR_KEY.to_owned(),
- S::from_config(template.clone()),
+ S::from_config(default_config),
);
Self {
cursors,
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs
index fccca5b473..ab4f315036 100644
--- a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs
+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs
@@ -780,6 +780,12 @@ impl RenderStateCore {
self.motion = m;
true
}
+ OverlayCommand::ApplyMotion(args) => {
+ if let Ok(motion) = self.motion.with_motion_args(&args) {
+ self.motion = motion;
+ }
+ true
+ }
OverlayCommand::PinAbove(wid) => {
self.pinned_wid = Some(wid);
true
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
index 770e551650..1d35cd553c 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
@@ -335,6 +335,9 @@ pub fn init(cfg: CursorConfig) {
reduced_motion: selection.reduced_motion,
},
),
+ CursorEvent::SelectMotion { session, motion } => {
+ (session, OverlayCommand::ApplyMotion(motion))
+ }
};
send_command_for(session, cmd);
},
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
index 5096e7483e..ca0dec422a 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
@@ -13053,6 +13053,7 @@ impl Tool for GetConfigTool {
"platform": "linux",
"capture_mode": cfg.capture_mode,
"max_image_dimension": cfg.max_image_dimension,
+ "cursor": { "motion": cursor_overlay::motion_defaults::read_saved().config_json() },
"experimental_pip": pip_enabled,
"experimental_pip_geometry": pip_geometry
}))
@@ -13061,6 +13062,13 @@ impl Tool for GetConfigTool {
// ── set_config ────────────────────────────────────────────────────────────────
+fn with_cursor_motion_config_properties(mut schema: Value) -> Value {
+ if let Some(properties) = schema.get_mut("properties").and_then(Value::as_object_mut) {
+ properties.extend(cursor_overlay::motion_defaults::config_schema_properties());
+ }
+ schema
+}
+
pub struct SetConfigTool {
state: Arc<ToolState>,
}
@@ -13079,15 +13087,17 @@ impl Tool for SetConfigTool {
- **Legacy per-field**: `{\"capture_mode\": \"som\", \"max_image_dimension\": 0}`.\n\n\
The experimental_pip keys persist to ~/.cua-driver/config.json and apply on next \
daemon restart (the PiP backend is initialised once at startup; \
- Linux ships only the trait stub today — see issue #1729).".into(),
- input_schema: json!({"type":"object","properties":{
+ Linux ships only the trait stub today — see issue #1729).\n\n\
+ `cursor.motion.style`, `cursor.motion.timing` and `cursor.motion.effects.<name>` \
+ save the default cursor motion for sessions started afterwards.".into(),
+ input_schema: with_cursor_motion_config_properties(json!({"type":"object","properties":{
"key":{"type":"string","description":"Name of a single config field to write ({key, value} shape). Pair with `value`."},
"value":{"description":"New value for `key`. JSON type depends on the key."},
"capture_mode":{"type":"string","enum":["ax","vision"],"description":"Legacy per-field shape. Default capture mode for get_window_state. (\"som\"/\"screenshot\" still decode as deprecated aliases.)"},
"max_image_dimension":{"type":"integer","description":"Legacy per-field shape. Max dimension for screenshot resizing (0 = no limit)."},
"experimental_pip":{"type":"boolean","description":"Enable the experimental PiP preview window (applies next restart; Linux backend stubbed)."},
"experimental_pip_geometry":{"type":"string","description":"PiP window size + optional position in `WxH` or `WxH+X+Y` form."}
- },"additionalProperties":false}),
+ },"additionalProperties":false})),
read_only: false, destructive: false, idempotent: true, open_world: false,
})
}
@@ -13105,8 +13115,15 @@ impl Tool for SetConfigTool {
"replacement": "action.target",
}));
}
+ let motion_keys = match cursor_overlay::motion_defaults::apply_config_args(&args) {
+ Ok(keys) => keys,
+ Err(message) => return ToolResult::error(message),
+ };
let mut cfg = self.state.config.write().unwrap();
- let mut parts = Vec::new();
+ let mut parts: Vec<String> = motion_keys
+ .iter()
+ .map(|key| format!("{key} (applies to sessions started from now on)"))
+ .collect();
// {key, value} shape (what the Swift/macOS and Windows callers send).
// Linux previously read only the legacy per-field keys below, so a
// `{"key":"max_image_dimension","value":800}` write was silently
@@ -13158,8 +13175,9 @@ impl Tool for SetConfigTool {
}
None => return ToolResult::error(format!("`experimental_pip_geometry` must be a string, got {val}.")),
},
+ other if motion_keys.iter().any(|written| written == other) => {}
other => return ToolResult::error(format!(
- "Unknown config key `{other}`. Known: capture_mode, max_image_dimension, experimental_pip, experimental_pip_geometry."
+ "Unknown config key `{other}`. Known: capture_mode, max_image_dimension, experimental_pip, experimental_pip_geometry, cursor.motion.style, cursor.motion.timing, cursor.motion.effects.<name>."
)),
}
}
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs
index eae8a5bda9..7b88534c6a 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs
@@ -253,6 +253,9 @@ pub fn init(cfg: CursorConfig) {
reduced_motion: selection.reduced_motion,
},
),
+ CursorEvent::SelectMotion { session, motion } => {
+ (session, OverlayCommand::ApplyMotion(motion))
+ }
};
send_command(session, cmd);
},
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/get_config.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/get_config.rs
index a1dc0cbab1..0db24fb1de 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/get_config.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/get_config.rs
@@ -82,6 +82,9 @@ impl Tool for GetConfigTool {
"agent_cursor": {
"enabled": cursor_enabled,
},
+ "cursor": {
+ "motion": cursor_overlay::motion_defaults::read_saved().config_json(),
+ },
"experimental_pip": pip_enabled,
"experimental_pip_geometry": pip_geometry,
}))
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/set_config.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/set_config.rs
index dbf3d225f3..9c451e3c77 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/set_config.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/set_config.rs
@@ -20,6 +20,13 @@ impl SetConfigTool {
static DEF: std::sync::OnceLock<ToolDef> = std::sync::OnceLock::new();
+fn with_cursor_motion_properties(mut schema: Value) -> Value {
+ if let Some(properties) = schema.get_mut("properties").and_then(Value::as_object_mut) {
+ properties.extend(cursor_overlay::motion_defaults::config_schema_properties());
+ }
+ schema
+}
+
fn def() -> &'static ToolDef {
DEF.get_or_init(|| ToolDef {
name: "set_config".into(),
@@ -30,8 +37,13 @@ fn def() -> &'static ToolDef {
initialised once at startup).\n\nNote: capture_mode is a per-call \
param (on get_window_state / click), not a stored setting. Capture \
modality is selected by each action's target; the old \
- capture_scope config key is retired.".into(),
- input_schema: serde_json::json!({
+ capture_scope config key is retired.\n\nCursor motion defaults: \
+ cursor.motion.style, cursor.motion.timing and \
+ cursor.motion.effects.<trail|glow|magnet|ripple|squish> are saved to \
+ ~/.cua-driver/config.json and seed sessions started afterwards. \
+ start_session cursor_motion and set_agent_cursor_motion override them; \
+ reduced motion always wins.".into(),
+ input_schema: with_cursor_motion_properties(serde_json::json!({
"type": "object",
"properties": {
"key": {
@@ -59,7 +71,7 @@ fn def() -> &'static ToolDef {
}
},
"additionalProperties": false
- }),
+ })),
read_only: false,
destructive: false,
idempotent: true,
@@ -95,6 +107,13 @@ impl Tool for SetConfigTool {
// sessions don't clobber each other or the persisted default.
let session_id = args.opt_str("_session_id");
+ // Cursor motion defaults are a driver-wide saved setting, so they are
+ // validated and persisted like the other config.json keys.
+ let motion_keys = match cursor_overlay::motion_defaults::apply_config_args(&args) {
+ Ok(keys) => keys,
+ Err(message) => return ToolResult::error(message),
+ };
+
// Accept BOTH the direct field and {key,value} shapes.
let kv: Option<(String, Value)> = args
.opt_str("key")
@@ -177,6 +196,12 @@ impl Tool for SetConfigTool {
);
}
}
+ if !motion_keys.is_empty() {
+ pip_note.push_str(&format!(
+ " — saved {} (applies to sessions started from now on)",
+ motion_keys.join(", ")
+ ));
+ }
let scope_note = if session_id.is_some() {
" (session-scoped; persisted default unchanged)"
} else {
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs b/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs
index dad5c28ed8..b00c19ed00 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/overlay.rs
@@ -198,6 +198,9 @@ pub fn init(cfg: CursorConfig) {
reduced_motion: selection.reduced_motion,
},
),
+ CursorEvent::SelectMotion { session, motion } => {
+ (session, OverlayCommand::ApplyMotion(motion))
+ }
};
send_command(session, cmd);
},
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
index d9b522d65d..5bb612937c 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
@@ -8531,6 +8531,7 @@ impl Tool for GetConfigTool {
"capture_mode": cfg.capture_mode,
"max_image_dimension": cfg.max_image_dimension,
"agent_cursor": { "enabled": cursor_enabled },
+ "cursor": { "motion": cursor_overlay::motion_defaults::read_saved().config_json() },
"experimental_pip": pip_enabled,
"experimental_pip_geometry": pip_geometry,
});
@@ -8542,6 +8543,13 @@ impl Tool for GetConfigTool {
// ── set_config ────────────────────────────────────────────────────────────────
+fn with_cursor_motion_config_properties(mut schema: Value) -> Value {
+ if let Some(properties) = schema.get_mut("properties").and_then(Value::as_object_mut) {
+ properties.extend(cursor_overlay::motion_defaults::config_schema_properties());
+ }
+ schema
+}
+
pub struct SetConfigTool {
state: Arc<ToolState>,
}
@@ -8569,15 +8577,16 @@ impl Tool for SetConfigTool {
- `max_image_dimension` (integer)\n\
- `experimental_pip` (boolean; persisted to config.json, applies on next daemon restart — Windows backend stubbed today, see issue #1729)\n\
- `experimental_pip_geometry` (string `WxH` or `WxH+X+Y`; persisted; applies on next daemon restart)\n\n\
+ - `cursor.motion.style`, `cursor.motion.timing`, `cursor.motion.effects.<name>` — saved default cursor motion for sessions started afterwards (see the cursor docs).\n\n\
Returns the full updated config in the same shape as `get_config`.".into(),
- input_schema: json!({"type":"object","properties":{
+ input_schema: with_cursor_motion_config_properties(json!({"type":"object","properties":{
"key":{"type":"string","description":"Dotted snake_case path to a leaf config field (Swift-compatible shape). Pair with `value`."},
"value":{"description":"New value for `key`. JSON type depends on the key."},
"capture_mode":{"type":"string","enum":["ax","vision"],"description":"DEPRECATED and ignored — get_window_state always returns both the UIA tree and a screenshot. Still accepted/persisted for back-compat but has no effect. (\"som\"/\"screenshot\" still decode as deprecated aliases.)"},
"max_image_dimension":{"type":"integer","description":"Legacy per-field shape."},
"experimental_pip":{"type":"boolean","description":"Legacy per-field shape. Enables PiP preview (applies next restart)."},
"experimental_pip_geometry":{"type":"string","description":"Legacy per-field shape. PiP window size + optional position."}
- },"additionalProperties":false}),
+ },"additionalProperties":false})),
read_only: false, destructive: false, idempotent: true, open_world: false,
})
}
@@ -8594,8 +8603,12 @@ impl Tool for SetConfigTool {
"replacement": "action.target",
}));
}
+ let motion_keys = match cursor_overlay::motion_defaults::apply_config_args(&args) {
+ Ok(keys) => keys,
+ Err(message) => return ToolResult::error(message),
+ };
let mut cfg = self.state.config.write().unwrap();
- let mut applied = false;
+ let mut applied = !motion_keys.is_empty();
// Swift-compatible {key, value} shape.
if let (Some(key), Some(val)) =
(args.get("key").and_then(|v| v.as_str()), args.get("value"))
@@ -8644,8 +8657,9 @@ impl Tool for SetConfigTool {
}
None => return ToolResult::error(format!("`experimental_pip_geometry` must be a string, got {val}.")),
},
+ other if motion_keys.iter().any(|written| written == other) => {}
other => return ToolResult::error(format!(
- "Unknown config key `{other}`. Known: capture_mode, max_image_dimension, experimental_pip, experimental_pip_geometry."
+ "Unknown config key `{other}`. Known: capture_mode, max_image_dimension, experimental_pip, experimental_pip_geometry, cursor.motion.style, cursor.motion.timing, cursor.motion.effects.<name>."
)),
}
}
diff --git a/libs/cua-driver/typescript/src/native/cua_driver_contract.ts b/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
index a03769d886..c63b6e3051 100644
--- a/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
+++ b/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
@@ -1614,6 +1614,144 @@ const FfiConverterTypeCursorMotionOutput = (() => {
return new FFIConverter();
})();
+/**
+ * Cursor motion for a session, with the fields of `set_agent_cursor_motion` minus `session`.
+ * Omitted or null fields keep the saved default (`cursor.motion.*` in the driver config), then
+ * the built-in `signature_arc`.
+ */
+export type CursorMotionSelection = {
+ /**
+ * Trajectory style. `signature_arc` (default) is one arc with a small follow-through;
+ * `spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;
+ * `comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for
+ * small targets and a swoop for long moves; `classic` is the previous Dubins glide. When
+ * the theme's reduced motion is on, every move is a short straight glide with no effects.
+ */
+ style?: CursorMotionStyle,
+ /**
+ * `native` uses the style's own timing; `fitts` scales the move time with distance and
+ * target size; `fixed` uses glide_duration_ms (1430 ms when 0).
+ */
+ timing?: CursorMotionTiming,
+ /**
+ * Turn single effects on or off. An omitted effect keeps its current setting; null
+ * restores the style's default.
+ */
+ effects?: CursorMotionEffects,
+ /**
+ * Arc control-point offset from the start, as a fraction of the distance, for
+ * `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).
+ */
+ startHandle?: number,
+ /**
+ * Arc control-point offset from the end, as a fraction of the distance, for
+ * `signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).
+ */
+ endHandle?: number,
+ /**
+ * Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)
+ * keeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.
+ */
+ arcSize?: number,
+ /**
+ * Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:
+ * positive moves the apex toward the destination. Clamped to -1..1 (default 0).
+ */
+ arcFlow?: number,
+ /**
+ * Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped
+ * to 0.3..1 (default 0.72).
+ */
+ spring?: number,
+ /**
+ * Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A
+ * nonzero value with `native` timing also fixes the duration. Clamped to 0..5000.
+ */
+ glideDurationMs?: number,
+ /**
+ * Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).
+ */
+ dwellAfterClickMs?: number,
+ /**
+ * Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to
+ * 0..60000 (default 15000).
+ */
+ idleHideMs?: number,
+ /**
+ * Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.
+ * Clamped to 1..1000 (default 80).
+ */
+ turnRadius?: number
+}
+
+/**
+ * Generated factory for {@link CursorMotionSelection} record objects.
+ */
+export const CursorMotionSelection = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<CursorMotionSelection, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<CursorMotionSelection>,
+ });
+})();
+
+const FfiConverterTypeCursorMotionSelection = (() => {
+ type TypeName = CursorMotionSelection;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ style: FfiConverterOptionalTypeCursorMotionStyle.read(from),
+ timing: FfiConverterOptionalTypeCursorMotionTiming.read(from),
+ effects: FfiConverterOptionalTypeCursorMotionEffects.read(from),
+ startHandle: FfiConverterOptionalFloat64.read(from),
+ endHandle: FfiConverterOptionalFloat64.read(from),
+ arcSize: FfiConverterOptionalFloat64.read(from),
+ arcFlow: FfiConverterOptionalFloat64.read(from),
+ spring: FfiConverterOptionalFloat64.read(from),
+ glideDurationMs: FfiConverterOptionalFloat64.read(from),
+ dwellAfterClickMs: FfiConverterOptionalFloat64.read(from),
+ idleHideMs: FfiConverterOptionalFloat64.read(from),
+ turnRadius: FfiConverterOptionalFloat64.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterOptionalTypeCursorMotionStyle.write(value.style, into);
+ FfiConverterOptionalTypeCursorMotionTiming.write(value.timing, into);
+ FfiConverterOptionalTypeCursorMotionEffects.write(value.effects, into);
+ FfiConverterOptionalFloat64.write(value.startHandle, into);
+ FfiConverterOptionalFloat64.write(value.endHandle, into);
+ FfiConverterOptionalFloat64.write(value.arcSize, into);
+ FfiConverterOptionalFloat64.write(value.arcFlow, into);
+ FfiConverterOptionalFloat64.write(value.spring, into);
+ FfiConverterOptionalFloat64.write(value.glideDurationMs, into);
+ FfiConverterOptionalFloat64.write(value.dwellAfterClickMs, into);
+ FfiConverterOptionalFloat64.write(value.idleHideMs, into);
+ FfiConverterOptionalFloat64.write(value.turnRadius, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterOptionalTypeCursorMotionStyle.allocationSize(value.style) +
+ FfiConverterOptionalTypeCursorMotionTiming.allocationSize(value.timing) +
+ FfiConverterOptionalTypeCursorMotionEffects.allocationSize(value.effects) +
+ FfiConverterOptionalFloat64.allocationSize(value.startHandle) +
+ FfiConverterOptionalFloat64.allocationSize(value.endHandle) +
+ FfiConverterOptionalFloat64.allocationSize(value.arcSize) +
+ FfiConverterOptionalFloat64.allocationSize(value.arcFlow) +
+ FfiConverterOptionalFloat64.allocationSize(value.spring) +
+ FfiConverterOptionalFloat64.allocationSize(value.glideDurationMs) +
+ FfiConverterOptionalFloat64.allocationSize(value.dwellAfterClickMs) +
+ FfiConverterOptionalFloat64.allocationSize(value.idleHideMs) +
+ FfiConverterOptionalFloat64.allocationSize(value.turnRadius);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
export type CursorPointOutput = {
x: number,
y: number
@@ -5499,7 +5637,14 @@ export type StartSessionInput = {
* Optional initial cursor theme. The host applies it before the cursor is
* first made visible, avoiding a flash of the default theme.
*/
- cursorTheme?: CursorThemeSelection
+ cursorTheme?: CursorThemeSelection,
+ /**
+ * Optional initial cursor motion (style, timing, effects and tuning). The host applies it
+ * before the cursor is first made visible. A later `set_agent_cursor_motion` call wins;
+ * this wins over the saved default (`cursor.motion.*` in the driver config) and the
+ * built-in `signature_arc`. Reduced motion always wins.
+ */
+ cursorMotion?: CursorMotionSelection
}
/**
@@ -5525,18 +5670,21 @@ const FfiConverterTypeStartSessionInput = (() => {
return {
session: FfiConverterOptionalString.read(from),
captureScope: FfiConverterOptionalTypeCaptureScope.read(from),
- cursorTheme: FfiConverterOptionalTypeCursorThemeSelection.read(from)
+ cursorTheme: FfiConverterOptionalTypeCursorThemeSelection.read(from),
+ cursorMotion: FfiConverterOptionalTypeCursorMotionSelection.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
FfiConverterOptionalString.write(value.session, into);
FfiConverterOptionalTypeCaptureScope.write(value.captureScope, into);
FfiConverterOptionalTypeCursorThemeSelection.write(value.cursorTheme, into);
+ FfiConverterOptionalTypeCursorMotionSelection.write(value.cursorMotion, into);
}
allocationSize(value: TypeName): number {
return FfiConverterOptionalString.allocationSize(value.session) +
FfiConverterOptionalTypeCaptureScope.allocationSize(value.captureScope) +
- FfiConverterOptionalTypeCursorThemeSelection.allocationSize(value.cursorTheme);
+ FfiConverterOptionalTypeCursorThemeSelection.allocationSize(value.cursorTheme) +
+ FfiConverterOptionalTypeCursorMotionSelection.allocationSize(value.cursorMotion);
}
};
@@ -5549,7 +5697,11 @@ const FfiConverterTypeStartSessionInput = (() => {
export type StartSessionOutput = {
state: SessionStateOutput,
active: boolean,
- revived: boolean
+ revived: boolean,
+ /**
+ * The `cursor_motion` this call applied, echoed as sent. Absent when the call did not set one.
+ */
+ cursorMotion?: CursorMotionSelection
}
/**
@@ -5575,18 +5727,21 @@ const FfiConverterTypeStartSessionOutput = (() => {
return {
state: FfiConverterTypeSessionStateOutput.read(from),
active: FfiConverterBool.read(from),
- revived: FfiConverterBool.read(from)
+ revived: FfiConverterBool.read(from),
+ cursorMotion: FfiConverterOptionalTypeCursorMotionSelection.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
FfiConverterTypeSessionStateOutput.write(value.state, into);
FfiConverterBool.write(value.active, into);
FfiConverterBool.write(value.revived, into);
+ FfiConverterOptionalTypeCursorMotionSelection.write(value.cursorMotion, into);
}
allocationSize(value: TypeName): number {
return FfiConverterTypeSessionStateOutput.allocationSize(value.state) +
FfiConverterBool.allocationSize(value.active) +
- FfiConverterBool.allocationSize(value.revived);
+ FfiConverterBool.allocationSize(value.revived) +
+ FfiConverterOptionalTypeCursorMotionSelection.allocationSize(value.cursorMotion);
}
};
@@ -6311,6 +6466,9 @@ const FfiConverterOptionalTypeCursorMotionTiming = new FfiConverterOptional(FfiC
// FfiConverter for CursorMotionEffectsOutput | undefined
const FfiConverterOptionalTypeCursorMotionEffectsOutput = new FfiConverterOptional(FfiConverterTypeCursorMotionEffectsOutput);
+// FfiConverter for CursorMotionEffects | undefined
+const FfiConverterOptionalTypeCursorMotionEffects = new FfiConverterOptional(FfiConverterTypeCursorMotionEffects);
+
// FfiConverter for ActionTarget | undefined
const FfiConverterOptionalTypeActionTarget = new FfiConverterOptional(FfiConverterTypeActionTarget);
@@ -6368,15 +6526,15 @@ const FfiConverterOptionalTypeScrollBy = new FfiConverterOptional(FfiConverterTy
// FfiConverter for EscalationReason | undefined
const FfiConverterOptionalTypeEscalationReason = new FfiConverterOptional(FfiConverterTypeEscalationReason);
-// FfiConverter for CursorMotionEffects | undefined
-const FfiConverterOptionalTypeCursorMotionEffects = new FfiConverterOptional(FfiConverterTypeCursorMotionEffects);
-
// FfiConverter for CaptureScope | undefined
const FfiConverterOptionalTypeCaptureScope = new FfiConverterOptional(FfiConverterTypeCaptureScope);
// FfiConverter for CursorThemeSelection | undefined
const FfiConverterOptionalTypeCursorThemeSelection = new FfiConverterOptional(FfiConverterTypeCursorThemeSelection);
+// FfiConverter for CursorMotionSelection | undefined
+const FfiConverterOptionalTypeCursorMotionSelection = new FfiConverterOptional(FfiConverterTypeCursorMotionSelection);
+
// FfiConverter for BoundsExpectation | undefined
const FfiConverterOptionalTypeBoundsExpectation = new FfiConverterOptional(FfiConverterTypeBoundsExpectation);
@@ -6458,6 +6616,7 @@ export default Object.freeze({
FfiConverterTypeCursorMotionEffects,
FfiConverterTypeCursorMotionEffectsOutput,
FfiConverterTypeCursorMotionOutput,
+ FfiConverterTypeCursorMotionSelection,
FfiConverterTypeCursorMotionStyle,
FfiConverterTypeCursorMotionTiming,
FfiConverterTypeCursorPointOutput,
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
index 1446ac3eab..7514db9781 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
@@ -2274,7 +2274,7 @@
"read_only": true
},
{
- "description": "Update cua-driver-rs configuration. capture_mode / max_image_dimension take effect immediately.\n\nTwo input shapes (both accepted, matching Windows/Swift):\n- **{key, value}** (preferred): `{\"key\": \"max_image_dimension\", \"value\": 800}` — single leaf write.\n- **Legacy per-field**: `{\"capture_mode\": \"som\", \"max_image_dimension\": 0}`.\n\nThe experimental_pip keys persist to ~/.cua-driver/config.json and apply on next daemon restart (the PiP backend is initialised once at startup; Linux ships only the trait stub today — see issue #1729).",
+ "description": "Update cua-driver-rs configuration. capture_mode / max_image_dimension take effect immediately.\n\nTwo input shapes (both accepted, matching Windows/Swift):\n- **{key, value}** (preferred): `{\"key\": \"max_image_dimension\", \"value\": 800}` — single leaf write.\n- **Legacy per-field**: `{\"capture_mode\": \"som\", \"max_image_dimension\": 0}`.\n\nThe experimental_pip keys persist to ~/.cua-driver/config.json and apply on next daemon restart (the PiP backend is initialised once at startup; Linux ships only the trait stub today — see issue #1729).\n\n`cursor.motion.style`, `cursor.motion.timing` and `cursor.motion.effects.<name>` save the default cursor motion for sessions started afterwards.",
"destructive": false,
"idempotent": true,
"input_schema": {
@@ -2288,6 +2288,50 @@
],
"type": "string"
},
+ "cursor.motion": {
+ "description": "Pass null (or `default`) to clear every saved cursor motion default."
+ },
+ "cursor.motion.effects.glow": {
+ "description": "Saved default for the `glow` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.magnet": {
+ "description": "Saved default for the `magnet` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.ripple": {
+ "description": "Saved default for the `ripple` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.squish": {
+ "description": "Saved default for the `squish` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.trail": {
+ "description": "Saved default for the `trail` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.style": {
+ "description": "Saved default cursor motion style for new sessions. Overridden by start_session cursor_motion and set_agent_cursor_motion; reduced motion always wins. Built-in default: signature_arc.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "cursor.motion.timing": {
+ "description": "Saved default cursor move timing for new sessions.",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
"experimental_pip": {
"description": "Enable the experimental PiP preview window (applies next restart; Linux backend stubbed).",
"type": "boolean"
@@ -3110,6 +3154,145 @@
],
"type": "string"
},
+ "cursor_motion": {
+ "additionalProperties": false,
+ "description": "Optional initial cursor motion (style, timing, effects and tuning). The host applies it\nbefore the cursor is first made visible. A later `set_agent_cursor_motion` call wins;\nthis wins over the saved default (`cursor.motion.*` in the driver config) and the\nbuilt-in `signature_arc`. Reduced motion always wins.",
+ "properties": {
+ "arc_flow": {
+ "description": "Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:\npositive moves the apex toward the destination. Clamped to -1..1 (default 0).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "arc_size": {
+ "description": "Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)\nkeeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "dwell_after_click_ms": {
+ "description": "Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "effects": {
+ "additionalProperties": false,
+ "description": "Turn single effects on or off. An omitted effect keeps its current setting; null\nrestores the style's default.",
+ "properties": {
+ "glow": {
+ "description": "Soft glow around the cursor that grows with speed.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "magnet": {
+ "description": "Target glow when the `magnetic` style locks on.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ripple": {
+ "description": "Ring that expands from the hotspot on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "squish": {
+ "description": "Brief scale-down of the cursor on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "trail": {
+ "description": "Short fading trail behind the cursor.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "end_handle": {
+ "description": "Arc control-point offset from the end, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "glide_duration_ms": {
+ "description": "Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A\nnonzero value with `native` timing also fixes the duration. Clamped to 0..5000.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "idle_hide_ms": {
+ "description": "Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to\n0..60000 (default 15000).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "spring": {
+ "description": "Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped\nto 0.3..1 (default 0.72).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "start_handle": {
+ "description": "Arc control-point offset from the start, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "style": {
+ "description": "Trajectory style. `signature_arc` (default) is one arc with a small follow-through;\n`spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;\n`comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for\nsmall targets and a swoop for long moves; `classic` is the previous Dubins glide. When\nthe theme's reduced motion is on, every move is a short straight glide with no effects.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "timing": {
+ "description": "`native` uses the style's own timing; `fitts` scales the move time with distance and\ntarget size; `fixed` uses glide_duration_ms (1430 ms when 0).",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
+ "turn_radius": {
+ "description": "Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.\nClamped to 1..1000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
"cursor_theme": {
"description": "Optional initial cursor theme. The host applies it before the cursor is\nfirst made visible, avoiding a flash of the default theme.",
"properties": {
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
index 63bc4a4daa..673a99fbff 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
@@ -1918,12 +1918,56 @@
"read_only": true
},
{
- "description": "Update cua-driver-rs configuration. Changes to max_image_dimension take effect immediately. The experimental_pip keys are persisted to ~/.cua-driver/config.json and take effect on the next daemon restart (the PiP backend is initialised once at startup).\n\nNote: capture_mode is a per-call param (on get_window_state / click), not a stored setting. Capture modality is selected by each action's target; the old capture_scope config key is retired.",
+ "description": "Update cua-driver-rs configuration. Changes to max_image_dimension take effect immediately. The experimental_pip keys are persisted to ~/.cua-driver/config.json and take effect on the next daemon restart (the PiP backend is initialised once at startup).\n\nNote: capture_mode is a per-call param (on get_window_state / click), not a stored setting. Capture modality is selected by each action's target; the old capture_scope config key is retired.\n\nCursor motion defaults: cursor.motion.style, cursor.motion.timing and cursor.motion.effects.<trail|glow|magnet|ripple|squish> are saved to ~/.cua-driver/config.json and seed sessions started afterwards. start_session cursor_motion and set_agent_cursor_motion override them; reduced motion always wins.",
"destructive": false,
"idempotent": true,
"input_schema": {
"additionalProperties": false,
"properties": {
+ "cursor.motion": {
+ "description": "Pass null (or `default`) to clear every saved cursor motion default."
+ },
+ "cursor.motion.effects.glow": {
+ "description": "Saved default for the `glow` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.magnet": {
+ "description": "Saved default for the `magnet` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.ripple": {
+ "description": "Saved default for the `ripple` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.squish": {
+ "description": "Saved default for the `squish` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.trail": {
+ "description": "Saved default for the `trail` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.style": {
+ "description": "Saved default cursor motion style for new sessions. Overridden by start_session cursor_motion and set_agent_cursor_motion; reduced motion always wins. Built-in default: signature_arc.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "cursor.motion.timing": {
+ "description": "Saved default cursor move timing for new sessions.",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
"experimental_pip": {
"description": "Enable the experimental picture-in-picture preview window. Applies on next daemon restart.",
"type": "boolean"
@@ -2746,6 +2790,145 @@
],
"type": "string"
},
+ "cursor_motion": {
+ "additionalProperties": false,
+ "description": "Optional initial cursor motion (style, timing, effects and tuning). The host applies it\nbefore the cursor is first made visible. A later `set_agent_cursor_motion` call wins;\nthis wins over the saved default (`cursor.motion.*` in the driver config) and the\nbuilt-in `signature_arc`. Reduced motion always wins.",
+ "properties": {
+ "arc_flow": {
+ "description": "Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:\npositive moves the apex toward the destination. Clamped to -1..1 (default 0).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "arc_size": {
+ "description": "Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)\nkeeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "dwell_after_click_ms": {
+ "description": "Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "effects": {
+ "additionalProperties": false,
+ "description": "Turn single effects on or off. An omitted effect keeps its current setting; null\nrestores the style's default.",
+ "properties": {
+ "glow": {
+ "description": "Soft glow around the cursor that grows with speed.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "magnet": {
+ "description": "Target glow when the `magnetic` style locks on.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ripple": {
+ "description": "Ring that expands from the hotspot on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "squish": {
+ "description": "Brief scale-down of the cursor on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "trail": {
+ "description": "Short fading trail behind the cursor.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "end_handle": {
+ "description": "Arc control-point offset from the end, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "glide_duration_ms": {
+ "description": "Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A\nnonzero value with `native` timing also fixes the duration. Clamped to 0..5000.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "idle_hide_ms": {
+ "description": "Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to\n0..60000 (default 15000).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "spring": {
+ "description": "Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped\nto 0.3..1 (default 0.72).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "start_handle": {
+ "description": "Arc control-point offset from the start, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "style": {
+ "description": "Trajectory style. `signature_arc` (default) is one arc with a small follow-through;\n`spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;\n`comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for\nsmall targets and a swoop for long moves; `classic` is the previous Dubins glide. When\nthe theme's reduced motion is on, every move is a short straight glide with no effects.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "timing": {
+ "description": "`native` uses the style's own timing; `fitts` scales the move time with distance and\ntarget size; `fixed` uses glide_duration_ms (1430 ms when 0).",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
+ "turn_radius": {
+ "description": "Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.\nClamped to 1..1000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
"cursor_theme": {
"description": "Optional initial cursor theme. The host applies it before the cursor is\nfirst made visible, avoiding a flash of the default theme.",
"properties": {
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
index f8213e3260..c3a73f357b 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
@@ -1966,7 +1966,7 @@
"read_only": true
},
{
- "description": "Write a setting into the persistent driver config. Values take effect immediately.\n\nTwo input shapes:\n- **Swift-compatible** (preferred): `{\"key\": \"max_image_dimension\", \"value\": 1568}` — single dotted-path leaf write.\n- **Legacy per-field** (Rust-only): `{\"max_image_dimension\": 0}` — bulk write of named fields.\n\nKnown keys:\n- `capture_mode` (string: `vision` | `ax` | `som`) — DEPRECATED and ignored; `get_window_state` always returns both the UIA tree and a screenshot. Still accepted/persisted for back-compat but has no effect.\n- `max_image_dimension` (integer)\n- `experimental_pip` (boolean; persisted to config.json, applies on next daemon restart — Windows backend stubbed today, see issue #1729)\n- `experimental_pip_geometry` (string `WxH` or `WxH+X+Y`; persisted; applies on next daemon restart)\n\nReturns the full updated config in the same shape as `get_config`.",
+ "description": "Write a setting into the persistent driver config. Values take effect immediately.\n\nTwo input shapes:\n- **Swift-compatible** (preferred): `{\"key\": \"max_image_dimension\", \"value\": 1568}` — single dotted-path leaf write.\n- **Legacy per-field** (Rust-only): `{\"max_image_dimension\": 0}` — bulk write of named fields.\n\nKnown keys:\n- `capture_mode` (string: `vision` | `ax` | `som`) — DEPRECATED and ignored; `get_window_state` always returns both the UIA tree and a screenshot. Still accepted/persisted for back-compat but has no effect.\n- `max_image_dimension` (integer)\n- `experimental_pip` (boolean; persisted to config.json, applies on next daemon restart — Windows backend stubbed today, see issue #1729)\n- `experimental_pip_geometry` (string `WxH` or `WxH+X+Y`; persisted; applies on next daemon restart)\n\n- `cursor.motion.style`, `cursor.motion.timing`, `cursor.motion.effects.<name>` — saved default cursor motion for sessions started afterwards (see the cursor docs).\n\nReturns the full updated config in the same shape as `get_config`.",
"destructive": false,
"idempotent": true,
"input_schema": {
@@ -1980,6 +1980,50 @@
],
"type": "string"
},
+ "cursor.motion": {
+ "description": "Pass null (or `default`) to clear every saved cursor motion default."
+ },
+ "cursor.motion.effects.glow": {
+ "description": "Saved default for the `glow` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.magnet": {
+ "description": "Saved default for the `magnet` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.ripple": {
+ "description": "Saved default for the `ripple` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.squish": {
+ "description": "Saved default for the `squish` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.effects.trail": {
+ "description": "Saved default for the `trail` cursor effect. Unset follows the style.",
+ "type": "boolean"
+ },
+ "cursor.motion.style": {
+ "description": "Saved default cursor motion style for new sessions. Overridden by start_session cursor_motion and set_agent_cursor_motion; reduced motion always wins. Built-in default: signature_arc.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "cursor.motion.timing": {
+ "description": "Saved default cursor move timing for new sessions.",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
"experimental_pip": {
"description": "Legacy per-field shape. Enables PiP preview (applies next restart).",
"type": "boolean"
@@ -2802,6 +2846,145 @@
],
"type": "string"
},
+ "cursor_motion": {
+ "additionalProperties": false,
+ "description": "Optional initial cursor motion (style, timing, effects and tuning). The host applies it\nbefore the cursor is first made visible. A later `set_agent_cursor_motion` call wins;\nthis wins over the saved default (`cursor.motion.*` in the driver config) and the\nbuilt-in `signature_arc`. Reduced motion always wins.",
+ "properties": {
+ "arc_flow": {
+ "description": "Added to the arc asymmetry of `signature_arc`, `spring_settle` and `comet_swoop`:\npositive moves the apex toward the destination. Clamped to -1..1 (default 0).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "arc_size": {
+ "description": "Scales the arc of `signature_arc`, `spring_settle` and `comet_swoop`: 0.25 (default)\nkeeps the style's arc, 0 is a straight line, 0.5 doubles it. Clamped to 0..1.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "dwell_after_click_ms": {
+ "description": "Pause after a click animation, in milliseconds. Clamped to 0..5000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "effects": {
+ "additionalProperties": false,
+ "description": "Turn single effects on or off. An omitted effect keeps its current setting; null\nrestores the style's default.",
+ "properties": {
+ "glow": {
+ "description": "Soft glow around the cursor that grows with speed.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "magnet": {
+ "description": "Target glow when the `magnetic` style locks on.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ripple": {
+ "description": "Ring that expands from the hotspot on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "squish": {
+ "description": "Brief scale-down of the cursor on click.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "trail": {
+ "description": "Short fading trail behind the cursor.",
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "end_handle": {
+ "description": "Arc control-point offset from the end, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "glide_duration_ms": {
+ "description": "Move duration in milliseconds for `fixed` timing (1430 ms when 0, the default). A\nnonzero value with `native` timing also fixes the duration. Clamped to 0..5000.",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "idle_hide_ms": {
+ "description": "Hide the cursor after this many idle milliseconds; 0 never hides it. Clamped to\n0..60000 (default 15000).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "spring": {
+ "description": "Arrival spring damping for `classic`: 1 is critically damped, 0.3 is bouncy. Clamped\nto 0.3..1 (default 0.72).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "start_handle": {
+ "description": "Arc control-point offset from the start, as a fraction of the distance, for\n`signature_arc`, `spring_settle` and `comet_swoop`. Clamped to 0..1 (default 0.3).",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "style": {
+ "description": "Trajectory style. `signature_arc` (default) is one arc with a small follow-through;\n`spring_settle` lands with one soft bounce; `magnetic` is pulled into the target;\n`comet_swoop` is a wide arc with a short trail; `adaptive` picks a careful approach for\nsmall targets and a swoop for long moves; `classic` is the previous Dubins glide. When\nthe theme's reduced motion is on, every move is a short straight glide with no effects.",
+ "enum": [
+ "signature_arc",
+ "spring_settle",
+ "magnetic",
+ "comet_swoop",
+ "adaptive",
+ "classic"
+ ],
+ "type": "string"
+ },
+ "timing": {
+ "description": "`native` uses the style's own timing; `fitts` scales the move time with distance and\ntarget size; `fixed` uses glide_duration_ms (1430 ms when 0).",
+ "enum": [
+ "native",
+ "fitts",
+ "fixed"
+ ],
+ "type": "string"
+ },
+ "turn_radius": {
+ "description": "Minimum turning radius of the `classic` glide path, in points; smaller turns tighter.\nClamped to 1..1000 (default 80).",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "type": [
+ "object",
+ "null"
+ ]
+ },
"cursor_theme": {
"description": "Optional initial cursor theme. The host applies it before the cursor is\nfirst made visible, avoiding a flash of the default theme.",
"properties": {
diff --git a/scripts/docs-generators/cli-specs/cua-driver.json b/scripts/docs-generators/cli-specs/cua-driver.json
index 762c5a83e8..f0077d9f1a 100644
--- a/scripts/docs-generators/cli-specs/cua-driver.json
+++ b/scripts/docs-generators/cli-specs/cua-driver.json
@@ -1001,11 +1001,23 @@
"type": "String"
}
],
- "discussion": "",
+ "discussion": "Cursor motion defaults are saved keys that apply to sessions started afterwards: cursor.motion.style (signature_arc, spring_settle, magnetic, comet_swoop, adaptive, classic), cursor.motion.timing (native, fitts, fixed) and cursor.motion.effects.<trail|glow|magnet|ripple|squish> (true, false). Use null for a key to clear it, or cursor.motion null to clear all. A start_session cursor_motion or a set_agent_cursor_motion call overrides the saved default.",
"examples": [
{
"command": "cua-driver config set max_image_dimension 1568",
"description": "Downscale screenshots to at most 1568 px"
+ },
+ {
+ "command": "cua-driver config set cursor.motion.style magnetic",
+ "description": "Make magnetic the default cursor motion for new sessions"
+ },
+ {
+ "command": "cua-driver config set cursor.motion.timing fitts",
+ "description": "Scale cursor move time with distance and target size"
+ },
+ {
+ "command": "cua-driver config set cursor.motion.effects.trail true",
+ "description": "Turn the cursor trail on by default"
}
],
"flags": [],