From 76f7ac32cc3c14dd5ff6eb8b29c8e45daa763ce0 Mon Sep 17 00:00:00 2001 From: cosine <1726697408@qq.com> Date: Tue, 17 Nov 2026 13:07:08 +0800 Subject: [PATCH] feat(mcp): iphone_batch taps a run of keys in one gesture with one_gesture A batch of iphone_tap steps waits for the interface to go idle after each tap, so pressing keys one by one (for fields that don't take iphone_type_text) costs about 0.5 s per key. With one_gesture: true the points go out as one W3C actions gesture, one touch pointer per point, each pausing through the earlier points' ticks so the presses come one after another. Any other kind of step makes the batch an error before anything runs; without WDA the points are tapped one by one over HID. On an iPhone 12 mini, 7 digit keys take 1.9 s instead of 3.6 s and 20 take 4.6 s instead of 9.6 s, all read back correctly. Closes #142 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++ CHANGELOG.zh-CN.md | 4 ++ crates/ictl-daemon/src/core.rs | 2 + crates/ictl-daemon/src/tasks.rs | 1 + crates/ictl-daemon/src/tools/input.rs | 49 ++++++++++++++++++++ crates/ictl-mcp/src/lib.rs | 48 ++++++++++++++++++-- crates/ictl-protocol/src/lib.rs | 12 +++++ crates/ictl-wda/src/client.rs | 64 ++++++++++++++++++++++++++- crates/ictl-wda/src/lib.rs | 2 +- docs/dev/regression-cases.md | 1 + docs/tools.md | 2 + website/en/guide/tools.md | 2 +- website/guide/tools.md | 2 +- 13 files changed, 186 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d433e42..0315f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ What changed in each release, one line per change. Versions follow [Semantic Ver ## [Unreleased] +### New + +- `iphone_batch` takes `one_gesture`: a batch of coordinate taps runs as one gesture, about twice as fast for pressing keys on a keyboard. + ### Improvements - An action that had to unlock the phone first says so, and how long it took (#135). diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index fa578f6..a0cb0b3 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -6,6 +6,10 @@ ## [Unreleased] +### 新功能 + +- `iphone_batch` 新增 `one_gesture`:全是坐标点击的一批步骤放进一个手势里点完,在键盘上逐个按键快一倍左右。 + ### 改进 - 操作前先自动解锁了的话,结果里会说明,并写明用了多久(#135)。 diff --git a/crates/ictl-daemon/src/core.rs b/crates/ictl-daemon/src/core.rs index 6bc2b5b..81331ae 100644 --- a/crates/ictl-daemon/src/core.rs +++ b/crates/ictl-daemon/src/core.rs @@ -1214,6 +1214,7 @@ impl Daemon { text }), Request::Tap { x, y } => self.tap(g, x, y, view).await, + Request::TapSequence { points } => self.tap_sequence(g, &points).await, Request::TapElement { text, index, max_age_ms } => { self.tap_element(g, &text, index, Duration::from_millis(max_age_ms)).await.map(|(t, missed)| { outcome.tapped_nothing = missed; @@ -1337,6 +1338,7 @@ fn lane(req: &Request) -> Lane { | Request::Screenshot { .. } | Request::ListElements { .. } | Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } diff --git a/crates/ictl-daemon/src/tasks.rs b/crates/ictl-daemon/src/tasks.rs index 1d4f02a..7b9bbfd 100644 --- a/crates/ictl-daemon/src/tasks.rs +++ b/crates/ictl-daemon/src/tasks.rs @@ -214,6 +214,7 @@ pub fn scope_check(req: &Request) -> Option { Request::LaunchApp { app } => Some(Check::Launch(app.clone())), Request::OpenUrl { url } => Some(Check::Url(url.clone())), Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } diff --git a/crates/ictl-daemon/src/tools/input.rs b/crates/ictl-daemon/src/tools/input.rs index 64eb36b..f71a9c9 100644 --- a/crates/ictl-daemon/src/tools/input.rs +++ b/crates/ictl-daemon/src/tools/input.rs @@ -67,6 +67,55 @@ impl Daemon { Ok(ictl_l10n::trf!("已点击 {pos}(经 HID)", "Tapped {pos} (via HID)")) } + /// 依次点几个点(`iphone_batch` 的 `one_gesture`):WDA 发一个手势([`WdaClient::tap_sequence`]),HID 在同一个会话里连发。 + /// 和 [`Self::tap`] 一样只有连不上 WDA 才退到 HID + pub(crate) async fn tap_sequence(&self, g: &mut Inner, points: &[(f64, f64)]) -> crate::error::Result { + if points.is_empty() || points.len() > crate::protocol::MAX_SEQUENCE_POINTS { + return Err(ictl_l10n::trf!( + "一个手势要点 1 到 {} 个点", + "a gesture takes 1 to {} points", + crate::protocol::MAX_SEQUENCE_POINTS + ) + .into()); + } + self.prepare_coordinates(g, None, true).await?; + let n = points.len(); + let list: Vec = points.iter().map(|(x, y)| format!("({},{})", fmt_g(*x), fmt_g(*y))).collect(); + let list = list.join(" "); + if let Some(w) = self.wda(g) { + match w.tap_sequence(points).await { + Ok(()) => { + return Ok(ictl_l10n::trf!( + "在一个手势里依次点了 {n} 个点:{list}", + "Tapped {n} points in one gesture: {list}" + )); + } + Err(WdaError::Unavailable(_)) => {} + Err(e) => return Err(e.into()), + } + } + let native = self.native(g); + let rot = self.hid_touch_rotation(g).await?; + let pts = points.to_vec(); + self.hid_do(g, move |h| { + Box::pin(async move { + h.rotation = rot; + for (i, (x, y)) in pts.into_iter().enumerate() { + if i > 0 { + tokio::time::sleep(Duration::from_millis(ictl_wda::SEQUENCE_GAP_MS)).await; + } + h.tap(x, y).await?; + } + Ok(()) + }) + }) + .await?; + if native { + return Ok(ictl_l10n::trf!("依次点了 {n} 个点:{list}", "Tapped {n} points: {list}")); + } + Ok(ictl_l10n::trf!("依次点了 {n} 个点(经 HID):{list}", "Tapped {n} points (via HID): {list}")) + } + /// Follow the viewer pointer with one HID report per call. The first event prepares the device. /// Later events reuse the open HID session and reject a change in display orientation. pub(crate) async fn touch( diff --git a/crates/ictl-mcp/src/lib.rs b/crates/ictl-mcp/src/lib.rs index 2d53ed2..68c73c9 100644 --- a/crates/ictl-mcp/src/lib.rs +++ b/crates/ictl-mcp/src/lib.rs @@ -549,7 +549,9 @@ then 在全部做完(或停下)后返回一次界面。", "Run several steps in "steps": {"type": "array", "items": {"type": "object"}, "description": ictl_l10n::tr!("要执行的步骤,1 到 20 个,例如 [{\"tool\": \"iphone_tap_element\", \"text\": \"通用\"}]", "the steps to run, 1 to 20, e.g. [{\"tool\": \"iphone_tap_element\", \"text\": \"General\"}]")}, "reuse_elements": {"type": "boolean", "default": false, - "description": ictl_l10n::tr!("这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置", "Set to true when the steps don't change the layout (e.g. pressing keys on the same keypad): tapping by text reuses the most recent element tree, saving 0.3-0.8 s per step. Don't use it for steps that navigate, or it may tap where things used to be")} + "description": ictl_l10n::tr!("这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置", "Set to true when the steps don't change the layout (e.g. pressing keys on the same keypad): tapping by text reuses the most recent element tree, saving 0.3-0.8 s per step. Don't use it for steps that navigate, or it may tap where things used to be")}, + "one_gesture": {"type": "boolean", "default": false, + "description": ictl_l10n::tr!("步骤全是 iphone_tap 时可设为 true:这些点在一个手势里依次点完(每个点一根手指,间隔约 0.04 秒),中间不等界面空闲。用于在同一个键盘上连按,例如输入框不接受 iphone_type_text 时逐个点数字键:7 个键约 1.9 秒,分开点约 3.6 秒。点的过程中不看界面,中途跳了页面后面的点也照样点下去;点完截图或读元素核对", "Only when every step is iphone_tap: set to true to tap the points one after another in a single gesture (one finger per point, about 0.04 s apart) without waiting for the interface in between. For pressing keys on the same keyboard, e.g. digit keys one by one when a field doesn't take iphone_type_text: 7 keys in about 1.9 s instead of about 3.6 s. Nothing is checked while it taps, so if a tap navigates, the remaining points still land; check the result with a screenshot or elements afterwards")} })), &["steps"], ), @@ -762,13 +764,14 @@ pub fn batch_steps(args: &Map) -> Result, String> { .and_then(Value::as_array) .ok_or(ictl_l10n::tr!("缺少 steps(数组)", "missing steps (array)"))?; let reuse = Args(args).b_or("reuse_elements", false)?; + let one_gesture = Args(args).b_or("one_gesture", false)?; if steps.is_empty() || steps.len() > BATCH_MAX_STEPS { return Err(ictl_l10n::trf!( "steps 要有 1 到 {BATCH_MAX_STEPS} 步", "steps must have 1 to {BATCH_MAX_STEPS} steps" )); } - steps + let steps: Vec = steps .iter() .enumerate() .map(|(i, s)| { @@ -805,7 +808,23 @@ pub fn batch_steps(args: &Map) -> Result, String> { }; Ok(Step::Request { tool: tool.to_owned(), req }) }) - .collect() + .collect::>()?; + if !one_gesture { + return Ok(steps); + } + // 全是坐标点击才能并成一个手势:别的步骤(按名字点、等待、输入)都要在点之间看界面或花时间 + let points = steps + .iter() + .map(|s| match s { + Step::Request { req: Request::Tap { x, y }, .. } => Some((*x, *y)), + _ => None, + }) + .collect::>>() + .ok_or(ictl_l10n::tr!( + "one_gesture 只能用于步骤全是 iphone_tap(按坐标点)的批量", + "one_gesture only works when every step is iphone_tap (tap by coordinates)" + ))?; + Ok(vec![Step::Request { tool: "iphone_tap".into(), req: Request::TapSequence { points } }]) } /// tap_element 的结果是不是「没点到」(没找到、index 超出匹配个数、或整个被别的东西盖住) @@ -819,6 +838,7 @@ pub fn tap_missed(text: &str, outcome: Option) -> bool { pub fn wants_alert_check(req: &Request) -> bool { match req { Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } @@ -1203,6 +1223,28 @@ mod tests { with_lang(Lang::Zh, || assert!(has_cjk(instructions()))); } + /// one_gesture 把全是坐标点击的批量并成一个 TapSequence;混了别的步骤就报错,一步都不执行 + #[test] + fn one_gesture_turns_taps_into_one_sequence() { + let steps = batch_steps(&args(json!({"one_gesture": true, "steps": [ + {"tool": "iphone_tap", "x": 60, "y": 548}, + {"tool": "iphone_tap", "x": 23, "y": 548.5} + ]}))); + let req = Request::TapSequence { points: vec![(60.0, 548.0), (23.0, 548.5)] }; + assert_eq!(steps, Ok(vec![Step::Request { tool: "iphone_tap".into(), req }])); + for other in [ + json!({"tool": "iphone_tap_element", "text": "1"}), + json!({"tool": "wait", "seconds": 0.1}), + json!({"tool": "iphone_type_text", "text": "1"}), + ] { + let steps = json!({"one_gesture": true, "steps": [{"tool": "iphone_tap", "x": 1, "y": 2}, other]}); + assert!(batch_steps(&args(steps)).is_err()); + } + // without it a batch of taps stays step by step + let steps = batch_steps(&args(json!({"steps": [{"tool": "iphone_tap", "x": 1, "y": 2}]}))).unwrap(); + assert_eq!(steps, vec![Step::Request { tool: "iphone_tap".into(), req: Request::Tap { x: 1.0, y: 2.0 } }]); + } + #[test] fn alert_check_after_actions_but_not_buttons_or_reads() { assert!(wants_alert_check(&Request::Swipe { from: (0.0, 0.0), to: (1.0, 1.0), seconds: 0.3 })); diff --git a/crates/ictl-protocol/src/lib.rs b/crates/ictl-protocol/src/lib.rs index b9fe2e6..a6a29d3 100644 --- a/crates/ictl-protocol/src/lib.rs +++ b/crates/ictl-protocol/src/lib.rs @@ -43,6 +43,9 @@ pub fn default_socket() -> PathBuf { } } +/// [`Request::TapSequence`] 一个手势最多点几个点(同 `iphone_batch` 最多几步) +pub const MAX_SEQUENCE_POINTS: usize = 20; + #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TouchPhase { @@ -81,6 +84,10 @@ pub enum Request { x: f64, y: f64, }, + /// 依次点几个点,一个手势(`iphone_batch` 的 `one_gesture`):同一个键盘上连按。旧版本守护进程不认识,报错,不会只点一部分 + TapSequence { + points: Vec<(f64, f64)>, + }, TapElement { text: String, index: usize, @@ -417,6 +424,7 @@ impl Request { match self { Self::Tap { .. } | Self::TapElement { .. } + | Self::TapSequence { .. } | Self::LongPress { .. } | Self::Swipe { .. } | Self::TypeText { .. } @@ -907,6 +915,10 @@ mod tests { let s = serde_json::to_string(&r).unwrap(); assert!(s.starts_with(r#"{"op":"swipe""#), "{s}"); assert_eq!(serde_json::from_str::(&s).unwrap(), r); + let r = Request::TapSequence { points: vec![(60.0, 548.0), (23.0, 548.0)] }; + let s = serde_json::to_string(&r).unwrap(); + assert_eq!(s, r#"{"op":"tap_sequence","points":[[60.0,548.0],[23.0,548.0]]}"#); + assert_eq!(serde_json::from_str::(&s).unwrap(), r); let e: Response = serde_json::from_str(r#"{"kind":"error","message":"x"}"#).unwrap(); assert_eq!(e, Response::error("x")); } diff --git a/crates/ictl-wda/src/client.rs b/crates/ictl-wda/src/client.rs index f9d8c44..02b81f4 100644 --- a/crates/ictl-wda/src/client.rs +++ b/crates/ictl-wda/src/client.rs @@ -46,6 +46,8 @@ impl StallReason { const SCREEN_RECHECK: Duration = Duration::from_secs(60); /// 普通点击按下的时长(毫秒)。太短可能不被识别成点击;解锁按键另有自己的时长 const TAP_PRESS_MS: u64 = 50; +/// 一个手势里依次点几个点时,前一个抬起到后一个按下停多久(毫秒)。真机上 20、40、60 都没有漏键、多键 +pub const SEQUENCE_GAP_MS: u64 = 40; /// W3C pointer 动作的一步 #[derive(Debug, Clone, Copy, PartialEq)] @@ -72,6 +74,32 @@ pub fn swipe_steps(from: (f64, f64), to: (f64, f64), ms: u64) -> Vec Value { + let pause = |ms: u64| json!({"type": "pause", "duration": ms}); + let fingers: Vec = points + .iter() + .enumerate() + .map(|(k, &(x, y))| { + let mut actions = Vec::with_capacity(5 * k + 4); + for _ in 0..k { + actions.extend([pause(0), pause(0), pause(press_ms), pause(0), pause(gap_ms)]); + } + actions.extend([ + json!({"type": "pointerMove", "duration": 0, "x": x, "y": y}), + json!({"type": "pointerDown", "button": 0}), + pause(press_ms), + json!({"type": "pointerUp", "button": 0}), + ]); + json!({"type": "pointer", "id": format!("finger{}", k + 1), "parameters": {"pointerType": "touch"}, "actions": actions}) + }) + .collect(); + json!({"actions": fingers}) +} + /// `POST /session/{id}/actions` 的请求体 pub fn actions_body(steps: &[PointerStep]) -> Value { let actions: Vec = steps @@ -779,6 +807,14 @@ impl WdaClient { self.quick_gesture(&tap_steps(x, y, TAP_PRESS_MS), IdleSettings::NO_COOL_OFF).await } + /// 依次点几个点,一个手势([`tap_sequence_body`]):同一个键盘、键盘上连按时用。分开点每下都要等界面空闲, + /// 数字键盘上点 7 个键约 3.6 秒,一个手势约 1.9 秒。点的过程中界面变了(跳了页面)后面的点也照样点下去, + /// 所以只给点的时候布局不变的一串点用 + pub async fn tap_sequence(&mut self, points: &[(f64, f64)]) -> Result<()> { + let body = tap_sequence_body(points, TAP_PRESS_MS, SEQUENCE_GAP_MS); + self.quick_actions(body, IdleSettings::NO_COOL_OFF).await + } + /// 长按:按下、停 `seconds` 秒、抬起,一个 actions 手势。`/wda/touchAndHold` 前后都等界面空闲, /// 真机上主屏长按图标 1.2 秒要约 12 秒才返回。等待设置同 [`Self::tap`] pub async fn touch_and_hold(&mut self, x: f64, y: f64, seconds: f64) -> Result<()> { @@ -849,9 +885,13 @@ impl WdaClient { /// 发一个手势,期间把等待设置临时换成 `during`(见 [`Self::tap`]),做完恢复 async fn quick_gesture(&mut self, steps: &[PointerStep], during: IdleSettings) -> Result<()> { + self.quick_actions(actions_body(steps), during).await + } + + async fn quick_actions(&mut self, body: Value, during: IdleSettings) -> Result<()> { let baseline = self.baseline().await?; self.set_idle_settings(during).await?; - let r = self.actions(steps).await; + let r = self.post("/actions", body).await.map(drop); if let Err(e) = self.set_idle_settings(baseline).await { tracing::warn!( "{}", @@ -1237,6 +1277,28 @@ mod tests { assert_eq!(steps.iter().filter(|s| s["type"] == "pointerDown").count(), 1); } + /// 依次点几个点:每个点一根手指,第 k 根先空等前面的点按完;各手指的节拍数对得上,按下抬起一个接一个、不重叠 + #[test] + fn a_sequence_is_one_finger_per_point_in_turn() { + let body = tap_sequence_body(&[(10.0, 20.0), (30.0, 40.0), (50.0, 60.0)], 50, 40); + let fingers = body["actions"].as_array().unwrap(); + assert_eq!(fingers.len(), 3); + for (k, f) in fingers.iter().enumerate() { + let a = f["actions"].as_array().unwrap(); + assert_eq!(a.len(), 5 * k + 4, "finger {k}"); + // pauses only until its own turn, then move, down, hold, up at its point + assert!(a[..5 * k].iter().all(|s| s["type"] == "pause")); + assert_eq!(a[5 * k]["type"], "pointerMove"); + assert_eq!(a[5 * k]["x"].as_f64(), Some(10.0 + 20.0 * k as f64)); + assert_eq!(a[5 * k + 1]["type"], "pointerDown"); + assert_eq!(a[5 * k + 3]["type"], "pointerUp"); + assert_ne!(fingers[0]["id"], fingers[k.max(1)]["id"]); + } + // finger k waits 5 ticks per earlier point: move, down, hold, up, gap + assert_eq!(fingers[1]["actions"][2]["duration"], 50); + assert_eq!(fingers[1]["actions"][4]["duration"], 40); + } + #[tokio::test] async fn remote_error_keeps_first_line_and_unreachable_maps_to_unavailable() { let m = Mock::with(&[ diff --git a/crates/ictl-wda/src/lib.rs b/crates/ictl-wda/src/lib.rs index ede821c..3d0242f 100644 --- a/crates/ictl-wda/src/lib.rs +++ b/crates/ictl-wda/src/lib.rs @@ -9,7 +9,7 @@ pub mod elements; pub mod http; pub mod runner; -pub use client::{IdleSettings, Launch, WdaClient, swipe_steps, tap_steps}; +pub use client::{IdleSettings, Launch, SEQUENCE_GAP_MS, WdaClient, swipe_steps, tap_sequence_body, tap_steps}; pub use runner::WdaRunner; #[derive(Debug, thiserror::Error)] diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index 5f0a9f3..b48e9e6 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -149,3 +149,4 @@ | 143 | 原生:Spotlight 打开时选中上次的搜索词,再粘贴同样的词会把它替换成自己,输入框的值不变,`iphone_type_text` 报「粘贴了…但输入框里没有这段文字」(带 `submit` 时还不按回车),其实已经输进去了 | 「允许粘贴」点过之后,输入框原来就有这段文字、1.5 秒不变,算输入成功并提示截图确认;没点过「允许粘贴」时仍报错 | 单测 `a_paste_that_replaced_the_same_text_is_told_apart_from_one_that_missed` + 真机(Spotlight 留着「设置」时再输入「设置」,`run.py` 连跑两遍);真机脚本 `scenarios.py typing` | | 144 | 设备闲置时自动锁屏,下一个操作先自动解锁(iPad 经 WDA 约 15 秒,iPhone 原生约 9 秒),结果和事件日志都没说,看着像「切换设备后第一个操作慢」 | 结果第一行(截图在说明里、出错时在报错里)写「手机锁着,先自动解锁了,用时 X 秒」,事件日志记「已自动解锁」 | 单测 `an_unlock_first_is_said_on_the_answers_first_line` + 真机(锁屏后按名字点击、截图,两台设备);真机脚本 `scenarios.py lock` | | 145 | WDA 的短探测已正常应答或返回远端错误,却不清零超时计数,三个独立慢请求仍会触发重启;连接失败反而清零。日志还把长请求和短探测均未应答写成「连续 3 次」、宣称尚未检查的 `/status` 正常,请求超时本身缺端点日志 | 只有正常响应或远端错误清零,连接失败不清零;连续无应答和长请求后的失败探测分别记录原因及实际次数;超时诊断记录方法、短路径和耗时,不记录查询参数或正文 | 单测 `answered_probe_resets_stall_count_after_each_slow_request`、`connection_error_does_not_reset_unanswered_count`、`long_request_and_failed_probe_keep_the_actual_count_and_reason`、`three_short_unanswered_requests_report_a_consecutive_stall`、`answered_session_delete_does_not_mask_a_failed_probe`、`failed_request_log_keeps_endpoint_and_time_without_query`、`successful_request_log_does_not_include_response_body`;真机:同一 iPad、同一 WDA,把只读业务请求的客户端时限缩短到 20ms,短探测保留 5s,对照修复前后各 3 轮 | +| 148 | 输入框不接受 `iphone_type_text`(应用内网页里的输入框),只能逐个点键盘上的键:`iphone_batch` 每步都等界面空闲,7 个键 3.6 秒;把同一根手指在一个手势里挪到各个键上点,每个键会被按两次 | `one_gesture: true` 把全是 `iphone_tap` 的批量并成一个 W3C 手势,每个点一根手指,第 k 根先空等前面的点按完再按(间隔 0.04 秒),中间不等界面空闲;混了别的步骤直接报错、一步都不执行;没有 WDA 时退回逐个点 | 单测 `one_gesture_turns_taps_into_one_sequence`、`a_sequence_is_one_finger_per_point_in_turn` + 真机(iPhone 12 mini,iOS 26.4.1,Spotlight 数字键盘 7/16/20 位、字母键盘 10 个字母,各重复 3~5 次读回输入框的值全对)| diff --git a/docs/tools.md b/docs/tools.md index c7ae63c..fa79f4b 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -96,6 +96,8 @@ Without `then`, the result still warns when a system alert covers the screen, be Steps run in order. The batch stops at the first error or the first `iphone_tap_element` that finds nothing, and reports which step it stopped at. `then` applies once, after the last step. `reuse_elements: true` lets `iphone_tap_element` reuse the element tree from the last 10 seconds; use it only when the steps don't change the layout (for example pressing keys on the same keypad). +`one_gesture: true` is for a batch made only of `iphone_tap` steps: the points are tapped one after another in a single WDA gesture, one finger per point, about 0.04 s apart, with no wait for the interface in between. Use it to press keys on one keyboard when a field doesn't take `iphone_type_text` (some in-app web views only take key taps): on an iPhone 12 mini, 7 digit keys took 1.9 s instead of 3.6 s, 20 took 4.6 s instead of 9.6 s. Nothing is checked between the taps, so check the result afterwards with `then` or a screenshot. Any other kind of step in the batch is an error and nothing runs. Without WDA it falls back to tapping the points one by one. + If the MCP client cancels the call, the remaining steps don't run; a request still queued for the device is dropped too. If no device was selected and the controlled device changes during a batch (for example it was unplugged and another one took over), the batch stops with an error. ```json diff --git a/website/en/guide/tools.md b/website/en/guide/tools.md index c863000..96840b4 100644 --- a/website/en/guide/tools.md +++ b/website/en/guide/tools.md @@ -26,7 +26,7 @@ With [auto-unlock](./auto-unlock) on, `iphone_screenshot`, `iphone_list_elements | `iphone_press_button` | `home`, `volume_up`, `volume_down`, `lock` | | `iphone_launch_app` / `iphone_terminate_app` | Launch / quit an app by name (e.g. `设置`) or bundle id | | `iphone_open_url` | Open a link or URL scheme | -| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error. If the MCP client cancels the call, the remaining steps don't run; with no device selected, it also stops with an error if the controlled device changes | +| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error. When every step is a coordinate tap, `one_gesture` taps them in turn within one gesture, for pressing keys on one keyboard. If the MCP client cancels the call, the remaining steps don't run; with no device selected, it also stops with an error if the controlled device changes | ## Several devices diff --git a/website/guide/tools.md b/website/guide/tools.md index 08bf887..10c76cb 100644 --- a/website/guide/tools.md +++ b/website/guide/tools.md @@ -26,7 +26,7 @@ MCP 服务提供 17 个工具,开启[开发者工具](#开发者工具-显式 | `iphone_press_button` | `home`、`volume_up`、`volume_down`、`lock` | | `iphone_launch_app` / `iphone_terminate_app` | 启动 / 结束 App,可以用名字(如「设置」)或 Bundle ID | | `iphone_open_url` | 打开链接或 URL Scheme | -| `iphone_batch` | 一次执行最多 20 步,出错就停。MCP 客户端取消调用时,剩下的步骤不再执行;没选定设备时,执行中控制的设备变了也会停下报错 | +| `iphone_batch` | 一次执行最多 20 步,出错就停。步骤全是坐标点击时,`one_gesture` 把它们放进一个手势里依次点完,适合在同一个键盘上连按。MCP 客户端取消调用时,剩下的步骤不再执行;没选定设备时,执行中控制的设备变了也会停下报错 | ## 接着多台设备