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
feat(spaces-macos): pass creatingElsewhere through the WKWebView host (CUA-2349) (#6012)
cua-agents[bot]4b84caa4053b
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swiftindex d8d8e055ee..8bf29a68cc 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift@@ -78,6 +78,15 @@ public final class AppModel {/// Your other computers' rows are the last known ones (kept across a/// daemon restart), not yet confirmed.public private(set) var listStale = false+ /// What your other computers are creating now (CUA-2349), as the last list read said.+ public private(set) var listCreating: [SpaceCreatingElsewhere] = []+ /// `listCreating` less what the list already has a row for (the same+ /// name on that computer), like the Electron host.+ public var creatingElsewhere: [SpaceCreatingElsewhere] {+ listCreating.filter { c in+ !spaces.contains { $0.name == c.name && $0.id.hasPrefix("relay:\(c.machineId)") }+ }+ }/// The Spaces page's empty state and "Reaching N computers…" line, as/// the core decides them: the first-run page only for a complete list.public var listView: AppListView {@@ -881,6 +890,7 @@ public final class AppModel {listIncomplete = list.incompletelistReaching = list.reachinglistStale = list.stale+ listCreating = list.creating// Your other computers could not be read: their rows are the// last known ones (this Mac's are current).rosterError = list.notice.isEmpty ? nildiff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swiftindex f198be1517..ef36d318b0 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift@@ -164,8 +164,12 @@ public struct AppListRead: Sendable {public var stale: Bool/// Why your other computers could not be read, when they could not.public var notice: String+ /// Spaces your other computers are creating now (`SpaceList.creating`, CUA-2349).+ public var creating: [SpaceCreatingElsewhere]- public init(rows: [AppSpaceRow], incomplete: Bool = false, reaching: UInt32 = 0, stale: Bool = false, notice: String = "") {+ public init(rows: [AppSpaceRow], incomplete: Bool = false, reaching: UInt32 = 0, stale: Bool = false, notice: String = "",+ creating: [SpaceCreatingElsewhere] = []) {+ self.creating = creatingself.rows = rowsself.incomplete = incompleteself.reaching = reaching@@ -272,7 +276,8 @@ public final class LiveSpacesBackend: SpacesBackend, @unchecked Sendable {public func listRead() async throws -> AppListRead {let list = try await cua.spaces().listKnown()return AppListRead(rows: await probe(list.spaces), incomplete: list.incomplete,- reaching: list.reaching, stale: list.stale, notice: list.notice)+ reaching: list.reaching, stale: list.stale, notice: list.notice,+ creating: list.creating)}/// The rows of `infos`, each with a bounded reachability probe.@@ -872,10 +877,13 @@ public final class FixtureSpacesBackend: SpacesBackend, @unchecked Sendable {/// Your other computers still answering, as a daemon reaching them says.public var fixtureIncomplete = falsepublic var fixtureReaching: UInt32 = 0+ /// Spaces another computer is creating, as its relay meta says.+ public var fixtureCreating: [SpaceCreatingElsewhere] = []public func listRead() async throws -> AppListRead {await MainActor.run {fixtureListReads += 1- return AppListRead(rows: fixtureRows, incomplete: fixtureIncomplete, reaching: fixtureReaching, stale: fixtureIncomplete)+ return AppListRead(rows: fixtureRows, incomplete: fixtureIncomplete, reaching: fixtureReaching, stale: fixtureIncomplete,+ creating: fixtureCreating)}}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swiftindex 12d0ec504a..44c63e9223 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift@@ -492,6 +492,18 @@ final class WebUIBridge: NSObject, WKScriptMessageHandlerWithReply {"reaching": Int(model.listReaching),// Your other computers' rows are the last known ones, not yet confirmed."stale": model.listStale,+ // Spaces your other computers are creating now (relay meta `cua.new`,+ // CUA-2349): the page shows "Creating macOS on Mac mini… 40%".+ "creatingElsewhere": model.creatingElsewhere.map { c in+ [+ "machineId": c.machineId,+ "machineName": c.machineName,+ "name": c.name,+ "os": c.os,+ "phase": c.phase,+ "percent": Int(c.percent),+ ] as [String: Any]+ },]}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/IncompleteListTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/IncompleteListTests.swiftindex 5f3ae1ed9d..70dafc5591 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/IncompleteListTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/IncompleteListTests.swift@@ -67,4 +67,30 @@ struct IncompleteListTests {#expect(m.listView.empty == false)#expect(m.listView.reachingLine == "Reaching 1 computer…")}++ @Test func aSpaceAnotherComputerIsCreatingReachesThePage() async throws {+ let backend = FixtureSpacesBackend(rows: [])+ backend.fixtureCreating = [+ SpaceCreatingElsewhere(machineId: "m1", machineName: "Mac mini", name: "build", os: "macos",+ phase: "creating", percent: 40, updatedAtMs: 1),+ ]+ let m = model(backend)+ let bridge = WebUIBridge(model: m, allowedOrigins: [])+ await m.refresh()+ let answer = try #require(try await bridge.handle("spaces.list", [:]) as? [String: Any])+ let rows = try #require(answer["creatingElsewhere"] as? [[String: Any]])+ #expect(rows.count == 1)+ #expect(rows[0]["machineId"] as? String == "m1")+ #expect(rows[0]["machineName"] as? String == "Mac mini")+ #expect(rows[0]["name"] as? String == "build")+ #expect(rows[0]["os"] as? String == "macos")+ #expect(rows[0]["phase"] as? String == "creating")+ #expect(rows[0]["percent"] as? Int == 40)++ // Nothing being created: an empty list, never a missing key.+ backend.fixtureCreating = []+ await m.refresh(fresh: true)+ let none = try #require(try await bridge.handle("spaces.list", [:]) as? [String: Any])+ #expect((none["creatingElsewhere"] as? [Any])?.isEmpty == true)+ }}