Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): do not report a submitted type_text as partial delivery (#4741)

Francesco Bonacciaa7a31a5f363
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/type_text.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/type_text.rs
index d977e2dad0..663ebc9f45 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/type_text.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/type_text.rs
@@ -876,6 +876,14 @@ fn typed_progress(before: Option<&str>, after: Option<&str>, text: &str) -> Type
if after.contains(text) {
return TypedProgress::Complete;
}
+ // Enter, Tab and Return are not characters a field keeps: they submit,
+ // move focus, or reset the field (a spreadsheet Name Box jumps and
+ // rewrites itself). A read-back after them says nothing about how many
+ // characters landed, so a shortfall must not be reported as partial
+ // delivery that the caller then retries.
+ if text.contains(['\n', '\r', '\t']) {
+ return TypedProgress::Unverifiable;
+ }
let Some(before) = before else {
return TypedProgress::Unverifiable;
};
@@ -1535,6 +1543,9 @@ mod tests {
),
(Some("ab"), Some("ab"), "hi", Unchanged),
(None, None, "", Complete),
+ // A submitted field rewrites itself; the shortfall proves nothing.
+ (Some("A1"), Some("A1xx"), "$Controls.A1\n", Unverifiable),
+ (Some(""), Some("one\ntwo"), "one\ntwo", Complete),
] {
assert_eq!(
typed_progress(before, after, text),