Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools
Rust ai-agentautomationclaudeclaude-codedockeriosiphonelinuxmcpmcp-servermodel-context-protocolrustwebdriveragent
fix(elements): drop scroll bars in any system language (#31)
TheSalaty0f099c2adb6f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cfac95d..1e57618 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,10 @@ All notable changes to this project are documented here. The format is based on- The MCP server sends its language with each request and the daemon answers in it; requests from older clients carry none and get Chinese as before, so mixed versions during an upgrade keep working.- Text responses carry an optional `outcome` (`tapped_nothing`, `alert_reported`), so the MCP server no longer reads result text to stop a batch after a missed tap or to skip the extra alert check. Responses without it (older daemons) are still recognised by their Chinese prefixes.+### Fixed++- Scroll bars are dropped from element lists in every system language, not only Chinese and English: they are recognised by their percentage value and thin shape instead of their label. On a German iPhone, for example, lines like `Other "Vertikaler Rollbalken, 1 Seite"` no longer appear.+## [0.1.4] - 2026-11-07### Securitydiff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.mdindex c34aecd..107d8b4 100644--- a/CHANGELOG.zh-CN.md+++ b/CHANGELOG.zh-CN.md@@ -12,6 +12,10 @@- MCP 在每个请求里带上自己的语言,守护进程按它回答;旧版本客户端的请求不带语言,照旧用中文,升级过程中新旧版本混用也不受影响。- 文字响应带可选的 `outcome`(`tapped_nothing`、`alert_reported`),MCP 端据此在没点到时停下批量、跳过多余的弹窗检查,不再从结果文字里认;没有这个字段的响应(旧版本守护进程)照旧按中文开头认。+### 修复++- 任何系统语言下元素列表都会去掉滚动条,不再只认中文和英文:改按百分比的值和细长的形状认,不看标签。例如德语 iPhone 上不再出现 `Other "Vertikaler Rollbalken, 1 Seite"` 这样的行。+## [0.1.4] - 2026-11-07### 安全diff --git a/crates/ictl-wda/src/elements.rs b/crates/ictl-wda/src/elements.rsindex 69fe914..8a4c510 100644--- a/crates/ictl-wda/src/elements.rs+++ b/crates/ictl-wda/src/elements.rs@@ -312,8 +312,25 @@ fn looks_like_identifier(s: &str) -> bool {s.len() >= 3 && s.is_ascii() && !s.contains(char::is_whitespace) && s.contains(['_', '-', '.', ':'])}-fn is_scroll_bar(kind: &str, label: &str) -> bool {- kind == "Other" && (label.contains("滚动条") || label.to_lowercase().contains("scroll bar"))+/// A scroll bar: an `Other` whose value is the scroll position as a percentage and that is a thin strip+/// (about 30 points across). Its label depends on the system language ("垂直滚动条, 1页",+/// "Vertikaler Rollbalken, 1 Seite", …), so the label is only an extra hint for Chinese and English+fn is_scroll_bar(kind: &str, label: &str, value: &str, size: (f64, f64)) -> bool {+ if kind != "Other" {+ return false;+ }+ if label.contains("滚动条") || label.to_lowercase().contains("scroll bar") {+ return true;+ }+ let thin = size.0.min(size.1);+ is_percentage(value) && thin > 0.0 && thin <= 32.0+}++/// "0%", "73 %" (with a no-break space in German and French), "%40" (Turkish)+fn is_percentage(v: &str) -> bool {+ let v = v.trim();+ let n = v.strip_suffix('%').or_else(|| v.strip_prefix('%')).map(str::trim);+ n.is_some_and(|n| !n.is_empty() && n.chars().all(char::is_numeric))}/// 超长文字截断显示(筛选、按名字点仍按全文)@@ -468,7 +485,7 @@ pub fn parse_tree(xml: &str, view: impl Into<View>) -> Tree {let (vx1, vy1) = (scr.x.max(0.0), scr.y.max(0.0));let visible = Rect { x: vx1, y: vy1, w: (scr.x + scr.w).min(sw) - vx1, h: (scr.y + scr.h).min(sh) - vy1 };let text = [&label, &name, &value].into_iter().find(|s| !s.is_empty()).cloned();- let scroll_bar = is_scroll_bar(&kind, &label);+ let scroll_bar = is_scroll_bar(&kind, &label, &value, (raw.w, raw.h));if kind == "ActivityIndicator" && onscreen {tree.loading = true;}@@ -740,6 +757,8 @@ mod tests {const HOME_WIDGETS_IOS27: &str = include_str!("../tests/fixtures/home-widgets-ios27.xml");const WALLET_IOS27: &str = include_str!("../tests/fixtures/settings-wallet-ios27.xml");const IPAD_TOUCHID: &str = include_str!("../tests/fixtures/ipad-touchid-landscape.xml");+ /// iPhone 15, iOS 27.2, German: Clock → Stopwatch, with four scroll bars labelled "… Rollbalken"+ const CLOCK_DE_IOS27: &str = include_str!("../tests/fixtures/clock-stopwatch-de-ios27.xml");const IPAD_PIN: &str = include_str!("../tests/fixtures/ipad-passcode-landscape.xml");const IPAD_LOCK_P: &str = include_str!("../tests/fixtures/ipad-lockscreen-portrait.xml");const IPAD_TOUCHID_P: &str = include_str!("../tests/fixtures/ipad-touchid-portrait.xml");@@ -844,6 +863,30 @@ mod tests {assert!(!labels(&parse(SETTINGS_IOS27, SCREEN)).iter().any(|l| l.contains("滚动条")));}+ /// Scroll bars are recognised by shape and value, not by their label, so they are dropped in any+ /// system language (here German, with "0\u{a0}%" as the value)+ #[test]+ fn scroll_bars_are_dropped_in_any_language() {+ let els = parse(CLOCK_DE_IOS27, ScreenSize { width: 393.0, height: 852.0 });+ let l = labels(&els);+ assert!(!l.iter().any(|l| l.contains("Rollbalken")), "{l:?}");+ assert!(l.iter().any(|l| l == "Stoppuhr") && l.iter().any(|l| l == "Start"), "{l:?}");+ assert!(els.iter().any(|e| e.kind == "PageIndicator"), "a percentage-free value stays");+ }++ #[test]+ fn percentages_in_several_locales() {+ for v in ["0%", "73%", "100 %", "0\u{a0}%", "0\u{202f}%", "%40"] {+ assert!(is_percentage(v), "{v:?}");+ }+ for v in ["", "%", "1", "Seite 1 von 2", "50% off", "1,5 %"] {+ assert!(!is_percentage(v), "{v:?}");+ }+ assert!(!is_scroll_bar("Other", "Akku", "80 %", (60.0, 120.0)), "too wide for a scroll bar");+ assert!(!is_scroll_bar("Slider", "Lautstärke", "50 %", (300.0, 30.0)), "only Other");+ assert!(is_scroll_bar("Other", "Barre de défilement verticale, 1 page", "0\u{202f}%", (30.0, 700.0)));+ }+/// 真机:设置首页往上滑后,「钱包与Apple Pay」那一行(832~886)被底部悬浮搜索栏盖住:/// 栏的底板从 856 起,实际吞点击的范围再往上约 20 点,露出来的部分点不中#[test]diff --git a/crates/ictl-wda/tests/fixtures/clock-stopwatch-de-ios27.xml b/crates/ictl-wda/tests/fixtures/clock-stopwatch-de-ios27.xmlnew file mode 100644index 0000000..98a3f89--- /dev/null+++ b/crates/ictl-wda/tests/fixtures/clock-stopwatch-de-ios27.xml@@ -0,0 +1,129 @@+<?xml version="1.0" encoding="UTF-8"?>+<XCUIElementTypeApplication type="XCUIElementTypeApplication" name="Uhr" label="Uhr" x="0" y="0" width="393" height="852" processId="3777" bundleId="com.apple.mobiletimer">+ <XCUIElementTypeWindow type="XCUIElementTypeWindow" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeScrollView type="XCUIElementTypeScrollView" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="99"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="719" width="393" height="133"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="59" width="393" height="574">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="59" width="393" height="292">+ <XCUIElementTypeScrollView type="XCUIElementTypeScrollView" x="0" y="59" width="393" height="292">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="59" width="393" height="292">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="0 Sekunden" name="stopwatch-time" label="0 Sekunden" x="0" y="152" width="393" height="106"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Vertikaler Rollbalken, 2 Seiten" label="Vertikaler Rollbalken, 2 Seiten" x="-33" y="59" width="30" height="292">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="-6" y="20" width="3" height="36"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeScrollView>+ </XCUIElementTypeOther>+ <XCUIElementTypeImage type="XCUIElementTypeImage" x="15" y="392" width="86" height="86"/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Runde" label="Runde" x="16" y="393" width="84" height="84">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Runde" name="Runde" label="Runde" x="33" y="424" width="50" height="21"/>+ </XCUIElementTypeButton>+ <XCUIElementTypeImage type="XCUIElementTypeImage" x="292" y="392" width="86" height="86"/>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Start" label="Start" x="293" y="393" width="84" height="84">+ <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Start" name="Start" label="Start" x="316" y="424" width="38" height="21"/>+ </XCUIElementTypeButton>+ <XCUIElementTypePageIndicator type="XCUIElementTypePageIndicator" value="Seite 1 von 2, Digitale Stoppuhr" x="169" y="422" width="56" height="31"/>+ <XCUIElementTypeTable type="XCUIElementTypeTable" name="Leere Liste" label="Leere Liste" x="0" y="493" width="393" height="140">+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Vertikaler Rollbalken, 1 Seite" label="Vertikaler Rollbalken, 1 Seite" x="360" y="493" width="30" height="140">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="387" y="623" width="3" height="7"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Horizontaler Rollbalken, 1 Seite" label="Horizontaler Rollbalken, 1 Seite" x="0" y="600" width="393" height="30">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="3" y="627" width="387" height="3"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeTable>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Vertikaler Rollbalken, 1 Seite" label="Vertikaler Rollbalken, 1 Seite" x="360" y="59" width="30" height="710">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="387" y="759" width="3" height="7"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Horizontaler Rollbalken, 1 Seite" label="Horizontaler Rollbalken, 1 Seite" x="55" y="736" width="283" height="30">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="383" y="763" width="7" height="3"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Vertikaler Rollbalken, 1 Seite" label="Vertikaler Rollbalken, 1 Seite" x="360" y="59" width="30" height="710">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="387" y="759" width="3" height="7"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" value="0 %" name="Horizontaler Rollbalken, 1 Seite" label="Horizontaler Rollbalken, 1 Seite" x="55" y="736" width="283" height="30">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="383" y="763" width="7" height="3"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeScrollView>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeToolbar type="XCUIElementTypeToolbar" name="Toolbar" label="Symbolleiste" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852"/>+ </XCUIElementTypeToolbar>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="0" width="393" height="852">+ <XCUIElementTypeTabBar type="XCUIElementTypeTabBar" name="Tableiste" label="Tableiste" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="21" y="769" width="351" height="62">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="21" y="769" width="93" height="54"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="21" y="769" width="351" height="62">+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Weltuhr" label="Weltuhr" x="25" y="773" width="93" height="54">+ <XCUIElementTypeImage type="XCUIElementTypeImage" name="globe" label="Globus" x="57" y="779" width="28" height="28"/>+ </XCUIElementTypeButton>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Wecker" label="Wecker" x="108" y="773" width="94" height="54">+ <XCUIElementTypeImage type="XCUIElementTypeImage" name="alarm.fill" label="Wecker" x="141" y="778" width="27" height="28"/>+ </XCUIElementTypeButton>+ <XCUIElementTypeButton type="XCUIElementTypeButton" value="1" name="Stoppuhr" label="Stoppuhr" x="191" y="773" width="94" height="54">+ <XCUIElementTypeImage type="XCUIElementTypeImage" name="stopwatch.fill" label="Stoppuhr" x="224" y="777" width="28" height="30"/>+ </XCUIElementTypeButton>+ <XCUIElementTypeButton type="XCUIElementTypeButton" name="Timer" label="Timer" x="275" y="773" width="93" height="54">+ <XCUIElementTypeImage type="XCUIElementTypeImage" name="timer" label="Timer" x="307" y="779" width="29" height="28"/>+ </XCUIElementTypeButton>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="21" y="769" width="351" height="62"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54"/>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54"/>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="191" y="773" width="94" height="54"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeTabBar>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83">+ <XCUIElementTypeOther type="XCUIElementTypeOther" x="0" y="769" width="393" height="83"/>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeOther>+ </XCUIElementTypeWindow>+</XCUIElementTypeApplication>