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): list only Spaces in the notch, never the machines that provide them (#5190)
ddupont1ed129f64ece
diff --git a/apps/cua-spaces-desktop/test/host-bridge.test.ts b/apps/cua-spaces-desktop/test/host-bridge.test.tsindex 419072b318..11be934af2 100644--- a/apps/cua-spaces-desktop/test/host-bridge.test.ts+++ b/apps/cua-spaces-desktop/test/host-bridge.test.ts@@ -763,6 +763,31 @@ describe.skipIf(!built)("This machine, Devices and Settings on the app core", ()expect(items.map((i) => i.id)).toEqual(expect.arrayContaining(["open", "newSpace", "settings", "quit"]));});+ it("the notch lists the Spaces, never a machine that only provides them (CUA-1619)", async () => {+ const { wireView } = await import("../src/notch/core");+ await call("host.setUp", { request: { mode: "direct", direct: "0.0.0.0:3211" } });+ backend.rowsNow = [+ ...backend.rowsNow,+ { ...backend.rowsNow[2]!, id: "relay:m1", name: "studio-mac", provider: "relay", host: undefined },+ { ...backend.rowsNow[2]!, id: "relay:m1/space-1", name: "on-studio", provider: "relay", host: "m1" },+ ];+ await model.refresh();+ // What the notch helper draws (NotchModel.view): the core's view of the+ // app's Spaces (feedNotch hands it model.spaces, machines included).+ const core = native as unknown as import("../src/notch/core").NotchCore;+ const shown = core.appNotchReduce(core.appNotchInitial(), { tag: "Visibility", inner: { shown: true } });+ const opened = core.appNotchReduce(shown.state, { tag: "Click" });+ const view = wireView(core.appNotchView(opened.state, model.spaces));+ const ids = view.tiles.map((t) => t.id);+ expect(ids).toContain("relay:m1/space-1");+ expect(ids).not.toContain("relay:m1");+ expect(ids).not.toContain("this-mac");+ expect(ids.some((id) => isMachineDesktop(model.spaces.find((s) => s.id === id)!))).toBe(false);+ // The list and the menu's count are the same Spaces.+ expect(ids.sort()).toEqual(realSpaces(model.spaces).map((s) => s.id).sort());+ expect(view.tab.count).toBe(String(ids.length));+ });+it("says the launch is still waiting first", async () => {model.startup.phase = { kind: "starting" };const items = menuItems(bridge.context);diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swiftindex ee6dd49dee..bef698069f 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift@@ -188,6 +188,35 @@ struct NotchTests {#expect(notch.view.phase == .closed)}+ /// Hovering the notch lists the Spaces, never a machine that only+ /// provides them (CUA-1619): This machine and your other Mac on the+ /// relay stay off the tiles, the Space that Mac provides is listed, and+ /// the tab counts what the tiles list.+ @Test func hoverListsOnlySpacesNeverTheMachinesThatProvideThem() async {+ var machine = FixtureSpacesBackend.sample[0]+ machine.id = "relay:studio"+ machine.name = "Studio"+ machine.provider = "relay"+ var provided = FixtureSpacesBackend.sample[0]+ provided.id = "relay:studio/dev"+ provided.name = "Dev"+ provided.provider = "relay"+ provided.host = "studio"+ let m = ViewModelTests().makeModel(FixtureSpacesBackend(rows: [machine, provided]))+ await m.refresh()+ #expect(m.notch.spaces.contains { $0.id == "relay:studio" }, "the roster still has the machine")++ let clock = ManualScheduler()+ let notch = NotchModel(scheduler: clock)+ notch.spaces = m.notch.spaces+ notch.send(.hoverEnter)+ clock.advance(motion.hoverDwellMs)+ #expect(notch.view.phase == .tiles)+ #expect(notch.view.tiles.map(\.id) == ["relay:studio/dev"])+ #expect(notch.view.tab.count == "1")+ #expect(notch.view.tiles.count == Int(appOpenableCount(spaces: notch.spaces)))+ }+// MARK: - The presentation state machine@Test func openingSpringsTheShapeThenFadesTheContentIn() {diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swiftindex 93ffd3b940..61c3515f19 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift@@ -188,7 +188,15 @@ struct SnapshotTests {#expect(space.os.label == expected)var notch = appNotchInitial()notch.open = true- let tile = try #require(appNotchView(state: notch, spaces: [space]).tiles.first)+ // The machine itself is no notch tile (CUA-1619): a Space it+ // provides, with the same OS, is.+ var providedRow = row+ providedRow.id = "relay:test-host/dev"+ providedRow.host = "test-host"+ let provided = appRowsToSpaces(rows: [providedRow], nowMs: 0)[0]+ #expect(appNotchView(state: notch, spaces: [space]).tiles.isEmpty)+ let tile = try #require(appNotchView(state: notch, spaces: [space, provided]).tiles.first)+ #expect(tile.id == provided.id)#expect(tile.symbol == (os == nil ? "computer" : "os-macos"))let view = VStack(alignment: .leading, spacing: 12) {HStack { OsIconImage(id: tile.symbol, size: 18); Text(space.name) }diff --git a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rsindex 0d43213a0f..c584c68434 100644--- a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs@@ -490,16 +490,19 @@ pub fn filter(spaces: &[Space], query: &str) -> Vec<Space> {.collect()}-/// The Space tiles: MRU order, not this machine, at most [`MAX_TILES`].+/// The Space tiles: the Spaces the user can open+/// ([`crate::spaces::openable_spaces`], never This machine or another+/// machine that only provides Spaces, the same Spaces the tab counts), in+/// MRU order, at most [`MAX_TILES`].pub fn tiles(spaces: &[Space], targeted: Option<&str>) -> Vec<NotchTile> {tiles_matching(spaces, targeted, "")}/// [`tiles`] narrowed by the header's search.pub fn tiles_matching(spaces: &[Space], targeted: Option<&str>, query: &str) -> Vec<NotchTile> {- sort_by_mru(spaces)+ sort_by_mru(&crate::spaces::openable_spaces(spaces)).into_iter()- .filter(|s| s.id != THIS_MACHINE_ID && matches(s, query))+ .filter(|s| matches(s, query)).take(MAX_TILES).map(|s| NotchTile {location: location(&s, spaces),@@ -1448,6 +1451,63 @@ mod tests {assert_eq!(t[0].label, "Dev, Linux, This Mac, Running");}+ /// Hovering the notch lists the Spaces, never the machines that only+ /// provide them (CUA-1619): not This machine while it hosts, not one of+ /// your machines on the relay. The list and the tab's count are the same+ /// Spaces, searching included.+ #[test]+ fn the_tiles_leave_out_the_machines_that_provide_spaces() {+ use crate::host::{HostSummaryInput, this_machine_space};+ use crate::model::SpaceProvider;+ let hosting = HostSummaryInput {+ configured: true,+ service_running: true,+ sharing: true,+ ..Default::default()+ };+ let this_mac = this_machine_space(Some(&hosting), 0, SpaceOs::Macos);+ let mut machine = space(+ "relay:studio",+ "Studio",+ SpaceOs::Macos,+ SpaceStatus::Running,+ );+ machine.provider = Some(SpaceProvider::Relay);+ let mut provided = space(+ "relay:studio/dev",+ "Dev",+ SpaceOs::Linux,+ SpaceStatus::Running,+ );+ provided.provider = Some(SpaceProvider::Relay);+ provided.host = Some("studio".into());+ let spaces = vec![this_mac, machine, provided];++ let ids = |t: &[NotchTile]| t.iter().map(|t| t.id.clone()).collect::<Vec<_>>();+ assert_eq!(ids(&tiles(&spaces, None)), ["relay:studio/dev"]);+ let open = NotchState {+ open: true,+ ..Default::default()+ };+ let v = view(&open, &spaces);+ assert_eq!(ids(&v.tiles), ["relay:studio/dev"]);+ assert_eq!(v.label, "1 Space");+ assert_eq!(v.count_label, "1 Space");+ assert_eq!(+ v.tiles.len(),+ crate::spaces::openable_count(&spaces) as usize+ );+ // The provided Space still says which machine it runs on.+ assert_eq!(v.tiles[0].location, "Studio");+ // A search never brings the machines back.+ assert!(tiles_matching(&spaces, None, "this mac").is_empty());+ assert!(tiles_matching(&spaces, None, "macos").is_empty());+ // Only machines: no tiles, "0 Spaces".+ let v = view(&open, &spaces[..2]);+ assert!(v.tiles.is_empty());+ assert_eq!(v.count_label, "0 Spaces");+ }+#[test]fn the_tab_counts_remote_spaces_and_tucks_away_during_a_drag() {let spaces = vec![diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rsindex 30dd349b61..e65abc0541 100644--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs@@ -384,13 +384,24 @@ pub fn is_machine_desktop(space: &Space) -> bool {.is_some_and(|own| !own.is_empty() && !own.contains('/') && !own.starts_with("space-"))}-/// The Spaces the user can open: every Space but the machines' own-/// desktops ([`is_machine_desktop`]): not This machine, even while it-/// provides Spaces, and not one of your machines on the relay. A Space a-/// machine provides counts. The notch tab and the menu bar item both show-/// this number.+/// The Spaces the user can open, in `spaces`' order: every Space but the+/// machines' own desktops ([`is_machine_desktop`]): not This machine, even+/// while it provides Spaces, and not one of your machines on the relay. A+/// Space a machine provides is listed. The notch's tiles list these, and+/// its tab and the menu bar item count them ([`openable_count`]), so the+/// list and the count always agree.+pub fn openable_spaces(spaces: &[Space]) -> Vec<Space> {+ spaces+ .iter()+ .filter(|s| !is_machine_desktop(s))+ .cloned()+ .collect()+}++/// How many [`openable_spaces`] there are: the notch tab's and the menu bar+/// item's number.pub fn openable_count(spaces: &[Space]) -> u32 {- spaces.iter().filter(|s| !is_machine_desktop(s)).count() as u32+ openable_spaces(spaces).len() as u32}/// The three ambient status dots.@@ -470,7 +481,8 @@ mod tests {fn unknown_os_stays_neutral_across_the_roster_and_details() {let space = row_to_space(&SpaceRow {- id: "relay:mac-host".into(),+ // A Space a machine provides (the machine itself is no tile).+ id: "relay:space-0a1b2c3d".into(),provider: "relay".into(),os: None,// Neither stale names nor a known image may invent an OS.