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(spaces): teleport refusal wording, picker title after Back, Status of an unreachable Space (#5103)
ddupont154f225f5467
diff --git a/apps/cua-spaces-web/src/__tests__/space-detail-sections.test.tsx b/apps/cua-spaces-web/src/__tests__/space-detail-sections.test.tsxindex 8228189681..bf3d65b9a3 100644--- a/apps/cua-spaces-web/src/__tests__/space-detail-sections.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/space-detail-sections.test.tsx@@ -69,4 +69,25 @@ describe.skipIf(!wasmBuilt)("a Space's Agents and Teleport sections (real routesact(() => dropOn(well, ["Google Chrome.app"]));await waitFor(() => expect(document.querySelector("[data-teleport]")).not.toBeNull());});++ it("titles the picker for the Space again after Back from an app's options", async () => {+ const { router } = await mountApp(`/spaces/${SPACE}`, host());+ await router.load();+ const open = await screen.findByRole("button", { name: "Teleport an app…" });+ fireEvent.click(open);+ const title = () => document.querySelector("[data-teleport-title]")?.textContent;+ const tile = await waitFor(() => {+ const t = document.querySelector<HTMLElement>("[data-teleport][data-step=pick] [data-tile]:not([data-disabled])");+ expect(t).not.toBeNull();+ return t!;+ });+ const gridTitle = title();+ expect(gridTitle).toMatch(/^Teleport an app to /);+ fireEvent.doubleClick(tile);+ await waitFor(() => expect(document.querySelector("[data-teleport][data-step=options]")).not.toBeNull());+ expect(title()).not.toBe(gridTitle);+ fireEvent.click(screen.getByRole("button", { name: "Back" }));+ await waitFor(() => expect(document.querySelector("[data-teleport][data-step=pick]")).not.toBeNull());+ expect(title()).toBe(gridTitle);+ });});diff --git a/libs/cua/crates/cua-daemon/src/lib.rs b/libs/cua/crates/cua-daemon/src/lib.rsindex 68d69f5234..fc18838aa0 100644--- a/libs/cua/crates/cua-daemon/src/lib.rs+++ b/libs/cua/crates/cua-daemon/src/lib.rs@@ -506,8 +506,10 @@ impl From<cua_spaces::Error> for Error {E::CapabilityMissing { .. } => Error::CapabilityMissing(m),E::HostCapabilityMissing { .. } => Error::HostCapabilityMissing(m),E::WrongProvider { .. } => Error::Unsupported(m),- // Both are a consent gate saying no; the message names which.- E::TeleportRefused(_) | E::LoginRefused(_) => Error::TeleportRefused(m),+ // Both are a consent gate saying no; the message names which (a+ // teleport's own words: this error says "teleport refused:" itself).+ E::TeleportRefused(why) => Error::TeleportRefused(why),+ E::LoginRefused(_) => Error::TeleportRefused(m),E::Timeout(_) => Error::Timeout(m),E::Cancelled(c) => Error::Cancelled(c),E::Env(env) => Error::from(env),@@ -767,6 +769,18 @@ pub fn random_token() -> String {mod tests {use super::*;+ #[cfg(feature = "spaces")]+ #[test]+ fn a_teleport_refusal_says_teleport_refused_once() {+ let err = Error::from(cua_spaces::Error::TeleportRefused(+ "the approver declined".into(),+ ));+ assert_eq!(err, Error::TeleportRefused("the approver declined".into()));+ assert_eq!(err.to_string(), "teleport refused: the approver declined");+ let back = Error::from_status(&err.to_status());+ assert_eq!(back.to_string(), "teleport refused: the approver declined");+ }+#[test]fn error_roundtrips_through_status() {for e in [diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rsindex 171114f983..d93952a6c2 100644--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs@@ -1846,6 +1846,9 @@ impl From<cua_spaces::Error> for CuaError {match e {cua_spaces::Error::Env(env) => env.into(),cua_spaces::Error::Fleet(f) => f.into(),+ // The refusal's own words: `CuaError::TeleportRefused` says+ // "teleport refused:" itself (not twice).+ cua_spaces::Error::TeleportRefused(why) => CuaError::TeleportRefused(why),_ => tag_error(kind, message),}}@@ -4157,6 +4160,15 @@ mod tests {use super::*;use std::collections::BTreeSet;+ #[test]+ fn a_teleport_refusal_says_teleport_refused_once() {+ let err = CuaError::from(cua_spaces::Error::TeleportRefused(+ "the approver declined".into(),+ ));+ assert!(matches!(err, CuaError::TeleportRefused(_)), "{err:?}");+ assert_eq!(err.to_string(), "teleport refused: the approver declined");+ }+#[test]fn an_embedded_insufficient_disk_becomes_insufficient_disk() {let err = cua_spaces::Error::from(cua_sandbox_core::Error::Runtime(diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.jsonindex 20c0ee1e4f..a0440155d1 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json@@ -2311,7 +2311,7 @@"canStream": false,"deleteLabel": "Remove","facts": [- "Status: timed out",+ "Status: Unreachable ?timed out","Identifier: direct:10.0.0.5:3211 [copy direct:10.0.0.5:3211 doc.on.doc Copy / checkmark Copied 1500ms]","System: Unknown"],diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.jsonindex 9edf4b3f23..2e39f553b8 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json@@ -233,7 +233,7 @@"canStream": false,"confirm": "Delete their-box? | It runs in Google Cloud · us-central1 and was created on another device. Remove from List keeps it running there. | Delete Permanently (disabled: Created on another device: delete it there, or remove it from this list.) / Remove from List / Cancel","facts": [- "Status: offline",+ "Status: Unreachable ?offline","Location: Google Cloud · us-central1","Identifier: relay:cloud-0000000000000e01 [copy relay:cloud-0000000000000e01 doc.on.doc Copy / checkmark Copied 1500ms]","System: Linux"@@ -284,7 +284,7 @@"canStream": false,"confirm": "Delete builder? | Everything inside it, including its files, is deleted and can't be recovered. | Delete Space / Keep","facts": [- "Status: timed out",+ "Status: Unreachable ?timed out","Identifier: cloud:builder [copy cloud:builder doc.on.doc Copy / checkmark Copied 1500ms]","System: Linux"],diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/space-facts.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/space-facts.jsonindex 09b3ee7f1c..7dbcc81f60 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/space-facts.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/space-facts.json@@ -57,7 +57,7 @@{"case": "no OS name at all","facts": [- "Status: timed out",+ "Status: Unreachable ?timed out","Identifier: cloud:builder [copy cloud:builder doc.on.doc Copy / checkmark Copied 1500ms]","System: Linux"]diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/teleport-sign-ins.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/teleport-sign-ins.jsonindex 8ba8689f88..db554d7ab2 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/teleport-sign-ins.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/teleport-sign-ins.json@@ -96,10 +96,10 @@},{"frame": {- "canPlan": true,- "entry": "slack",+ "canPlan": false,+ "entry": null,"error": null,- "move": "app_with_state",+ "move": null,"permille": 0,"planSensitive": [],"report": null,diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rsindex c115587b00..e45150618b 100644--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs@@ -834,8 +834,16 @@ fn detail_facts(.filter(|p| p.off && p.turning_on.is_none() && space.status == SpaceStatus::Suspended).filter(|_| !space.progress.as_ref().is_some_and(|p| p.error.is_some())).map(|p| super::off_hint(p.control).to_string());+ // Unreachable: why, in the shell's words, as the Status row's help.+ let why = space+ .sdk+ .as_ref()+ .filter(|sdk| !sdk.reachable && status == UNREACHABLE)+ .and_then(|sdk| sdk.error.as_deref())+ .filter(|e| !e.trim().is_empty())+ .map(crate::errors::plain_error);let mut facts = vec![Fact {- help: hint,+ help: hint.or(why),..fact("Status", status)}];if let Some(place) = space@@ -889,6 +897,9 @@ pub fn detail(space: &Space) -> SpaceDetail {detail_live(space, None, None)}+/// The Status of a Space the app cannot reach (why is the row's help).+const UNREACHABLE: &str = "Unreachable";+/// The detail of `space` with its current memory and storage use./// `host_arch` is this machine's CPU architecture (`arm64`, `x86_64`, ...):/// a local Space of another one shows a warning on its Architecture.@@ -916,11 +927,8 @@ pub fn detail_live(None if p.transfer.is_some() => p.label.clone(),None => format!("{} {}", p.label, percent(p.permille)),},- (Some(sdk), None) if !sdk.reachable => sdk- .error- .clone()- .filter(|e| !e.is_empty())- .unwrap_or_else(|| "Unreachable".into()),+ // The probe's error is its help (the row's tooltip), not the value.+ (Some(sdk), None) if !sdk.reachable => UNREACHABLE.into(),_ => status_text(space),};let preview_text = match (creating, &failed) {@@ -1227,6 +1235,34 @@ mod tests {d.facts.iter().find(|f| f.label == label)}+ /// A Space the app cannot reach says "Unreachable"; the probe's error+ /// is the row's help (in plain words), never the Status itself.+ #[test]+ fn an_unreachable_space_says_unreachable_with_why_as_help() {+ let x = crate::experiments::Experiments::default();+ for (raw, why) in [+ (+ "cua-spacesd is not available: relay:studio has no cua-spacesd (gRPC: relay assertion refused)",+ "cua-spacesd is not available: relay:studio has no cua-spacesd (gRPC: relay assertion refused)",+ ),+ (+ "transport: Connection refused (os error 61)",+ crate::errors::DAEMON_NOT_RUNNING,+ ),+ ] {+ let mut space = machine(&[], false);+ space.sdk.as_mut().unwrap().error = Some(raw.into());+ let d = detail_with(&space, None, None, &x);+ let status = fact_of(&d, "Status").unwrap();+ assert_eq!(status.value, "Unreachable");+ assert_eq!(status.help.as_deref(), Some(why));+ }+ // No error: no help.+ let d = detail_with(&machine(&[], false), None, None, &x);+ assert_eq!(fact_of(&d, "Status").unwrap().value, "Unreachable");+ assert_eq!(fact_of(&d, "Status").unwrap().help, None);+ }+/// One of your machines on the relay, as the app's probe saw it.fn machine(features: &[&str], reachable: bool) -> Space {let row: SpaceRow = serde_json::from_value(serde_json::json!({diff --git a/libs/cua/crates/cua-spaces-app-core/src/teleport/flow.rs b/libs/cua/crates/cua-spaces-app-core/src/teleport/flow.rsindex 35cc6de481..e6783cfc94 100644--- a/libs/cua/crates/cua-spaces-app-core/src/teleport/flow.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/teleport/flow.rs@@ -1210,6 +1210,12 @@ pub fn reduce(s: &PickerState, e: &PickerEvent) -> PickerState {if s.entries.is_some() {n.step = Step::Pick;n.plan = None;+ // Back on the grid: no app is open any more (the sheet's+ // title goes back to "Teleport an app to …"); the grid+ // keeps its selection.+ n.entry = None;+ n.moves = None;+ n.sensitive.clear();}}Step::Consent => {@@ -1224,6 +1230,11 @@ pub fn reduce(s: &PickerState, e: &PickerEvent) -> PickerState {n.step = s.error_back;n.error = None;n.install_prompt = None;+ if n.step == Step::Pick {+ n.entry = None;+ n.moves = None;+ n.sensitive.clear();+ }}_ => {}},@@ -1636,6 +1647,40 @@ mod tests {}}+ /// Back from an app's options returns to the grid with no app open, so+ /// the sheet's title is the grid's again; the grid keeps its selection.+ #[test]+ fn back_to_the_grid_closes_the_app() {+ let chrome = chrome_entry();+ let s = reduce(+ &initial("dev"),+ &PickerEvent::Loaded {+ entries: vec![chrome.clone()],+ },+ );+ let s = reduce(+ &s,+ &PickerEvent::Choose {+ id: Some(chrome.id.clone()),+ },+ );+ assert_eq!(s.step, Step::Options);+ assert!(s.entry.is_some());+ let back = reduce(&s, &PickerEvent::Back);+ assert_eq!(back.step, Step::Pick);+ assert_eq!(back.entry, None);+ assert_eq!(back.moves, None);+ assert!(back.sensitive.is_empty());+ assert!(!can_plan(&back));+ // Choosing again opens it afresh.+ let again = reduce(&back, &PickerEvent::Choose { id: None });+ assert_eq!(again.step, Step::Options);+ assert_eq!(+ again.entry.as_ref().map(|e| e.id.as_str()),+ Some(chrome.id.as_str())+ );+ }+/// Walks `initial` to `Step::Consent` the way the picker really does/// (preselect, choose the signed-in state move, plan).fn consent_state() -> PickerState {diff --git a/libs/cua/crates/cua-spaces-ffi/src/teleport_app.rs b/libs/cua/crates/cua-spaces-ffi/src/teleport_app.rsindex d22c6383b3..3addbbd9df 100644--- a/libs/cua/crates/cua-spaces-ffi/src/teleport_app.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/teleport_app.rs@@ -21,7 +21,8 @@ pub(crate) fn ux_err(e: UxError) -> CuaError {match e {UxError::Unsupported(_) => CuaError::Unsupported(m),UxError::Invalid(_) => CuaError::InvalidArgument(m),- UxError::NotApproved(_) => CuaError::TeleportRefused(m),+ // Its own words: the error says "teleport refused:" itself.+ UxError::NotApproved(why) => CuaError::TeleportRefused(why),UxError::PermissionDenied(_) | UxError::HostEffectsRefused(_) => {CuaError::PermissionDenied(m)}