Skip to content

feat(mcp): iphone_tap taps the same point several times with count - #141

Merged
Derrors merged 2 commits into
Derrors:mainfrom
cosinec:feat/tap-count
Nov 17, 2026
Merged

Derrors merged 2 commits into
Derrors:mainfrom
cosinec:feat/tap-count

Conversation

@cosinec

@cosinec cosinec commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Separate taps each wait for the interface to go idle, so they land about 0.5 s apart; iphone_batch with 5 iphone_tap steps took about 2.8 s on an iPhone 12 mini. That rules out a double tap and any entry that needs several taps within a short time, for example a hidden debug menu that opens on 5 taps within 800 ms. On the keyboard, tapping Shift twice through two calls only turns it on and off again; Caps Lock never comes on. docs/dev/wda-dependency-research.md §7 already notes that the taps of a double tap have to be in one event path.

iphone_tap gets an optional count (1-10, default 1):

  • WDA: one actions gesture. One finger moves to the point once, then goes down and up count times, MULTI_TAP_GAP_MS (100 ms) apart, with a 50 ms press like a normal tap. 5 taps take 650 ms of gesture time. The same quick idle settings as tap are used. I keep it to one point on purpose: on an iPhone 17 (iOS 26.5.2), a single pointer that moved to a different point inside one gesture had every tap registered twice (7 keypad keys gave 14 digits).
  • HID (native on iOS 27, or the fallback): the taps go through the same HID session, one rotation check, MULTI_TAP_GAP_MS apart.
  • Protocol: Request::Tap gets count with #[serde(default = 1, skip_serializing_if = 1)]. Requests without it (older clients) mean one tap. With count 1 the request is byte-for-byte what it was. An older daemon given count > 1 ignores the field and taps once (verified with 0.2.7, see below), the same as with any new optional field. The CHANGELOG line says so.
  • MCP: count in the iphone_tap schema (minimum/maximum). 0, 11, 2.5 or a string is an error, not a silent 1. It works inside iphone_batch too. The result says 已点击 (x,y),连点 N 下 / Tapped (x,y), N times. When count is 1 the output is unchanged.

The tool name, the existing parameters and the default output don't change (D10).

Tests

1. Unit tests

  • cargo test --workspace --all-features --locked, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings and cargo fmt --check (per package) pass (Rust 1.99.1, macOS)
  • New or changed behaviour has a unit test:
    • ictl-wda: client::tests::multi_tap_is_one_request_at_one_point. It checks for one /actions request, one pointerMove, 5 downs and 5 ups, and a total duration of 5×50 + 4×100 ms (< 800).
    • ictl-mcp: tests::tap_count_defaults_to_one_and_rejects_out_of_range, which also covers a batch step.
    • ictl-protocol: tests::a_tap_without_count_is_one_tap_on_the_wire. Old JSON decodes as 1, and count 1 is not serialized.
  • No existing test removed, ignored or loosened. Existing Request::Tap { .. } constructions in tests only gained count: 1.
  • #[ignore] tests of the changed area run by hand: none apply

2. Real-device regression

  • Device, iOS version, host (Linux / macOS): iPhone 12 mini (iPhone13,1), iOS 26.4.1, macOS (Apple silicon); WDA 16.14.0 launched in the background by the daemon
  • tests/device/run.py default steps pass on this branch (exit code 0): 14 calls, 0 failed, 12.0 s
  • The same steps on the latest release, same device: v0.2.7 release binary, 14 calls, 0 failed, 23.2 s. No step on the branch is clearly slower. The release's total is higher because its first home took 8.2 s, right after WDA had started.
  • Steps exercising this change: see section 4
  • Longer run: not affected
run.py output
this branch:

