Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces): show a machine's shared desktop in its Machines row instead of "No Spaces" (#6084)

injaneityd5373879e9e0
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachinesPaletteTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachinesPaletteTests.swift
index b735b78076..0ea829129b 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachinesPaletteTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachinesPaletteTests.swift
@@ -78,6 +78,51 @@ struct MachinesPaletteTests {
#expect(answer?.map { $0["spacesLabel"] as? String } == rows.map(\.spacesLabel))
}
+ /// A machine sharing only its own desktop reads "Desktop shared", not "No Spaces".
+ @Test func aMachineSharingOnlyItsDesktopReadsDesktopShared() throws {
+ let input = try appMachinesPageInputFromJson(json: """
+ {"hostOs": "macos", "now": 1800000000, "spaces": [
+ {"id": "relay:solo", "name": "solo", "os": "macos", "status": "running", "detail": "",
+ "lastUsedAt": 0, "scene": "linux-terminal", "provider": "relay",
+ "sdk": {"features": ["desktop_stream"], "spacesdVersion": "", "reachable": true}}
+ ], "devices": [], "hostnames": {}, "presence": {}}
+ """)
+ let row = appMachinesPageRows(input: input)[1]
+ #expect(row.spaces == 0)
+ #expect(row.spacesLabel == "Desktop shared")
+ }
+
+ /// A machine sharing its desktop and providing a Space reads "Desktop · 1 Space".
+ @Test func aMachineSharingItsDesktopAndSpacesReadsDesktopAndCount() throws {
+ let input = try appMachinesPageInputFromJson(json: """
+ {"hostOs": "macos", "now": 1800000000, "spaces": [
+ {"id": "relay:both", "name": "both", "os": "macos", "status": "running", "detail": "",
+ "lastUsedAt": 0, "scene": "linux-terminal", "provider": "relay",
+ "sdk": {"features": ["desktop_stream"], "spacesdVersion": "", "reachable": true}},
+ {"id": "relay:both/space-1", "name": "s1", "os": "linux", "status": "running", "detail": "",
+ "lastUsedAt": 0, "scene": "linux-terminal", "provider": "relay", "host": "both"}
+ ], "devices": [], "hostnames": {}, "presence": {}}
+ """)
+ let row = appMachinesPageRows(input: input)[1]
+ #expect(row.spaces == 1)
+ #expect(row.spacesLabel == "Desktop · 1 Space")
+ }
+
+ /// A machine providing only Spaces reads the plain count.
+ @Test func aMachineProvidingOnlySpacesReadsTheCount() throws {
+ let input = try appMachinesPageInputFromJson(json: """
+ {"hostOs": "macos", "now": 1800000000, "spaces": [
+ {"id": "relay:box/space-1", "name": "s1", "os": "linux", "status": "running", "detail": "",
+ "lastUsedAt": 0, "scene": "linux-terminal", "provider": "relay", "host": "box"},
+ {"id": "relay:box/space-2", "name": "s2", "os": "linux", "status": "running", "detail": "",
+ "lastUsedAt": 0, "scene": "linux-terminal", "provider": "relay", "host": "box"}
+ ], "devices": [], "hostnames": {}, "presence": {}}
+ """)
+ let row = appMachinesPageRows(input: input)[1]
+ #expect(row.spaces == 2)
+ #expect(row.spacesLabel == "2 Spaces")
+ }
+
@Test func navigationKeysAreTheSharedOnes() {
#expect(SharedShortcuts.shortcut("commandPalette.toggle") == KeyboardShortcut("k", modifiers: .command))
#expect(SharedShortcuts.shortcut("nav.machines") == KeyboardShortcut("2", modifiers: .command))
diff --git a/apps/cua-spaces-web/src/__tests__/machines-page.test.tsx b/apps/cua-spaces-web/src/__tests__/machines-page.test.tsx
index 85eafb8b8c..ca45cbabc5 100644
--- a/apps/cua-spaces-web/src/__tests__/machines-page.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/machines-page.test.tsx
@@ -320,6 +320,19 @@ describe.skipIf(!wasmBuilt)("the Machines page (real routes, wasm core)", () =>
expect(rows[1]!.textContent).not.toContain("Desktop");
});
+ it("reads a shared desktop in the row: desktop only, desktop with Spaces, Spaces only", async () => {
+ const view = await issuesView("a machine sharing only its desktop");
+ const { router } = await mountApp("/machines", hostDrawn(view, []));
+ await router.load();
+ await screen.findByText(view.summary);
+ const line = (id: string) => document.querySelector(`[data-machine-id="${id}"] [data-machine-line]`)?.textContent;
+ expect([line("solo"), line("both"), line("spaces")]).toEqual(["Desktop shared", "Desktop \u00b7 2 Spaces", "1 Space running"]);
+ select("solo");
+ const detail = await detailOf("solo");
+ const rows = [...detail.querySelectorAll<HTMLElement>("[data-machine-spaces] [data-space-row]")];
+ expect(rows.map((r) => r.dataset.spaceRow)).toEqual(["relay:solo"]);
+ });
+
it("draws the clouds: a group under the machines, each cloud's page, and Connect a cloud", async () => {
const { router, hooks } = await mountApp("/machines", { failsCreates: false, listsGhost: false, demo: { clouds: "connected" } });
await router.load();
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts
index ffbcdc72b9..3733b1a789 100644
--- a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts
+++ b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts
@@ -10,7 +10,7 @@ import type { TelemetryView } from "../contracts/host";
import { sanitizeSignals } from "../ops/telemetry";
import { TelemetryForwarder, telemetryAllowed } from "../telemetry";
import { toMachineRows } from "../adapters/webkit";
-import { machineIdOf, rowsToSpaces, toMachines } from "../derive";
+import { machineIdOf, machinesView, rowsToSpaces, toMachines } from "../derive";
import { agentRunLines, desktopCover, PIP_CHANGED_EVENT, SpaceDetailStore, spaceDetail } from "../space-detail";
import type { CoreClient } from "../core";
import { parseDropped, sendFiles, splitDrop } from "../space-files";
@@ -311,3 +311,32 @@ describe("the Machines page's rows from the host (machines.pageRows)", () => {
]);
});
});
+
+describe("the Machines rows listed here for an older host (machinesView)", () => {
+ const desktop = (id: string, over: object = {}) =>
+ ({ id: `relay:${id}`, name: id, os: "macos", status: "running", provider: "relay", sdk: { features: ["desktop_stream"], reachable: true }, ...over }) as never;
+ const hosted = (id: string, n: number) => ({ id: `relay:${id}/space-${n}`, name: `s${n}`, status: "running", provider: "relay", host: id }) as never;
+ const machine = (id: string, over: object = {}) => ({ id, name: id, os: "macos", via: "relay", connection: "relay", online: true, current: false, spaceIds: [], limits: [], ...over }) as never;
+
+ /** The rows the core is asked to draw. */
+ function rowsFor(machines: never[], spaces: never[]) {
+ let rows: { id: string; spacesLabel: string }[] = [];
+ const core = {
+ tryCall: (op: string, args: { input: { rows: typeof rows } }) => {
+ if (op !== "machines.view") return null;
+ rows = args.input.rows;
+ return {};
+ },
+ } as unknown as CoreClient;
+ machinesView(core, { hostView: null, machines, spaces, host: null });
+ return Object.fromEntries(rows.map((r) => [r.id, r.spacesLabel]));
+ }
+
+ it("says a shared desktop, a desktop with Spaces, Spaces only, and a machine that stopped sharing", () => {
+ const labels = rowsFor(
+ [machine("solo"), machine("both"), machine("box"), machine("stopped", { notSharing: "stopped sharing" })],
+ [desktop("solo"), desktop("both"), hosted("both", 1), hosted("box", 1), hosted("box", 2), desktop("stopped", { sdk: { features: [], reachable: false, error: "stopped sharing" } })],
+ );
+ expect(labels).toEqual({ solo: "Desktop shared", both: "Desktop · 1 Space", box: "2 Spaces", stopped: "No Spaces" });
+ });
+});
diff --git a/apps/cua-spaces-web/src/bridge/derive.ts b/apps/cua-spaces-web/src/bridge/derive.ts
index 7b125e8752..f81f11d235 100644
--- a/apps/cua-spaces-web/src/bridge/derive.ts
+++ b/apps/cua-spaces-web/src/bridge/derive.ts
@@ -364,12 +364,23 @@ export interface Machine {
accessNotice?: MachineAccessNotice;
}
+/** The words for a machine's Spaces, as the core says them
+ * (`machines::spaces_label`, and `machines::desktop_spaces_label` when the
+ * machine shares its own desktop). */
+export function machineSpacesLabel(desktop: boolean, n: number): string {
+ const count = n === 0 ? "No Spaces" : `${n} Space${n === 1 ? "" : "s"}`;
+ if (!desktop) return count;
+ return n === 0 ? "Desktop shared" : `Desktop \u00b7 ${count}`;
+}
+
/** One Machines row as the core lists it, from the page's own machine
* (an older host's rows, merged here): the core draws the page from it. */
-function pageRowOf(m: Machine, spaces: readonly Space[]): MachinePageRow {
+function pageRowOf(m: Machine, spaces: readonly Space[], core?: CoreClient): MachinePageRow {
const own = m.current ? spaces.find((s) => s.id === "this-mac") : spaces.find((s) => s.id === `relay:${m.id}`);
// The Spaces on it, never its own desktop (`machines::page_rows`).
const n = spaces.filter((s) => (m.current ? s.provider === "local" && s.id !== "this-mac" : s.host === m.id)).length;
+ // Its own desktop is shared (`machines::page_rows`).
+ const desktop = Boolean(own && m.online && !m.notSharing && (m.current ? own.status === "local" : sharesDesktop(core, own) !== false));
return {
id: m.id,
name: m.name,
@@ -384,7 +395,7 @@ function pageRowOf(m: Machine, spaces: readonly Space[]): MachinePageRow {
lastSeen: m.lastSeen ?? null,
status: m.status ?? (!m.online ? "Offline" : m.notSharing ? "Not sharing" : "Online"),
spaces: n,
- spacesLabel: m.spacesLabel ?? (m.device ? "" : n === 0 ? "No Spaces" : `${n} Space${n === 1 ? "" : "s"}`),
+ spacesLabel: m.spacesLabel ?? (m.device ? "" : machineSpacesLabel(desktop, n)),
};
}
@@ -412,7 +423,7 @@ export function machinesView(
core?.tryCall<MachinesView>("machines.view", {
input: {
page: { hostOs, spaces: input.spaces, now: input.nowSecs ?? Math.floor(Date.now() / 1000) },
- rows: input.machines.map((m) => pageRowOf(m, input.spaces)),
+ rows: input.machines.map((m) => pageRowOf(m, input.spaces, core)),
host: input.host,
clouds: input.clouds ?? null,
},
diff --git a/apps/cua-spaces-web/src/lib/machines.test.ts b/apps/cua-spaces-web/src/lib/machines.test.ts
index 933c261ea8..c659b935b2 100644
--- a/apps/cua-spaces-web/src/lib/machines.test.ts
+++ b/apps/cua-spaces-web/src/lib/machines.test.ts
@@ -70,6 +70,14 @@ describe("machines", () => {
expect(spacesLabel(machine({}), 1)).toBe("1 Space");
});
+ it("counts a shared desktop in the words (machines::desktop_spaces_label)", () => {
+ expect(spacesLabel(machine({}), 0, true)).toBe("Desktop shared");
+ expect(spacesLabel(machine({}), 2, true)).toBe("Desktop · 2 Spaces");
+ // A label the core sent still wins.
+ expect(spacesLabel(machine({ spacesLabel: "No Spaces" }), 0, true)).toBe("No Spaces");
+ expect(spacesLabel(machine({ device: true, spacesLabel: "" }), 0, true)).toBe("");
+ });
+
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.ts
index eec7dc8d5d..20569c516f 100644
--- a/apps/cua-spaces-web/src/lib/machines.ts
+++ b/apps/cua-spaces-web/src/lib/machines.ts
@@ -2,6 +2,7 @@
// Copyright (c) 2026 Cua AI, Inc.
import type { Machine, SpaceOs } from "@/bridge";
+import { machineSpacesLabel } from "@/bridge/derive";
import { OS_NAME } from "@/components/os-icon";
import { plural } from "@/lib/plural";
import { relativeTime } from "@/lib/utils";
@@ -63,15 +64,15 @@ export function presenceWord(m: Pick<Machine, "online" | "notSharing" | "status"
/** "1 Space", "3 Spaces", "No Spaces". */
export function spaceCount(n: number): string {
- if (n === 0) return "No Spaces";
- return `${n} ${n === 1 ? "Space" : "Spaces"}`;
+ return machineSpacesLabel(false, n);
}
/** 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);
+ * device of its own (it runs no Spaces). `desktop`: the machine shares its
+ * own desktop ("Desktop shared", "Desktop · 2 Spaces"). */
+export function spacesLabel(m: Pick<Machine, "spacesLabel">, n: number, desktop = false): string {
+ return m.spacesLabel ?? machineSpacesLabel(desktop, n);
}
/** The selected machine: the chosen one if it is still listed, else the first. */
diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/machines.json
index 4280ee5746..d48fc92b39 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,7 +46,7 @@
{
"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 \"Online\" \"1 Space\"",
+ "This Mac [this-mac] local macos online (this machine) + dev_me desktop this-mac \"Online\" \"Desktop · 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\"",
@@ -57,17 +57,26 @@
"page": "a machine that provides Spaces and one sharing its desktop, signed out",
"rows": [
"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\"",
+ "Spare Mac mini [m-mini] relay macos online desktop relay:m-mini \"Online\" \"Desktop shared\"",
"Build box [m-box] relay ? online \"Online\" \"2 Spaces\""
]
},
+ {
+ "page": "a machine sharing only its desktop, one sharing its desktop and Spaces, one providing Spaces only",
+ "rows": [
+ "This computer [this-mac] local linux online (this machine) \"Online\" \"No Spaces\"",
+ "solo [solo] relay macos online desktop relay:solo \"Online\" \"Desktop shared\"",
+ "both [both] relay macos online desktop relay:both \"Online\" \"Desktop · 2 Spaces\"",
+ "spaces [spaces] relay macos online desktop relay:spaces \"Online\" \"1 Space\""
+ ]
+ },
{
"groups": [
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running",
- "● cua's Mac Studio — 1 Space running",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces",
+ "● cua's Mac Studio — Desktop · 1 Space",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -82,7 +91,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -248,8 +257,8 @@
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running [fail]",
- "● cua's Mac Studio — 1 Space running [warn]",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces [fail]",
+ "● cua's Mac Studio — Desktop · 1 Space [warn]",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -264,7 +273,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -352,8 +361,8 @@
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running [fail]",
- "● cua's Mac Studio — 1 Space running [warn]",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces [fail]",
+ "● cua's Mac Studio — Desktop · 1 Space [warn]",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -368,7 +377,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -456,8 +465,8 @@
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running [fail]",
- "● cua's Mac Studio — 1 Space running [warn]",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces [fail]",
+ "● cua's Mac Studio — Desktop · 1 Space [warn]",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -472,7 +481,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -606,8 +615,8 @@
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running [fail]",
- "● cua's Mac Studio — 1 Space running [warn]",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces [fail]",
+ "● cua's Mac Studio — Desktop · 1 Space [warn]",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -622,7 +631,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -757,8 +766,8 @@
{
"group": "Your machines",
"rows": [
- "● Ada's MacBook Pro [This Mac] — 1 Space running [fail]",
- "● cua's Mac Studio — 1 Space running [warn]",
+ "● Ada's MacBook Pro [This Mac] — Desktop · 2 Spaces [fail]",
+ "● cua's Mac Studio — Desktop · 1 Space [warn]",
"○ Cua BYOC tests — Offline",
"○ Adas-MacBook-Pro-2.local — Not sharing",
"● Ana's laptop — Online"
@@ -773,7 +782,7 @@
{
"group": "Team machines",
"rows": [
- "● build-mini-01 — Ready for Spaces"
+ "● build-mini-01 — Desktop shared"
]
}
],
@@ -855,6 +864,63 @@
],
"summary": "7 machines, 4 online",
"view": "the clouds as the daemon reports them: AWS through the CLI sign-in offering OIDC, Hetzner revoked elsewhere with the daemon's sentence, Modal's raise approvable by this person on a host that can't approve the rest"
+ },
+ {
+ "groups": [
+ {
+ "group": "Your machines",
+ "rows": [
+ "● Ada's MacBook Pro [This computer] — No Spaces",
+ "● solo — Desktop shared",
+ "● both — Desktop · 2 Spaces",
+ "● spaces — 1 Space running"
+ ]
+ }
+ ],
+ "pages": [
+ [
+ "Ada's MacBook Pro — Online",
+ "Let my other devices use this computer: off (disabled)",
+ "spaces: No Spaces yet.",
+ "New Space here on local",
+ "details: OS: macOS 26.5.2; App: 0.9.1"
+ ],
+ [
+ "solo — Online (rename: machine)",
+ "Provide Spaces: on (read-only)",
+ "Share this desktop: on (read-only)",
+ "note: Change this on that Mac.",
+ "desktop solo · macOS · Running [Desktop] -> relay:solo",
+ "spaces: No other Spaces yet.",
+ "New Space here on host:solo",
+ "details: OS: macOS; Connection: via Cua relay; Service: Running",
+ "Remove from account -> solo (disabled: It’s online. Remove it on that Mac, or here once it’s offline.)"
+ ],
+ [
+ "both — Online (rename: machine)",
+ "Provide Spaces: on (read-only)",
+ "Share this desktop: on (read-only)",
+ "note: Change this on that Mac.",
+ "desktop both · macOS · Running [Desktop] -> relay:both",
+ "space one · Linux · Running -> relay:both/space-1",
+ "space two · Linux · Suspended -> relay:both/space-2",
+ "New Space here on host:both",
+ "details: OS: macOS; Connection: via Cua relay; Service: Running",
+ "Remove from account -> both (disabled: It’s online. Remove it on that Mac, or here once it’s offline.)"
+ ],
+ [
+ "spaces — Online (rename: machine)",
+ "Provide Spaces: on (read-only)",
+ "Share this desktop: off (read-only)",
+ "note: Change this on that Mac.",
+ "space box · Linux · Running -> relay:spaces/space-1",
+ "New Space here on host:spaces",
+ "details: OS: macOS; Connection: via Cua relay; Service: Running",
+ "Remove from account -> spaces (disabled: It’s online. Remove it on that Mac, or here once it’s offline.)"
+ ]
+ ],
+ "summary": "4 machines, 4 online",
+ "view": "a machine sharing only its desktop, one sharing its desktop and Spaces, one providing Spaces only"
}
]
}
diff --git a/libs/cua/crates/cua-spaces-app-core/parity/machines.json b/libs/cua/crates/cua-spaces-app-core/parity/machines.json
index d0597523a2..640da2a849 100644
--- a/libs/cua/crates/cua-spaces-app-core/parity/machines.json
+++ b/libs/cua/crates/cua-spaces-app-core/parity/machines.json
@@ -99,6 +99,104 @@
"hostnames": { "m-mini": "mini.lan" },
"presence": { "m-box": true}
}
+ },
+ {
+ "name": "a machine sharing only its desktop, one sharing its desktop and Spaces, one providing Spaces only",
+ "input": {
+ "hostOs": "linux",
+ "now": 1800000000,
+ "spaces": [
+ {
+ "name": "solo",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:solo",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "desktop_stream"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "both",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "desktop_stream"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "one",
+ "os": "linux",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both/space-1",
+ "provider": "relay",
+ "host": "both",
+ "hostName": "both"
+ },
+ {
+ "name": "two",
+ "os": "linux",
+ "status": "suspended",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both/space-2",
+ "provider": "relay",
+ "host": "both",
+ "hostName": "both"
+ },
+ {
+ "name": "spaces",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:spaces",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "host_spaces"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "box",
+ "os": "linux",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:spaces/space-1",
+ "provider": "relay",
+ "host": "spaces",
+ "hostName": "spaces"
+ }
+ ],
+ "devices": [],
+ "presence": {}
+ }
}
],
"views": [
@@ -1154,6 +1252,128 @@
}
},
{"name": "the clouds: AWS connected, Hetzner with a refused token, Modal waiting for approval; Google Cloud not connected is not listed", "input": {"page": {"hostOs": "macos", "now": 1800000000, "spaces": [{"name": "This Mac", "os": "macos", "status": "local", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "this-mac"}, {"name": "space-cdf71481c4", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-cdf71481c4", "osPrettyName": "macOS 26.5.2", "provider": "local"}, {"name": "space-1cef393ac1", "os": "linux", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-1cef393ac1", "provider": "local"}, {"name": "cua's Mac Studio", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio", "osPrettyName": "macOS 26.5.2", "provider": "relay"}, {"name": "xm-before-linux", "os": "linux", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio/xm", "osPrettyName": "Ubuntu 24.04.5 LTS", "provider": "relay", "host": "studio", "hostName": "cua's Mac Studio"}, {"name": "Cua BYOC tests", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:byoc", "provider": "relay"}, {"name": "mac-mini-staging", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:old1", "provider": "relay"}, {"name": "build-mini-01", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:team", "provider": "relay"}, {"name": "Adas-MacBook-Pro-2.local", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:b695", "provider": "relay", "sdk": {"features": [], "spacesdVersion": "", "reachable": false, "error": "unauthenticated: Adas-MacBook-Pro-2.local stopped sharing: ask its owner to Resume sharing (or run `cua host start` there)"}}], "devices": [{"id": "dev_byoc", "name": "Cua BYOC tests", "platform": "macos", "lastSeen": 1799222400, "state": "enrolled"}, {"id": "dev_old1", "name": "mac-mini-staging", "platform": "macos", "lastSeen": 1796457600, "state": "enrolled"}, {"id": "dev_lap", "name": "Ana's laptop", "platform": "windows", "lastSeen": 1799999880, "state": "enrolled"}], "hostnames": {}, "presence": {}}, "relay": [{"id": "studio", "role": "owner", "providesSpaces": true}, {"id": "byoc", "role": "owner", "providesSpaces": true}, {"id": "old1", "role": "owner", "providesSpaces": false}, {"id": "team", "role": "shared", "team": "team-1", "providesSpaces": true}, {"id": "b695", "role": "owner", "providesSpaces": false}], "host": {"configured": true, "mode": "relay", "name": "Ada's MacBook Pro", "sharing": true, "serviceInstalled": true, "serviceRunning": true, "serviceKind": "launchd", "shareDesktop": true, "provideSpaces": false}, "about": {"computerName": "Ada's MacBook Pro", "appVersion": "0.9.1", "osVersion": "macOS 26.5.2"}, "health": [{"id": "this-mac", "cuaVersion": "0.4.1", "checks": [{"id": "machine.local_network", "status": "fail", "message": "Cua can't reach this Mac's macOS VMs (space-cdf71481c4 at 192.168.64.4, No route to host): Local Network access is off for Cua Spaces", "facts": {"app": "Cua Spaces", "app_path": "/Applications/Cua Spaces.app", "settings_url": "x-apple.systempreferences:com.apple.preference.security?Privacy_LocalNetwork"}}, {"id": "machine.disk", "status": "warn", "message": "only 21 GB free on Macintosh HD; a macOS Space needs about 30 GB", "facts": {"free_gb": "21", "volume": "Macintosh HD", "settings_url": "x-apple.systempreferences:com.apple.settings.Storage"}}, {"id": "machine.virtualization", "status": "pass", "message": "ready: lume, container"}]}, {"id": "studio", "cuaVersion": "0.5.0", "checks": [{"id": "machine.memory", "status": "warn", "message": "running Spaces use 28 of 32 GB of memory; another may not start", "facts": {"used_gb": "28", "total_gb": "32"}}, {"id": "machine.disk", "status": "pass", "message": "412 GB free on Macintosh HD", "facts": {"free_gb": "412"}}]}, {"id": "old1", "cuaVersion": "0.4.1", "checks": [{"id": "machine.disk", "status": "fail", "message": "only 3 GB free", "facts": {"free_gb": "3"}}]}], "clouds": {"now": 1792843200, "canApprove": true, "providers": [{"name": "aws", "connected": true, "auth": "oidc", "status": "connected", "region": "us-west-2", "account": "210987654321", "budgetCents": 20000, "maxSize": "4x16", "spentCents": 4218, "running": 2}, {"name": "hetzner", "connected": true, "auth": "sealed", "status": "failed", "region": "fsn1", "budgetCents": 5000, "maxSize": "4x8", "spentCents": 640, "running": 1, "holders": ["This Mac", "Mac mini"]}, {"name": "modal", "connected": true, "auth": "cli", "status": "waiting-for-approval", "approval": "connection", "environment": "main", "budgetCents": 5000, "agent": "Claude Code on This Mac"}, {"name": "gcp", "status": "not-connected"}], "machines": [{"provider": "aws", "id": "i-1", "sandbox": "aws:rl-env-0412", "state": "running", "startedBy": "agent eval-runner", "costCents": 8}, {"provider": "aws", "id": "i-2", "sandbox": "aws:build-cache", "state": "running", "startedBy": "ada on Mac mini", "costCents": 5}, {"provider": "hetzner", "id": "h-1", "sandbox": "hetzner:rl-box", "state": "running"}]}}},
- {"name": "the clouds as the daemon reports them: AWS through the CLI sign-in offering OIDC, Hetzner revoked elsewhere with the daemon's sentence, Modal's raise approvable by this person on a host that can't approve the rest", "input": {"page": {"hostOs": "macos", "now": 1800000000, "spaces": [{"name": "This Mac", "os": "macos", "status": "local", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "this-mac"}, {"name": "space-cdf71481c4", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-cdf71481c4", "osPrettyName": "macOS 26.5.2", "provider": "local"}, {"name": "space-1cef393ac1", "os": "linux", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-1cef393ac1", "provider": "local"}, {"name": "cua's Mac Studio", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio", "osPrettyName": "macOS 26.5.2", "provider": "relay"}, {"name": "xm-before-linux", "os": "linux", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio/xm", "osPrettyName": "Ubuntu 24.04.5 LTS", "provider": "relay", "host": "studio", "hostName": "cua's Mac Studio"}, {"name": "Cua BYOC tests", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:byoc", "provider": "relay"}, {"name": "mac-mini-staging", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:old1", "provider": "relay"}, {"name": "build-mini-01", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:team", "provider": "relay"}, {"name": "Adas-MacBook-Pro-2.local", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:b695", "provider": "relay", "sdk": {"features": [], "spacesdVersion": "", "reachable": false, "error": "unauthenticated: Adas-MacBook-Pro-2.local stopped sharing: ask its owner to Resume sharing (or run `cua host start` there)"}}], "devices": [{"id": "dev_byoc", "name": "Cua BYOC tests", "platform": "macos", "lastSeen": 1799222400, "state": "enrolled"}, {"id": "dev_old1", "name": "mac-mini-staging", "platform": "macos", "lastSeen": 1796457600, "state": "enrolled"}, {"id": "dev_lap", "name": "Ana's laptop", "platform": "windows", "lastSeen": 1799999880, "state": "enrolled"}], "hostnames": {}, "presence": {}}, "relay": [{"id": "studio", "role": "owner", "providesSpaces": true}, {"id": "byoc", "role": "owner", "providesSpaces": true}, {"id": "old1", "role": "owner", "providesSpaces": false}, {"id": "team", "role": "shared", "team": "team-1", "providesSpaces": true}, {"id": "b695", "role": "owner", "providesSpaces": false}], "host": {"configured": true, "mode": "relay", "name": "Ada's MacBook Pro", "sharing": true, "serviceInstalled": true, "serviceRunning": true, "serviceKind": "launchd", "shareDesktop": true, "provideSpaces": false}, "about": {"computerName": "Ada's MacBook Pro", "appVersion": "0.9.1", "osVersion": "macOS 26.5.2"}, "health": [{"id": "this-mac", "cuaVersion": "0.4.1", "checks": [{"id": "machine.local_network", "status": "fail", "message": "Cua can't reach this Mac's macOS VMs (space-cdf71481c4 at 192.168.64.4, No route to host): Local Network access is off for Cua Spaces", "facts": {"app": "Cua Spaces", "app_path": "/Applications/Cua Spaces.app", "settings_url": "x-apple.systempreferences:com.apple.preference.security?Privacy_LocalNetwork"}}, {"id": "machine.disk", "status": "warn", "message": "only 21 GB free on Macintosh HD; a macOS Space needs about 30 GB", "facts": {"free_gb": "21", "volume": "Macintosh HD", "settings_url": "x-apple.systempreferences:com.apple.settings.Storage"}}, {"id": "machine.virtualization", "status": "pass", "message": "ready: lume, container"}]}, {"id": "studio", "cuaVersion": "0.5.0", "checks": [{"id": "machine.memory", "status": "warn", "message": "running Spaces use 28 of 32 GB of memory; another may not start", "facts": {"used_gb": "28", "total_gb": "32"}}, {"id": "machine.disk", "status": "pass", "message": "412 GB free on Macintosh HD", "facts": {"free_gb": "412"}}]}, {"id": "old1", "cuaVersion": "0.4.1", "checks": [{"id": "machine.disk", "status": "fail", "message": "only 3 GB free", "facts": {"free_gb": "3"}}]}], "clouds": {"now": 1792843200, "canApprove": false, "providers": [{"name": "aws", "connected": true, "auth": "cli", "status": "connected", "region": "us-west-2", "account": "210987654321", "budgetCents": 20000, "maxSize": "4x16", "spentCents": 4218, "running": 2, "suggestAuth": "oidc"}, {"name": "hetzner", "connected": true, "auth": "sealed", "status": "failed", "region": "fsn1", "budgetCents": 5000, "maxSize": "4x8", "spentCents": 640, "running": 1, "holders": ["This Mac", "Mac mini"], "issue": "Hetzner was disconnected on another device, and 1 server this computer made may still run there. Reconnect, then delete it."}, {"name": "modal", "connected": true, "auth": "cli", "status": "waiting-for-approval", "approval": "limits", "environment": "main", "budgetCents": 5000, "agent": "eval-runner", "canApprove": true, "pendingBudgetCents": 20000, "pendingMaxSize": "8x32"}, {"name": "gcp", "status": "not-connected"}], "machines": [{"provider": "aws", "id": "i-1", "sandbox": "aws:rl-env-0412", "state": "running", "startedBy": "agent eval-runner", "costCents": 8}, {"provider": "aws", "id": "i-2", "sandbox": "aws:build-cache", "state": "running", "startedBy": "ada on Mac mini", "costCents": 5}, {"provider": "hetzner", "id": "h-1", "sandbox": "hetzner:rl-box", "state": "running"}]}}}
+ {"name": "the clouds as the daemon reports them: AWS through the CLI sign-in offering OIDC, Hetzner revoked elsewhere with the daemon's sentence, Modal's raise approvable by this person on a host that can't approve the rest", "input": {"page": {"hostOs": "macos", "now": 1800000000, "spaces": [{"name": "This Mac", "os": "macos", "status": "local", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "this-mac"}, {"name": "space-cdf71481c4", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-cdf71481c4", "osPrettyName": "macOS 26.5.2", "provider": "local"}, {"name": "space-1cef393ac1", "os": "linux", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "local:space-1cef393ac1", "provider": "local"}, {"name": "cua's Mac Studio", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio", "osPrettyName": "macOS 26.5.2", "provider": "relay"}, {"name": "xm-before-linux", "os": "linux", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:studio/xm", "osPrettyName": "Ubuntu 24.04.5 LTS", "provider": "relay", "host": "studio", "hostName": "cua's Mac Studio"}, {"name": "Cua BYOC tests", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:byoc", "provider": "relay"}, {"name": "mac-mini-staging", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:old1", "provider": "relay"}, {"name": "build-mini-01", "os": "macos", "status": "running", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:team", "provider": "relay"}, {"name": "Adas-MacBook-Pro-2.local", "os": "macos", "status": "suspended", "detail": "", "lastUsedAt": 0, "scene": "linux-terminal", "id": "relay:b695", "provider": "relay", "sdk": {"features": [], "spacesdVersion": "", "reachable": false, "error": "unauthenticated: Adas-MacBook-Pro-2.local stopped sharing: ask its owner to Resume sharing (or run `cua host start` there)"}}], "devices": [{"id": "dev_byoc", "name": "Cua BYOC tests", "platform": "macos", "lastSeen": 1799222400, "state": "enrolled"}, {"id": "dev_old1", "name": "mac-mini-staging", "platform": "macos", "lastSeen": 1796457600, "state": "enrolled"}, {"id": "dev_lap", "name": "Ana's laptop", "platform": "windows", "lastSeen": 1799999880, "state": "enrolled"}], "hostnames": {}, "presence": {}}, "relay": [{"id": "studio", "role": "owner", "providesSpaces": true}, {"id": "byoc", "role": "owner", "providesSpaces": true}, {"id": "old1", "role": "owner", "providesSpaces": false}, {"id": "team", "role": "shared", "team": "team-1", "providesSpaces": true}, {"id": "b695", "role": "owner", "providesSpaces": false}], "host": {"configured": true, "mode": "relay", "name": "Ada's MacBook Pro", "sharing": true, "serviceInstalled": true, "serviceRunning": true, "serviceKind": "launchd", "shareDesktop": true, "provideSpaces": false}, "about": {"computerName": "Ada's MacBook Pro", "appVersion": "0.9.1", "osVersion": "macOS 26.5.2"}, "health": [{"id": "this-mac", "cuaVersion": "0.4.1", "checks": [{"id": "machine.local_network", "status": "fail", "message": "Cua can't reach this Mac's macOS VMs (space-cdf71481c4 at 192.168.64.4, No route to host): Local Network access is off for Cua Spaces", "facts": {"app": "Cua Spaces", "app_path": "/Applications/Cua Spaces.app", "settings_url": "x-apple.systempreferences:com.apple.preference.security?Privacy_LocalNetwork"}}, {"id": "machine.disk", "status": "warn", "message": "only 21 GB free on Macintosh HD; a macOS Space needs about 30 GB", "facts": {"free_gb": "21", "volume": "Macintosh HD", "settings_url": "x-apple.systempreferences:com.apple.settings.Storage"}}, {"id": "machine.virtualization", "status": "pass", "message": "ready: lume, container"}]}, {"id": "studio", "cuaVersion": "0.5.0", "checks": [{"id": "machine.memory", "status": "warn", "message": "running Spaces use 28 of 32 GB of memory; another may not start", "facts": {"used_gb": "28", "total_gb": "32"}}, {"id": "machine.disk", "status": "pass", "message": "412 GB free on Macintosh HD", "facts": {"free_gb": "412"}}]}, {"id": "old1", "cuaVersion": "0.4.1", "checks": [{"id": "machine.disk", "status": "fail", "message": "only 3 GB free", "facts": {"free_gb": "3"}}]}], "clouds": {"now": 1792843200, "canApprove": false, "providers": [{"name": "aws", "connected": true, "auth": "cli", "status": "connected", "region": "us-west-2", "account": "210987654321", "budgetCents": 20000, "maxSize": "4x16", "spentCents": 4218, "running": 2, "suggestAuth": "oidc"}, {"name": "hetzner", "connected": true, "auth": "sealed", "status": "failed", "region": "fsn1", "budgetCents": 5000, "maxSize": "4x8", "spentCents": 640, "running": 1, "holders": ["This Mac", "Mac mini"], "issue": "Hetzner was disconnected on another device, and 1 server this computer made may still run there. Reconnect, then delete it."}, {"name": "modal", "connected": true, "auth": "cli", "status": "waiting-for-approval", "approval": "limits", "environment": "main", "budgetCents": 5000, "agent": "eval-runner", "canApprove": true, "pendingBudgetCents": 20000, "pendingMaxSize": "8x32"}, {"name": "gcp", "status": "not-connected"}], "machines": [{"provider": "aws", "id": "i-1", "sandbox": "aws:rl-env-0412", "state": "running", "startedBy": "agent eval-runner", "costCents": 8}, {"provider": "aws", "id": "i-2", "sandbox": "aws:build-cache", "state": "running", "startedBy": "ada on Mac mini", "costCents": 5}, {"provider": "hetzner", "id": "h-1", "sandbox": "hetzner:rl-box", "state": "running"}]}}},
+ {
+ "name": "a machine sharing only its desktop, one sharing its desktop and Spaces, one providing Spaces only",
+ "input": {
+ "page": {
+ "hostOs": "linux",
+ "now": 1800000000,
+ "spaces": [
+ {
+ "name": "solo",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:solo",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "desktop_stream"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "both",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "desktop_stream"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "one",
+ "os": "linux",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both/space-1",
+ "provider": "relay",
+ "host": "both",
+ "hostName": "both"
+ },
+ {
+ "name": "two",
+ "os": "linux",
+ "status": "suspended",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:both/space-2",
+ "provider": "relay",
+ "host": "both",
+ "hostName": "both"
+ },
+ {
+ "name": "spaces",
+ "os": "macos",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:spaces",
+ "provider": "relay",
+ "sdk": {
+ "features": [
+ "host_spaces"
+ ],
+ "spacesdVersion": "",
+ "reachable": true
+ }
+ },
+ {
+ "name": "box",
+ "os": "linux",
+ "status": "running",
+ "detail": "",
+ "lastUsedAt": 0,
+ "scene": "linux-terminal",
+ "id": "relay:spaces/space-1",
+ "provider": "relay",
+ "host": "spaces",
+ "hostName": "spaces"
+ }
+ ],
+ "devices": []
+ },
+ "relay": [
+ {
+ "id": "solo",
+ "role": "owner",
+ "providesSpaces": true
+ },
+ {
+ "id": "both",
+ "role": "owner",
+ "providesSpaces": true
+ },
+ {
+ "id": "spaces",
+ "role": "owner",
+ "providesSpaces": true
+ }
+ ],
+ "about": {
+ "computerName": "Ada's MacBook Pro",
+ "appVersion": "0.9.1",
+ "osVersion": "macOS 26.5.2"
+ },
+ "health": []
+ }
+ }
]
}
diff --git a/libs/cua/crates/cua-spaces-app-core/src/machines.rs b/libs/cua/crates/cua-spaces-app-core/src/machines.rs
index d3bff6661e..4d06c8c8f2 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/machines.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/machines.rs
@@ -408,7 +408,8 @@ pub fn status_word(online: bool, stopped_sharing: bool) -> &'static str {
}
}
-/// "1 Space", "3 Spaces", "No Spaces".
+/// "1 Space", "3 Spaces", "No Spaces". For a machine that shares its own
+/// desktop see [`desktop_spaces_label`].
pub fn spaces_label(n: u32) -> String {
match n {
0 => "No Spaces".into(),
@@ -417,6 +418,19 @@ pub fn spaces_label(n: u32) -> String {
}
}
+/// The words for a machine that shares its own desktop with no Spaces.
+pub const DESKTOP_SHARED: &str = "Desktop shared";
+
+/// "Desktop shared", or "Desktop \u{b7} 2 Spaces" when the machine also
+/// provides Spaces. Every UI shows this label for a machine that shares
+/// its own desktop.
+pub fn desktop_spaces_label(n: u32) -> String {
+ match n {
+ 0 => DESKTOP_SHARED.into(),
+ n => format!("Desktop \u{b7} {}", spaces_label(n)),
+ }
+}
+
/// 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.
@@ -434,6 +448,20 @@ fn spaces_on(spaces: &[Space], id: &str, current: bool) -> u32 {
u32::try_from(n).unwrap_or(u32::MAX)
}
+/// Whether a live machine shares its own desktop: this machine's roster
+/// entry is `Local`; another machine's desktop does not say it keeps it to
+/// itself.
+fn shares_own_desktop(spaces: &[Space], space_id: Option<&str>, current: bool, live: bool) -> bool {
+ let Some(entry) = space_id.and_then(|id| spaces.iter().find(|s| s.id == id)) else {
+ return false;
+ };
+ live && if current {
+ entry.status == SpaceStatus::Local
+ } else {
+ crate::spaces::sidebar::shares_desktop(entry) != Some(false)
+ }
+}
+
/// A Space's error says its machine refused because its owner stopped
/// sharing it (the web UI's `STOPPED_SHARING_ERROR`).
fn says_stopped_sharing(space: &Space) -> bool {
@@ -589,6 +617,12 @@ pub fn page_rows(input: &MachinesPageInput) -> Vec<MachinePageRow> {
};
let stopped_sharing = extra[i].stopped_sharing && r.online;
let spaces = spaces_on(&input.spaces, &r.id, r.current);
+ let desktop = shares_own_desktop(
+ &input.spaces,
+ extra[i].space_id.as_deref(),
+ r.current,
+ r.online && !stopped_sharing,
+ );
MachinePageRow {
os,
via: extra[i].via.into(),
@@ -597,7 +631,11 @@ pub fn page_rows(input: &MachinesPageInput) -> Vec<MachinePageRow> {
last_seen,
status: status_word(r.online, stopped_sharing).into(),
spaces,
- spaces_label: spaces_label(spaces),
+ spaces_label: if desktop {
+ desktop_spaces_label(spaces)
+ } else {
+ spaces_label(spaces)
+ },
id: r.id,
name: r.name,
online: r.online,
@@ -864,7 +902,7 @@ mod tests {
assert_eq!(
words,
[
- ("Online", "1 Space"),
+ ("Online", "Desktop \u{b7} 1 Space"),
("Not sharing", "No Spaces"),
("Online", "1 Space"),
("Offline", ""),
@@ -911,6 +949,147 @@ mod tests {
assert_eq!(spaces_label(3), "3 Spaces");
}
+ fn label_of(spaces: Vec<serde_json::Value>, id: &str) -> (u32, String) {
+ let rows = page_rows(&MachinesPageInput {
+ spaces: spaces.into_iter().map(space).collect(),
+ now: NOW,
+ ..Default::default()
+ });
+ let r = rows.iter().find(|r| r.id == id).unwrap();
+ (r.spaces, r.spaces_label.clone())
+ }
+
+ fn desktop(id: &str, features: &[&str]) -> serde_json::Value {
+ serde_json::json!({
+ "id": format!("relay:{id}"), "name": id, "os": "macos",
+ "status": "running", "provider": "relay",
+ "sdk": {"features": features, "spacesdVersion": "", "reachable": true}
+ })
+ }
+
+ fn hosted(id: &str, n: u32, status: &str) -> serde_json::Value {
+ serde_json::json!({
+ "id": format!("relay:{id}/space-{n}"), "name": format!("s{n}"),
+ "status": status, "provider": "relay", "host": id
+ })
+ }
+
+ fn this_mac_space(status: &str) -> serde_json::Value {
+ serde_json::json!({"id": "this-mac", "name": "This Mac", "os": "macos", "status": status})
+ }
+
+ fn local_space(n: u32, status: &str) -> serde_json::Value {
+ serde_json::json!({"id": format!("local:s{n}"), "name": format!("s{n}"), "status": status, "provider": "local"})
+ }
+
+ #[test]
+ fn a_machine_sharing_only_its_desktop_reads_desktop_shared() {
+ assert_eq!(
+ label_of(vec![desktop("m-mini", &["desktop_stream"])], "m-mini"),
+ (0, "Desktop shared".into())
+ );
+ assert_eq!(
+ label_of(vec![this_mac_space("local")], "this-mac"),
+ (0, "Desktop shared".into())
+ );
+ }
+
+ #[test]
+ fn a_machine_sharing_its_desktop_and_spaces_reads_desktop_and_the_count() {
+ assert_eq!(
+ label_of(
+ vec![
+ desktop("m-mini", &["desktop_stream"]),
+ hosted("m-mini", 1, "running")
+ ],
+ "m-mini"
+ ),
+ (1, "Desktop \u{b7} 1 Space".into())
+ );
+ assert_eq!(
+ label_of(
+ vec![
+ this_mac_space("local"),
+ local_space(1, "running"),
+ local_space(2, "suspended")
+ ],
+ "this-mac"
+ ),
+ (2, "Desktop \u{b7} 2 Spaces".into())
+ );
+ }
+
+ #[test]
+ fn a_machine_providing_only_spaces_reads_the_count() {
+ assert_eq!(
+ label_of(
+ vec![hosted("m-box", 1, "running"), hosted("m-box", 2, "running")],
+ "m-box"
+ ),
+ (2, "2 Spaces".into())
+ );
+ assert_eq!(
+ label_of(
+ vec![
+ desktop("m-x", &["host_spaces"]),
+ hosted("m-x", 1, "running")
+ ],
+ "m-x"
+ ),
+ (1, "1 Space".into())
+ );
+ assert_eq!(
+ label_of(
+ vec![this_mac_space("suspended"), local_space(1, "running")],
+ "this-mac"
+ ),
+ (1, "1 Space".into())
+ );
+ }
+
+ #[test]
+ fn the_desktop_words_never_replace_offline_stopped_or_device_rows() {
+ // Offline desktop.
+ let mut off = desktop("m-off", &["desktop_stream"]);
+ off["status"] = "suspended".into();
+ let rows = page_rows(&MachinesPageInput {
+ spaces: vec![space(off)],
+ now: NOW,
+ ..Default::default()
+ });
+ assert_eq!(
+ (rows[1].status.as_str(), rows[1].spaces_label.as_str()),
+ (OFFLINE, "No Spaces")
+ );
+ // Stopped sharing.
+ let rows = page_rows(&MachinesPageInput {
+ spaces: vec![space(serde_json::json!({
+ "id": "relay:b695", "name": "b", "os": "macos",
+ "status": "suspended", "provider": "relay",
+ "sdk": {"features": ["desktop_stream"], "spacesdVersion": "", "reachable": false,
+ "error": "b stopped sharing: ask its owner"}
+ }))],
+ now: NOW,
+ ..Default::default()
+ });
+ assert_eq!(
+ (rows[1].status.as_str(), rows[1].spaces_label.as_str()),
+ (NOT_SHARING, "No Spaces")
+ );
+ // A device of its own.
+ let rows = page_rows(&MachinesPageInput {
+ devices: vec![device("dev_x", "Phone")],
+ now: NOW,
+ ..Default::default()
+ });
+ assert_eq!(rows[1].spaces_label, "");
+ // An older daemon reporting no features counts as sharing.
+ assert_eq!(
+ label_of(vec![desktop("m-old", &[])], "m-old"),
+ (0, "Desktop shared".into())
+ );
+ }
+
fn merge_rows(rows: &[MachinePageRow]) -> Vec<MachineOut> {
rows.iter()
.map(|r| MachineOut {
diff --git a/libs/cua/crates/cua-spaces-app-core/src/machines_view.rs b/libs/cua/crates/cua-spaces-app-core/src/machines_view.rs
index 6f50f622a6..2b4af5d8c3 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/machines_view.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/machines_view.rs
@@ -630,13 +630,16 @@ pub fn view(input: &MachinesViewInput) -> MachinesView {
};
// The row's one line.
- // One short label: no "a · b" chains (the switches show the rest).
+ // One short label: no "a · b" chains (the switches show the rest),
+ // except a shared desktop's "Desktop · N Spaces".
let line = if !row.online {
machines::OFFLINE.into()
} else if row.stopped_sharing {
machines::NOT_SHARING.into()
} else if row.device_only {
machines::ONLINE.into()
+ } else if has_desktop {
+ machines::desktop_spaces_label(u32::try_from(on.len()).unwrap_or(u32::MAX))
} else {
let mut parts = vec![];
if n_running > 0 {
@@ -1217,11 +1220,15 @@ mod tests {
assert_eq!(
lines,
[
- ("Ada's MacBook Pro", "2 Spaces running", Some("This Mac")),
- ("cua's Mac Studio", "1 Space running", None),
+ (
+ "Ada's MacBook Pro",
+ "Desktop \u{b7} 2 Spaces",
+ Some("This Mac")
+ ),
+ ("cua's Mac Studio", "Desktop \u{b7} 1 Space", None),
("Cua BYOC tests", "Offline", None),
("mac-mini-staging", "Offline", None),
- ("build-mini-01", "Ready for Spaces", None),
+ ("build-mini-01", "Desktop shared", None),
]
);
assert_eq!(v.summary, "5 machines, 3 online");
@@ -1394,14 +1401,125 @@ mod tests {
assert!(studio.line.contains("1 Space"), "{}", studio.line);
// Offline machines show none.
assert!(by_id(&v, "byoc").desktop.is_none());
- // With no provided Spaces the empty line says "other".
- if let Some(m) = v
- .machines
- .iter()
- .find(|m| m.desktop.is_some() && m.spaces.is_empty() && m.online)
- {
- assert_eq!(m.spaces_empty.as_deref(), Some("No other Spaces yet."));
- }
+ }
+
+ fn view_of(
+ spaces: Vec<serde_json::Value>,
+ relay_rows: Vec<MachinesViewRelay>,
+ host: Option<HostState>,
+ ) -> MachinesView {
+ view(&MachinesViewInput {
+ page: MachinesPageInput {
+ spaces: spaces.into_iter().map(space).collect(),
+ now: NOW,
+ ..Default::default()
+ },
+ relay: relay_rows,
+ host,
+ ..Default::default()
+ })
+ }
+
+ fn relay_desktop(id: &str, features: &[&str]) -> serde_json::Value {
+ serde_json::json!({
+ "id": format!("relay:{id}"), "name": id, "os": "macos",
+ "status": "running", "provider": "relay",
+ "sdk": {"features": features, "spacesdVersion": "", "reachable": true}
+ })
+ }
+
+ fn relay_hosted(id: &str, n: u32, status: &str) -> serde_json::Value {
+ serde_json::json!({
+ "id": format!("relay:{id}/space-{n}"), "name": format!("s{n}"),
+ "status": status, "provider": "relay", "host": id
+ })
+ }
+
+ fn this_mac(status: &str) -> serde_json::Value {
+ serde_json::json!({"id": "this-mac", "name": "This Mac", "os": "macos", "status": status})
+ }
+
+ fn local(n: u32, status: &str) -> serde_json::Value {
+ serde_json::json!({"id": format!("local:s{n}"), "name": format!("s{n}"), "status": status, "provider": "local"})
+ }
+
+ #[test]
+ fn a_machine_sharing_only_its_desktop_lists_it_alone() {
+ let v = view_of(
+ vec![relay_desktop("m1", &["desktop_stream"])],
+ vec![relay("m1", "owner", Some(true))],
+ None,
+ );
+ let m = by_id(&v, "m1");
+ assert_eq!(m.line, "Desktop shared");
+ let d = m.desktop.as_ref().unwrap();
+ assert_eq!((d.label.as_str(), d.id.as_str()), ("Desktop", "relay:m1"));
+ assert!(m.spaces.is_empty());
+ assert_eq!(m.spaces_empty.as_deref(), Some("No other Spaces yet."));
+ }
+
+ #[test]
+ fn a_machine_sharing_its_desktop_and_spaces_counts_all_of_them() {
+ let v = view_of(
+ vec![
+ relay_desktop("m1", &["desktop_stream"]),
+ relay_hosted("m1", 1, "running"),
+ ],
+ vec![relay("m1", "owner", Some(true))],
+ None,
+ );
+ let m = by_id(&v, "m1");
+ assert_eq!(m.line, "Desktop \u{b7} 1 Space");
+ assert!(m.desktop.is_some());
+ assert_eq!(m.spaces.len(), 1);
+ let v = view_of(
+ vec![
+ this_mac("local"),
+ local(1, "running"),
+ local(2, "suspended"),
+ ],
+ vec![],
+ Some(host(true, true)),
+ );
+ assert_eq!(by_id(&v, "this-mac").line, "Desktop \u{b7} 2 Spaces");
+ }
+
+ #[test]
+ fn a_machine_providing_only_spaces_keeps_the_sandbox_line() {
+ let v = view_of(
+ vec![
+ relay_desktop("m1", &["host_spaces"]),
+ relay_hosted("m1", 1, "running"),
+ ],
+ vec![relay("m1", "owner", Some(true))],
+ None,
+ );
+ let m = by_id(&v, "m1");
+ assert_eq!(m.line, "1 Space running");
+ assert!(m.desktop.is_none() && m.spaces_empty.is_none());
+ let v = view_of(vec![this_mac("local")], vec![], Some(host(true, false)));
+ assert_eq!(by_id(&v, "this-mac").line, "Ready for Spaces");
+ }
+
+ /// The page rows get no host settings, so for this machine a host set
+ /// to provide Spaces only still reads "Desktop shared" in the row
+ /// label while the view's line follows the host.
+ #[test]
+ fn this_machines_row_label_is_weaker_than_the_view_line() {
+ let input = MachinesViewInput {
+ page: MachinesPageInput {
+ spaces: vec![space(this_mac("local"))],
+ now: NOW,
+ ..Default::default()
+ },
+ host: Some(host(true, false)),
+ ..Default::default()
+ };
+ assert_eq!(
+ machines::page_rows(&input.page)[0].spaces_label,
+ "Desktop shared"
+ );
+ assert_eq!(by_id(&view(&input), "this-mac").line, "Ready for Spaces");
}
#[test]