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(spacesd): ask get_window_state for structured elements in the tool backend (#4908)

Francesco Bonacciba4c6369660a
diff --git a/libs/cua-spacesd/crates/cua-spacesd-desktop/src/grpc/tool_backend.rs b/libs/cua-spacesd/crates/cua-spacesd-desktop/src/grpc/tool_backend.rs
index 6280f9e54f..275ae0ab5e 100644
--- a/libs/cua-spacesd/crates/cua-spacesd-desktop/src/grpc/tool_backend.rs
+++ b/libs/cua-spacesd/crates/cua-spacesd-desktop/src/grpc/tool_backend.rs
@@ -869,10 +869,13 @@ impl DesktopBackend for ToolBackend {
max_nodes: u32,
) -> Result<A11yTree, ProviderError> {
let native = self.native(window)?;
+ // get_window_state returns compact Markdown by default; this backend
+ // reads the structured `elements` array (with explicit element_tokens).
let mut arguments = json!({
"pid": native.pid,
"window_id": native.window_id,
"include_screenshot": false,
+ "tree_format": "elements",
});
if max_nodes > 0 {
arguments["max_elements"] = max_nodes.into();
@@ -1469,6 +1472,9 @@ mod tests {
let (backend, tools) = backend();
let window = backend.windows().unwrap().remove(0);
let tree = backend.a11y_tree(&window, 0, 0).unwrap();
+ let (name, arguments) = last_call(&tools);
+ assert_eq!(name, "get_window_state");
+ assert_eq!(arguments["tree_format"], json!("elements"));
assert_eq!(tree.nodes.len(), 3);
assert_eq!(tree.nodes[0].role, "button");
assert_eq!(tree.nodes[1].role, "text_field");