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): one-time migration turns Space sharing on for 0.9.0 settings (CUA-1668) (#5225)
Francesco Bonacci749636a5df27
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swiftindex 74b9888042..9a0f470a8a 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift@@ -395,8 +395,9 @@ struct ViewModelTests {#expect(model.host.formView?.canSubmit == true)}- /// Settings, Experiments: every switch off; Cua Volume on shows Storage- /// after General, is saved, recorded, and reaches the first run.+ /// Settings, Experiments: every switch off except Sharing (on by+ /// default); Cua Volume on shows Storage after General, is saved,+ /// recorded, and reaches the first run.@Test func experimentsAreOffAndCuaVolumeShowsStorage() async {let telemetry = FixtureTelemetry()let model = makeModel(telemetry: telemetry)@@ -404,8 +405,10 @@ struct ViewModelTests {#expect(toggles.map(\.id) == ["experiment:cua_volume", "experiment:your_cloud", "experiment:sharing","experiment:classic_ui"])// Off, the New UI shows as "Use classic UI" on (tests run with no app version: no default).+ // Sharing is on unless turned off.+ let onByDefault: Set<String> = ["experiment:classic_ui", "experiment:sharing"]#expect(toggles.allSatisfy { r in- r.options.first { $0.id == (r.id == "experiment:classic_ui" ? "on" : "off") }?.active == true+ r.options.first { $0.id == (onByDefault.contains(r.id) ? "on" : "off") }?.active == true})#expect(!model.settingsPageWithStorage.sections.map(\.id).contains("storage"))model.chooseExperiment(row: "experiment:cua_volume", option: "on")@@ -1062,10 +1065,11 @@ struct ViewModelTests {#expect(row("cloud:builder")?.power == nil, "a cloud Space cannot be turned off")let aurora = try #require(model.spaces.first { $0.id == "local:aurora" })#expect(row(aurora.id)?.power?.help == "Suspend")- // No Share without the Sharing experiment; with it, before power.+ // Share before power (Sharing is on by default); none with Sharing turned off.+ #expect(model.detail(aurora).actions.map(\.id) == [.teleport, .pip, .share, .power, .delete, .open])+ model.chooseExperiment(row: "experiment:sharing", option: "off")#expect(model.detail(aurora).actions.map(\.id) == [.teleport, .pip, .power, .delete, .open])model.chooseExperiment(row: "experiment:sharing", option: "on")- #expect(model.detail(aurora).actions.map(\.id) == [.teleport, .pip, .share, .power, .delete, .open])model.setPower(aurora, on: false)// Synchronously, before the SDK has done anything.diff --git a/libs/cua/crates/cua-spaces-app-core/src/settings.rs b/libs/cua/crates/cua-spaces-app-core/src/settings.rsindex b0210075dd..9e42ae62ae 100644--- a/libs/cua/crates/cua-spaces-app-core/src/settings.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/settings.rs@@ -121,6 +121,7 @@ pub fn load(path: &Path) -> AppSettings {.ok().and_then(|s| serde_json::from_str(&s).ok()).unwrap_or_default();+ migrate_sharing(path, &mut s);if s.new_ui.is_none() && s.experiments.web_ui {s.new_ui = Some(true);}@@ -128,6 +129,37 @@ pub fn load(path: &Path) -> AppSettings {s}+/// The migration marker next to the settings file. The shells round-trip+/// [`AppSettings`] through their own mirrors, so the marker lives in a file of+/// its own that no shell rewrites.+fn migrations_path(path: &Path) -> std::path::PathBuf {+ path.with_file_name("settings-migrations.json")+}++/// Sharing became on by default in 0.9.1 (CUA-1668). 0.9.0 saved+/// `sharing: false` for anyone who toggled any experiment, without them+/// choosing it, and left no record of an explicit choice. The first load+/// without the marker turns a stored `false` on once and writes the marker+/// (also on a fresh install, so a later "off" is never overridden); from then+/// on the stored value is the user's. Best effort: a failed write only+/// repeats the migration on the next load.+fn migrate_sharing(path: &Path, s: &mut AppSettings) {+ let marker = migrations_path(path);+ if marker.exists() {+ return;+ }+ if !s.experiments.sharing {+ s.experiments.sharing = true;+ if path.exists() && save(path, s).is_err() {+ return;+ }+ }+ if let Some(dir) = marker.parent() {+ let _ = std::fs::create_dir_all(dir);+ }+ let _ = std::fs::write(&marker, r#"{"sharingDefaultOn":true}"#);+}+/// `settings` with the New UI as this launch shows it: the user's choice,/// else [`crate::experiments::new_ui_default`] for the update channel and/// the running app's `version`. Again after the channel changes.@@ -1394,4 +1426,42 @@ mod tests {};assert!(resolve_new_ui(&fresh, "0.8.1-beta.1").experiments.web_ui);}++ #[test]+ fn sharing_on_by_default_migrates_a_0_9_0_false_once() {+ // Fresh install: on, and an "off" afterwards survives restarts.+ let (dir, path) = temp_settings("sharing-fresh");+ let s = load(&path);+ assert!(s.experiments.sharing);+ let off = choose_experiment(&s, "experiment:sharing", "off");+ save(&path, &off).unwrap();+ assert!(!load(&path).experiments.sharing);+ assert!(!load(&path).experiments.sharing, "and again");+ let _ = std::fs::remove_dir_all(dir);++ // 0.9.0: toggling any experiment saved sharing false, no marker.+ let (dir, path) = temp_settings("sharing-090");+ std::fs::write(+ &path,+ r#"{"experiments":{"cuaVolume":true,"sharing":false}}"#,+ )+ .unwrap();+ let s = load(&path);+ assert!(s.experiments.sharing && s.experiments.cua_volume);+ let raw: serde_json::Value =+ serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();+ assert_eq!(raw["experiments"]["sharing"], true, "persisted");+ // The user turns it off in 0.9.1: stays off across restarts.+ save(&path, &choose_experiment(&s, "experiment:sharing", "off")).unwrap();+ assert!(!load(&path).experiments.sharing);+ assert!(!load(&path).experiments.sharing);+ assert!(load(&path).experiments.cua_volume);+ let _ = std::fs::remove_dir_all(dir);++ // 0.9.0 settings with sharing already true stay true.+ let (dir, path) = temp_settings("sharing-true");+ std::fs::write(&path, r#"{"experiments":{"sharing":true}}"#).unwrap();+ assert!(load(&path).experiments.sharing);+ let _ = std::fs::remove_dir_all(dir);+ }}diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex 59e8d1f83b..31c433caa1 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -13930,7 +13930,8 @@ public struct AppExperiments: Equatable, Hashable {*/public var yourCloud: Bool/**- * Sharing a Space with other accounts.+ * Sharing a Space with other accounts. On unless turned off: a missing+ * key reads as on (the plans on cua.ai/pricing list sharing).*/public var sharing: Bool/**@@ -13949,7 +13950,8 @@ public struct AppExperiments: Equatable, Hashable {* Your own clouds in the New Space wizard.*/yourCloud: Bool,/**- * Sharing a Space with other accounts.+ * Sharing a Space with other accounts. On unless turned off: a missing+ * key reads as on (the plans on cua.ai/pricing list sharing).*/sharing: Bool,/*** The New UI (the shared web UI) is the main window: the user's choice