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): run the cursor event loop when PiP is enabled (#4304)

Ziming Wang5933507e73be
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/main.rs b/libs/cua-driver/rust/crates/cua-driver/src/main.rs
index e1af27af99..93cb21b222 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/main.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/main.rs
@@ -722,22 +722,18 @@ fn main() {
// Keep the main thread alive for the daemon.
//
- // PiP needs the AppKit main run loop to process the
- // dispatch_async_f calls that push frames into NSImageView;
- // park main in NSApplication.run() when --experimental-pip is
- // on. Otherwise just join the serve thread so the process
- // stays up as long as the daemon does.
- if pip_cfg.enabled {
- platform_macos::pip::run_appkit_main_loop();
- } else if cursor_cfg.enabled {
- // Render the agent-cursor overlay: park the main thread in the
- // AppKit run loop so the overlay NSWindow draws. `run_on_main_thread`
- // self-guards on `has_graphic_access()` and returns immediately
- // when the daemon has no Window Server session — fall through to
- // join so the daemon still serves headless. The serve thread runs
- // on its background thread regardless.
+ // The agent-cursor overlay and PiP both need the AppKit main run
+ // loop. The overlay's loop is NSApplication.run() plus the cursor
+ // command consumer, so it also drains the dispatch_async_f calls
+ // that create the PiP window and push its frames. Run it whenever
+ // the cursor is enabled; PiP's own loop alone would leave cursor
+ // commands unconsumed. Without either, just join the serve thread
+ // so the process stays up as long as the daemon does.
+ if cursor_cfg.enabled {
platform_macos::cursor::overlay::run_on_main_thread();
let _ = serve_handle.join();
+ } else if pip_cfg.enabled {
+ platform_macos::pip::run_appkit_main_loop();
} else {
let _ = serve_handle.join();
}