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 machine state in both UIs, from the core (CUA-1617) (#5188)
ddupontf8202745a66a
diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.tsindex 46078dbfda..9a18c7a00f 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts@@ -10524,7 +10524,22 @@ export type AppMachinePageRow = {/*** The device's last session (Unix seconds), when it has a device.*/- lastSeen?: bigint+ lastSeen?: bigint,+ /**+ * The row's status word, the same in every UI ([`status_word`]):+ * "Online", "Not sharing" or "Offline".+ */+ status: string,+ /**+ * The Spaces it runs that the Spaces list shows: this machine's local+ * Spaces, or the Spaces another machine provides (`host`).+ */+ spaces: number,+ /**+ * "1 Space", "3 Spaces", "No Spaces" ([`spaces_label`]); empty for a+ * device of its own, which runs no Spaces.+ */+ spacesLabel: string}/**@@ -10558,7 +10573,10 @@ const FfiConverterTypeAppMachinePageRow = (() => {deviceOnly: FfiConverterBool.read(from),spaceId: FfiConverterOptionalString.read(from),stoppedSharing: FfiConverterBool.read(from),- lastSeen: FfiConverterOptionalUInt64.read(from)+ lastSeen: FfiConverterOptionalUInt64.read(from),+ status: FfiConverterString.read(from),+ spaces: FfiConverterUInt32.read(from),+ spacesLabel: FfiConverterString.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -10573,6 +10591,9 @@ const FfiConverterTypeAppMachinePageRow = (() => {FfiConverterOptionalString.write(value.spaceId, into);FfiConverterBool.write(value.stoppedSharing, into);FfiConverterOptionalUInt64.write(value.lastSeen, into);+ FfiConverterString.write(value.status, into);+ FfiConverterUInt32.write(value.spaces, into);+ FfiConverterString.write(value.spacesLabel, into);}allocationSize(value: TypeName): number {return FfiConverterString.allocationSize(value.id) +@@ -10585,7 +10606,10 @@ const FfiConverterTypeAppMachinePageRow = (() => {FfiConverterBool.allocationSize(value.deviceOnly) +FfiConverterOptionalString.allocationSize(value.spaceId) +FfiConverterBool.allocationSize(value.stoppedSharing) +- FfiConverterOptionalUInt64.allocationSize(value.lastSeen);+ FfiConverterOptionalUInt64.allocationSize(value.lastSeen) ++ FfiConverterString.allocationSize(value.status) ++ FfiConverterUInt32.allocationSize(value.spaces) ++ FfiConverterString.allocationSize(value.spacesLabel);}};diff --git a/apps/cua-spaces-desktop/test/checklist-machines.test.ts b/apps/cua-spaces-desktop/test/checklist-machines.test.tsindex 9a7a9d7f79..b2bc704d80 100644--- a/apps/cua-spaces-desktop/test/checklist-machines.test.ts+++ b/apps/cua-spaces-desktop/test/checklist-machines.test.ts@@ -80,8 +80,13 @@ describe.skipIf(!built)("the checklist and the Machines rows on the app core", (expect(rows[0]).toMatchObject({ id: "this-mac", current: true, device: "dev_mac" });expect(rows.filter((r) => r.deviceOnly).map((r) => r.name)).toEqual(["Work laptop"]);// The page gets the same rows.- const answer = (await call("machines.list")) as { rows: { id: string }[] };+ const answer = (await call("machines.list")) as { rows: { id: string; status: string; spacesLabel: string }[] };expect(answer.rows.map((r) => r.id)).toEqual(rows.map((r) => r.id));+ // With the core's status word and Spaces count (CUA-1617), as the+ // SwiftUI list shows them.+ expect(answer.rows.map((r) => [r.status, r.spacesLabel])).toEqual(rows.map((r) => [r.status, r.spacesLabel]));+ expect(rows[0]!.status).toBe("Online");+ expect(rows.find((r) => r.deviceOnly)!.spacesLabel).toBe("");});it("ticks steps off from what the app shows, and the page changes the same copy", async () => {diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swiftindex 85d4ba9676..bc1a0cc097 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swift@@ -20,7 +20,7 @@ struct MachinesPageView: View {VStack(alignment: .leading, spacing: 0) {List(selection: $selectedId) {ForEach(rows, id: \.id) { row in- MachineRowView(row: row, status: status(row), spaces: spacesCount(row))+ MachineRowView(row: row, status: status(row)).tag(row.id)}}@@ -70,36 +70,26 @@ struct MachinesPageView: View {}}- /// The row's second line: the sidebar's status for a machine with a- /// desktop row, the device's platform, state and last session for a- /// device of its own, else whether it is online.+ /// The row's second line: the device's platform, state and last+ /// session for a device of its own, else the core's status word+ /// (`machines::status_word`: "Online", "Not sharing", "Offline"), the+ /// same the New UI shows. Never a Space's word ("Suspended").private func status(_ row: AppMachinePageRow) -> String {- if let id = row.spaceId,- let s = model.sidebar.sections.flatMap(\.rows).first(where: { $0.id == id }) ?? model.sidebar.thisMachine.flatMap({ $0.id == id ? $0 : nil }) {- return s.statusText- }if row.deviceOnly, let d = model.devices.view.rows.first(where: { $0.id == row.device }) {return model.devices.rowDetail(d)}- return row.online ? "Online" : "Offline"- }-- /// The Spaces a machine provides (none for this machine or a device).- private func spacesCount(_ row: AppMachinePageRow) -> Int? {- guard !row.current, !row.deviceOnly else { return nil }- return model.hostedRows(row.spaceId ?? "relay:\(row.id)").count+ return row.status}}/// The OS mark for a page row's system (`os-macos`, ..., `computer`).private func osIcon(_ os: String) -> String { os.isEmpty ? "computer" : "os-\(os)" }-/// One machine: its OS mark, name, status line and how many Spaces it runs.+/// One machine: its OS mark, name, status line and how many Spaces it runs+/// (the core's `spacesLabel`, none for a device of its own).struct MachineRowView: View {let row: AppMachinePageRowlet status: String- /// Spaces it provides (nil for This machine and a device).- let spaces: Int?var body: some View {HStack(spacing: 10) {@@ -120,8 +110,8 @@ struct MachineRowView: View {.lineLimit(1)}Spacer(minLength: 4)- if let spaces {- Text(spaces == 1 ? "1 Space" : "\(spaces) Spaces")+ if !row.spacesLabel.isEmpty {+ Text(row.spacesLabel).font(.callout.monospacedDigit()).foregroundStyle(.secondary)}@@ -147,7 +137,7 @@ struct MachineInfoView: View {let hosted = row.deviceOnly ? [] : model.hostedRows("relay:\(row.id)")Form {Section {- LabeledContent("Status", value: row.online ? "Online" : "Offline")+ LabeledContent("Status", value: row.status)if !row.os.isEmpty {LabeledContent("System", value: device?.platform.isEmpty == false ? device!.platform : row.os)}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ChecklistPaletteTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ChecklistPaletteTests.swiftindex 43764d22ca..1ea11ccaf3 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ChecklistPaletteTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ChecklistPaletteTests.swift@@ -113,6 +113,31 @@ struct ChecklistPaletteTests {}}+ /// CUA-1617: a Mac whose owner stopped sharing reads "Not sharing" and+ /// "No Spaces" in the classic list, from the core's row (never a+ /// Space's "Suspended"), and the New UI gets the same words.+ @Test func aMachineThatStoppedSharingReadsTheSameInBothUIs() async throws {+ let input = try appMachinesPageInputFromJson(json: """+ {"hostOs": "macos", "now": 1800000000, "spaces": [+ {"id": "relay:b695", "name": "Dillons-MacBook-Pro-2.local", "os": "macos",+ "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal",+ "provider": "relay",+ "sdk": {"features": [], "spacesdVersion": "", "reachable": false,+ "error": "unauthenticated: Dillons-MacBook-Pro-2.local stopped sharing: ask its owner"}}+ ], "devices": [], "hostnames": {}, "presence": {"b695": false}}+ """)+ let row = appMachinesPageRows(input: input)[1]+ #expect(row.status == "Not sharing")+ #expect(row.spacesLabel == "No Spaces")++ let m = await signedInModel()+ let rows = m.machinePageRows+ let bridge = WebUIBridge(model: m, allowedOrigins: [])+ let answer = bridge.machines()["rows"] as? [[String: Any]]+ #expect(answer?.map { $0["status"] as? String } == rows.map(\.status))+ #expect(answer?.map { $0["spacesLabel"] as? String } == rows.map(\.spacesLabel))+ }+/// CUA-1509: the app ticks the checklist off itself, whichever UI is/// open, and the New UI reads and changes the same copy.@Test func bothUIsShareOneChecklist() async throws {diff --git a/apps/cua-spaces-web/src/__tests__/machines-reach.test.tsx b/apps/cua-spaces-web/src/__tests__/machines-reach.test.tsxindex 72ad199bc5..04c591afea 100644--- a/apps/cua-spaces-web/src/__tests__/machines-reach.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/machines-reach.test.tsx@@ -2,8 +2,8 @@// Copyright (c) 2026 Cua AI, Inc.// A machine its owner stopped sharing is not counted-// online and reads "Not reachable" (the core's word, as the SwiftUI detail-// shows it), its Status line wraps instead of being cut, and it can be+// online and reads "Not sharing" (the core's word, `machines::NOT_SHARING`,+// as the SwiftUI Machines list shows it), its Status line wraps instead of being cut, and it can be// removed with the core's Delete action, as the SwiftUI toolbar has it.import { act, cleanup, fireEvent, screen, waitFor, within } from "@testing-library/react";@@ -43,7 +43,7 @@ function host(removed: string[]): TestHost {}describe.skipIf(!wasmBuilt)("a machine its owner stopped sharing (real routes, wasm core)", () => {- it("is not counted online, reads Not reachable, shows its whole Status line, and can be removed", async () => {+ it("is not counted online, reads Not sharing, shows its whole Status line, and can be removed", async () => {const removed: string[] = [];const { router, hooks } = await mountApp("/machines", host(removed));await router.load();@@ -53,11 +53,11 @@ describe.skipIf(!wasmBuilt)("a machine its owner stopped sharing (real routes, wawait screen.findByText(`${total} machines, ${online} online`);const row = document.querySelector('[data-machine-id="studio"]') as HTMLElement;- expect(within(row).getByText("Not reachable")).toBeTruthy();+ expect(within(row).getByText("Not sharing")).toBeTruthy();act(() => row.click());const detail = await screen.findByRole("region", { name: "Studio details" });expect(within(detail).queryByText(/Online, not sharing/)).toBeNull();- expect(within(detail).getAllByText("Not reachable").length).toBeGreaterThan(0);+ expect(within(detail).getAllByText("Not sharing").length).toBeGreaterThan(0);const status = within(detail).getByText("Status").closest("div")!.parentElement!.parentElement!;const value = status.querySelector("[data-fact-value]")!;expect(value.textContent).toContain("cua host start");diff --git a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.tsindex a77d57186d..b8233124c0 100644--- a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts+++ b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts@@ -250,9 +250,9 @@ describe("the Machines page's rows from the host (machines.pageRows)", () => {thisMachine: { status: "local", statusText: "Sharing", detail: "Sharing · Relay" },deviceStates: { dev_l1: "enrolled" },rows: [- { id: "this-mac", name: "This Mac", online: true, os: "macos", via: "local", current: true, device: "dev_me", deviceOnly: false, spaceId: "this-mac", stoppedSharing: false, lastSeen: 1799999990 },- { id: "b695", name: "studio-2.local", online: true, os: "macos", via: "relay", current: false, device: "dev_s", deviceOnly: false, spaceId: "relay:b695", stoppedSharing: true, lastSeen: null },- { id: "dev_l1", name: "Laptop", online: false, os: "macos", via: "relay", current: false, device: "dev_l1", deviceOnly: true, spaceId: null, stoppedSharing: false, lastSeen: 1797000000 },+ { id: "this-mac", name: "This Mac", online: true, os: "macos", via: "local", current: true, device: "dev_me", deviceOnly: false, spaceId: "this-mac", stoppedSharing: false, lastSeen: 1799999990, status: "Online", spaces: 1, spacesLabel: "1 Space" },+ { id: "b695", name: "studio-2.local", online: true, os: "macos", via: "relay", current: false, device: "dev_s", deviceOnly: false, spaceId: "relay:b695", stoppedSharing: true, lastSeen: null, status: "Not sharing", spaces: 0, spacesLabel: "No Spaces" },+ { id: "dev_l1", name: "Laptop", online: false, os: "macos", via: "relay", current: false, device: "dev_l1", deviceOnly: true, spaceId: null, stoppedSharing: false, lastSeen: 1797000000, status: "Offline", spaces: 0, spacesLabel: "" },],},);@@ -267,5 +267,11 @@ describe("the Machines page's rows from the host (machines.pageRows)", () => {const machines = toMachines(rows, []);expect(machines.map((m) => m.id)).toEqual(["this-mac", "b695", "dev_l1"]);expect(machines[2]!.device).toBe(true);+ // The core's words for each row, as the SwiftUI list shows them.+ expect(machines.map((m) => [m.status, m.spacesLabel])).toEqual([+ ["Online", "1 Space"],+ ["Not sharing", "No Spaces"],+ ["Offline", ""],+ ]);});});diff --git a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts b/apps/cua-spaces-web/src/bridge/adapters/webkit.tsindex 7bc6ca5616..67270c38c2 100644--- a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/webkit.ts@@ -216,6 +216,9 @@ function fromPageRows(spaces: WkSpaces, machines: WkMachines, rows: MachinePageRlimits: r.stoppedSharing ? withNotSharing([], stoppedSharingLine(r.name)) : [],merged: true,};+ // The core's words for the row, the same the SwiftUI list shows.+ if (r.status) row.status = r.status;+ if (r.spacesLabel != null) row.spacesLabel = r.spacesLabel;const detail = r.current ? machines.thisMachine?.detail : r.deviceOnly ? dev?.detail : own?.detail || dev?.detail;if (detail) row.detail = detail;if (r.lastSeen != null) row.lastSeen = r.lastSeen;diff --git a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.jsonindex cb313ada90..303b7ffd33 100644--- a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json+++ b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json@@ -1514,6 +1514,15 @@"number","null"]+ },+ "status": {+ "type": "string"+ },+ "spaces": {+ "type": "number"+ },+ "spacesLabel": {+ "type": "string"}},"required": [@@ -1527,7 +1536,10 @@"deviceOnly","spaceId","stoppedSharing",- "lastSeen"+ "lastSeen",+ "status",+ "spaces",+ "spacesLabel"]},"MachineRow": {@@ -1629,6 +1641,12 @@},"merged": {"type": "boolean"+ },+ "status": {+ "type": "string"+ },+ "spacesLabel": {+ "type": "string"}},"required": [diff --git a/apps/cua-spaces-web/src/bridge/contracts/host.ts b/apps/cua-spaces-web/src/bridge/contracts/host.tsindex a040668b63..7dc2e10515 100644--- a/apps/cua-spaces-web/src/bridge/contracts/host.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/host.ts@@ -151,6 +151,10 @@ export interface MachineRow extends SpaceHost {/** The host listed the rows with the core (`machines.pageRows`): each* computer is already once, so the store does not merge them again. */merged?: boolean;+ /** The core's status word for the row (`MachinePageRow.status`). */+ status?: string;+ /** The core's Spaces count for the row (`MachinePageRow.spacesLabel`). */+ spacesLabel?: string;}/** One Machines row as the core lists it (`machines::MachinePageRow`),@@ -173,6 +177,12 @@ export interface MachinePageRow {stoppedSharing: boolean;/** The device's last session (Unix seconds). */lastSeen: number | null;+ /** "Online", "Not sharing" or "Offline" (`machines::status_word`). */+ status?: string;+ /** The Spaces it runs (`machines::page_rows`). */+ spaces?: number;+ /** "1 Space", "3 Spaces", "No Spaces"; empty for a device of its own. */+ spacesLabel?: string;}export interface ServiceState {diff --git a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts b/apps/cua-spaces-web/src/bridge/contracts/shapes.tsindex 7c9c441d51..e6efdcc8ea 100644--- a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts@@ -172,6 +172,8 @@ const MachineRowShape = ref(presence: optNull(bool),accessNotice: optNull(MachineAccessNoticeShape),merged: opt(bool),+ status: opt(str),+ spacesLabel: opt(str),}),);@@ -642,6 +644,9 @@ const MachinePageRowShape = ref(spaceId: nullable(str),stoppedSharing: bool,lastSeen: nullable(num),+ status: str,+ spaces: num,+ spacesLabel: str,}),);diff --git a/apps/cua-spaces-web/src/bridge/derive.ts b/apps/cua-spaces-web/src/bridge/derive.tsindex ad016c306b..a57a9bf1ee 100644--- a/apps/cua-spaces-web/src/bridge/derive.ts+++ b/apps/cua-spaces-web/src/bridge/derive.ts@@ -304,6 +304,12 @@ export interface Machine {/** Online, but its owner stopped sharing it: why, in one line. Calls to it* are refused, so New Space lists it as not sharing. */notSharing?: string;+ /** The core's status word for the row (`machines::status_word`), when+ * the host listed the rows with the core. */+ status?: string;+ /** The core's Spaces count for the row (`machines::spaces_label`; empty+ * for a device of its own), when the host listed the rows with the core. */+ spacesLabel?: string;/** The machine this UI runs on. */current: boolean;model?: string;@@ -457,6 +463,8 @@ export function toMachines(rows: MachineRow[], spaces: Space[], core?: CoreClienpanel: m.current && m.host && core ? hostPanel(core, m.host) : undefined,...(m.current && m.host?.progress ? { hostProgress: m.host.progress } : {}),...(notSharing ? { notSharing } : {}),+ ...(m.status ? { status: m.status } : {}),+ ...(m.spacesLabel != null ? { spacesLabel: m.spacesLabel } : {}),...(m.device ? { device: true } : {}),...(m.current && m.accessNotice ? { accessNotice: m.accessNotice } : {}),};diff --git a/apps/cua-spaces-web/src/lib/machines.test.ts b/apps/cua-spaces-web/src/lib/machines.test.tsindex 588d3021f5..4872e93ba1 100644--- a/apps/cua-spaces-web/src/lib/machines.test.ts+++ b/apps/cua-spaces-web/src/lib/machines.test.ts@@ -4,7 +4,7 @@import { describe, expect, it } from "vitest";import type { Machine } from "@/bridge";-import { connectionLabel, machineOs, machinesSummary, machineSubtitle, presenceLabel, presenceWord, reachable, selectedMachine, spaceCount } from "./machines";+import { connectionLabel, machineOs, machinesSummary, machineSubtitle, presenceLabel, presenceWord, reachable, selectedMachine, spaceCount, spacesLabel } from "./machines";const NOW = Date.parse("2026-10-03T12:00:00Z");@@ -47,12 +47,11 @@ describe("machines", () => {expect(presenceLabel(machine({ online: false, lastSeen: (NOW - 2 * 86_400_000) / 1000 }), NOW)).toBe("Offline, last seen 2 days ago");});- it("says a machine its owner stopped sharing is not reachable", () => {+ it("says a machine its owner stopped sharing is not sharing", () => {const stopped = machine({ notSharing: "Studio stopped sharing" });- // As the SwiftUI detail says it: the core's word, not "online".- expect(presenceLabel(stopped, NOW)).toBe("Not reachable");- expect(presenceWord(stopped)).toBe("Not reachable");- expect(presenceLabel(stopped, NOW, "Unreachable here")).toBe("Unreachable here");+ // The core's word (`machines::NOT_SHARING`), as the SwiftUI list says it.+ expect(presenceLabel(stopped, NOW)).toBe("Not sharing");+ expect(presenceWord(stopped)).toBe("Not sharing");expect(reachable(stopped)).toBe(false);expect(reachable(machine({}))).toBe(true);expect(presenceWord(machine({}))).toBe("Online");@@ -61,6 +60,16 @@ describe("machines", () => {expect(presenceLabel(machine({ online: false, notSharing: "x" }), NOW)).toBe("Offline");});+ it("shows the core's status word and Spaces count when the host has them", () => {+ // CUA-1617: never a Space's "Suspended" or "Not reachable".+ const row = machine({ notSharing: "x", status: "Not sharing", spacesLabel: "No Spaces" });+ expect(presenceWord(row)).toBe("Not sharing");+ expect(presenceLabel(row, NOW)).toBe("Not sharing");+ expect(spacesLabel(row, 4)).toBe("No Spaces");+ expect(spacesLabel(machine({ device: true, spacesLabel: "" }), 0)).toBe("");+ expect(spacesLabel(machine({}), 1)).toBe("1 Space");+ });+it("counts Spaces and keeps a valid selection", () => {expect([0, 1, 3].map(spaceCount)).toEqual(["No Spaces", "1 Space", "3 Spaces"]);const list = [machine({ id: "a" }), machine({ id: "b" })];diff --git a/apps/cua-spaces-web/src/lib/machines.ts b/apps/cua-spaces-web/src/lib/machines.tsindex 9f684eec0d..2e6b7a1c9c 100644--- a/apps/cua-spaces-web/src/lib/machines.ts+++ b/apps/cua-spaces-web/src/lib/machines.ts@@ -37,26 +37,28 @@ export function machineSubtitle(m: Pick<Machine, "os" | "connection" | "current"return [m.model ?? osName(m), connectionLabel(m)].join(" · ");}-/** The core's word for a machine its owner stopped sharing: it cannot be- * reached from here (`sidebar::detail_live`'s preview line). */-export const NOT_REACHABLE = "Not reachable";+/** The core's word for a machine its owner stopped sharing+ * (`machines::NOT_SHARING`): connected to the relay, but it refuses every+ * call. */+export const NOT_SHARING = "Not sharing";/** Usable from here: online and shared (a machine whose owner stopped* sharing it is connected, but nothing here can reach it). */export const reachable = (m: Pick<Machine, "online" | "notSharing">): boolean => m.online && !m.notSharing;-/** "Online", "Not reachable" (its owner stopped sharing it; `reach` is the- * core's word for its Space, as the SwiftUI detail shows it), or "Offline"- * with when it was last seen. */-export function presenceLabel(m: Pick<Machine, "online" | "lastSeen" | "notSharing">, now: number, reach?: string | null): string {- if (m.online) return m.notSharing ? (reach ?? NOT_REACHABLE) : "Online";- return m.lastSeen ? `Offline, last seen ${relativeTime(m.lastSeen * 1000, now)}` : "Offline";+/** The detail's line: the row's word, and when an offline machine was+ * last seen. */+export function presenceLabel(m: Pick<Machine, "online" | "lastSeen" | "notSharing" | "status">, now: number): string {+ if (m.online || !m.lastSeen) return presenceWord(m);+ return `Offline, last seen ${relativeTime(m.lastSeen * 1000, now)}`;}-/** The list row's one word: "Online", "Not reachable" or "Offline". */-export function presenceWord(m: Pick<Machine, "online" | "notSharing">, reach?: string | null): string {+/** The list row's one word: the core's (`machines::status_word`, the same+ * the SwiftUI Machines list shows): "Online", "Not sharing" or "Offline". */+export function presenceWord(m: Pick<Machine, "online" | "notSharing" | "status">): string {+ if (m.status) return m.status;if (!m.online) return "Offline";- return m.notSharing ? (reach ?? NOT_REACHABLE) : "Online";+ return m.notSharing ? NOT_SHARING : "Online";}/** "1 Space", "3 Spaces", "No Spaces". */@@ -65,6 +67,13 @@ export function spaceCount(n: number): string {return `${n} ${n === 1 ? "Space" : "Spaces"}`;}+/** The row's Spaces count: the core's (`machines::spaces_label`, the same+ * the SwiftUI Machines list shows), else `n` counted here. Empty for a+ * device of its own (it runs no Spaces). */+export function spacesLabel(m: Pick<Machine, "spacesLabel">, n: number): string {+ return m.spacesLabel ?? spaceCount(n);+}+/** The selected machine: the chosen one if it is still listed, else the first. */export function selectedMachine<T extends Pick<Machine, "id">>(machines: readonly T[], id: string | null): T | undefined {return machines.find((m) => m.id === id) ?? machines[0];diff --git a/apps/cua-spaces-web/src/routes/machines/index.tsx b/apps/cua-spaces-web/src/routes/machines/index.tsxindex da8055ea87..8b2172e2a3 100644--- a/apps/cua-spaces-web/src/routes/machines/index.tsx+++ b/apps/cua-spaces-web/src/routes/machines/index.tsx@@ -15,7 +15,7 @@ import { StateLabel } from "@/components/state-dot";import { ConfirmDialog } from "@/components/ui/alert-dialog";import { Button } from "@/components/ui/button";import { toast } from "@/components/ui/toast";-import { connectionLabel, machineOs, machinesSummary, machineSubtitle, osName, presenceLabel, presenceWord, reachable, selectedMachine, spaceCount } from "@/lib/machines";+import { connectionLabel, machineOs, machinesSummary, machineSubtitle, osName, presenceLabel, presenceWord, reachable, selectedMachine, spacesLabel } from "@/lib/machines";import { osLabel, realSpaces, spaceState } from "@/lib/spaces";import { cn, relativeTime } from "@/lib/utils";@@ -46,17 +46,13 @@ function MachinesPage() {// Reachable from here: a machine whose owner stopped sharing it is not.const online = machines.filter(reachable).length;// Another machine's own Space (`relay:<id>`), drawn by the core as the- // SwiftUI detail draws it: its word when it can't be reached, and Remove.+ // SwiftUI detail draws it: its Remove action.const access = machines.find((m) => m.current)?.accessNotice ?? null;const detailOf = (m: Machine): { space: Space; detail: SpaceDetailView } | null => {if (m.current) return null;const space = spaces.find((s) => s.id === `relay:${m.id}`);return space ? { space, detail: spaceDetail(core, space, null, null, experiments, access) } : null;};- const reachWord = (m: Machine) => {- const d = detailOf(m)?.detail;- return d && !d.canStream && !d.desktopNote ? d.previewText : null;- };return (<Page>@@ -97,7 +93,6 @@ function MachinesPage() {<li key={m.id}><MachineRowmachine={m}- reach={reachWord(m)}spaces={realSpaces(spaces).filter((s) => m.spaceIds.includes(s.id)).length}selected={m.id === selected?.id}onSelect={() => setSelectedId(m.id)}@@ -115,7 +110,6 @@ function MachinesPage() {<MachineDetailkey={selected.id}machine={selected}- reach={reachWord(selected)}own={detailOf(selected)}spaces={realSpaces(spaces).filter((s) => selected.spaceIds.includes(s.id))}onRemoved={() => setSelectedId(null)}@@ -142,7 +136,8 @@ function PresenceDot({ online, notSharing }: { online: boolean; notSharing?: booreturn <span className={cn("size-1.5 shrink-0 rounded-full", tone)} aria-hidden />;}-function MachineRow({ machine: m, reach, spaces, selected, onSelect }: { machine: Machine; reach: string | null; spaces: number; selected: boolean; onSelect: () => void }) {+function MachineRow({ machine: m, spaces, selected, onSelect }: { machine: Machine; spaces: number; selected: boolean; onSelect: () => void }) {+ const count = spacesLabel(m, spaces);return (<buttontype="button"@@ -169,9 +164,9 @@ function MachineRow({ machine: m, reach, spaces, selected, onSelect }: { machine<div className="flex shrink-0 flex-col items-end gap-1"><span className="inline-flex items-center gap-1.5 text-xs text-muted-foreground"><PresenceDot online={m.online} notSharing={Boolean(m.notSharing)} />- {presenceWord(m, reach)}+ {presenceWord(m)}</span>- <span className="text-xs text-muted-foreground tabular-nums">{spaceCount(spaces)}</span>+ {count ? <span className="text-xs text-muted-foreground tabular-nums">{count}</span> : null}</div></button>);@@ -179,13 +174,11 @@ function MachineRow({ machine: m, reach, spaces, selected, onSelect }: { machinefunction MachineDetail({machine: m,- reach,own,spaces,onRemoved,}: {machine: Machine;- reach: string | null;own: { space: Space; detail: SpaceDetailView } | null;spaces: Space[];onRemoved: () => void;@@ -214,7 +207,7 @@ function MachineDetail({<h2 className="truncate text-[15px] font-semibold">{m.name}</h2><p className="flex items-center gap-1.5 text-xs text-muted-foreground"><PresenceDot online={m.online} notSharing={Boolean(m.notSharing)} />- {presenceLabel(m, now, reach)}+ {presenceLabel(m, now)}</p></div>{remove ? (diff --git a/docs/content/docs/cua-sdk/reference/spaces/machines-app-core.mdx b/docs/content/docs/cua-sdk/reference/spaces/machines-app-core.mdxindex b0d9ede2ca..d1598107b9 100644--- a/docs/content/docs/cua-sdk/reference/spaces/machines-app-core.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/machines-app-core.mdx@@ -47,6 +47,9 @@ Returned by [`app_machines_page_rows`](#app_machines_page_rows).| `space_id` / `spaceId` | `Option<String>` | | The Spaces list's row that is this machine's own desktop (`this-mac`, `relay:<machine>`), when there is one: the classic UI's detail for it. || `stopped_sharing` / `stoppedSharing` | `bool` | | Online, but its owner stopped sharing it. || `last_seen` / `lastSeen` | `Option<u64>` | | The device's last session (Unix seconds), when it has a device. |+| `status` | `String` | | The row's status word, the same in every UI (`status_word`): "Online", "Not sharing" or "Offline". |+| `spaces` | `u32` | | The Spaces it runs that the Spaces list shows: this machine's local Spaces, or the Spaces another machine provides (`host`). |+| `spaces_label` / `spacesLabel` | `String` | | "1 Space", "3 Spaces", "No Spaces" (`spaces_label`); empty for a device of its own, which runs no Spaces. |## `AppMachinesPageInput` recorddiff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.jsonindex 4a1306d5e0..c9485d4e3a 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.json@@ -46,19 +46,19 @@{"page": "a spare Mac with one Space, a machine that stopped sharing and devices only in the device list","rows": [- "This Mac [this-mac] local macos online (this machine) + dev_me desktop this-mac",- "studio-2.local [b6953d14ff94b10fcbb38bdd13c47824] relay macos online + dev_s desktop relay:b6953d14ff94b10fcbb38bdd13c47824 (stopped sharing)",- "BYOC tests [dev_byoc] relay macos offline (a device)",- "Ana's MacBook Pro [dev_l1] relay macos online (a device)",- "Ana's MacBook Pro [dev_l2] relay macos offline (a device)"+ "This Mac [this-mac] local macos online (this machine) + dev_me desktop this-mac \"Online\" \"1 Space\"",+ "studio-2.local [b6953d14ff94b10fcbb38bdd13c47824] relay macos online + dev_s desktop relay:b6953d14ff94b10fcbb38bdd13c47824 (stopped sharing) \"Not sharing\" \"No Spaces\"",+ "BYOC tests [dev_byoc] relay macos offline (a device) \"Offline\"",+ "Ana's MacBook Pro [dev_l1] relay macos online (a device) \"Online\"",+ "Ana's MacBook Pro [dev_l2] relay macos offline (a device) \"Offline\""]},{"page": "a machine that provides Spaces and one sharing its desktop, signed out","rows": [- "This computer [this-mac] local linux online (this machine)",- "Spare Mac mini [m-mini] relay macos online desktop relay:m-mini",- "Build box [m-box] relay ? online"+ "This computer [this-mac] local linux online (this machine) \"Online\" \"No Spaces\"",+ "Spare Mac mini [m-mini] relay macos online desktop relay:m-mini \"Online\" \"No Spaces\"",+ "Build box [m-box] relay ? online \"Online\" \"2 Spaces\""]}]diff --git a/libs/cua/crates/cua-spaces-app-core/src/checklist.rs b/libs/cua/crates/cua-spaces-app-core/src/checklist.rsindex 4cfc4dd9f7..27678b5ec6 100644--- a/libs/cua/crates/cua-spaces-app-core/src/checklist.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/checklist.rs@@ -562,6 +562,9 @@ mod tests {space_id: None,stopped_sharing: false,last_seen: None,+ status: "Online".into(),+ spaces: 0,+ spaces_label: "No Spaces".into(),}}diff --git a/libs/cua/crates/cua-spaces-app-core/src/machines.rs b/libs/cua/crates/cua-spaces-app-core/src/machines.rsindex a842360e95..448b98869b 100644--- a/libs/cua/crates/cua-spaces-app-core/src/machines.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/machines.rs@@ -374,6 +374,64 @@ pub struct MachinePageRow {pub stopped_sharing: bool,/// The device's last session (Unix seconds), when it has a device.pub last_seen: Option<u64>,+ /// The row's status word, the same in every UI ([`status_word`]):+ /// "Online", "Not sharing" or "Offline".+ #[serde(default)]+ pub status: String,+ /// The Spaces it runs that the Spaces list shows: this machine's local+ /// Spaces, or the Spaces another machine provides (`host`).+ #[serde(default)]+ pub spaces: u32,+ /// "1 Space", "3 Spaces", "No Spaces" ([`spaces_label`]); empty for a+ /// device of its own, which runs no Spaces.+ #[serde(default)]+ pub spaces_label: String,+}++/// A machine that is reachable from here.+pub const ONLINE: &str = "Online";+/// A machine that is connected to the relay but whose owner stopped+/// sharing it (the relay's own word for it, and New Space's "(not+/// sharing)"): every call to it is refused.+pub const NOT_SHARING: &str = "Not sharing";+/// A machine the app did not reach and the relay does not see connected.+pub const OFFLINE: &str = "Offline";++/// A Machines row's status word. A machine is not a Space: it is never+/// "Suspended" or "Not reachable", only online, online but not sharing,+/// or offline.+pub fn status_word(online: bool, stopped_sharing: bool) -> &'static str {+ match (online, stopped_sharing) {+ (false, _) => OFFLINE,+ (true, true) => NOT_SHARING,+ (true, false) => ONLINE,+ }+}++/// "1 Space", "3 Spaces", "No Spaces".+pub fn spaces_label(n: u32) -> String {+ match n {+ 0 => "No Spaces".into(),+ 1 => "1 Space".into(),+ n => format!("{n} Spaces"),+ }+}++/// The Spaces on a machine: this machine's local Spaces, or those another+/// machine provides (the classic UI's `hosted_rows`). A machine's own+/// desktop is not one of them.+fn spaces_on(spaces: &[Space], id: &str, current: bool) -> u32 {+ let n = spaces+ .iter()+ .filter(|s| {+ if current {+ s.provider == Some(SpaceProvider::Local) && s.id != THIS_MACHINE_ID+ } else {+ s.host.as_deref() == Some(id)+ }+ })+ .count();+ u32::try_from(n).unwrap_or(u32::MAX)}/// A Space's error says its machine refused because its owner stopped@@ -511,6 +569,9 @@ pub fn page_rows(input: &MachinesPageInput) -> Vec<MachinePageRow> {space_id: None,stopped_sharing: false,last_seen,+ status: status_word(r.online, false).into(),+ spaces: 0,+ spaces_label: String::new(),id: r.id,name: r.name,online: r.online,@@ -526,12 +587,17 @@ pub fn page_rows(input: &MachinesPageInput) -> Vec<MachinePageRow> {} else {m.os.clone()};+ let stopped_sharing = extra[i].stopped_sharing && r.online;+ let spaces = spaces_on(&input.spaces, &r.id, r.current);MachinePageRow {os,via: extra[i].via.into(),space_id: extra[i].space_id.clone(),- stopped_sharing: extra[i].stopped_sharing,+ stopped_sharing,last_seen,+ status: status_word(r.online, stopped_sharing).into(),+ spaces,+ spaces_label: spaces_label(spaces),id: r.id,name: r.name,online: r.online,@@ -790,6 +856,59 @@ mod tests {assert!(rows[1].stopped_sharing);assert_eq!(rows[3].last_seen, Some(NOW - 3_600));assert_eq!(run_on_ids(&merge_rows(&rows)), ["b695", "m-mini"]);+ // One status word and Spaces count per row, for every UI.+ let words: Vec<(&str, &str)> = rows+ .iter()+ .map(|r| (r.status.as_str(), r.spaces_label.as_str()))+ .collect();+ assert_eq!(+ words,+ [+ ("Online", "1 Space"),+ ("Not sharing", "No Spaces"),+ ("Online", "1 Space"),+ ("Offline", ""),+ ]+ );+ }++ /// CUA-1617: your other Mac stopped sharing; the relay lists its+ /// desktop as unreachable (a Space would read "Suspended") and it+ /// provides no Spaces. Every UI says "Not sharing" and "No Spaces",+ /// never a Space's "Suspended" or "Not reachable".+ #[test]+ fn a_machine_that_stopped_sharing_reads_not_sharing_with_no_spaces() {+ let rows = page_rows(&MachinesPageInput {+ spaces: vec![space(serde_json::json!({+ "id": "relay:b695", "name": "Dillons-MacBook-Pro-2.local", "os": "macos",+ "status": "suspended", "provider": "relay",+ "sdk": {"features": [], "spacesdVersion": "", "reachable": false,+ "error": "unauthenticated: Dillons-MacBook-Pro-2.local stopped sharing: ask its owner to Resume sharing (or run `cua host start` there)"}+ }))],+ presence: [("b695".to_string(), false)].into(),+ now: NOW,+ ..Default::default()+ });+ let r = &rows[1];+ assert_eq!(+ (+ r.online,+ r.status.as_str(),+ r.spaces,+ r.spaces_label.as_str()+ ),+ (true, NOT_SHARING, 0, "No Spaces")+ );+ // Unreachable without a refusal: offline, not "Suspended".+ let rows = page_rows(&MachinesPageInput {+ spaces: vec![space(serde_json::json!({+ "id": "relay:b695", "name": "studio", "os": "macos",+ "status": "suspended", "provider": "relay"+ }))],+ ..Default::default()+ });+ assert_eq!(rows[1].status, OFFLINE);+ assert_eq!(spaces_label(3), "3 Spaces");}fn merge_rows(rows: &[MachinePageRow]) -> Vec<MachineOut> {diff --git a/libs/cua/crates/cua-spaces-app-core/src/parity.rs b/libs/cua/crates/cua-spaces-app-core/src/parity.rsindex a2eaa9de33..bdab78ec47 100644--- a/libs/cua/crates/cua-spaces-app-core/src/parity.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/parity.rs@@ -2972,7 +2972,8 @@ fn run_machines(f: &Value, h: &dyn Host) -> Result<Value, String> {/// The Machines page's rows (`machines.pageRows`), one line each: name,/// id, how it is reached, its system, online, the device in it or a-/// device of its own, its desktop's Space, and whether it stopped sharing.+/// device of its own, its desktop's Space, whether it stopped sharing, and+/// the status word and Spaces count every UI shows.fn page_lines(rows: &Value) -> Vec<String> {rows.as_array().into_iter()@@ -3008,6 +3009,11 @@ fn page_lines(rows: &Value) -> Vec<String> {if r["stoppedSharing"].as_bool() == Some(true) {line.push_str(" (stopped sharing)");}+ // The words every UI shows: its status and its Spaces.+ line.push_str(&format!(" \"{}\"", str_of(&r["status"])));+ if !str_of(&r["spacesLabel"]).is_empty() {+ line.push_str(&format!(" \"{}\"", str_of(&r["spacesLabel"])));+ }line}).collect()diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rsindex d7c1e4a140..597356ce0f 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs@@ -9129,6 +9129,15 @@ pub struct AppMachinePageRow {pub stopped_sharing: bool,/// The device's last session (Unix seconds), when it has a device.pub last_seen: Option<u64>,+ /// The row's status word, the same in every UI ([`status_word`]):+ /// "Online", "Not sharing" or "Offline".+ pub status: String,+ /// The Spaces it runs that the Spaces list shows: this machine's local+ /// Spaces, or the Spaces another machine provides (`host`).+ pub spaces: u32,+ /// "1 Space", "3 Spaces", "No Spaces" ([`spaces_label`]); empty for a+ /// device of its own, which runs no Spaces.+ pub spaces_label: String,}/// One step, in the order the checklist lists themdiff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex e01c7fd8d9..9dc751f5fb 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -18716,6 +18716,21 @@ public struct AppMachinePageRow: Equatable, Hashable {* The device's last session (Unix seconds), when it has a device.*/public var lastSeen: UInt64?+ /**+ * The row's status word, the same in every UI ([`status_word`]):+ * "Online", "Not sharing" or "Offline".+ */+ public var status: String+ /**+ * The Spaces it runs that the Spaces list shows: this machine's local+ * Spaces, or the Spaces another machine provides (`host`).+ */+ public var spaces: UInt32+ /**+ * "1 Space", "3 Spaces", "No Spaces" ([`spaces_label`]); empty for a+ * device of its own, which runs no Spaces.+ */+ public var spacesLabel: String// Default memberwise initializers are never public by default, so we// declare one manually.@@ -18757,7 +18772,19 @@ public struct AppMachinePageRow: Equatable, Hashable {*/stoppedSharing: Bool,/*** The device's last session (Unix seconds), when it has a device.- */lastSeen: UInt64?) {+ */lastSeen: UInt64?,+ /**+ * The row's status word, the same in every UI ([`status_word`]):+ * "Online", "Not sharing" or "Offline".+ */status: String,+ /**+ * The Spaces it runs that the Spaces list shows: this machine's local+ * Spaces, or the Spaces another machine provides (`host`).+ */spaces: UInt32,+ /**+ * "1 Space", "3 Spaces", "No Spaces" ([`spaces_label`]); empty for a+ * device of its own, which runs no Spaces.+ */spacesLabel: String) {self.id = idself.name = nameself.online = online@@ -18769,6 +18796,9 @@ public struct AppMachinePageRow: Equatable, Hashable {self.spaceId = spaceIdself.stoppedSharing = stoppedSharingself.lastSeen = lastSeen+ self.status = status+ self.spaces = spaces+ self.spacesLabel = spacesLabel}@@ -18797,7 +18827,10 @@ public struct FfiConverterTypeAppMachinePageRow: FfiConverterRustBuffer {deviceOnly: FfiConverterBool.read(from: &buf),spaceId: FfiConverterOptionString.read(from: &buf),stoppedSharing: FfiConverterBool.read(from: &buf),- lastSeen: FfiConverterOptionUInt64.read(from: &buf)+ lastSeen: FfiConverterOptionUInt64.read(from: &buf),+ status: FfiConverterString.read(from: &buf),+ spaces: FfiConverterUInt32.read(from: &buf),+ spacesLabel: FfiConverterString.read(from: &buf))}@@ -18813,6 +18846,9 @@ public struct FfiConverterTypeAppMachinePageRow: FfiConverterRustBuffer {FfiConverterOptionString.write(value.spaceId, into: &buf)FfiConverterBool.write(value.stoppedSharing, into: &buf)FfiConverterOptionUInt64.write(value.lastSeen, into: &buf)+ FfiConverterString.write(value.status, into: &buf)+ FfiConverterUInt32.write(value.spaces, into: &buf)+ FfiConverterString.write(value.spacesLabel, into: &buf)}}