Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-spacesd): declare DPI awareness for Windows Host (#4805)
Kwizii34d69bf2c7d9
diff --git a/libs/cua-spacesd/Cargo.lock b/libs/cua-spacesd/Cargo.lockindex be6f536bdb..50308378e0 100644--- a/libs/cua-spacesd/Cargo.lock+++ b/libs/cua-spacesd/Cargo.lock@@ -1572,6 +1572,7 @@ dependencies = ["cua-spacesd-server","cua-spacesd-session","cua-volume",+ "embed-resource","futures-util","libc","platform-linux",@@ -1854,7 +1855,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",- "toml_edit",+ "toml_edit 0.25.13+spec-1.1.0","ureq",]@@ -2089,6 +2090,20 @@ dependencies = ["serde",]+[[package]]+name = "embed-resource"+version = "2.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d506610004cfc74a6f5ee7e8c632b355de5eca1f03ee5e5e0ec11b77d4eb3d61"+dependencies = [+ "cc",+ "memchr",+ "rustc_version",+ "toml 0.8.23",+ "vswhom",+ "winreg 0.52.0",+]+[[package]]name = "embedded-io"version = "0.4.0"@@ -4590,7 +4605,7 @@ dependencies = ["shared_library","shell-words","winapi",- "winreg",+ "winreg 0.10.1",][[package]]@@ -4646,7 +4661,7 @@ version = "3.5.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"dependencies = [- "toml_edit",+ "toml_edit 0.25.13+spec-1.1.0",][[package]]@@ -5434,6 +5449,15 @@ dependencies = ["syn 3.0.4",]+[[package]]+name = "serde_spanned"+version = "0.6.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"+dependencies = [+ "serde",+]+[[package]]name = "serde_spanned"version = "1.1.1"@@ -6020,6 +6044,18 @@ dependencies = ["tokio",]+[[package]]+name = "toml"+version = "0.8.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"+dependencies = [+ "serde",+ "serde_spanned 0.6.9",+ "toml_datetime 0.6.11",+ "toml_edit 0.22.27",+]+[[package]]name = "toml"version = "0.9.12+spec-1.1.0"@@ -6028,13 +6064,22 @@ checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863"dependencies = ["indexmap","serde_core",- "serde_spanned",+ "serde_spanned 1.1.1","toml_datetime 0.7.5+spec-1.1.0","toml_parser","toml_writer","winnow 0.7.15",]+[[package]]+name = "toml_datetime"+version = "0.6.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"+dependencies = [+ "serde",+]+[[package]]name = "toml_datetime"version = "0.7.5+spec-1.1.0"@@ -6053,6 +6098,20 @@ dependencies = ["serde_core",]+[[package]]+name = "toml_edit"+version = "0.22.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"+dependencies = [+ "indexmap",+ "serde",+ "serde_spanned 0.6.9",+ "toml_datetime 0.6.11",+ "toml_write",+ "winnow 0.7.15",+]+[[package]]name = "toml_edit"version = "0.25.13+spec-1.1.0"@@ -6075,6 +6134,12 @@ dependencies = ["winnow 1.0.4",]+[[package]]+name = "toml_write"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"+[[package]]name = "toml_writer"version = "1.1.2+spec-1.1.0"@@ -6438,7 +6503,7 @@ dependencies = ["serde","tempfile","textwrap",- "toml",+ "toml 0.9.12+spec-1.1.0","uniffi_internal_macros","uniffi_meta","uniffi_pipeline",@@ -6484,7 +6549,7 @@ dependencies = ["quote","serde","syn 2.0.119",- "toml",+ "toml 0.9.12+spec-1.1.0","uniffi_meta",]@@ -6671,6 +6736,26 @@ version = "0.8.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"+[[package]]+name = "vswhom"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b"+dependencies = [+ "libc",+ "vswhom-sys",+]++[[package]]+name = "vswhom-sys"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fb067e4cbd1ff067d1df46c9194b5de0e98efd2810bbc95c5d5e5f25a3231150"+dependencies = [+ "cc",+ "libc",+]+[[package]]name = "walkdir"version = "2.5.0"@@ -7376,6 +7461,16 @@ dependencies = ["winapi",]+[[package]]+name = "winreg"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"+dependencies = [+ "cfg-if",+ "windows-sys 0.48.0",+]+[[package]]name = "wit-bindgen"version = "0.57.1"diff --git a/libs/cua-spacesd/crates/cua-spacesd/Cargo.toml b/libs/cua-spacesd/crates/cua-spacesd/Cargo.tomlindex fd00b06870..5b3196cbf6 100644--- a/libs/cua-spacesd/crates/cua-spacesd/Cargo.toml+++ b/libs/cua-spacesd/crates/cua-spacesd/Cargo.toml@@ -8,6 +8,9 @@ license.workspace = truerepository.workspace = truepublish = false+[build-dependencies]+embed-resource = "2"+[dependencies]cua-driver-core = { path = "../../../cua-driver/rust/crates/cua-driver-core" }cua-spacesd-desktop = { path = "../cua-spacesd-desktop" }@@ -67,5 +70,6 @@ platform-windows = { path = "../../../cua-driver/rust/crates/platform-windows" }[target.'cfg(target_os = "windows")'.dev-dependencies]windows = { version = "0.58", features = ["Win32_Foundation",+ "Win32_UI_HiDpi","Win32_UI_WindowsAndMessaging",] }diff --git a/libs/cua-spacesd/crates/cua-spacesd/build.rs b/libs/cua-spacesd/crates/cua-spacesd/build.rsindex 329b69773b..8e8790fca6 100644--- a/libs/cua-spacesd/crates/cua-spacesd/build.rs+++ b/libs/cua-spacesd/crates/cua-spacesd/build.rs@@ -25,6 +25,14 @@ fn git(args: &[&str]) -> Option<String> {}fn main() {+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {+ // The linked Windows driver expects physical pixels. Declare the+ // process context before any async, native, or overlay thread starts.+ println!("cargo:rerun-if-changed=cua-spacesd.rc");+ println!("cargo:rerun-if-changed=cua-spacesd.manifest");+ embed_resource::compile_for("cua-spacesd.rc", ["cua-spacesd"], embed_resource::NONE);+ }+println!("cargo:rerun-if-env-changed=CUA_SPACESD_GIT_SHA");let from_env = std::env::var("CUA_SPACESD_GIT_SHA").unwrap_or_default();let sha = if !from_env.trim().is_empty() {diff --git a/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.manifest b/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.manifestnew file mode 100644index 0000000000..c84a7ee600--- /dev/null+++ b/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.manifest@@ -0,0 +1,23 @@+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">+ <assemblyIdentity type="win32" name="com.trycua.spacesd" version="1.0.0.0"/>+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">+ <security>+ <requestedPrivileges>+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>+ </requestedPrivileges>+ </security>+ </trustInfo>+ <application xmlns="urn:schemas-microsoft-com:asm.v3">+ <windowsSettings>+ <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>+ <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2</dpiAwareness>+ </windowsSettings>+ </application>+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">+ <application>+ <!-- Windows 10 / Windows 11 -->+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>+ </application>+ </compatibility>+</assembly>diff --git a/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.rc b/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.rcnew file mode 100644index 0000000000..b51373b7c0--- /dev/null+++ b/libs/cua-spacesd/crates/cua-spacesd/cua-spacesd.rc@@ -0,0 +1,3 @@+// RT_MANIFEST = 24, CREATEPROCESS_MANIFEST_RESOURCE_ID = 1.+// Numeric type 24 ensures the Windows loader applies this as a manifest.+1 24 "cua-spacesd.manifest"diff --git a/libs/cua-spacesd/crates/cua-spacesd/tests/windows_dpi.rs b/libs/cua-spacesd/crates/cua-spacesd/tests/windows_dpi.rsnew file mode 100644index 0000000000..2bf5b486c6--- /dev/null+++ b/libs/cua-spacesd/crates/cua-spacesd/tests/windows_dpi.rs@@ -0,0 +1,89 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++//! Check the DPI context of the shipped executable, not this test process.+//! No desktop services, screen capture, or input are enabled.+#![cfg(target_os = "windows")]++use std::os::windows::io::AsRawHandle;+use std::process::{Child, Command, Stdio};+use std::time::Duration;++use cua_proto::env::v1::GetCapabilitiesRequest;+use cua_spacesd_client::{ConnectOptions, SpacesdClient, TransportPreference};+use windows::Win32::Foundation::HANDLE;+use windows::Win32::UI::HiDpi::{GetProcessDpiAwareness, PROCESS_PER_MONITOR_DPI_AWARE};++struct Host(Child);++impl Drop for Host {+ fn drop(&mut self) {+ let _ = self.0.kill();+ let _ = self.0.wait();+ }+}++#[tokio::test]+async fn host_starts_per_monitor_dpi_aware() {+ let dir = tempfile::tempdir().unwrap();+ let port = std::net::TcpListener::bind("127.0.0.1:0")+ .unwrap()+ .local_addr()+ .unwrap()+ .port();+ let token = uuid::Uuid::new_v4().to_string();+ let mut host = Host(+ Command::new(env!("CARGO_BIN_EXE_cua-spacesd"))+ .args([+ "serve",+ "--no-desktop",+ "--no-driver",+ "--no-mcp",+ "--quic-port",+ "0",+ ])+ .arg("--listen")+ .arg(format!("127.0.0.1:{port}"))+ .arg("--data-dir")+ .arg(dir.path().join("data"))+ .arg("--token-file")+ .arg(dir.path().join("token"))+ .env("CUA_ENV_TOKEN", &token)+ .env("CUA_ENV_TEST_SANDBOX", "1")+ .env("CUA_ENV_LOG", "warn")+ .stdout(Stdio::null())+ .spawn()+ .unwrap(),+ );+ let options = ConnectOptions::parse(&format!("http://127.0.0.1:{port}"))+ .unwrap()+ .transport(TransportPreference::Native)+ .probe(false)+ .token(token);+ tokio::time::timeout(Duration::from_secs(15), async {+ loop {+ assert!(+ host.0.try_wait().unwrap().is_none(),+ "Host exited before becoming ready"+ );+ if let Ok(client) = SpacesdClient::connect(options.clone()).await {+ if client+ .system()+ .get_capabilities(GetCapabilitiesRequest::default())+ .await+ .is_ok()+ {+ break;+ }+ }+ tokio::time::sleep(Duration::from_millis(50)).await;+ }+ })+ .await+ .expect("Host did not become ready");++ // Query Windows independently of Host tool responses. This also catches a+ // missing DPI declaration on CI machines whose display scaling is 100%.+ let awareness = unsafe { GetProcessDpiAwareness(HANDLE(host.0.as_raw_handle())).unwrap() };+ assert_eq!(awareness, PROCESS_PER_MONITOR_DPI_AWARE);+}