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): preserve live OS metadata and show unknown honestly (#4671)

injaneityf25fe3691e65
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
index e632d7b5a0..9211dcd2da 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
@@ -189,10 +189,10 @@ public final class LiveSpacesBackend: SpacesBackend, @unchecked Sendable {
switch probe {
case .success(let space):
row.reachable = true
- row.os = AppSpaceOs(word: space.info().os) ?? row.os
let info = space.info()
- if !info.osName.isEmpty { row.osName = info.osName }
- if !info.osPrettyName.isEmpty { row.osPrettyName = info.osPrettyName }
+ row.os = AppSpaceOs(word: info.os)
+ row.osName = info.osName.isEmpty ? nil : info.osName
+ row.osPrettyName = info.osPrettyName.isEmpty ? nil : info.osPrettyName
if !info.image.isEmpty { row.image = info.image }
if !info.imageDigest.isEmpty { row.imageDigest = info.imageDigest }
if let kind = AppSpaceKind(word: info.kind) { row.kind = kind }
@@ -471,6 +471,7 @@ extension AppSpaceOs {
case .macos: return "macOS"
case .windows: return "Windows"
case .linux: return "Linux"
+ case .unknown: return "Unknown"
}
}
}
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift
index 0679e33bd9..49268f1765 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift
@@ -397,11 +397,7 @@ public struct NewSpaceWizardView: View {
}
private func osOf(_ id: String) -> AppSpaceOs {
- switch id {
- case "macos": return .macos
- case "windows": return .windows
- default: return .linux
- }
+ AppSpaceOs(word: id) ?? .unknown
}
private func runtimeOf(_ word: String) -> AppRuntime {
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
index 4294f5c41e..f4b3ed32e7 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
@@ -172,6 +172,30 @@ struct SnapshotTests {
try assertSnapshot(form(true), "space-facts-copied", size: size)
}
+ /// OS-only regression: the real app core, facts view and icon renderer.
+ @Test func relayOperatingSystemFacts() throws {
+ for (os, name, expected) in [(Optional<AppSpaceOs>.none, "Unknown", "Unknown"), (.macos, "macOS", "macOS")] {
+ let row = AppSpaceRow(id: "relay:test-host", name: "Test host", provider: "relay",
+ spacesdVersion: "0.4.1", features: [], addedAt: nil, os: os,
+ osName: nil, osPrettyName: nil, image: nil, imageDigest: nil,
+ kind: nil, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ let space = appRowsToSpaces(rows: [row], nowMs: 0)[0]
+ let facts = appSpaceDetail(space: space).facts
+ #expect(facts.first { $0.label == "System" }?.value == expected)
+ #expect(space.os.label == expected)
+ var notch = appNotchInitial()
+ notch.open = true
+ let tile = try #require(appNotchView(state: notch, spaces: [space]).tiles.first)
+ #expect(tile.symbol == (os == nil ? "computer" : "os-macos"))
+ let view = VStack(alignment: .leading, spacing: 12) {
+ HStack { OsIconImage(id: tile.symbol, size: 18); Text(space.name) }
+ Form { Section { FactRows(facts: facts, write: { _ in }, copied: false) } }.formStyle(.grouped)
+ }.padding().background(Color.white)
+ try assertSnapshot(view, "relay-os-" + name, size: CGSize(width: 520, height: 300))
+ }
+ }
+
/// The live desktop's card: its content runs flush to the card's edges
/// (no row inset, no letterbox) at the default desktop's 16:10, with
/// only the card's corner radius, above the facts card.
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.png
new file mode 100644
index 0000000000..ac1cf426d7
Binary files /dev/null and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.png differ
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.png
new file mode 100644
index 0000000000..42e5652811
Binary files /dev/null and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.png differ
diff --git a/apps/cua-spaces/src-tauri/src/core.rs b/apps/cua-spaces/src-tauri/src/core.rs
index 574106a8b1..86a7555613 100644
--- a/apps/cua-spaces/src-tauri/src/core.rs
+++ b/apps/cua-spaces/src-tauri/src/core.rs
@@ -449,7 +449,7 @@ impl SpaceRow {
kind: (!info.kind.is_empty()).then_some(info.kind),
arch: (!info.arch.is_empty()).then_some(info.arch),
added_at: info.added_at,
- os: None,
+ os: matches!(info.os.as_str(), "macos" | "windows" | "linux").then_some(info.os),
reachable: false,
error: None,
host: (!info.host.is_empty()).then_some(info.host),
@@ -464,24 +464,10 @@ impl SpaceRow {
fn connected(info: SpaceInfo, space: &Space) -> Self {
let mut row = Self::from_info(info);
- row.os = Some(os_name(space).into());
- if let Some(name) = space
- .capabilities()
- .os
- .as_ref()
- .map(|o| o.name.clone())
- .filter(|n| !n.is_empty())
- {
- row.os_name = Some(name);
- }
- if let Some(pretty) = space
- .capabilities()
- .os
- .as_ref()
- .map(|o| o.pretty_name.clone())
- .filter(|n| !n.is_empty())
- {
- row.os_pretty_name = Some(pretty);
+ if let Some((family, name, pretty_name)) = space.reported_os() {
+ row.os = (!family.is_empty()).then(|| family.to_string());
+ row.os_name = (!name.is_empty()).then(|| name.to_string());
+ row.os_pretty_name = (!pretty_name.is_empty()).then(|| pretty_name.to_string());
}
if let Some((image, digest)) = space.image() {
row.image = Some(image.to_string());
@@ -508,14 +494,6 @@ impl SpaceRow {
}
}
-fn os_name(space: &Space) -> &'static str {
- match space.os_family() {
- pb::OsFamily::Macos => "macos",
- pb::OsFamily::Windows => "windows",
- _ => "linux",
- }
-}
-
/// `create_space` input: where (`on`), what (`kind`) and which engine
/// (`runtime`), as the SDK's placement model spells them. Every field is
/// optional: `on` defaults to the configured default location
diff --git a/apps/cua-spaces/src-tauri/tests/commands.rs b/apps/cua-spaces/src-tauri/tests/commands.rs
index 52136522ac..7f490cec8e 100644
--- a/apps/cua-spaces/src-tauri/tests/commands.rs
+++ b/apps/cua-spaces/src-tauri/tests/commands.rs
@@ -102,6 +102,78 @@ async fn add_by_address_lists_screenshots_windows_and_streams_direct() {
assert!(app.list_spaces().await.unwrap().is_empty());
}
+#[tokio::test]
+async fn live_os_metadata_is_coherent_in_app_commands() {
+ for (family, expected) in [
+ (Some(2), Some("macos")),
+ (Some(3), Some("windows")),
+ (Some(1), Some("linux")),
+ (None, None),
+ (Some(0), None),
+ (Some(999), None),
+ ] {
+ let home = tempfile::tempdir().unwrap();
+ let app = core(home.path());
+ let srv = mock_space("t", &[]).await;
+ // First register Linux, then change the handshake. A stale record must
+ // never win over the connected host, including an unknown future OS.
+ let row = app
+ .add_space(&srv.url(), Some("t".into()), Some("Test host".into()))
+ .await
+ .unwrap();
+ *srv.state.os.lock().unwrap() =
+ Some(family.map(|family| cua_proto::env::v1::OperatingSystem {
+ family,
+ name: "Live OS".into(),
+ pretty_name: "Live OS 1".into(),
+ ..Default::default()
+ }));
+ // Reopen the app against the saved registry: the existing connection
+ // retains its handshake for its lifetime.
+ drop(app);
+ let app = core(home.path());
+ let rows = app.list_spaces().await.unwrap();
+ let detail = app.space_info(&row.id).await.unwrap();
+ for actual in [&rows[0], &detail] {
+ assert_eq!(actual.os.as_deref(), expected, "family={family:?}");
+ assert_eq!(actual.os_name.as_deref(), expected.map(|_| "Live OS"));
+ assert_eq!(
+ actual.os_pretty_name.as_deref(),
+ expected.map(|_| "Live OS 1")
+ );
+ assert!(actual.reachable);
+ assert_eq!(actual.id, row.id);
+ }
+ }
+}
+
+#[tokio::test]
+async fn generic_space_keeps_registered_os_in_app_commands() {
+ let home = tempfile::tempdir().unwrap();
+ let id = "direct:127.0.0.1:9";
+ cua_spaces::registry::Registry::new(home.path())
+ .upsert(
+ cua_proto::daemon::v1::Space {
+ id: id.into(),
+ name: "Generic service".into(),
+ os: "macos".into(),
+ os_name: "Darwin".into(),
+ os_pretty_name: "macOS".into(),
+ ..Default::default()
+ },
+ cua_spaces::registry::Credential {
+ service_urls: [("service".into(), "http://127.0.0.1:9/mcp".into())].into(),
+ ..Default::default()
+ },
+ )
+ .unwrap();
+ let app = core(home.path());
+ let row = app.space_info(id).await.unwrap();
+ assert_eq!(row.os.as_deref(), Some("macos"));
+ assert_eq!(row.os_name.as_deref(), Some("Darwin"));
+ assert_eq!(row.os_pretty_name.as_deref(), Some("macOS"));
+}
+
#[tokio::test]
async fn a_wrong_token_is_refused_and_nothing_is_registered() {
let home = tempfile::tempdir().unwrap();
@@ -195,6 +267,9 @@ async fn an_unreachable_space_is_listed_within_the_probe_bound() {
assert_eq!(rows[0].id, row.id);
assert!(!rows[0].reachable);
assert!(rows[0].error.is_some());
+ assert_eq!(rows[0].os, row.os);
+ assert_eq!(rows[0].os_name, row.os_name);
+ assert_eq!(rows[0].os_pretty_name, row.os_pretty_name);
}
#[tokio::test]
diff --git a/apps/cua-spaces/src/model/fleet.test.ts b/apps/cua-spaces/src/model/fleet.test.ts
index 2aaae654b8..d51207cce1 100644
--- a/apps/cua-spaces/src/model/fleet.test.ts
+++ b/apps/cua-spaces/src/model/fleet.test.ts
@@ -43,6 +43,10 @@ describe("resolveMembers", () => {
});
describe("estimateHourly", () => {
+ it("does not price or create an unknown OS as Linux", () => {
+ expect(() => hourlyRate("unknown", "standard")).toThrow("Cannot price an unknown operating system");
+ expect(() => createFleetLocally({ ...qa, templateId: "custom", customOs: "unknown" }, [], FIXTURE_NOW)).toThrow("Choose an operating system");
+ });
it("prices by OS multiplier and sums honestly", () => {
expect(hourlyRate("linux", "standard")).toBe(0.34);
expect(hourlyRate("windows", "standard")).toBe(0.46);
diff --git a/apps/cua-spaces/src/model/fleet.ts b/apps/cua-spaces/src/model/fleet.ts
index 07a45bea78..0806338948 100644
--- a/apps/cua-spaces/src/model/fleet.ts
+++ b/apps/cua-spaces/src/model/fleet.ts
@@ -17,7 +17,7 @@ import type {
* Synthetic OS multipliers on top of the Linux list price. Windows and macOS
* carry licensing overhead; these numbers are illustrative only.
*/
-const OS_MULTIPLIER: Record<SpaceOs, number> = {
+const OS_MULTIPLIER: Record<Exclude<SpaceOs, "unknown">, number> = {
linux: 1,
windows: 1.35,
macos: 2.1,
@@ -55,6 +55,8 @@ function stripIndex(name: string): string {
function sceneFor(os: SpaceOs): TemplateMember["scene"] {
switch (os) {
+ case "unknown":
+ return "blank";
case "windows":
return "windows-desktop";
case "macos":
@@ -65,6 +67,7 @@ function sceneFor(os: SpaceOs): TemplateMember["scene"] {
}
export function hourlyRate(os: SpaceOs, size: MachineSize): number {
+ if (os === "unknown") throw new Error("Cannot price an unknown operating system");
const option = SIZES.find((s) => s.id === size);
if (!option) throw new Error(`Unknown size: ${size}`);
return round2(option.linuxHourlyUsd * OS_MULTIPLIER[os]);
@@ -110,6 +113,7 @@ export function createFleetLocally(
): CreateFleetResult {
const template = getTemplate(draft.templateId);
const members = resolveMembers(draft);
+ if (members.some((m) => m.os === "unknown")) throw new Error("Choose an operating system before creating a Space");
const ordinal = existing.filter((s) => s.fleetId).reduce((set, s) => set.add(s.fleetId!), new Set<string>()).size + 1;
const fleetId = `fleet-${ordinal}-${template.id}`;
const usedNames = new Set(existing.map((s) => s.name));
diff --git a/apps/cua-spaces/src/model/spaces.test.ts b/apps/cua-spaces/src/model/spaces.test.ts
index 6fdc60be01..6b1e31c69a 100644
--- a/apps/cua-spaces/src/model/spaces.test.ts
+++ b/apps/cua-spaces/src/model/spaces.test.ts
@@ -46,12 +46,12 @@ describe("rowToSpace", () => {
expect(space.detail).toContain("timed out");
});
- it("maps direct and local rows, defaulting the OS to linux", () => {
+ it("maps direct and local rows, preserving an unknown OS", () => {
const direct = rowToSpace(
row({ id: "space://direct/10.0.0.5:3211", name: "10.0.0.5:3211", provider: "direct", os: undefined, addedAt: undefined }),
42,
);
- expect(direct.os).toBe("linux");
+ expect(direct.os).toBe("unknown");
expect(direct.detail).toBe("10.0.0.5:3211");
expect(direct.name).toBe("10.0.0.5:3211");
expect(direct.lastUsedAt).toBe(42);
diff --git a/apps/cua-spaces/src/model/types.ts b/apps/cua-spaces/src/model/types.ts
index 046465cd14..00388cf63e 100644
--- a/apps/cua-spaces/src/model/types.ts
+++ b/apps/cua-spaces/src/model/types.ts
@@ -9,7 +9,7 @@
*/
/** Operating system a Space runs. */
-export type SpaceOs = "macos" | "windows" | "linux";
+export type SpaceOs = "macos" | "windows" | "linux" | "unknown";
/**
* Lifecycle status of a Space.
diff --git a/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx b/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
index 68430146c9..a5ae06fc38 100644
--- a/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
+++ b/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
@@ -1478,6 +1478,7 @@ impl Space {
fn require(&self, name: &str) -> Result<()>;
fn require_any(&self, names: &[&str]) -> Result<()>;
fn os_family(&self) -> OsFamily;
+ fn reported_os(&self) -> Option<(&'static str, &str, &str)>;
fn is_windows(&self) -> bool;
async fn websocket_headers(&self) -> Result<Vec<(String, String)>>;
fn websocket_url(&self, ws_path: &str) -> Result<String>;
diff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
index e90880d72b..099012ae69 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
@@ -726,6 +726,7 @@ AppSpaceKind::Vm
.macos
.windows
.linux
+.unknown
```
</Tab>
@@ -735,6 +736,7 @@ AppSpaceKind::Vm
AppSpaceOs::Macos
AppSpaceOs::Windows
AppSpaceOs::Linux
+AppSpaceOs::Unknown
```
</Tab>
@@ -745,6 +747,7 @@ AppSpaceOs::Linux
| `Macos` | macOS. |
| `Windows` | Windows. |
| `Linux` | Linux. |
+| `Unknown` | The host has not reported a recognized operating system. |
## `AppSpaceProvider` enum
diff --git a/docs/content/docs/cua-sdk/reference/spaces/space.mdx b/docs/content/docs/cua-sdk/reference/spaces/space.mdx
index debedfe132..1804c340d5 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/space.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/space.mdx
@@ -12,7 +12,7 @@ description: "A connected Space: shell, files, tools, windows and the hotspot."
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
-A `Space` is a connected machine. Every primitive checks the spacesd feature it needs first and fails with `CapabilityMissing` when the Space lacks it. Streams, teleport and agents have their own pages.
+Connected machine primitives; missing spacesd features return `CapabilityMissing`.
## `Space`
@@ -69,7 +69,7 @@ Returned by [`Spaces.space`](/cua-sdk/reference/spaces#spacesspace).
| Accessor | Returns | Description |
| --- | --- | --- |
| `id()` | `String` | Id. |
-| `info()` | [`SpaceInfo`](/cua-sdk/reference/spaces#spaceinfo-record) | The registry entry. |
+| `info()` | [`SpaceInfo`](/cua-sdk/reference/spaces#spaceinfo-record) | Connection-time snapshot; never refreshed. With spacesd, handshake `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown families clear them. Other fields and non-spacesd services retain registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views. |
| `services()` | `Vec<String>` | The MCP services this Space exposes: `driver` when its spacesd has the tool registry, then every declared service (reached over generic MCP; no spacesd needed). |
### `Space.bash`
diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rs
index 79da0cbc45..31b72125b3 100644
--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs
+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs
@@ -2720,7 +2720,14 @@ impl Spaces {
pub async fn space(&self, space: String) -> Result<Arc<Space>> {
let host = self.host.clone();
run(async move {
- let (info, inner) = host.connect(&space).await?;
+ let (mut info, inner) = host.connect(&space).await?;
+ // Relay discovery has no OS fields. Use the handshake already
+ // fetched by either topology, without registering the machine.
+ if let Some((family, name, pretty_name)) = inner.reported_os() {
+ info.os = family.into();
+ info.os_name = name.into();
+ info.os_pretty_name = pretty_name.into();
+ }
Ok(Arc::new(Space { host, info, inner }))
})
.await
@@ -2866,7 +2873,10 @@ impl Space {
self.info.id.clone()
}
- /// The registry entry.
+ /// Connection-time snapshot; never refreshed. With spacesd, handshake
+ /// `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ /// families clear them. Other fields and non-spacesd services retain
+ /// registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
pub fn info(&self) -> SpaceInfo {
self.info.clone()
}
diff --git a/libs/cua/crates/cua-sdk/tests/space_os.rs b/libs/cua/crates/cua-sdk/tests/space_os.rs
new file mode 100644
index 0000000000..e2cc41bb83
--- /dev/null
+++ b/libs/cua/crates/cua-sdk/tests/space_os.rs
@@ -0,0 +1,187 @@
+//! Connected relay metadata must come from the handshake without registering
+//! the discovered machine locally. Only in-process fixtures and temporary homes.
+use cua_daemon::{
+ Runtime, RuntimeConfig, fixtures,
+ server::{self, ServerConfig},
+};
+use cua_host::{StaticToken, relay::RegisterRequest, testing::FakeRelay};
+use cua_sdk::Cua;
+use cua_spaces::relay::RelayAccount;
+use std::sync::Arc;
+
+#[tokio::test]
+async fn generic_space_preserves_registered_os_metadata() {
+ let home = tempfile::tempdir().unwrap();
+ let runtime = Runtime::new(RuntimeConfig {
+ state_dir: Some(home.path().join("sandboxes")),
+ spaces_home: Some(home.path().join("cua")),
+ ..Default::default()
+ })
+ .unwrap();
+ let id = "direct:127.0.0.1:9";
+ runtime
+ .spaces()
+ .registry()
+ .upsert(
+ cua_proto::daemon::v1::Space {
+ id: id.into(),
+ name: "Generic service".into(),
+ os: "macos".into(),
+ os_name: "Darwin".into(),
+ os_pretty_name: "macOS".into(),
+ ..Default::default()
+ },
+ cua_spaces::registry::Credential {
+ // Declared MCP services have no spacesd handshake. Constructing
+ // the handle does not contact this endpoint.
+ service_urls: [("service".into(), "http://127.0.0.1:9/mcp".into())].into(),
+ ..Default::default()
+ },
+ )
+ .unwrap();
+ let cua = Cua::from_runtime(runtime);
+ let space = cua.spaces().space(id.into()).await.unwrap();
+ assert_eq!(space.info().os, "macos");
+ assert_eq!(space.info().os_name, "Darwin");
+ assert_eq!(space.info().os_pretty_name, "macOS");
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn discovered_relay_os_survives_embedded_and_daemon_connections() {
+ for daemon in [false, true] {
+ for registered in [false, true] {
+ for (family, expected) in [
+ (Some(2), "macos"),
+ (Some(3), "windows"),
+ (Some(1), "linux"),
+ (None, ""),
+ (Some(0), ""),
+ (Some(999), ""),
+ ] {
+ let relay = FakeRelay::start().await;
+ relay.legacy_enrollment(true);
+ relay.add_account("owner-token", "owner", None);
+ let id = "00112233445566778899aabbccddeeff";
+ cua_host::RelayClient::new(&relay.url)
+ .unwrap()
+ .register(
+ "owner-token",
+ &RegisterRequest {
+ id: id.into(),
+ name: "Test host".into(),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap();
+ let env = fixtures::start_env(None, None).await;
+ *env.mock.state.os.lock().unwrap() =
+ Some(family.map(|family| cua_proto::env::v1::OperatingSystem {
+ family,
+ name: "Live OS".into(),
+ pretty_name: "Live OS 1".into(),
+ ..Default::default()
+ }));
+ relay.tunnel(id, &env.url);
+ relay.set_online(id, true, "0.0.0-mock");
+ let home = tempfile::tempdir().unwrap();
+ let runtime = Runtime::new(RuntimeConfig {
+ state_dir: Some(home.path().join("sandboxes")),
+ spaces_home: Some(home.path().join("cua")),
+ ..Default::default()
+ })
+ .unwrap();
+ runtime.spaces().set_relay(Some(RelayAccount::new(
+ &relay.url,
+ Arc::new(StaticToken("owner-token".into())),
+ )));
+ let registry_home = home.path().join("cua");
+ if registered {
+ runtime
+ .spaces()
+ .registry()
+ .upsert(
+ cua_proto::daemon::v1::Space {
+ id: format!("relay:{id}"),
+ name: "Test host".into(),
+ os: "stale-family".into(),
+ os_name: "Stale OS".into(),
+ os_pretty_name: "Stale OS 0".into(),
+ ..Default::default()
+ },
+ Default::default(),
+ )
+ .unwrap();
+ }
+
+ let (cua, server) = if daemon {
+ let h = server::start(
+ runtime,
+ ServerConfig {
+ socket_path: Some(home.path().join("cua.sock")),
+ loopback: Some("127.0.0.1:0".parse().unwrap()),
+ token: "daemon-token".into(),
+ discovery_path: Some(home.path().join("daemon.json")),
+ bridge_ticket_ttl: std::time::Duration::from_secs(30),
+ },
+ )
+ .await
+ .unwrap();
+ (
+ Cua::connect(h.loopback_url.clone(), Some(h.token.clone())).unwrap(),
+ Some(h),
+ )
+ } else {
+ (Cua::from_runtime(runtime), None)
+ };
+ let spaces = cua.spaces();
+ let rows = spaces.list().await.unwrap();
+ let key = format!("relay:{id}");
+ assert!(
+ rows.iter()
+ .any(|r| r.id == key && (registered || r.os.is_empty()))
+ );
+ let connected = spaces.space(key.clone()).await.unwrap();
+ assert_eq!(
+ connected.info().os,
+ expected,
+ "daemon={daemon}, family={family:?}"
+ );
+ assert_eq!(
+ connected.info().os_name,
+ if expected.is_empty() { "" } else { "Live OS" }
+ );
+ assert_eq!(
+ connected.info().os_pretty_name,
+ if expected.is_empty() { "" } else { "Live OS 1" }
+ );
+ assert!(
+ registered || !registry_home.join("spaces.json").exists(),
+ "discovery must not register a machine"
+ );
+ assert_eq!(connected.info().id, key);
+ assert_eq!(connected.info().name, "Test host");
+ if !registered {
+ // Connected info does not backfill discovery/resolve or
+ // make those APIs probe a now-offline host.
+ relay.set_online(id, false, "0.0.0-mock");
+ let listed = spaces
+ .list()
+ .await
+ .unwrap()
+ .into_iter()
+ .find(|r| r.id == key)
+ .unwrap();
+ assert!(listed.os.is_empty());
+ assert!(spaces.resolve(key.clone()).await.unwrap().os.is_empty());
+ }
+ drop(connected);
+ drop(cua);
+ if let Some(server) = server {
+ server.shutdown();
+ server.wait().await;
+ }
+ }
+ }
+ }
+}
diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json
index 6e59d3b0d4..aef34bf825 100644
--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json
+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/create-space.json
@@ -2313,7 +2313,7 @@
"facts": [
"Status: timed out",
"Identifier: direct:10.0.0.5:3211 [copy direct:10.0.0.5:3211 doc.on.doc Copy / checkmark Copied 1500ms]",
- "System: Linux"
+ "System: Unknown"
],
"previewText": "Not reachable",
"showSections": false,
diff --git a/libs/cua/crates/cua-spaces-app-core/src/model.rs b/libs/cua/crates/cua-spaces-app-core/src/model.rs
index 3d7a94cd4b..42ccc4b412 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/model.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/model.rs
@@ -17,6 +17,9 @@ pub enum SpaceOs {
Windows,
/// Linux.
Linux,
+ /// The host has not reported a recognized operating system.
+ #[serde(other)]
+ Unknown,
}
impl SpaceOs {
@@ -26,6 +29,7 @@ impl SpaceOs {
SpaceOs::Macos => "macOS",
SpaceOs::Windows => "Windows",
SpaceOs::Linux => "Linux",
+ SpaceOs::Unknown => "Unknown",
}
}
@@ -35,6 +39,7 @@ impl SpaceOs {
SpaceOs::Macos => "macos",
SpaceOs::Windows => "windows",
SpaceOs::Linux => "linux",
+ SpaceOs::Unknown => "unknown",
}
}
diff --git a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs
index 572829db72..0d43213a0f 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs
@@ -363,6 +363,7 @@ pub const OS_ICONS: &[&str] = &[
/// family's (`os-macos`, `os-windows`, `os-linux`).
pub fn os_icon(os: SpaceOs, os_name: Option<&str>) -> &'static str {
match os {
+ SpaceOs::Unknown => "computer",
SpaceOs::Macos => "os-macos",
SpaceOs::Windows => "os-windows",
SpaceOs::Linux => {
@@ -378,6 +379,9 @@ pub fn os_icon(os: SpaceOs, os_name: Option<&str>) -> &'static str {
/// The icon's artwork (a single-color 24 x 24 SVG; the shells tint it).
pub fn os_icon_svg(id: &str) -> Option<&'static str> {
Some(match id {
+ "computer" => {
+ r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M3 3h18v14h-8v3h5v2H6v-2h5v-3H3V3zm2 2v10h14V5H5z"/></svg>"#
+ }
"os-macos" => include_str!("../../assets/os-icons/os-macos.svg"),
"os-windows" => include_str!("../../assets/os-icons/os-windows.svg"),
"os-linux" => include_str!("../../assets/os-icons/os-linux.svg"),
@@ -400,7 +404,11 @@ pub fn os_icon_svg(id: &str) -> Option<&'static str> {
/// The system symbol to draw instead of the SVG on macOS (`apple.logo`
/// for macOS Spaces), if any.
pub fn os_icon_system_symbol(id: &str) -> Option<&'static str> {
- (id == "os-macos").then_some("apple.logo")
+ match id {
+ "os-macos" => Some("apple.logo"),
+ "computer" => Some("desktopcomputer"),
+ _ => None,
+ }
}
/// Where a Space runs, in words, for its tile: "This Mac" for one on this
diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
index 18ceda2550..6793d9217b 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
@@ -314,7 +314,7 @@ pub fn pending_name(name: &str, os: SpaceOs) -> String {
match os {
SpaceOs::Macos => "macOS Space".into(),
SpaceOs::Windows => "Windows Space".into(),
- SpaceOs::Linux => "New Space".into(),
+ SpaceOs::Linux | SpaceOs::Unknown => "New Space".into(),
}
}
@@ -331,6 +331,8 @@ pub const PHASES: [&str; 6] = [
/// The kinds of create, by how long their phases take.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CreateFamily {
+ /// No recognized OS; no timing estimate.
+ Unknown,
/// A Linux container on this Mac.
Container,
/// A Linux VM on this Mac, native (QEMU with HVF).
@@ -361,6 +363,7 @@ pub enum CreateFamily {
/// does not report is 0.
pub fn expected_seconds(family: CreateFamily) -> [f64; 6] {
match family {
+ CreateFamily::Unknown => [0.0; 6],
CreateFamily::Container => [1.0, 15.0, 0.3, 0.2, 3.5, 0.1],
CreateFamily::Vm => [1.3, 19.0, 0.0, 0.2, 17.0, 0.2],
CreateFamily::EmulatedVm => [1.4, 63.0, 0.0, 0.2, 115.0, 0.5],
@@ -373,6 +376,7 @@ pub fn expected_seconds(family: CreateFamily) -> [f64; 6] {
/// The create's family.
pub fn family(p: &PendingCreate) -> CreateFamily {
match (p.provider, p.os) {
+ (_, SpaceOs::Unknown) => CreateFamily::Unknown,
(SpaceProvider::Cloud, _) => CreateFamily::Cloud,
(_, SpaceOs::Macos) => CreateFamily::Macos,
(_, SpaceOs::Windows) => CreateFamily::Windows,
@@ -600,7 +604,7 @@ pub fn reduce(state: &CreatesState, action: &CreateAction) -> CreatesState {
host_arch,
gpu,
} => {
- if next.pending.iter().any(|p| &p.id == id) {
+ if *os == SpaceOs::Unknown || next.pending.iter().any(|p| &p.id == id) {
return next;
}
let image = image.clone().filter(|i| !i.trim().is_empty());
@@ -1061,6 +1065,15 @@ mod tests {
}
}
+ #[test]
+ fn unknown_os_cannot_start_a_create() {
+ let state = CreatesState::default();
+ assert_eq!(
+ reduce(&state, &start("pending:unknown", "", SpaceOs::Unknown)),
+ state
+ );
+ }
+
/// The first macOS create on a Mac without Lume: the built-in Lume's
/// download shows on the Space's own row, in words, with its bytes.
#[test]
diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
index e2a18cb583..24fba35023 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
@@ -84,6 +84,7 @@ pub fn scene_for_os(os: SpaceOs) -> ThumbnailScene {
SpaceOs::Macos => ThumbnailScene::MacDesktop,
SpaceOs::Windows => ThumbnailScene::WindowsDesktop,
SpaceOs::Linux => ThumbnailScene::LinuxTerminal,
+ SpaceOs::Unknown => ThumbnailScene::Blank,
}
}
@@ -203,7 +204,7 @@ fn cloud_place_of(row: &SpaceRow) -> Option<&str> {
/// Maps one registry row onto a Space. `now` stands in for a missing
/// `added_at`.
pub fn row_to_space(row: &SpaceRow, now: i64) -> Space {
- let os = row.os.unwrap_or(SpaceOs::Linux);
+ let os = row.os.unwrap_or(SpaceOs::Unknown);
let power = power_of_row(row);
// Turned off as the SDK recorded it: not running, whatever a probe
// that raced the turn-off said.
@@ -221,14 +222,20 @@ pub fn row_to_space(row: &SpaceRow, now: i64) -> Space {
let namespace = cloud_namespace_of(&row.id);
let text = |v: &Option<String>| v.clone().filter(|v| !v.trim().is_empty());
let (os_name, os_pretty_name, image) = (
- text(&row.os_name),
- text(&row.os_pretty_name),
+ (os != SpaceOs::Unknown)
+ .then(|| text(&row.os_name))
+ .flatten(),
+ (os != SpaceOs::Unknown)
+ .then(|| text(&row.os_pretty_name))
+ .flatten(),
text(&row.image),
);
// Until the Space reports its OS, the catalog's distribution for its
// image names it ("Omarchy", not "Linux").
let distro = match (&os_name, &os_pretty_name) {
- (None, None) => image.as_deref().and_then(crate::wizard::image_distro),
+ (None, None) if os != SpaceOs::Unknown => {
+ image.as_deref().and_then(crate::wizard::image_distro)
+ }
_ => None,
};
Space {
@@ -441,6 +448,58 @@ mod tests {
}
}
+ #[test]
+ fn unknown_os_stays_neutral_across_the_roster_and_details() {
+ let space = row_to_space(
+ &SpaceRow {
+ id: "relay:mac-host".into(),
+ provider: "relay".into(),
+ os: None,
+ // Neither stale names nor a known image may invent an OS.
+ os_pretty_name: Some("Ubuntu old".into()),
+ image: Some("linux:24.04".into()),
+ ..row()
+ },
+ 0,
+ );
+ assert_eq!(space.os.label(), "Unknown");
+ assert_eq!(space.scene, ThumbnailScene::Blank);
+ assert_eq!(space.os_name, None);
+ assert_eq!(space.os_pretty_name, None);
+ assert_eq!(sidebar::system_text(&space), "Unknown");
+ let tile = crate::notch::tiles(std::slice::from_ref(&space), None).remove(0);
+ assert_eq!(tile.symbol, "computer");
+ assert!(tile.label.contains("Unknown"), "{}", tile.label);
+ assert!(crate::notch::os_icon_svg("computer").is_some());
+ assert_eq!(
+ crate::notch::os_icon_system_symbol("computer"),
+ Some("desktopcomputer")
+ );
+ let mut future = serde_json::to_value(&space).unwrap();
+ future["os"] = "future-os".into();
+ assert_eq!(
+ serde_json::from_value::<Space>(future).unwrap().os,
+ SpaceOs::Unknown
+ );
+ for (os, label, icon) in [
+ (SpaceOs::Macos, "macOS", "os-macos"),
+ (SpaceOs::Windows, "Windows", "os-windows"),
+ (SpaceOs::Linux, "Linux", "os-linux"),
+ ] {
+ let known = row_to_space(
+ &SpaceRow {
+ os: Some(os),
+ os_name: None,
+ os_pretty_name: None,
+ ..row()
+ },
+ 0,
+ );
+ assert_eq!(sidebar::system_text(&known), label);
+ assert_eq!(crate::notch::os_icon(known.os, None), icon);
+ }
+ }
+
#[test]
fn maps_a_reachable_cloud_row() {
let s = row_to_space(&row(), 1_000);
@@ -479,7 +538,7 @@ mod tests {
},
42,
);
- assert_eq!(d.os, SpaceOs::Linux);
+ assert_eq!(d.os.label(), "Unknown");
assert_eq!(d.detail, "10.0.0.5:3211");
assert_eq!(d.name, "10.0.0.5:3211");
assert_eq!(d.last_used_at, 42);
diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs
index 3cbf641673..c975fadca7 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs
@@ -784,6 +784,9 @@ pub fn usage_text(used: u64, total: u64) -> String {
/// The OS in words: the full string the Space reported ("Ubuntu 24.04.3
/// LTS"), else its product name, else the family ("Linux").
pub fn system_text(space: &Space) -> String {
+ if space.os == crate::model::SpaceOs::Unknown {
+ return space.os.label().into();
+ }
[&space.os_pretty_name, &space.os_name]
.into_iter()
.flatten()
diff --git a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs
index 5472efc465..da62a0f0fd 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs
@@ -19,7 +19,7 @@
use serde::{Deserialize, Serialize};
use crate::drive_settings::{StorageAction, StorageInput, StorageRequest, StorageState};
-use crate::model::{SpaceKind, SpaceOs};
+use crate::model::SpaceKind;
use crate::onboarding::{
OnboardingAction, OnboardingMode, OnboardingState, OnboardingStep, StorageChoice,
};
@@ -333,14 +333,6 @@ fn after_answers(before: &OnboardingState, after: &OnboardingState) -> Onboardin
// ---- Space creates -------------------------------------------------------------
-fn os_word(os: SpaceOs) -> &'static str {
- match os {
- SpaceOs::Macos => "macos",
- SpaceOs::Windows => "windows",
- SpaceOs::Linux => "linux",
- }
-}
-
fn kind_word(k: Option<SpaceKind>) -> &'static str {
match k {
Some(SpaceKind::Container) => "container",
@@ -352,7 +344,7 @@ fn kind_word(k: Option<SpaceKind>) -> &'static str {
fn create_event(p: &PendingCreate, outcome: &str, stalled: bool, now_ms: i64) -> TelemetrySignal {
TelemetrySignal::SpaceCreate {
location: p.provider.as_str().into(),
- guest_os: os_word(p.os).into(),
+ guest_os: p.os.as_str().into(),
kind: kind_word(p.kind).into(),
outcome: outcome.into(),
failed_phase: if outcome == "ok" {
@@ -389,7 +381,7 @@ pub fn creates(before: &CreatesState, action: &CreateAction, now_ms: i64) -> Vec
let started = after.pending.iter().find(|p| &p.id == id).map(|p| {
TelemetrySignal::SpaceCreateStarted {
location: p.provider.as_str().into(),
- guest_os: os_word(p.os).into(),
+ guest_os: p.os.as_str().into(),
kind: kind_word(p.kind).into(),
gpu: p.gpu,
}
@@ -740,7 +732,7 @@ pub fn welcome_left(t: &cua_telemetry::Telemetry, on: bool) -> std::io::Result<(
mod tests {
use super::*;
use crate::drive_settings::DriveMountInput;
- use crate::model::SpaceProvider;
+ use crate::model::{SpaceOs, SpaceProvider};
use crate::onboarding::{initial, reduce};
fn pages(v: &[TelemetrySignal]) -> Vec<String> {
@@ -843,6 +835,44 @@ mod tests {
p.clone()
}
+ #[test]
+ fn create_telemetry_preserves_os_words() {
+ for (os, expected) in [
+ (SpaceOs::Macos, "macos"),
+ (SpaceOs::Windows, "windows"),
+ (SpaceOs::Linux, "linux"),
+ (SpaceOs::Unknown, "unknown"),
+ ] {
+ let mut p = pending("pending:os", "booting", None);
+ p.os = os;
+ let finished = create_event(&p, "ok", false, 2_000);
+ let finished = serde_json::to_value(finished).unwrap();
+ let started = creates(
+ &CreatesState::default(),
+ &CreateAction::Start {
+ id: p.id.clone(),
+ name: "test".into(),
+ os,
+ provider: SpaceProvider::Local,
+ now: 1_000,
+ image: None,
+ kind: Some(SpaceKind::Vm),
+ host_arch: None,
+ gpu: false,
+ },
+ 1_000,
+ );
+ let event = started.iter().find_map(|s| match s {
+ TelemetrySignal::SpaceCreateStarted { guest_os, .. } => Some(guest_os.as_str()),
+ _ => None,
+ });
+ assert_eq!(
+ (finished["guestOs"].as_str(), event),
+ (Some(expected), (os != SpaceOs::Unknown).then_some(expected))
+ );
+ }
+ }
+
#[test]
fn a_create_counts_once_when_ready_or_failed_for_good() {
let st = CreatesState {
diff --git a/libs/cua/crates/cua-spaces-app-core/src/wizard.rs b/libs/cua/crates/cua-spaces-app-core/src/wizard.rs
index 00514d50c2..0023a5df1a 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/wizard.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/wizard.rs
@@ -630,6 +630,7 @@ pub struct PlacementOption {
pub fn cloud_family(image: &SandboxImage) -> &'static str {
let r = image.image_ref.to_ascii_lowercase();
match image.os {
+ SpaceOs::Unknown => "unknown",
SpaceOs::Macos => "macos",
SpaceOs::Windows => "windows",
SpaceOs::Linux if r.contains("omarchy") => "omarchy",
@@ -2584,12 +2585,13 @@ pub fn view(state: &WizardState, env: &WizardEnv) -> WizardView {
let custom = custom_ref(state).is_some();
let image_error = validate_image_ref(&state.image_text);
let disk = disk_view(state, &image, env);
- let can_continue = match state.step {
- 0 => placeable && placement_ready && image_error.is_none(),
- 1 => disk.error.is_none(),
- 2 => !name_invalid,
- _ => true,
- };
+ let can_continue = image.os != SpaceOs::Unknown
+ && match state.step {
+ 0 => placeable && placement_ready && image_error.is_none(),
+ 1 => disk.error.is_none(),
+ 2 => !name_invalid,
+ _ => true,
+ };
let images = &catalog().images;
let pressed_os = selected_os(state);
let os_tiles = [
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.rs
index ec838c6b78..0f52340eb6 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
@@ -19,6 +19,8 @@ pub enum AppSpaceOs {
Windows,
/// Linux.
Linux,
+ /// The host has not reported a recognized operating system.
+ Unknown,
}
/// Lifecycle status of a Space.
diff --git a/libs/cua/crates/cua-spaces/src/space.rs b/libs/cua/crates/cua-spaces/src/space.rs
index 71525d0c6e..a8a237c335 100644
--- a/libs/cua/crates/cua-spaces/src/space.rs
+++ b/libs/cua/crates/cua-spaces/src/space.rs
@@ -435,6 +435,22 @@ impl Space {
.unwrap_or(pb::OsFamily::Unspecified)
}
+ /// The connected handshake's canonical (family, name, pretty name).
+ /// `None` means no spacesd: preserve the registry/discovery metadata.
+ /// A missing or unrecognized live family returns three empty strings,
+ /// so consumers clear stale OS metadata together. Never uses the image
+ /// catalog or refreshes the connection.
+ pub fn reported_os(&self) -> Option<(&'static str, &str, &str)> {
+ if !self.has_spacesd() {
+ return None;
+ }
+ let family = crate::spaces::os_family(self.capabilities());
+ match (family, self.capabilities().os.as_ref()) {
+ ("", _) | (_, None) => Some(("", "", "")),
+ (family, Some(os)) => Some((family, &os.name, &os.pretty_name)),
+ }
+ }
+
/// Whether the guest is Windows (shell commands go through `cmd /C`).
pub fn is_windows(&self) -> bool {
self.os_family() == pb::OsFamily::Windows
diff --git a/libs/cua/crates/cua-spaces/src/spaces.rs b/libs/cua/crates/cua-spaces/src/spaces.rs
index a9227a9e70..134d221367 100644
--- a/libs/cua/crates/cua-spaces/src/spaces.rs
+++ b/libs/cua/crates/cua-spaces/src/spaces.rs
@@ -561,7 +561,7 @@ pub(crate) fn os_names(space: &Space) -> (String, String) {
/// The guest OS family from `GetCapabilities`: `linux`, `macos`,
/// `windows`, or empty when not reported.
-pub(crate) fn os_family(caps: &cua_proto::env::v1::GetCapabilitiesResponse) -> String {
+pub(crate) fn os_family(caps: &cua_proto::env::v1::GetCapabilitiesResponse) -> &'static str {
use cua_proto::env::v1::OsFamily;
match caps.os.as_ref().map(|o| o.family()) {
Some(OsFamily::Linux) => "linux",
@@ -569,7 +569,6 @@ pub(crate) fn os_family(caps: &cua_proto::env::v1::GetCapabilitiesResponse) -> S
Some(OsFamily::Windows) => "windows",
_ => "",
}
- .into()
}
/// Lowercase DNS label: `[a-z0-9-]`, trimmed of dashes, at most 63 chars.
@@ -1108,7 +1107,7 @@ impl Spaces {
.filter(|f| f.supported)
.map(|f| f.name.clone())
.collect(),
- os: os_family(caps),
+ os: os_family(caps).into(),
os_name,
os_pretty_name,
image: space
diff --git a/libs/cua/crates/cua-spacesd-client/src/testing.rs b/libs/cua/crates/cua-spacesd-client/src/testing.rs
index efac02e53f..47555705f1 100644
--- a/libs/cua/crates/cua-spacesd-client/src/testing.rs
+++ b/libs/cua/crates/cua-spacesd-client/src/testing.rs
@@ -152,6 +152,8 @@ pub struct MockState {
/// Features reported unsupported, with their limitation (a host that
/// does not share its desktop).
withheld_features: Mutex<Vec<(String, String)>>,
+ /// Override the reported OS, including absence for an older host.
+ pub os: Mutex<Option<Option<pb::OperatingSystem>>>,
/// `GetCapabilities.version` (default `0.0.0-mock`).
version: Mutex<Option<String>>,
/// `GetCapabilitiesResponse::machine_seal_public_key` (S1); empty (an
@@ -612,13 +614,19 @@ impl SystemService for Svc {
.unwrap_or_else(|| "0.0.0-mock".into()),
protocol_version: cua_proto::ENV_PROTOCOL_VERSION,
protocol_revision: cua_proto::ENV_PROTOCOL_REVISION,
- os: Some(pb::OperatingSystem {
- family: pb::OsFamily::Linux as i32,
- name: "MockOS".into(),
- version: "1".into(),
- kernel: "mock".into(),
- pretty_name: "MockOS 1.0.3 LTS".into(),
- }),
+ os: self
+ .0
+ .os
+ .lock()
+ .unwrap()
+ .clone()
+ .unwrap_or(Some(pb::OperatingSystem {
+ family: pb::OsFamily::Linux as i32,
+ name: "MockOS".into(),
+ version: "1".into(),
+ kernel: "mock".into(),
+ pretty_name: "MockOS 1.0.3 LTS".into(),
+ })),
runtime: pb::Runtime::Container as i32,
features: vec![
pb::Feature {
diff --git a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
index d30b7722a2..80f7481944 100644
--- a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
+++ b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt
@@ -3600,7 +3600,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
if (lib.uniffi_cua_sdk_checksum_method_space_id() != 55610.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
- if (lib.uniffi_cua_sdk_checksum_method_space_info() != 1726.toShort()) {
+ if (lib.uniffi_cua_sdk_checksum_method_space_info() != 20024.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_cua_sdk_checksum_method_space_join_presence() != 56636.toShort()) {
@@ -16229,7 +16229,10 @@ public interface SpaceInterface {
fun `id`(): kotlin.String
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/
fun `info`(): SpaceInfo
@@ -16971,7 +16974,10 @@ open class Space: Disposable, AutoCloseable, SpaceInterface
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/override fun `info`(): SpaceInfo {
return FfiConverterTypeSpaceInfo.lift(
callWithHandle {
diff --git a/libs/cua/python/src/cua/_native.py b/libs/cua/python/src/cua/_native.py
index f939d21fcb..d7360f5a8b 100644
--- a/libs/cua/python/src/cua/_native.py
+++ b/libs/cua/python/src/cua/_native.py
@@ -1041,7 +1041,7 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_sdk_checksum_method_space_id() != 55610:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_sdk_checksum_method_space_info() != 1726:
+ if lib.uniffi_cua_sdk_checksum_method_space_info() != 20024:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_sdk_checksum_method_space_join_presence() != 56636:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
@@ -32227,7 +32227,10 @@ class SpaceProtocol(typing.Protocol):
raise NotImplementedError
def info(self, ) -> SpaceInfo:
"""
- The registry entry.
+ Connection-time snapshot; never refreshed. With spacesd, handshake
+ `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ families clear them. Other fields and non-spacesd services retain
+ registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
"""
raise NotImplementedError
async def join_presence(self, identity: PresenceIdentity,timeout_ms: typing.Optional[int]) -> SpacePresence:
@@ -32868,7 +32871,10 @@ class Space(SpaceProtocol):
return _uniffi_lift_return(_uniffi_ffi_result)
def info(self, ) -> SpaceInfo:
"""
- The registry entry.
+ Connection-time snapshot; never refreshed. With spacesd, handshake
+ `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ families clear them. Other fields and non-spacesd services retain
+ registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
"""
_uniffi_lowered_args = (
self._uniffi_clone_handle(),
diff --git a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
index 6a4d21ed63..f468c50614 100644
--- a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
+++ b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
@@ -8337,7 +8337,10 @@ public protocol SpaceProtocol: AnyObject, Sendable {
func id() -> String
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/
func info() -> SpaceInfo
@@ -8953,7 +8956,10 @@ open func id() -> String {
}
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/
open func info() -> SpaceInfo {
return try! FfiConverterTypeSpaceInfo_lift(try! rustCall() {
@@ -40676,7 +40682,7 @@ private let initializationResult: InitializationResult = {
if (uniffi_cua_sdk_checksum_method_space_id() != 55610) {
return InitializationResult.apiChecksumMismatch
}
- if (uniffi_cua_sdk_checksum_method_space_info() != 1726) {
+ if (uniffi_cua_sdk_checksum_method_space_info() != 20024) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_cua_sdk_checksum_method_space_join_presence() != 56636) {
diff --git a/libs/cua/typescript/src/native/cua_sdk.ts b/libs/cua/typescript/src/native/cua_sdk.ts
index cd303ab321..eccde2a89c 100644
--- a/libs/cua/typescript/src/native/cua_sdk.ts
+++ b/libs/cua/typescript/src/native/cua_sdk.ts
@@ -30567,7 +30567,10 @@ export interface SpaceLike {
*/
id(): string;
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/
info(): SpaceInfo;
/**
@@ -31394,7 +31397,10 @@ private constructor(pointer: UniffiHandle) {
}
/**
- * The registry entry.
+ * Connection-time snapshot; never refreshed. With spacesd, handshake
+ * `os`, `os_name`, `os_pretty_name` replace record values; missing/unknown
+ * families clear them. Other fields and non-spacesd services retain
+ * registry/discovery values. `Spaces.list()`/`Spaces.resolve()` remain record views.
*/
info(): SpaceInfo {
return ((__rb: Uint8Array) => {
@@ -37595,7 +37601,7 @@ function uniffiEnsureInitialized() {
if (nativeModule().uniffi_cua_sdk_checksum_method_space_id() !== 55610) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_id");
}
- if (nativeModule().uniffi_cua_sdk_checksum_method_space_info() !== 1726) {
+ if (nativeModule().uniffi_cua_sdk_checksum_method_space_info() !== 20024) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_info");
}
if (nativeModule().uniffi_cua_sdk_checksum_method_space_join_presence() !== 56636) {
diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
index 468c42c0c6..466f4ab7cf 100644
--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
@@ -48202,6 +48202,10 @@ public enum AppSpaceOs: Equatable, Hashable {
* Linux.
*/
case linux
+ /**
+ * The host has not reported a recognized operating system.
+ */
+ case unknown
@@ -48229,6 +48233,8 @@ public struct FfiConverterTypeAppSpaceOs: FfiConverterRustBuffer {
case 3: return .linux
+ case 4: return .unknown
+
default: throw UniffiInternalError.unexpectedEnumCase
}
}
@@ -48248,6 +48254,10 @@ public struct FfiConverterTypeAppSpaceOs: FfiConverterRustBuffer {
case .linux:
writeInt(&buf, Int32(3))
+
+ case .unknown:
+ writeInt(&buf, Int32(4))
+
}
}
}
diff --git a/scripts/docs-generators/cua-sdk.ts b/scripts/docs-generators/cua-sdk.ts
index daba4496f0..7f34789a68 100644
--- a/scripts/docs-generators/cua-sdk.ts
+++ b/scripts/docs-generators/cua-sdk.ts
@@ -463,7 +463,7 @@ export const PAGES: PageSpec[] = [
title: 'Space',
description: 'A connected Space: shell, files, tools, windows and the hotspot.',
intro:
- 'A `Space` is a connected machine. Every primitive checks the spacesd feature it needs first and fails with `CapabilityMissing` when the Space lacks it. Streams, teleport and agents have their own pages.',
+ 'Connected machine primitives; missing spacesd features return `CapabilityMissing`.',
items: [
'Space',
'SpaceBashResult',