Skip to content

Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools

fix(viewer): a swipe on the control page doesn't wait for the list to stop (#108)

Qinghe Li278ddc177884
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0339ad..0bc0a51 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ All notable changes to this project are documented here. The format is based on
### Fixed
+- A swipe on the control page through WDA no longer waits for the list to stop before answering (reading the element tree again and again, up to 2.5 s): the person at the page sees it. On an iPad mini 5 a swipe took 3.1 s, now 1.6–2.3 s. Agents (MCP, CLI) still wait, so their next tap doesn't land on a moving list.
- The way Home and locking work on each device is kept in `state.json` instead of only in memory. After the daemon restarted, or another device was controlled meanwhile, the first Home on a device where IOHID's Home doesn't work tried it, waited 2 s for the home screen and pressed again: 4.4 s instead of 0.8 on an iPad mini 5.
## [0.2.6] - 2026-11-14
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index 7d9798e..0454519 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -8,6 +8,7 @@
### 修复
+- 控制台上经 WDA 的滑动不再等列表停下才返回(原来要反复读元素树,最多 2.5 秒):页面前的人看得见。iPad mini 5 上一次滑动从 3.1 秒降到 1.6–2.3 秒。Agent(MCP、命令行)仍然等,免得下一次点击落在还在滚的列表上。
- 每台设备按 Home 和锁屏该用哪种方式,现在记在 `state.json` 里,不再只放在内存。原来守护进程重启或中途控制过别的设备后,在 IOHID 的 Home 不起作用的设备上,第一次按 Home 会先用 IOHID 按,等 2 秒没回到主屏幕再补按一次:iPad mini 5 上要 4.4 秒,平时 0.8 秒。
## [0.2.6] - 2026-11-14
diff --git a/crates/ictl-daemon/src/core.rs b/crates/ictl-daemon/src/core.rs
index 4281bb3..46d6e43 100644
--- a/crates/ictl-daemon/src/core.rs
+++ b/crates/ictl-daemon/src/core.rs
@@ -1085,7 +1085,7 @@ impl Daemon {
})
}
Request::LongPress { x, y, seconds } => self.long_press(g, x, y, seconds, view).await,
- Request::Swipe { from, to, seconds } => self.swipe(g, from, to, seconds, view).await,
+ Request::Swipe { from, to, seconds } => self.swipe(g, from, to, seconds, view, watched).await,
Request::TypeText { text, submit } => self.type_text(g, &text, submit).await,
Request::PressButton { button } => self.press_button(g, &button, watched).await,
Request::Touch { phase, x, y } => {
diff --git a/crates/ictl-daemon/src/tools/input.rs b/crates/ictl-daemon/src/tools/input.rs
index e999777..05283cd 100644
--- a/crates/ictl-daemon/src/tools/input.rs
+++ b/crates/ictl-daemon/src/tools/input.rs
@@ -231,6 +231,7 @@ impl Daemon {
to: (f64, f64),
seconds: f64,
view: Option<&str>,
+ watched: bool,
) -> crate::error::Result<String> {
self.prepare_coordinates(g, view, true).await?;
let desc = format!("({},{}) → ({},{})", fmt_g(from.0), fmt_g(from.1), fmt_g(to.0), fmt_g(to.1));
@@ -238,6 +239,12 @@ impl Daemon {
match w.swipe_into_polling(from, to, (seconds * 1000.0) as u64).await {
// 滑动请求不等惯性滚动(等的话设置不对能卡十几秒),这里等列表停下再返回:
// 列表还在滚时下一次点击只会让它停住,点不到东西
+ // someone watches the screen ([`crate::protocol::WATCHED`]): they see when it stops
+ Ok(()) if watched => {
+ w.end_polling().await;
+ g.swiped_tree = None;
+ return Ok(ictl_l10n::trf!("已滑动 {desc}", "Swiped {desc}"));
+ }
Ok(()) => {
let vertical = (to.1 - from.1).abs() >= (to.0 - from.0).abs();
let (note, tree) = wait_scrolled(w, vertical).await;
diff --git a/crates/ictl-daemon/src/tools/mod.rs b/crates/ictl-daemon/src/tools/mod.rs
index f89368e..3eaf282 100644
--- a/crates/ictl-daemon/src/tools/mod.rs
+++ b/crates/ictl-daemon/src/tools/mod.rs
@@ -419,7 +419,7 @@ mod tests {
let down = |e: &str| e.contains("没有 HID 后备路线") || e.contains("no HID fallback");
let tap = d.tap(&mut g, 20., 50., None).await.unwrap_err().to_string();
assert!(down(&tap), "{tap}");
- let swipe = d.swipe(&mut g, (20., 50.), (20., 300.), 0.3, None).await.unwrap_err().to_string();
+ let swipe = d.swipe(&mut g, (20., 50.), (20., 300.), 0.3, None, false).await.unwrap_err().to_string();
assert!(down(&swipe), "{swipe}");
// a finger: the same, and the page may still send the whole gesture once WDA is back
match d.touch(&mut g, TouchPhase::Down, 20., 50., None).await {
diff --git a/crates/ictl-protocol/src/lib.rs b/crates/ictl-protocol/src/lib.rs
index cca0cab..768b20f 100644
--- a/crates/ictl-protocol/src/lib.rs
+++ b/crates/ictl-protocol/src/lib.rs
@@ -663,7 +663,8 @@ pub const LANG: &str = "lang";
pub const BACKGROUND: &str = "background";
/// Request key: someone watches the screen (the control page), so the daemon doesn't look before acting for what they
/// see anyway. Pressing Home skips the alert lookup that comes first (0.8 s of a 1.3 s press on the home screen) and
-/// looks only when the press didn't get to the home screen
+/// looks only when the press didn't get to the home screen; a swipe through WDA doesn't wait for the list to stop (up
+/// to 2.5 s of reading the element tree again and again, 3.1 s for a swipe on an iPad mini 5)
pub const WATCHED: &str = "watched";
/// Request key of a [`Request::ScreenStream`]: the page is in low-bandwidth mode, so the phone's video is capped at a
/// lower bitrate while it watches (for every page watching that phone: there is one stream). Older daemons ignore it
@@ -708,7 +709,8 @@ pub async fn call_watched(
exchange_on(socket, req, timeout, expect_udid, None, Some(WATCHED)).await
}
-/// Send a coordinate action only if this device and its measured geometry still match.
+/// Send a coordinate action only if this device and its measured geometry still match. Only the control page sends
+/// these, so they say someone watches the screen ([`WATCHED`])
pub async fn call_in_view(
socket: &std::path::Path,
req: &Request,
@@ -716,7 +718,7 @@ pub async fn call_in_view(
udid: &str,
view: &str,
) -> std::io::Result<Response> {
- exchange_on(socket, req, timeout, Some(udid), Some(view), None).await
+ exchange_on(socket, req, timeout, Some(udid), Some(view), Some(WATCHED)).await
}
async fn exchange_on(