Skip to content

Computer use CLI for AI agents

fix: resolve fullscreen AX tree retrieval returning ref_count: 0

noy4a52b7c704a4d
diff --git a/crates/macos/src/tree/builder.rs b/crates/macos/src/tree/builder.rs
index 4cec93e85..610ee563f 100644
--- a/crates/macos/src/tree/builder.rs
+++ b/crates/macos/src/tree/builder.rs
@@ -31,11 +31,16 @@ pub fn window_element_for(pid: i32, win_title: &str) -> AXElement {
let title = copy_string_attr(win, kAXTitleAttribute);
if title
.as_deref()
- .is_some_and(|t| t.contains(win_title) || win_title.contains(t))
+ .is_some_and(|t| !t.is_empty() && (t.contains(win_title) || win_title.contains(t)))
{
return win.clone();
}
}
+ for win in &windows {
+ if count_children(win, None) > 0 {
+ return win.clone();
+ }
+ }
if let Some(first) = windows.into_iter().next() {
return first;
}