Skip to content

fix: request checks and protocol edges (review P1-1) - #200

Merged
Derrors merged 2 commits into
mainfrom
fix/p1-protocol
Nov 25, 2026
Merged

Derrors merged 2 commits into
mainfrom
fix/p1-protocol

Conversation

@Derrors

@Derrors Derrors commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

What and why

P1, first batch, from the full review of main after #195: request checks and protocol edges in the daemon.

  • PressButton and alerts: Home that finds a system alert in the way reported it in the text, but Outcome::alert_reported stayed false, unlike LaunchApp and OpenUrl: a protocol client reading Outcome missed it (the MCP server doesn't check for alerts after a button anyway, so it wasn't affected). press_button and native_home now return (text, alert reported); the four returns that report one say true.

  • long_press and HID: on Route::Hid, or when WDA answers Unavailable, it reported WDA down where a tap falls back to HID. Now it falls back the same way (not for a point measured on the page's view through WDA), and says "(via HID)" as the other gestures do.

  • Checked before the lock: Tap.count (1–10), TapSequence.points (1–20, finite), PressButton.button (known names), and finite coordinates for Tap, LongPress and Swipe are checked in check_request. Before, such a request queued for the device lock and dropped the cached element tree first.

  • Touch Prepare (the page opens the HID session ahead of the finger) is no longer a device action:

    • not refused while a task runs;
    • not the user acting under takeover;
    • no cache drop and no quiet-period start.

    Also, touch_rotation is cleared once an up was sent, not before it: an up refused for its point leaves the finger down, to be lifted by the next one (review of fix: low-level crates (review P0-C) #198).

  • ScrollCollect and unknown fields: it no longer has deny_unknown_fields. Keys that apply to every request sit beside its fields, so a key a newer client adds would have made an older daemon refuse this request alone. This loosens the assertion added with it in Report input delivery and collect list rows across screens #170: an unknown key is now ignored, as for every other request; a wrong type in its own fields is still an error.

  • Small ones:

    • a stored passcode needs at least 4 digits, as passcode set asks; entering it relies on that;
    • Persisted::save writes nothing when serializing fails, instead of an empty state.json;
    • NotifyConfig's Debug shows only whether each key is set.

Tests

1. Unit tests

  • cargo test --workspace --all-features --locked: 580 passed; clippy -D warnings; cargo fmt --check for all 11 packages; tests/check_regression_cases.py: 0 missing
  • New: hopeless_requests_are_refused_up_front, getting_ready_for_a_touch_is_not_acting, notification_keys_stay_out_of_debug_output; added to others_may_look_but_not_act_until_the_user_takes_over (Prepare), missing_or_non_digit_passcode (3 digits)
  • Changed on purpose: raw_scroll_collect_validates_scope_and_bounds now asserts an unknown key is ignored and a wrongly typed field is refused (it asserted unknown keys fail)

2. Real-device regression

  • iPhone 15 Pro Max (iPhone16,2) iOS 27.2.1, native control; Debian 12
  • tests/device/run.py: 16 calls, 0 failed

3. Regression cases

4. Real-device proof

  • tap with count 0, press_button power, an empty tap_sequence: refused at once (0.00 s, not_sent/preflight)
  • scroll_collect with an extra top-level key: run
  • long_press and Home: as before
  • While a task held the phone: a page's touch prepare went through, a down was refused as before
  • Not tried: Home under a system alert (the alerts I could raise, a phone call or FaceTime prompt, risk placing a call); Route::Hid (neither test device takes it: iOS 27 is native, the iPad on iOS 26 has no HID fallback)

Checklist

  • MCP tool names, parameters and default outputs stay compatible (D10)
  • No new dependencies
  • CHANGELOG.md and CHANGELOG.zh-CN.md (Unreleased)
  • No private data in the outputs above

🤖 Generated with Claude Code

Derrors and others added 2 commits November 25, 2026 22:08
- PressButton sets Outcome::alert_reported when it reports a system alert
- long_press falls back to HID like a tap (Route::Hid, WDA unreachable)
- Tap count, TapSequence points, PressButton's button and non-finite
  coordinates are checked before the device lock and the cache drop
- Touch Prepare isn't a device action: not refused during a task, not the
  user acting under takeover; touch_rotation is cleared once an up was sent
- ScrollCollect no longer denies unknown fields (forward compatibility)
- a stored passcode needs 4 digits; state.json isn't replaced by an empty
  file when it doesn't serialize; NotifyConfig's Debug hides the keys

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MCP server never checked for alerts after a button (wants_alert_check),
so the fix fills Outcome::alert_reported for protocol clients; the changelog
and regression case said otherwise. A long press done by HID in WDA's place
says so, as the other gestures do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit aa2842f into main Nov 25, 2026
7 checks passed
@Derrors
Derrors deleted the fix/p1-protocol branch November 25, 2026 14:45
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.

1 participant