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): drop the foreground resend hint from delivered macOS hotkeys (#4982)

injaneity206c02649052
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
index 361ff254bd..87aed0fd84 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
@@ -499,28 +499,12 @@ impl Tool for HotkeyTool {
} else {
""
};
- // A combo is never read-back-verifiable. On the background rung,
- // point the agent at the foreground escalation for menu shortcuts
- // an app drops in the background — same contract as type_text.
- let mut structured = serde_json::json!({
- "path": if fg { "key_events_fg" } else { "key_events" },
- "verified": false,
- "effect": "unverifiable",
- });
- if !fg && window_id.is_some() {
- structured["escalation"] = serde_json::json!({
- "recommended": "foreground",
- "reason": "a background combo didn't land? menu key-equivalents \
- often need the window fronted — re-call with \
- delivery_mode:\"foreground\". (To type into a field, \
- pixel-click to focus then type_text instead.)"
- });
- }
ToolResult::text(format!(
- "Pressed {key_display} on pid {pid}{label}.{}",
+ "Pressed {key_display} on pid {pid}{label}. Read the window before \
+ sending it again.{}",
changes.result_suffix()
))
- .with_structured(structured)
+ .with_structured(delivered_structured(fg))
}
Ok(Err(e)) => ToolResult::error(format!("hotkey failed: {e}")),
Err(e) => ToolResult::error(format!("Task error: {e}")),
@@ -528,10 +512,28 @@ impl Tool for HotkeyTool {
}
}
+fn delivered_structured(foreground: bool) -> Value {
+ serde_json::json!({
+ "path": if foreground { "key_events_fg" } else { "key_events" },
+ "verified": false,
+ "effect": "unverifiable",
+ })
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ #[test]
+ fn a_delivered_combo_suggests_no_resend() {
+ for foreground in [false, true] {
+ let structured = delivered_structured(foreground);
+ assert!(structured.get("escalation").is_none());
+ assert_eq!(structured["effect"], "unverifiable");
+ assert_eq!(structured["verified"], false);
+ }
+ }
+
#[test]
fn hotkey_contract_accepts_snapshot_bound_ax_targets() {
let properties = def().input_schema["properties"]