=== iphone_status {} 0.13s
WDA 就绪: True
锁屏: 未锁屏
前台 App: com.apple.Spotlight
屏幕: 375x812 点
守护进程: 就绪
=== iphone_tap_element {"text": "不存在的按钮xyz"} 0.44s
没找到包含 "不存在的按钮xyz" 的元素,先用 iphone_list_elements 或截图看看屏幕
=== iphone_press_button {"button": "home"} 1.36s
已按 home
=== iphone_launch_app {"app": "时钟"} 1.21s
已启动 com.apple.mobiletimer
=== iphone_list_elements {"limit": 12} 0.24s
StaticText "0秒钟" id="stopwatch-time" @(188,235) 375x106
Button "分段" @(58,417) 84x84
Button "启动" @(317,417) 84x84
PageIndicator "第1页(共2页), 数码秒表" value="第1页(共2页), 数码秒表" @(188,420) 56x31
Table "空列表" @(188,644) 375x337
TabBar "标签页栏" @(188,770) 375x83
Button "世界时钟" @(72,760) 94x54
Button "闹钟" @(149,760) 94x54
Button "秒表" value="1" @(226,760) 94x54
Button "计时器" @(303,760) 94x54
=== iphone_tap_element {"text": "秒表", "then": "elements", "then_filter": "Button"} 1.54s
已点击 Button "秒表" value="1" @(226,760) 94x54
画面已静止(0.7 秒)
--- 操作后的界面 ---
Button "分段" @(58,417) 84x84
Button "启动" @(317,417) 84x84
Button "世界时钟" @(72,760) 94x54
Button "闹钟" @(149,760) 94x54
Button "秒表" value="1" @(226,760) 94x54
Button "计时器" @(303,760) 94x54
=== iphone_screenshot {} 0.19s
375x812 点,图像像素即点坐标(经 WDA)
=== iphone_screenshot {"x": 0, "y": 0, "width": 430, "height": 60} 0.14s
区域 (0,0) 起 375x60 点,放大 3 倍;图中像素 (u,v) 对应屏幕点 (0+u/3, 0+v/3)(经 WDA)
=== iphone_press_button {"button": "home"} 1.75s
已按 home
=== iphone_swipe {"from_x": 215, "from_y": 400, "to_x": 215, "to_y": 700} 1.73s
已滑动 (215,400) → (215,700)
=== iphone_type_text {"text": "设置"} 1.05s
已输入 2 个字符
=== iphone_wait_for {"text": "设置", "timeout": 5} 0.22s
已出现 Cell "设置" id="Identifier:GridCell,Section:0,Row:0" @(188,143) 330x114(0.2 秒)
=== iphone_screenshot {} 0.39s
375x812 点,图像像素即点坐标(经 WDA)
=== iphone_press_button {"button": "home"} 1.50s
已按 home
--- 14 calls, 0 failed, 12.0s in all

latest release (v0.2.7):

=== iphone_status {} 0.31s
WDA 就绪: True
锁屏: 未锁屏
前台 App: com.apple.Preferences
屏幕: 375x812 点
守护进程: 就绪
=== iphone_tap_element {"text": "不存在的按钮xyz"} 0.51s
没找到包含 "不存在的按钮xyz" 的元素,先用 iphone_list_elements 或截图看看屏幕
=== iphone_press_button {"button": "home"} 8.19s
已按 home,但前台还是 com.apple.Preferences,先截图看看
=== iphone_launch_app {"app": "时钟"} 1.67s
已启动 com.apple.mobiletimer
=== iphone_list_elements {"limit": 12} 0.22s
StaticText "0秒钟" id="stopwatch-time" @(188,235) 375x106
Button "分段" @(58,417) 84x84
Button "启动" @(317,417) 84x84
PageIndicator "第1页(共2页)" value="第1页(共2页)" @(188,420) 56x31
Table "空列表" @(188,644) 375x337
TabBar "标签页栏" @(188,770) 375x83
Button "世界时钟" @(72,760) 94x54
Button "闹钟" @(149,760) 94x54
Button "秒表" value="1" @(226,760) 94x54
Button "计时器" @(303,760) 94x54
=== iphone_tap_element {"text": "秒表", "then": "elements", "then_filter": "Button"} 1.53s
已点击 Button "秒表" value="1" @(226,760) 94x54
画面已静止(0.7 秒)
--- 操作后的界面 ---
Button "分段" @(58,417) 84x84
Button "启动" @(317,417) 84x84
Button "世界时钟" @(72,760) 94x54
Button "闹钟" @(149,760) 94x54
Button "秒表" value="1" @(226,760) 94x54
Button "计时器" @(303,760) 94x54
=== iphone_screenshot {} 0.19s
375x812 点,图像像素即点坐标(经 WDA)
=== iphone_screenshot {"x": 0, "y": 0, "width": 430, "height": 60} 0.14s
区域 (0,0) 起 375x60 点,放大 3 倍;图中像素 (u,v) 对应屏幕点 (0+u/3, 0+v/3)(经 WDA)
=== iphone_press_button {"button": "home"} 4.30s
已按 home
=== iphone_swipe {"from_x": 215, "from_y": 400, "to_x": 215, "to_y": 700} 1.74s
已滑动 (215,400) → (215,700)
=== iphone_type_text {"text": "设置"} 2.21s
已输入 2 个字符
=== iphone_wait_for {"text": "设置", "timeout": 5} 0.23s
已出现 Cell "设置" id="Identifier:GridCell,Section:0,Row:0" @(188,143) 330x114(0.2 秒)
=== iphone_screenshot {} 0.33s
375x812 点,图像像素即点坐标(经 WDA)
=== iphone_press_button {"button": "home"} 1.50s
已按 home
--- 14 calls, 0 failed, 23.2s in all

3. Regression cases (docs/dev/regression-cases.md)

