Repository navigation
Report input delivery and collect list rows across screens - #170
Conversation
Derrors
left a comment
There was a problem hiding this comment.
Review notes (each checked against 95fe042). 5 behaviour issues, 4 nits.
Should fix before merge
input.rsverify_typed: trailing\ncan be re-sent → Return pressed twice (duplicate sends in chat apps).native.rs: “Allow Paste” is tapped only once; a missed first tap leads to a timeout.native.rs: paste check no longer trims, so text with a trailing newline/space is reported as failed although it was typed.http.rs:Writeclassification applies to read-only WDA requests, removing the HID/native fallback (type_text,replace, unlock check).input.rsmissing_suffix: digit fields with display spaces are no longer repaired.
Nits: bridge reports unknown for definitely-unsent requests; tap_element scroll errors overwritten as not_sent; scroll_collect drops partial rows on interruption; doubled punctuation in input error suffix.
The overall direction (delivery separate from readback, multi-viewport collection) looks good.
| // 剩下的一个字一个字慢慢补 | ||
| let rest: Vec<char> = text.chars().skip(k).collect(); | ||
| for c in &rest { | ||
| let Some(rest) = missing_suffix(before, &reads[0], &reads[1], text) else { |
There was a problem hiding this comment.
Return can be sent twice for text ending in a control character (WDA path).
type_text("hi\n") into a single-line field that keeps focus and content after Return: the field reads back "hi", so newly_typed fails (length differs). Both reads are stable, so missing_suffix("", "hi", "hi", "hi\n") returns "\n", and the loop below sends "\n" again. In a chat app this sends the message twice. On main the whitespace-insensitive squash comparison treated this as success.
Suggestion: never repair whitespace/control characters. E.g. bail out (Typed::Unknown) when rest contains any control char, or only repair visible characters.
| self.native_tap(g, x, y).await?; | ||
| let screen = self.ax_snapshot(g, AX_WAIT, true).await.map_err(Error::readback)?; | ||
| let tree = self.snapshot_tree(g, &screen).await.map_err(Error::readback)?; | ||
| if answered.is_none() |
There was a problem hiding this comment.
“Allow Paste” is now tapped at most once.
On main the prompt was tapped on every iteration it was visible. With answered.is_none(), if the first HID tap doesn't take (prompt still animating in, or the prompt reappears), the loop never taps again and waits out PASTE_WAIT, then reports Pasted::Missing with the prompt still on screen.
Suggestion: keep tapping while the prompt is present; if the goal is to avoid hammering, rate-limit by time since answered instead of tapping only once.
| PasteTarget::Append(old) => { | ||
| paste_seen(elements::field_values(&tree.elements).as_deref(), old, text.trim()) | ||
| PasteTarget::Append(Some((object, old))) => { | ||
| append_seen(focused_text_field(&screen), object, old, text) |
There was a problem hiding this comment.
Paste verification dropped the text.trim() from main.
newly_typed requires the field to grow by exactly text.len() bytes. A single-line field strips newlines (and some fields trim surrounding spaces), so native type_text("北京\n") shows 北京, paste_seen returns Missing, and after PASTE_WAIT the call fails with a readback error even though the text went in. submit is also skipped.
Suggestion: normalise leading/trailing whitespace and newlines (as main did with trim()) before the newly_typed check.
| sock.write_all(&req).await.map_err(not_sent)?; | ||
| sock.flush().await.map_err(not_sent)?; | ||
| // After writing starts, a failed write/flush isn't evidence that the phone didn't act. | ||
| let write_failed = |e: std::io::Error| std::io::Error::new(WRITE_FAILED, e); |
There was a problem hiding this comment.
Write failures are now WdaError::Write for read-only requests too.
Before, a failed write/flush mapped to NotConnected → Unavailable, which read-only callers treat as "WDA not reachable, fall back". Now every request gets Write, including GET /wda/keyboard, focused_field, element-tree reads, and the lock check in ictl-unlock:
type_text:keyboard_shown()returningWriteis no longer theUnavailablearm, so it fails instead of falling back to HID/native.wda_replace:untouchedonly treatsUnavailableas untouched, soWritebecomes a preflight failure.ictl-unlock::ensure_unlocked:Unavailable→NotLocked, butWritenow propagates as an error.
A request that didn't fully write can't have been executed by a request that only reads, so it's safe to keep those as Unavailable. Suggestion: only classify as Write when acts(method, path); or have read-only callers treat Write like Unavailable.
| let want = squash(text); | ||
| values.iter().any(|v| squash(v).contains(&want)) | ||
| /// Repair only an observed append of the exact leading characters, stable across two fresh reads. | ||
| pub(super) fn missing_suffix<'a>(before: &str, first: &str, second: &str, text: &'a str) -> Option<&'a str> { |
There was a problem hiding this comment.
Digit fields with display spacing are no longer repaired.
newly_typed strips whitespace for all-digit text, but missing_suffix uses the raw strings. A phone field formatted as 138 0013 8 never matches strip_prefix against 13800138000, so a dropped tail becomes Mismatch instead of being re-typed. main's typed_prefix squashed first and repaired this.
Suggestion: when text is all ASCII digits, strip whitespace from before/first/second before computing the suffix.
| @@ -123,7 +123,23 @@ impl Link { | |||
| if let Err(e) = self.send(&msg, id.as_ref()).await { | |||
| match id { | |||
| Some(id) => { | |||
There was a problem hiding this comment.
nit: every send() failure for an input tool is reported as delivery: unknown, stage: transport, including cases where the remote certainly didn't act: r.send() failing to connect, or a non-2xx status such as 401/403/404 from remote::failure. The agent is then told to inspect the screen when it could simply fix auth and retry. Consider returning a distinct error from send() for "request not delivered / rejected" and mapping that to not_sent.
| break; | ||
| } | ||
| let next = Box::pin(self.search_scroll(g, s.down)).await?; | ||
| let next = Box::pin(self.search_scroll(g, s.down)).await.map_err(Error::preflight)?; |
There was a problem hiding this comment.
nit: .map_err(Error::preflight) wraps whatever search_scroll returned into not_sent/preflight, discarding its own classification (e.g. a WDA Write/Timeout swipe is unknown). After one or more scrolls the screen has already moved, so not_sent tells the agent it's safe to repeat from scratch. Same for the scroll-back at the !s.down call below. Suggestion: once scrolled > 0 (or always for the swipe itself), propagate the original Error::Action instead of overriding it.
| if !may_continue() { | ||
| return Err(ictl_l10n::trf!( | ||
| "滚动已中断,已滑动 {scrolls} 次", | ||
| "Collection interrupted after {scrolls} scrolls" |
There was a problem hiding this comment.
nit: on pause / cancel / takeover this returns a plain Msg error, so the rows already collected (and scrolls) are lost and the agent has to restart the scan. Consider returning the partial Data::ScrollCollection with a new ScrollStop::Interrupted, or at least including the collected rows in the text.
| } | ||
| Ok(match (resp, input) { | ||
| (Response::Error { mut message, .. }, Some(input)) => { | ||
| message += match input.delivery { |
There was a problem hiding this comment.
nit: the suffix is appended unconditionally. Many daemon messages already end with punctuation, e.g. the FocusChanged one (…no further keys or Return were sent.) becomes …were sent.. Input was sent. Inspect the screen before retrying. Some WDA timeout messages also already say to check the screen. Suggestion: trim trailing ./。 before appending, and skip the hint when the message already contains equivalent guidance.
|
Thanks for the quick turnaround. I checked
One thing remains: the branch now conflicts with |
Release 0.2.11 dated the changelogs' Unreleased section; the Derrors#170 entries stay under Unreleased, above 0.2.11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…licates Found by running this branch on an iPhone 15 Pro Max (iOS 27.2.1, native) and an iPad mini 5 (iPadOS 26.7.3, WDA, landscape) against main: - Natively, iphone_type_text "北京\n" failed with "the field didn't show the text" although Spotlight showed 北京: a single-line field turns a pasted newline into a space (it reads «北京 »), which the trimmed comparison didn't accept. A field that differs only in whitespace is now Trimmed (readback unverified), as intended; main had accepted it. «北京\n上海» (reads «北京 上海») too. - Through WDA, checking the field after typing read the focused element four requests at a time, twice, 0.3 s apart, and typing over a selected search (Spotlight keeps its last one) can never match: typing 设置 took 4.39 s against main's 2.55 s. A reread now asks only which element has focus and its value (WdaClient::active_element), and a first read that settles the case (a selection replaced) answers at once. - iphone_scroll_collect collected rows twice. Settings' large title collapses into the navigation bar, so the next viewport didn't start with the end of the previous one: a few elements may now lie between the overlap and the ends. Through WDA on an iPad split view no two viewports overlapped at all, and the 150-row limit came after two or three swipes: a detail row's Cell, label and chevron have middles a point apart, in an order that turned round as the list moved; the sidebar's navigation bar and search field stay put while its rows pass under them, between the rows in travel order; and the column that didn't scroll interleaves with the one that did. Elements are now ordered row by row (left to right within a row); when the tree has scroll areas only their content is matched, and the rest (bars, the list's own container) is new only when the previous viewport had nothing like it; the column that stayed is left out. A tree read natively has no scroll areas and is matched whole, as before. `x` picks where to swipe, so an iPad sidebar can be scanned. - The bridge's "no matching JSON-RPC reply" message comes in both languages, and in Chinese it joins its hint with 。 (it read «…回复. 未收到远端工具结果…»); the Chinese changelog's parentheses; D10 counts 18 tools. Regression cases 165-167. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
An agent can lose the reply to a tap that already reached the phone. Single input tools now expose
delivery(not_sent,unknown, orsent) independently of field and screen readback. A lost acknowledgement ends the call with an uncertain result so the agent can inspect the phone before repeating input.iphone_scroll_collectreads accessible rows across successive viewports, merges adjacent overlap, and can stop at a visible text match. It leaves the match on screen for a later decision. Bounds and a stop reason make the amount of scrolling explicit.Maintainer review follow-up
Commit
b9cdfe6addresses the five input/readback issues and the four smaller review findings. WDA no longer replays missing Return, Tab or whitespace, including during replacement. It can still repair a stable missing digit suffix in a formatted field. Read-only WDA writes retain their fallback; input writes with uncertain delivery do not replay. Native paste rechecks the system permission prompt before tapping it again and accepts trimmed field displays as unverified.The remote bridge distinguishes connection and authorization failures from a lost reply. Scroll search retains the swipe failure stage. A connected collector interrupted between gestures receives its partial rows, and the input error text avoids repeating screen-inspection guidance.
The physical-device results below apply to
95fe042. The native paste changes inb9cdfe6await a device retest.Tests
1. Unit tests
replace: true, partial field readback, failed screen readback, and incomplete list snapshots.interrupted_tool_reply_reports_unknown_instead_of_hanging_or_retrying,input_delivery_is_independent_of_field_and_screen_readback, andoverlap_preserves_separate_rows_in_both_directions_and_skips_fixed_content.2. Real-device regression
a876c12with pre-review commit95fe042on the same iPhone and Mac. Before each measured run, opened Clock and waited for its tabs, cleared the Spotlight query, then returned Home. Both versions ran the unchanged 16 default steps intests/device/run.pyfive times. All 80 calls passed on each version.tests/device/compare.pyflagged zero slower steps. The sum of per-step medians was 22.73 s on main and 20.30 s on this branch. These are five-run measurements on one phone.3. Regression cases
4. Real-device proof
sentand successful screen readback. The missing label reportednot_sentand kept the tab selected. A local socket relay suppressed the completed daemon reply after one real tap. Both versions selected the tab exactly once. Main exposed no delivery metadata. This branch returnedunknownat thereplystage.After USB reconnection, both idle cycles passed (#157, 2/2, 87.7 s). The original daemon regained the same native device in Ready state. The original Viewer and MCP status call were verified after handback.
Native portrait hardware was available. WDA, iPad, landscape, and Linux device control have not been exercised on hardware here.
Hardware retest of review fixes (b9cdfe6)
On an iPhone 14 running iOS 27.0.1 with the native backend, all seven tap and list checks passed. The Settings scan returned seven rows unique to the first viewport and six unique to the last. Pausing a separate scan after one swipe returned 25 rows, including 13 from the first viewport. Dropping the reply after a real Clock tap produced one send and no replay.
Spotlight accepted the ordinary Chinese paste and the paste with surrounding spaces. The system paste permission dialog was observed and handled. One case is still open: pasting
北京\nreported delivery assentand field readback asfailed, although an independent read showed北京. That screen read cannot establish what happened to the trailing newline. The failed readback reproduced twice. WDA was not exercised on this phone.Checklist