cua icon indicating copy to clipboard operation
cua copied to clipboard

[Bug]: set_window_frame and invoke_menu can't find an off-Space window that get_window_state resolves

Open FredAmartey opened this issue 2 months ago • 1 comments

Primary area

Cua Driver

Summary

On macOS, get_window_state resolves an AppKit window on another Space through the off-Space probe from #4068 and #4085, but set_window_frame and invoke_menu can't find that same window. They look it up with copy_ax_windows, which has nothing for an app whose windows are all off the current Space.

Reproduction

  1. Open a TextEdit document on a desktop Space, then switch to another Space (here a fullscreen app), so TextEdit has no window on the current Space.
  2. get_window_state on the TextEdit window.
  3. set_window_frame on it, same size, moved 40 pt.
  4. invoke_menu on it with ["Edit", "Select All"].

Expected behavior

set_window_frame and invoke_menu act on the window get_window_state just resolved, or refuse with an off-Space reason.

Actual behavior

list_windows:     window 34189, space_ids [6], on_current_space false (current Space 1239)
get_window_state: exact_window matched, 169 elements, AXWindow frame 656x422 at 218,84
set_window_frame: exit 1, "set_window_frame: window_id 34189 belongs to pid 34255 in WindowServer but has no matching AXWindow"
invoke_menu:      refused, menu_path_unavailable, "invoke_menu: target accessibility window is unavailable"

With the window on the current Space, both tools find it. (Stage Manager is on here, so set_window_frame then reported suspected_noop for a window in the strip; that part is separate.)

Environment

Cua Driver 0.33.3 release app, called through cua-driver call. macOS 27.0 (26A428), Apple silicon, Stage Manager on. TextEdit.

Evidence

get_window_state gets the window through copy_ax_windows_including, which adds the probe: https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/platform-macos/src/ax/tree.rs#L346

set_window_frame and invoke_menu use copy_ax_windows: https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/platform-macos/src/tools/set_window_frame.rs#L208 https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/platform-macos/src/tools/invoke_menu.rs#L319

Workaround and additional context

Bring the window onto the current Space first. Refs #3458.

Not the helper-window case from #4525: #4534 drops AX-less helper windows from list_windows and keeps windows on another Space. This one is titled, sits on Space 6 and get_window_state resolves it with 169 elements.

Submission checks

  • [x] I searched for duplicate issues and active pull requests.
  • [x] This issue describes a single problem.
  • [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.

FredAmartey avatar Oct 05 '26 03:10 FredAmartey

Thanks for the report, @FredAmartey. I've labelled it and assigned @injaneity to take a look. There is a related PR in #4636, which we'll review on its own.

f-trycua avatar Oct 06 '26 13:10 f-trycua