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): point a background-disabled invoke_menu refusal at the foreground shortcut (#5055)

Francesco Bonaccieccbce9778b0
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/invoke_menu.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/invoke_menu.rs
index d0b73a98d8..f6f7d90c94 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/invoke_menu.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/invoke_menu.rs
@@ -540,8 +540,10 @@ fn background_unavailable(reason: String) -> ToolResult {
let message = format!(
"{reason}. invoke_menu does not activate a background app: macOS keeps this menu item \
unavailable while the app is behind the user's window. If the user allows it, call \
- bring_to_front for this window first, then invoke_menu; or use the app's keyboard \
- shortcut with hotkey, or the control in the window."
+ bring_to_front for this window first, then invoke_menu, or send the app's keyboard \
+ shortcut with hotkey and delivery_mode:\"foreground\". A background hotkey does not \
+ help: the disabled item ignores its shortcut too. Otherwise use the control in the \
+ window."
);
ToolResult::error(message.clone()).with_structured(serde_json::json!({
"status": "refused",
@@ -753,6 +755,8 @@ mod tests {
let message = structured["refusal"]["message"].as_str().unwrap();
assert!(message.contains("does not activate a background app"));
assert!(message.contains("bring_to_front"));
+ assert!(message.contains("delivery_mode:\"foreground\""));
+ assert!(message.contains("A background hotkey does not help"));
}
#[test]