4. Real-device proof of the fix or feature

  • Device, iOS version, host (Linux / macOS): iPhone 12 mini, iOS 26.4.1, macOS
  • Feature: exercised end to end through the MCP server (tests/device/run.py with custom steps), including the error and edge cases
  • Untested conditions: the HID path (both phones I have are below iOS 27, and WDA was up throughout); landscape; iPad
Steps and results

Spotlight search field focused, English keyboard. Before each run the field was cleared, and afterwards its value was read through WDA. Each tap on the w key types one letter, so the letters count the taps that registered.

v0.2.7, iphone_batch with 5 × iphone_tap {"x":60,"y":548}     2.78 s, 2.75 s   -> "w w w w w"
v0.2.7, iphone_tap {"x":60,"y":548,"count":5}                 0.69 s           -> one "w" (count ignored)

this branch, iphone_tap {"x":60,"y":548,"count":N}:
  count=2   1.14 s   "w w"
  count=3   1.14 s   "w w w"
  count=5   1.46 s   "w w w w w"   (twice)
  count=10  2.62 s   10 × "w"
  iphone_batch [{"tool":"iphone_tap","x":60,"y":548,"count":3}]   1.14 s   3 more "w"
  count=0 / 11  -> 参数 count 要是 1 到 10 的整数   (nothing tapped)
  count=2.5     -> 参数 count 要是非负整数           (nothing tapped)

To show the taps fall inside the system's double-tap window, I tapped the keyboard's Shift (28,660) twice and then typed with count=3 on w. Three rounds each:

this branch: iphone_tap Shift count=2, then w count=3            -> "WWW"    (Caps Lock on)   3/3
two taps:    iphone_batch [tap Shift, tap Shift], then w count=3  -> "w w w"  (Shift on, off)  3/3

Checklist

  • MCP tool names, parameters and default outputs stay compatible (docs/decisions.md D10): one optional parameter added, nothing else changes
  • New or changed dependencies are pinned to exact versions; vendor changes recorded in THIRD_PARTY.md: no dependency changes

Docs: docs/tools.md, website/guide/tools.md, website/en/guide/tools.md, CHANGELOG.md, CHANGELOG.zh-CN.md.

🤖 Generated with Claude Code

Separate taps each wait for the interface to go idle, about 0.5 s apart
(iphone_batch: 5 taps in about 2.8 s), so a double tap, or an entry that
needs several taps in a short time, couldn't be done: double-tapping the
keyboard's Shift only turned it on and off again.

iphone_tap takes count (1-10, default 1). Through WDA the taps go in one
actions gesture, one finger moving once and tapping the same point
MULTI_TAP_GAP_MS (0.1 s) apart; one finger that moves to another point
inside a gesture had each tap registered twice. Through HID they go in
the same session. count travels in Request::Tap only when it isn't 1,
so older daemons see the same requests as before (and ignore it).

Regression case Derrors#147.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict in docs/dev/regression-cases.md: keep Derrors#146 (from Derrors#139)
and this branch's Derrors#147, in order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit 1451bfc into Derrors:main Nov 17, 2026
9 checks passed
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflicts with Derrors#139 and Derrors#141: keep both sides (TapSequence
next to Tap's new count, both constants, both client methods and their
tests, CHANGELOG lines, regression rows Derrors#146-Derrors#148 in order).

iphone_tap now carries count: a step with count under one_gesture is an
error instead of being tapped once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflicts with Derrors#139, Derrors#141 and Derrors#143 by keeping both sides:
drag_steps next to tap_sequence_body, the exports of both, the protocol
helpers, the MCP tests, CHANGELOG lines and regression rows Derrors#146-Derrors#149 in
order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflict in docs/dev/regression-cases.md: rows Derrors#146-Derrors#149 from
main, then this branch's Derrors#150. The repeat test's Request::Tap gains the
count field Derrors#141 added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflicts with Derrors#141, Derrors#143 and Derrors#144: keep both sides (Tap's
count and TapSequence next to TapElement's scroll, the protocol helpers,
the MCP tests, CHANGELOG lines, doc rows with iphone_tap's count and
iphone_tap_element's scroll, regression rows Derrors#146-Derrors#149 then Derrors#151).

The search scroll now builds the Stroke that Derrors#144's swipe takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflicts with Derrors#141-Derrors#147: keep both sets of client tests, and
rows Derrors#146-Derrors#151 from main. This branch's row becomes Derrors#153 (Derrors#152 goes to the
native floating search bar fix, Derrors#150).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors added a commit to cosinec/iphone-control that referenced this pull request Nov 17, 2026
Resolve the conflicts with Derrors#141-Derrors#150: TapElement's dispatch keeps main's
scroll search and this branch's clearing of before_action on a miss;
CHANGELOG lines after main's; this branch's regression row becomes Derrors#154
(Derrors#152 is Derrors#150's, Derrors#153 is Derrors#148's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors Derrors mentioned this pull request Nov 17, 2026
12 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants