Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(spaces-web): devices banner on every page, tile power button, Keyvault settings rows (CUA-1415) (#5027)
Francesco Bonaccid6174517b4a9
diff --git a/apps/cua-spaces-web/src/__tests__/settings-host-rows.test.tsx b/apps/cua-spaces-web/src/__tests__/settings-host-rows.test.tsxindex 8162a00cfe..4ebabfc4b7 100644--- a/apps/cua-spaces-web/src/__tests__/settings-host-rows.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/settings-host-rows.test.tsx@@ -72,7 +72,7 @@ describe.skipIf(!wasmBuilt)("the host's own settings (real routes, wasm core)",expect(within(row("linux-runtime")!).getByText("Linux")).toBeTruthy();expect(within(row("auto-connect")!).getByText("Connect to the desktop automatically")).toBeTruthy();expect(within(row("keyvault-auto-wipe")!).getByText("Wipe access from Spaces automatically")).toBeTruthy();- // Only the auto-wipe rows of the Keyvault section.+ // A host that doesn't report the site icons setting gets no switch for it.expect(row("keyvault-site-icons")).toBeNull();fireEvent.click(within(macos).getByText("Built-in"));diff --git a/apps/cua-spaces-web/src/__tests__/shell-parity.test.tsx b/apps/cua-spaces-web/src/__tests__/shell-parity.test.tsxnew file mode 100644index 0000000000..225d34d5b2--- /dev/null+++ b/apps/cua-spaces-web/src/__tests__/shell-parity.test.tsx@@ -0,0 +1,112 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++// The shell as the SwiftUI main window has it (real routes, the wasm core,+// the demo host): the enroll bar above every page, the power button on a+// Space's tile, and the Keyvault's Settings rows the host reports.++import { createMemoryHistory, createRouter, RouterProvider } from "@tanstack/react-router";+import { cleanup, fireEvent, render, waitFor, within } from "@testing-library/react";+import { afterEach, describe, expect, it } from "vitest";+import { BridgeProvider } from "@/bridge";+import type { DataAdapter } from "@/bridge/adapter";+import { createDemoAdapter, type DemoOptions } from "@/bridge/adapters/demo";+import { testCore, wasmBuilt } from "@/bridge/__tests__/testCore";+import { ToastProvider } from "@/components/ui/toast";+import { TooltipProvider } from "@/components/ui/tooltip";+import { routeTree } from "../routeTree.gen";+import { stubBrowserApis } from "./app-harness";++afterEach(cleanup);+stubBrowserApis();++async function mount(path: string, options: DemoOptions = {}) {+ const demo = createDemoAdapter({ latencyMs: 1, stepMs: 4, ...options });+ const calls: [string, unknown][] = [];+ const adapter: DataAdapter = {+ mode: demo.mode,+ subscribe: (l) => demo.subscribe(l),+ call: (async (op: string, args: unknown) => {+ calls.push([op, args]);+ return (demo.call as (o: string, a: unknown) => Promise<unknown>)(op, args);+ }) as DataAdapter["call"],+ };+ const router = createRouter({ routeTree, history: createMemoryHistory({ initialEntries: [path] }) });+ render(+ <BridgeProvider adapter={adapter} core={await testCore()} storeOptions={{ tickMs: 5 }}>+ <TooltipProvider delay={500}>+ <ToastProvider>+ <RouterProvider router={router} />+ </ToastProvider>+ </TooltipProvider>+ </BridgeProvider>,+ );+ return { router, calls };+}++const found = <T extends Element>(selector: string) =>+ waitFor(() => {+ const el = document.querySelector<T>(selector);+ if (!el) throw new Error(`no ${selector}`);+ return el;+ });++describe.skipIf(!wasmBuilt)("the shell as the SwiftUI main window (real routes, wasm core)", () => {+ it("shows the enroll bar above every page while this device is not enrolled, and Enroll… opens the sheet", async () => {+ const { router } = await mount("/spaces", { unenrolled: true });+ const bar = await found<HTMLElement>("[data-shell-devices-banner]");+ expect(bar.textContent).toMatch(/Enroll this device/);++ await router.navigate({ to: "/keyvault" });+ await found("[data-shell-devices-banner]");++ fireEvent.click(await found("[data-shell-banner-enroll]"));+ await waitFor(() => expect(router.state.location.pathname).toBe("/settings/devices"));+ await found("[data-enroll]");+ // The Devices page says it under its own row: no second bar there.+ expect(document.querySelector("[data-shell-devices-banner]")).toBeNull();++ fireEvent.click(await found('[data-enroll-option="sign-in"]'));+ await waitFor(() => expect(document.querySelector('[data-this-device-status="enrolled"]')).toBeTruthy());+ await router.navigate({ to: "/spaces" });+ await found("[data-space-id]");+ expect(document.querySelector("[data-shell-devices-banner]")).toBeNull();+ });++ it("shows no enroll bar for an enrolled device", async () => {+ await mount("/spaces");+ await found("[data-space-id]");+ await new Promise((r) => setTimeout(r, 50));+ expect(document.querySelector("[data-shell-devices-banner]")).toBeNull();+ });++ it("gives a Space's tile the core's power button, and pressing it turns the Space off", async () => {+ const { calls } = await mount("/spaces");+ const tile = (await found<HTMLElement>('[data-space-id][data-state="running"]')).parentElement!;+ const power = await waitFor(() => {+ const b = tile.querySelector<HTMLButtonElement>("[data-tile-power]");+ if (!b) throw new Error("no power button");+ return b;+ });+ expect(power.getAttribute("data-tile-power")).toBe("off");+ expect(["Suspend", "Turn off"]).toContain(power.title);+ fireEvent.click(power);+ await waitFor(() => expect(calls.some(([op, a]) => op === "spaces.setPower" && (a as { on: boolean }).on === false)).toBe(true));+ });++ it("lays out every Keyvault row the host reports, and changes its switches", async () => {+ const { calls } = await mount("/settings", { macHost: true });+ const section = await found<HTMLElement>('[data-settings-section="keyvault"]');+ const row = (id: string) => section.querySelector<HTMLElement>(`[data-setting-row="${id}"]`);+ await waitFor(() => expect(row("keyvault-unlock-prompt")).toBeTruthy());+ expect(row("keyvault-auto-wipe")).toBeTruthy();+ expect(row("keyvault-site-icons")).toBeTruthy();+ expect(row("keyvault-protection:Unlock")?.textContent).toContain("Mac login");++ fireEvent.click(within(row("keyvault-unlock-prompt")!).getByRole("switch"));+ await waitFor(() => expect(calls).toContainEqual(["settings.choose", { row: "keyvault-unlock-prompt", option: "off" }]));+ await waitFor(() => expect(within(row("keyvault-unlock-prompt")!).getByRole("switch").getAttribute("aria-checked")).toBe("false"));+ fireEvent.click(within(row("keyvault-site-icons")!).getByRole("switch"));+ await waitFor(() => expect(calls).toContainEqual(["settings.choose", { row: "keyvault-site-icons", option: "off" }]));+ });+});diff --git a/apps/cua-spaces-web/src/bridge/README.md b/apps/cua-spaces-web/src/bridge/README.mdindex e98862af82..8c8260720f 100644--- a/apps/cua-spaces-web/src/bridge/README.md+++ b/apps/cua-spaces-web/src/bridge/README.md@@ -92,7 +92,7 @@ Each is an existing Tauri command under a host-neutral name:| `machines.list` | `host_status` + `list_hosts` + `get_environment` || `host.status` | `host_status` || `settings.get` / `settings.set` `{key, value}` | UI storage (`ui_storage_set`), `telemetry_status`/`telemetry_set_enabled`, `get_default_location`/`set_default_location`, `login_item_status`/`login_item_set` (`launchAtLogin`). The Tauri updater has no channels, so `updateChannel` is `null` there. |-| `settings.choose` `{row, option}` | none: the Tauri shell lays out none of the host's own rows (`SettingsSnapshot.hostSettings`: the SwiftUI app's Runtimes, auto-connect and Keyvault auto-wipe, which the page draws from the core's Settings page and changes with `settings.choose`; New Space's "Use built-in Lume" too). |+| `settings.choose` `{row, option}` | none: the Tauri shell lays out none of the host's own rows (`SettingsSnapshot.hostSettings`: the SwiftUI app's Runtimes, auto-connect and Keyvault switches, which the page draws from the core's Settings page and changes with `settings.choose`; New Space's "Use built-in Lume" too). || `keyvault.overview` | `keyvault_overview` || `keyvault.unlock` `{passphrase?}` | `keyvault_unlock` / `keyvault_unlock_passphrase` || `keyvault.setUnattended` `{itemIds, unattended}` | `keyvault_set_unattended` |diff --git a/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.tsindex 3acd37a0bd..bae904e264 100644--- a/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts+++ b/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts@@ -795,13 +795,29 @@ describe("webkit adapter", () => {sections: [{ id: "general", rows: [toggle("auto-connect", false)] },{ id: "runtimes", rows: [choice("macos-runtime", "builtin"), choice("linux-runtime", "system")] },- { id: "keyvault", rows: [toggle("keyvault-auto-wipe", true)] },+ {+ id: "keyvault",+ rows: [+ toggle("keyvault-auto-wipe", true),+ toggle("keyvault-unlock-prompt", false),+ toggle("keyvault-site-icons", true),+ { id: "keyvault-protection:Unlock", kind: "text", label: "Unlock", value: "Mac login", enabled: true, options: [] },+ ],+ },],},};const { win, sent } = webkitHost(() => ok(page));const a = createWebkitAdapter(win);- expect((await a.call("settings.get", {})).hostSettings).toEqual({ lumeSource: "builtin", linuxSource: "system", autoConnect: false, keyvaultAutoWipe: true });+ expect((await a.call("settings.get", {})).hostSettings).toEqual({+ lumeSource: "builtin",+ linuxSource: "system",+ autoConnect: false,+ keyvaultAutoWipe: true,+ keyvaultUnlockPrompt: false,+ keyvaultSiteIcons: true,+ keyvaultProtection: [{ label: "Unlock", value: "Mac login" }],+ });await a.call("settings.choose", { row: "macos-runtime", option: "system" });expect(sent.slice(-2).map((r) => [r.method, r.args])).toEqual([["settings.choose", { row: "macos-runtime", option: "system" }],@@ -809,7 +825,15 @@ describe("webkit adapter", () => {]);// A host without these rows has none of them.const { win: bare } = webkitHost(() => ok(settingsPage));- expect((await createWebkitAdapter(bare).call("settings.get", {})).hostSettings).toEqual({ lumeSource: null, linuxSource: null, autoConnect: null, keyvaultAutoWipe: null });+ expect((await createWebkitAdapter(bare).call("settings.get", {})).hostSettings).toEqual({+ lumeSource: null,+ linuxSource: null,+ autoConnect: null,+ keyvaultAutoWipe: null,+ keyvaultUnlockPrompt: null,+ keyvaultSiteIcons: null,+ keyvaultProtection: null,+ });});it("maps Teleport's records onto the core's words, and keeps the host's keys for the plan and run", async () => {diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo.ts b/apps/cua-spaces-web/src/bridge/adapters/demo.tsindex 866d157068..f411555922 100644--- a/apps/cua-spaces-web/src/bridge/adapters/demo.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/demo.ts@@ -18,6 +18,7 @@ import {type OpArgs,type OpName,type OpResult,+ type HostSettings,type SessionSnapshot,type SettingsSnapshot,type SettingsValues,@@ -66,14 +67,17 @@ export interface DemoOptions {keychain?: boolean;/** Answer New Space's options as the SwiftUI host does (`demo/new-space.ts`). */macHost?: boolean;+ /** This device is not enrolled on the relay yet (the enroll bar above every page). */+ unenrolled?: boolean;/** The machine the demo runs on: a Mac on Apple silicon unless set (the* Electron shell passes its own system and architecture). */platform?: DemoPlatform;}/** `?demo=fresh` (signed out, first run), `?demo=locked` (Keyvault locked), `?demo=novault` (no Keyvault yet),- * `?demo=empty` (no Spaces yet), `?demo=keychain` (the startup screen) and- * `?demo=mac-host` (New Space options in the SwiftUI host's shape). */+ * `?demo=empty` (no Spaces yet), `?demo=keychain` (the startup screen),+ * `?demo=mac-host` (New Space options and the Keyvault's Settings rows in the+ * SwiftUI host's shape) and `?demo=unenrolled` (this device not enrolled). */export function demoOptionsFromSearch(search: string): DemoOptions {const flags = new Set((new URLSearchParams(search).get("demo") ?? "").split(",").filter(Boolean));return {@@ -84,9 +88,28 @@ export function demoOptionsFromSearch(search: string): DemoOptions {noSpaces: flags.has("empty"),keychain: flags.has("keychain"),macHost: flags.has("mac-host"),+ unenrolled: flags.has("unenrolled"),};}+/** The SwiftUI host's Keyvault settings (`?demo=mac-host`). */+const DEMO_MAC_HOST_SETTINGS: HostSettings = {+ keyvaultAutoWipe: false,+ keyvaultUnlockPrompt: true,+ keyvaultSiteIcons: true,+ keyvaultProtection: [+ { label: "Touch ID", value: "Asked by the Cua daemon to widen access" },+ { label: "Unlock", value: "Mac login" },+ { label: "This app", value: "Verified as Cua" },+ ],+};++const DEMO_KEYVAULT_ROWS: Partial<Record<string, "keyvaultAutoWipe" | "keyvaultUnlockPrompt" | "keyvaultSiteIcons">> = {+ "keyvault-auto-wipe": "keyvaultAutoWipe",+ "keyvault-unlock-prompt": "keyvaultUnlockPrompt",+ "keyvault-site-icons": "keyvaultSiteIcons",+};+const CREATE_PHASES = ["preparing", "pulling", "creating", "booting", "waiting_for_services", "connecting"];type Handler<K extends OpName> = (args: OpArgs<K>) => Promise<OpResult<K>> | OpResult<K>;@@ -114,6 +137,7 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { reagentSetup: demoAgentSetup(),platform: options.platform ?? MAC_DEMO_PLATFORM,paired: [],+ hostSettings: options.macHost ? DEMO_MAC_HOST_SETTINGS : undefined,volume: demoVolumeState(now(), options.onboarded !== false, options.platform),...demoTelemetryState(),...demoRelayUsageState(),@@ -149,6 +173,7 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { revalues: { ...state.settings },defaultLocation: { value: state.settings.defaultLocation, source: "config", path: "~/.cua/config.toml" },telemetry: demoTelemetry(state.settings.telemetry),+ ...(state.hostSettings ? { hostSettings: { ...state.hostSettings } } : {}),});const overview = () => {if (!state.keyvaultSetUp) return demoNoVaultOverview(now());@@ -281,8 +306,10 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { reemit({ type: "settings.changed" });return settingsSnapshot();},- // The demo lays out none of the host's own rows: nothing to change.- "settings.choose": async ({ row }) => {+ // The host's own rows: only the Keyvault's switches, as `?demo=mac-host`.+ "settings.choose": async ({ row, option }) => {+ const key = DEMO_KEYVAULT_ROWS[row];+ if (key && state.hostSettings) state.hostSettings = { ...state.hostSettings, [key]: option === "on" };// An AI agents row's button (the SwiftUI host's `press`): set it up, or remove what cua added.const agent = row.startsWith("agent:") ? state.agentSetup.find((r) => `agent:${r.agent}` === row && r.installed) : undefined;if (agent) {@@ -434,7 +461,7 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { re...demoShareHandlers({ wait, stepMs: step }),...demoAgentKeysHandlers({ wait, stepMs: step, now }),...demoVolumeHandlers({ state: state.volume, now, wait, step, emit, platform: state.platform }),- ...createDemoSettings({ now, wait, emit, stepMs: step, platform: state.platform, experiments: state.volume.experiments, signedIn: () => Boolean(state.identity), settings: () => state.settings, setSettings: (p) => ((state.settings = { ...state.settings, ...p }), emit({ type: "settings.changed" })), addMachine: (m) => ((state.paired = [...state.paired, m]), emit({ type: "machines.changed" })) }),+ ...createDemoSettings({ now, wait, emit, stepMs: step, platform: state.platform, unenrolled: options.unenrolled, experiments: state.volume.experiments, signedIn: () => Boolean(state.identity), settings: () => state.settings, setSettings: (p) => ((state.settings = { ...state.settings, ...p }), emit({ type: "settings.changed" })), addMachine: (m) => ((state.paired = [...state.paired, m]), emit({ type: "machines.changed" })) }),...demoTelemetryHandlers(ctx),...demoRelayUsageHandlers(ctx),...demoSpaceDetailHandlers(ctx),@@ -481,4 +508,6 @@ export interface DemoState extends DemoTelemetryState, DemoRelayUsageState, Demoplatform: DemoPlatform;/** Machines added with a pairing code ("Add a machine"). */paired: MachineRow[];+ /** `?demo=mac-host`: the Keyvault's switches the SwiftUI host lays out in Settings. */+ hostSettings?: HostSettings;}diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo/settings.ts b/apps/cua-spaces-web/src/bridge/adapters/demo/settings.tsindex ec889211cf..aa65115020 100644--- a/apps/cua-spaces-web/src/bridge/adapters/demo/settings.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/demo/settings.ts@@ -8,7 +8,7 @@*/import { HostError } from "../../adapter";-import type { DevicesInput, PairingCode } from "../../contracts/devices";+import type { DeviceInput, DevicesInput, PairingCode } from "../../contracts/devices";import type { MachineRow } from "../../contracts/host";import type { NotificationInput } from "../../contracts/notifications";import type { AboutInput, DriveCheckInput, Experiments, LoginItemReport, StorageInput } from "../../contracts/settings";@@ -34,6 +34,8 @@ export interface DemoSettingsContext {platform?: DemoPlatform;/** A machine joined with a pairing code: the host lists it from now on. */addMachine?: (machine: MachineRow) => void;+ /** This device is not on the relay until Enroll… signs in again. */+ unenrolled?: boolean;}/** How many times "Add a machine" reads the codes before the demo's other@@ -57,13 +59,16 @@ type Handlers = { [K in keyof Ops]: (args: Ops[K]["args"]) => Promise<Ops[K]["reconst DAY = 86_400;const GIB = 1024 ** 3;-/** The account's devices: this Mac, a Linux desktop, one waiting, one due. */-export function demoDevices(nowMs: number): DevicesInput {+/** This Mac, enrolled. */+const thisDemoDevice = (now: number): DeviceInput => ({ id: "dev_mac", name: "MacBook Pro", state: "enrolled", current: true, platform: "macos", enrolledUntil: now + 24 * DAY, lastSeen: now - 60 });++/** The account's devices: this Mac (unless not enrolled yet), a Linux desktop, one waiting, one due. */+export function demoDevices(nowMs: number, unenrolled = false): DevicesInput {const now = Math.floor(nowMs / 1000);return {localDeviceId: "dev_mac",devices: [- { id: "dev_mac", name: "MacBook Pro", state: "enrolled", current: true, platform: "macos", enrolledUntil: now + 24 * DAY, lastSeen: now - 60 },+ ...(unenrolled ? [] : [thisDemoDevice(now)]),{ id: "dev_studio", name: "Studio", state: "enrolled", platform: "linux", enrolledUntil: now + 12 * DAY, lastSeen: now - 3 * 3600 },{ id: "dev_work", name: "Work laptop", state: "pending", platform: "windows" },{ id: "dev_old", name: "Old laptop", state: "expired", platform: "linux", enrolledUntil: now - 2 * DAY, lastSeen: now - 33 * DAY },@@ -120,7 +125,7 @@ export function createDemoSettings(ctx: DemoSettingsContext): Handlers {let autoCheck = true;let autoInstall = false;let experiments: Experiments = { ...NO_EXPERIMENTS, ...ctx.experiments };- let devices = demoDevices(now());+ let devices = demoDevices(now(), ctx.unenrolled);// One code made earlier (`cua host pair`) that nobody used yet; only the// codes made here join a computer.const t0 = Math.floor(now() / 1000);@@ -210,7 +215,14 @@ export function createDemoSettings(ctx: DemoSettingsContext): Handlers {if (!ctx.signedIn()) throw new HostError("Sign in to Cua to see your devices", "signed_out");return structuredClone(devices);},- "devices.enroll": () => ({ enrolled: true, code: null }),+ // Signing in again enrolls this device at once.+ "devices.enroll": () => {+ if (!devices.devices?.some((d) => d.id === "dev_mac")) {+ devices = { ...devices, devices: [thisDemoDevice(Math.floor(now() / 1000)), ...(devices.devices ?? [])] };+ audit("device_enrolled", "dev_mac");+ }+ return { enrolled: true, code: null };+ },"devices.checkEnrolled": () => true,"devices.approve": async ({ code, deviceId }) => {await wait(stepMs);diff --git a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts b/apps/cua-spaces-web/src/bridge/adapters/webkit.tsindex 024f5d4f06..7e3471cfe2 100644--- a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/webkit.ts@@ -201,6 +201,9 @@ export function toSettingsSnapshot(s: WkSettings, page: Pick<SettingsValues, "th// them out again on the page (null: the host has none).const source = (id: string) => (rows.has(id) ? (active(rows.get(id)) ?? "auto") : null);const on = (id: string) => (rows.has(id) ? active(rows.get(id)) === "on" : null);+ const protection = [...rows.values()]+ .filter((r) => r.id.startsWith("keyvault-protection:"))+ .map((r) => ({ label: r.label, value: r.value ?? "" }));return {values: {theme: page.theme,@@ -230,6 +233,9 @@ export function toSettingsSnapshot(s: WkSettings, page: Pick<SettingsValues, "thlinuxSource: source("linux-runtime"),autoConnect: on("auto-connect"),keyvaultAutoWipe: on("keyvault-auto-wipe"),+ keyvaultUnlockPrompt: on("keyvault-unlock-prompt"),+ keyvaultSiteIcons: on("keyvault-site-icons"),+ keyvaultProtection: protection.length ? protection : null,},};}diff --git a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.jsonindex 92ffe9a1e5..d96e34f769 100644--- a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json+++ b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json@@ -1910,6 +1910,39 @@"boolean","null"]+ },+ "keyvaultUnlockPrompt": {+ "type": [+ "boolean",+ "null"+ ]+ },+ "keyvaultSiteIcons": {+ "type": [+ "boolean",+ "null"+ ]+ },+ "keyvaultProtection": {+ "type": [+ "array",+ "null"+ ],+ "items": {+ "type": "object",+ "properties": {+ "label": {+ "type": "string"+ },+ "value": {+ "type": "string"+ }+ },+ "required": [+ "label",+ "value"+ ]+ }}}}@@ -3205,6 +3238,12 @@"null"]},+ "value": {+ "type": [+ "string",+ "null"+ ]+ },"options": {"type": "array","items": {diff --git a/apps/cua-spaces-web/src/bridge/contracts/host.ts b/apps/cua-spaces-web/src/bridge/contracts/host.tsindex 084c176a68..289621a5c8 100644--- a/apps/cua-spaces-web/src/bridge/contracts/host.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/host.ts@@ -425,6 +425,12 @@ export interface SettingsInput {telemetry?: { enabled: boolean; lockedBy?: string | null } | null;/** The Keyvault's auto-wipe (none: no Keyvault section). */keyvaultAutoWipe?: boolean | null;+ /** The unlock prompt shows (none: no row). */+ keyvaultUnlockPrompt?: boolean | null;+ /** Load site icons the browser had none for (the core's default: on). */+ keyvaultSiteIcons?: boolean;+ /** The Keyvault's protection facts (Touch ID, the daemon's signature). */+ keyvaultProtection?: { label: string; value: string }[];/** "Connect to the desktop automatically" (none: no row). */autoConnect?: boolean | null;/** Which Lume macOS Spaces run on (none: no Runtimes section). */diff --git a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts b/apps/cua-spaces-web/src/bridge/contracts/shapes.tsindex 5647e1cf0a..43a484e8d0 100644--- a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts@@ -217,7 +217,15 @@ const SettingsShape = ref(obj<TelemetryView>()({ enabled: bool, source: str, sourceKind: str, noticeShown: bool, noticeText: str, docsUrl: str }),),hostSettings: opt(- obj<HostSettings>()({ lumeSource: optNull(str), linuxSource: optNull(str), autoConnect: optNull(bool), keyvaultAutoWipe: optNull(bool) }),+ obj<HostSettings>()({+ lumeSource: optNull(str),+ linuxSource: optNull(str),+ autoConnect: optNull(bool),+ keyvaultAutoWipe: optNull(bool),+ keyvaultUnlockPrompt: optNull(bool),+ keyvaultSiteIcons: optNull(bool),+ keyvaultProtection: optNull(list(obj<{ label: string; value: string }>()({ label: str, value: str }))),+ }),),}),);@@ -856,6 +864,7 @@ const WkSettingsShape = ref(label: str,enabled: bool,help: optNull(str),+ value: optNull(str),options: list(object({ id: str, label: str, active: bool })),}),),diff --git a/apps/cua-spaces-web/src/bridge/derive.ts b/apps/cua-spaces-web/src/bridge/derive.tsindex 516dcae6e5..28a1637280 100644--- a/apps/cua-spaces-web/src/bridge/derive.ts+++ b/apps/cua-spaces-web/src/bridge/derive.ts@@ -531,6 +531,9 @@ export function settingsPage(// The host's own settings (the SwiftUI app's): the core lays out the// Runtimes section, auto-connect and the Keyvault's auto-wipe as there.keyvaultAutoWipe: settings.hostSettings?.keyvaultAutoWipe ?? null,+ keyvaultUnlockPrompt: settings.hostSettings?.keyvaultUnlockPrompt ?? null,+ keyvaultSiteIcons: settings.hostSettings?.keyvaultSiteIcons ?? true,+ keyvaultProtection: settings.hostSettings?.keyvaultProtection ?? [],autoConnect: settings.hostSettings?.autoConnect ?? null,lumeSource: settings.hostSettings?.lumeSource ?? null,linuxSource: settings.hostSettings?.linuxSource ?? null,diff --git a/apps/cua-spaces-web/src/bridge/protocol.ts b/apps/cua-spaces-web/src/bridge/protocol.tsindex 6952660d87..90ef79d44a 100644--- a/apps/cua-spaces-web/src/bridge/protocol.ts+++ b/apps/cua-spaces-web/src/bridge/protocol.ts@@ -108,6 +108,12 @@ export interface HostSettings {autoConnect?: boolean | null;/** The Keyvault wipes access from Spaces automatically. */keyvaultAutoWipe?: boolean | null;+ /** The Keyvault explains unattended access before allowing it (off after "Never ask again"). */+ keyvaultUnlockPrompt?: boolean | null;+ /** The Keyvault loads site icons the browser had none for. */+ keyvaultSiteIcons?: boolean | null;+ /** The Keyvault's protection facts, as the host's Settings lists them. */+ keyvaultProtection?: { label: string; value: string }[] | null;}export const DEFAULT_SETTINGS: SettingsValues = {diff --git a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts b/apps/cua-spaces-web/src/bridge/webkit-protocol.tsindex 994c714fad..811548f587 100644--- a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts+++ b/apps/cua-spaces-web/src/bridge/webkit-protocol.ts@@ -286,6 +286,8 @@ export interface WkSettingsRow {label: string;enabled: boolean;help?: string | null;+ /** A text row's value (the Keyvault's protection facts). */+ value?: string | null;options: { id: string; label: string; active: boolean }[];}diff --git a/apps/cua-spaces-web/src/components/shell/devices-banner.tsx b/apps/cua-spaces-web/src/components/shell/devices-banner.tsxnew file mode 100644index 0000000000..8a1038128a--- /dev/null+++ b/apps/cua-spaces-web/src/components/shell/devices-banner.tsx@@ -0,0 +1,46 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { useLocation, useNavigate } from "@tanstack/react-router";+import { CircleAlertIcon, TriangleAlertIcon } from "lucide-react";++import { useDevices, useSession } from "@/bridge";+import { Button } from "@/components/ui/button";+import { shellDevicesBanner } from "@/lib/devices";+import { cn } from "@/lib/utils";++/**+ * This device needs enrolling or re-verifying: one bar above every page,+ * the core's words and its Enroll… (the SwiftUI app's `DevicesBanner`).+ * Settings, Devices says the same under its own row, so the bar stays off+ * that page.+ */+export function DevicesBanner() {+ const { data: session } = useSession();+ const devices = useDevices();+ const { pathname } = useLocation();+ const navigate = useNavigate();+ const banner = shellDevicesBanner(devices.data, session?.signedIn);+ if (!banner || pathname.startsWith("/settings/devices")) return null;++ const critical = banner.tone === "critical";+ const Icon = critical ? TriangleAlertIcon : CircleAlertIcon;+ // The enroll sheet is the Devices page's.+ const enroll = () => {+ devices.startEnroll();+ void navigate({ to: "/settings/devices" });+ };+ return (+ <div role="status" data-shell-devices-banner={banner.tone} className="flex shrink-0 items-center gap-2 border-b px-4 py-1.5 text-xs">+ <Icon className={cn("size-3.5 shrink-0", critical ? "text-destructive" : "text-warning")} />+ <span className="min-w-0 flex-1 truncate" title={banner.text}>+ {banner.text}+ </span>+ {banner.actionLabel ? (+ <Button size="sm" variant="outline" className="h-6" onClick={enroll} data-shell-banner-enroll>+ {banner.actionLabel}+ </Button>+ ) : null}+ </div>+ );+}diff --git a/apps/cua-spaces-web/src/lib/devices.test.ts b/apps/cua-spaces-web/src/lib/devices.test.tsindex 05482180cb..d3ea09a636 100644--- a/apps/cua-spaces-web/src/lib/devices.test.ts+++ b/apps/cua-spaces-web/src/lib/devices.test.ts@@ -3,7 +3,7 @@import { describe, expect, it } from "vitest";-import { devicesPageState } from "./devices";+import { devicesPageState, shellDevicesBanner } from "./devices";describe("devicesPageState", () => {it("never leaves the Devices tab blank", () => {@@ -15,3 +15,22 @@ describe("devicesPageState", () => {expect(devicesPageState({ unsupported: true, error: null }, true)).toBe("unsupported");});});++describe("shellDevicesBanner", () => {+ const banner = { tone: "warning" as const, text: "Enroll this device within 3 days to keep reaching your machines.", action: "enroll" as const, actionLabel: "Enroll…" };+ const read = (input: { devices?: { id: string; state: string }[]; readError?: string | null }) => ({ input, view: { banner } });++ it("shows the core's bar once signed in and read", () => {+ expect(shellDevicesBanner(read({ devices: [] }), true)).toBe(banner);+ expect(shellDevicesBanner(read({ devices: [] }), false)).toBeNull();+ expect(shellDevicesBanner(undefined, true)).toBeNull();+ expect(shellDevicesBanner({ input: {}, view: { banner: null } }, true)).toBeNull();+ });++ it("shows none when the first read was refused, as the SwiftUI app has no list then", () => {+ expect(shellDevicesBanner(read({ devices: [], readError: "not enrolled" }), true)).toBeNull();+ expect(shellDevicesBanner(read({ readError: "not enrolled" }), true)).toBeNull();+ // A later read failed: the list from before still stands.+ expect(shellDevicesBanner(read({ devices: [{ id: "d1", state: "expired" }], readError: "timed out" }), true)).toBe(banner);+ });+});diff --git a/apps/cua-spaces-web/src/lib/devices.ts b/apps/cua-spaces-web/src/lib/devices.tsindex 95936bce5d..1e000f0cd6 100644--- a/apps/cua-spaces-web/src/lib/devices.ts+++ b/apps/cua-spaces-web/src/lib/devices.ts@@ -4,7 +4,7 @@// Words the Devices page formats itself (the core leaves dates to the shell,// as the SwiftUI app's `DevicesModel` does).-import type { DeviceRow, DevicesLabels, ThisDevice } from "@/bridge";+import type { DeviceBanner, DeviceRow, DevicesInput, DevicesLabels, DevicesView, ThisDevice } from "@/bridge";/** "Oct 27, 2026" (a medium date, no time). */export function dateText(secs: number, locale?: string): string {@@ -66,3 +66,19 @@ export function devicesPageState(if (!r.data) return "loading";return r.data.view ? "ready" : "no-view";}++/**+ * The bar above every page when this device needs enrolling or re-verifying+ * (`DevicesModel.banner` in the SwiftUI app): signed in, and only once the+ * relay was read. A first read the relay refused leaves no list behind (the+ * hosts send an empty one with `readError`), and the SwiftUI app shows no+ * bar then either; Settings, Devices says why.+ */+export function shellDevicesBanner(+ data: { input: Pick<DevicesInput, "devices" | "readError">; view: Pick<DevicesView, "banner"> | null } | undefined,+ signedIn: boolean | undefined,+): DeviceBanner | null {+ if (!signedIn || !data?.view) return null;+ const read = !data.input.readError || (data.input.devices?.length ?? 0) > 0;+ return read ? data.view.banner : null;+}diff --git a/apps/cua-spaces-web/src/lib/keyvault.test.ts b/apps/cua-spaces-web/src/lib/keyvault.test.tsindex 3edc811e3f..1845e4d1cf 100644--- a/apps/cua-spaces-web/src/lib/keyvault.test.ts+++ b/apps/cua-spaces-web/src/lib/keyvault.test.ts@@ -4,7 +4,8 @@import { describe, expect, it } from "vitest";import type { VaultApp, VaultRow, VaultView } from "@/bridge/contracts/keyvault";-import { vaultLines } from "./keyvault";+import type { SettingsRow } from "@/bridge";+import { keyvaultRows, vaultLines } from "./keyvault";const row = (id: string): VaultRow => ({id,@@ -50,3 +51,22 @@ describe("vaultLines", () => {expect(vaultLines({ apps: [] } as unknown as VaultView)).toEqual([]);});});++describe("keyvaultRows", () => {+ const ids = ["keyvault-auto-wipe", "keyvault-auto-wipe-note", "keyvault-unlock-prompt", "keyvault-site-icons", "keyvault-site-icons-note", "keyvault-protection:Unlock"];+ const rows = ids.map((id) => ({ id }) as SettingsRow);++ it("keeps every row when the host reports the site icons setting", () => {+ expect(keyvaultRows(rows, { keyvaultSiteIcons: false }).map((r) => r.id)).toEqual(ids);+ });++ it("drops the site icons switch the core laid out from its default", () => {+ expect(keyvaultRows(rows, { keyvaultAutoWipe: true }).map((r) => r.id)).toEqual([+ "keyvault-auto-wipe",+ "keyvault-auto-wipe-note",+ "keyvault-unlock-prompt",+ "keyvault-protection:Unlock",+ ]);+ expect(keyvaultRows(rows, undefined)).toHaveLength(4);+ });+});diff --git a/apps/cua-spaces-web/src/lib/keyvault.ts b/apps/cua-spaces-web/src/lib/keyvault.tsindex 3ecab8bd8d..dcfc1217b5 100644--- a/apps/cua-spaces-web/src/lib/keyvault.ts+++ b/apps/cua-spaces-web/src/lib/keyvault.ts@@ -2,6 +2,7 @@// Copyright (c) 2026 Cua AI, Inc.import type { VaultApp, VaultFiles, VaultRow, VaultSite, VaultView } from "@/bridge/contracts/keyvault";+import type { HostSettings, SettingsRow } from "@/bridge";/** One line of the flattened vault list: an app, a site, the files of an app* or an item (the SwiftUI list's `VaultLine`). The core decides what is open. */@@ -29,3 +30,13 @@ export function vaultLines(view: VaultView): VaultLine[] {}return out;}++/**+ * The Settings, Keyvault rows the host told the page about: the core lays+ * out the site icons switch from a default, so it shows only where the host+ * reports the setting (the SwiftUI app and Electron do).+ */+export function keyvaultRows(rows: SettingsRow[], hostSettings: HostSettings | undefined): SettingsRow[] {+ const icons = hostSettings?.keyvaultSiteIcons != null;+ return rows.filter((r) => icons || !r.id.startsWith("keyvault-site-icons"));+}diff --git a/apps/cua-spaces-web/src/lib/spaces.test.ts b/apps/cua-spaces-web/src/lib/spaces.test.tsindex f0798f3c0c..9e1c988e77 100644--- a/apps/cua-spaces-web/src/lib/spaces.test.ts+++ b/apps/cua-spaces-web/src/lib/spaces.test.ts@@ -4,7 +4,7 @@import { describe, expect, it } from "vitest";import type { Machine, Space } from "@/bridge";-import { busyMacosSpaces, canDelete, canPower, createError, isMachineDesktop, machineName, macosLimitText, osLabel, powerPending, realSpaces, spacePlace, spaceState, visibleSpaces } from "./spaces";+import { busyMacosSpaces, canDelete, canPower, createError, powerButton, isMachineDesktop, machineName, macosLimitText, osLabel, powerPending, realSpaces, spacePlace, spaceState, visibleSpaces } from "./spaces";const space = (id: string, status: Space["status"], lastUsedAt: number, extra: Partial<Space> = {}): Space => ({id,@@ -140,3 +140,24 @@ describe("an unknown OS", () => {expect(spacePlace(space("a", "running", 1, { os: "macos", osPrettyName: "macOS Tahoe 26.0" }), "Studio")).toBe("macOS Tahoe 26.0 on Studio");});});++describe("powerButton", () => {+ const noCore = { tryCall: () => undefined };+ const on = space("p", "running", 1, { power: { control: "suspend", off: false } });++ it("follows the core when it answers", () => {+ const core = { tryCall: <T,>() => ({ symbol: "power", help: "Suspend", turnOn: false, enabled: true, busy: false }) as T };+ expect(powerButton(core, on)).toEqual({ help: "Suspend", turnOn: false, busy: false });+ expect(powerButton({ tryCall: <T,>() => null as T }, on)).toBeNull();+ });++ it("without the core, has the core's rule and words", () => {+ expect(powerButton(noCore, on)).toEqual({ help: "Suspend", turnOn: false, busy: false });+ expect(powerButton(noCore, { ...on, power: { control: "stop", off: true } })).toEqual({ help: "Turn on", turnOn: true, busy: false });+ expect(powerButton(noCore, { ...on, power: { control: "stop", off: false, turningOn: false } })).toEqual({ help: "Turning off…", turnOn: false, busy: true });+ expect(powerButton(noCore, space("c", "running", 1))).toBeNull();+ expect(powerButton(noCore, { ...on, status: "deleting" })).toBeNull();+ expect(powerButton(noCore, { ...on, id: "this-mac" })).toBeNull();+ expect(powerButton(noCore, { ...on, progress: { phase: "pulling", permille: 100, label: "Downloading" } })).toBeNull();+ });+});diff --git a/apps/cua-spaces-web/src/lib/spaces.ts b/apps/cua-spaces-web/src/lib/spaces.tsindex 812b24180d..ef9bf55142 100644--- a/apps/cua-spaces-web/src/lib/spaces.ts+++ b/apps/cua-spaces-web/src/lib/spaces.ts@@ -129,6 +129,39 @@ export function powerLabel(core: { tryCall<T>(op: string, args?: Record<string,return on ? (suspends ? "Resume" : "Turn on") : suspends ? "Suspend" : "Turn off";}+/** The core's power words (`sidebar::power_verb`): the press, then while it runs. */+const POWER_WORDS = {+ suspend: { on: ["Resume", "Resuming…"], off: ["Suspend", "Suspending…"] },+ stop: { on: ["Turn on", "Turning on…"], off: ["Turn off", "Turning off…"] },+} as const;++/** A Space row's power button (the app core's `sidebar::PowerButton`). */+export interface PowerButton {+ /** "Turn off", "Resume", or "Suspending…" while it runs. */+ help: string;+ /** A press turns it on (else off). */+ turnOn: boolean;+ /** An action runs: a spinner instead, and no press. */+ busy: boolean;+}++/**+ * The power button a Space's row shows (the core's `sidebar.powerButton`,+ * as the SwiftUI sidebar asks it): none for this machine, a Space being+ * created or deleted, or one whose provider cannot turn it off. Without the+ * core, the same rule and words.+ */+export function powerButton(core: { tryCall<T>(op: string, args?: Record<string, unknown>): T | undefined }, space: Space): PowerButton | null {+ const fromCore = core.tryCall<PowerButton | null>("sidebar.powerButton", { space });+ if (fromCore !== undefined) return fromCore ? { help: fromCore.help, turnOn: fromCore.turnOn, busy: fromCore.busy } : null;+ const power = space.power;+ if (!power || space.id === "this-mac" || space.progress || space.status === "deleting") return null;+ const busy = power.turningOn !== undefined && power.turningOn !== null;+ const turnOn = busy ? Boolean(power.turningOn) : power.off;+ const [idle, running] = POWER_WORDS[power.control === "suspend" ? "suspend" : "stop"][turnOn ? "on" : "off"];+ return { help: busy ? running : idle, turnOn, busy };+}+/** A power action is running now: "Starting…" or "Stopping…". */export function powerPending(space: Pick<Space, "power">): string | null {const on = space.power?.turningOn;diff --git a/apps/cua-spaces-web/src/routes/__root.tsx b/apps/cua-spaces-web/src/routes/__root.tsxindex e16dc88119..272ad87dee 100644--- a/apps/cua-spaces-web/src/routes/__root.tsx+++ b/apps/cua-spaces-web/src/routes/__root.tsx@@ -9,6 +9,7 @@ import { useBridge, useSavedOnboarding, useSession, useStartup } from "@/bridge"import { ChecklistTracker } from "@/components/getting-started";import { NewSpace } from "@/components/new-space";import { CommandPalette } from "@/components/shell/command-palette";+import { DevicesBanner } from "@/components/shell/devices-banner";import { Sidebar } from "@/components/shell/sidebar";import { RelayAllowanceNotice } from "@/components/shell/relay-allowance-notice";import { SpacesNotice } from "@/components/shell/spaces-notice";@@ -64,6 +65,7 @@ function RootLayout() {{sidebarOpen ? <Sidebar /> : null}<div className="flex min-w-0 flex-1 flex-col bg-background"><TopBar />+ <DevicesBanner /><SpacesNotice /><RelayAllowanceNotice /><main className="min-h-0 flex-1">diff --git a/apps/cua-spaces-web/src/routes/settings/index.tsx b/apps/cua-spaces-web/src/routes/settings/index.tsxindex c86049cf96..bdef71e12d 100644--- a/apps/cua-spaces-web/src/routes/settings/index.tsx+++ b/apps/cua-spaces-web/src/routes/settings/index.tsx@@ -30,6 +30,7 @@ import { Switch } from "@/components/ui/switch";import { lazy, Suspense } from "react";import { toastError } from "@/components/ui/toast";import { showsMacShellSettings, thisComputerLabel } from "@/lib/host-labels";+import { keyvaultRows } from "@/lib/keyvault";import { DEFAULT_KEYBINDINGS, type KeybindingCommand } from "@/lib/keybindings";import { useTheme, type ThemePreference } from "@/lib/theme";@@ -66,9 +67,6 @@ function SettingsPage() {return settings?.page ? <CoreGeneralPage page={settings.page} /> : <FallbackSettingsPage />;}-/** The rows the Keyvault section shows here (the rest needs the broker's state). */-const KEYVAULT_ROWS = new Set(["keyvault-auto-wipe", "keyvault-auto-wipe-note"]);-function CoreGeneralPage({ page }: { page: CorePage }) {const { data: settings, updateSetting, chooseSetting } = useSettings();const { signIn, signOut, cancelSignIn, openExternal } = useSession();@@ -82,11 +80,11 @@ function CoreGeneralPage({ page }: { page: CorePage }) {const privacy = section("privacy");const keyvault = section("keyvault");const agents = section("agents");- const autoWipe = keyvault && { ...keyvault, rows: keyvault.rows.filter((r) => KEYVAULT_ROWS.has(r.id)) };+ const keyvaultShown = keyvault && { ...keyvault, rows: keyvaultRows(keyvault.rows, settings?.hostSettings) };const mac = showsMacShellSettings();// What a row's choice changes: the settings every host has by key, the- // host's own (runtimes, auto-connect, auto-wipe) by row.+ // host's own (runtimes, auto-connect, the Keyvault's switches) by row.const choose = (row: CoreRow, option: string) => {const done = fail(`Couldn't change ${row.label}`);switch (row.id) {@@ -144,7 +142,7 @@ function CoreGeneralPage({ page }: { page: CorePage }) {{runtimes?.rows.length ? <CoreSettingsSection section={runtimes} foldNotes onChoose={choose} /> : null}{privacy ? <CoreSettingsSection section={privacy} onChoose={choose} onPress={press} /> : null}- {autoWipe?.rows.length ? <CoreSettingsSection section={autoWipe} foldNotes onChoose={choose} /> : null}+ {keyvaultShown?.rows.length ? <CoreSettingsSection section={keyvaultShown} foldNotes onChoose={choose} /> : null}{agents ? <AgentsSettingsSection section={agents} /> : null}diff --git a/apps/cua-spaces-web/src/routes/spaces/index.tsx b/apps/cua-spaces-web/src/routes/spaces/index.tsxindex 8152d66b5e..367c6b5cae 100644--- a/apps/cua-spaces-web/src/routes/spaces/index.tsx+++ b/apps/cua-spaces-web/src/routes/spaces/index.tsx@@ -2,7 +2,7 @@// Copyright (c) 2026 Cua AI, Inc.import { createFileRoute, Link } from "@tanstack/react-router";-import { KeyRoundIcon, MonitorIcon, PlusIcon } from "lucide-react";+import { KeyRoundIcon, LoaderCircleIcon, MonitorIcon, PlusIcon, PowerIcon } from "lucide-react";import { useRef, useState } from "react";import { emptyHome, useBridge, useFirstSpaceOffers, useMachines, useNewSpaceWizard, useSpaceAccess, useSpaces, useSpaceThumbnail, type Space } from "@/bridge";@@ -16,9 +16,11 @@ import { useTileVideo } from "@/components/video/tile-video";import { useNewSpace } from "@/hooks/use-new-space";import { Button } from "@/components/ui/button";import { Segmented } from "@/components/ui/segmented";+import { toastError } from "@/components/ui/toast";import { creatingLine, thisComputerText } from "@/lib/host-labels";import { plural } from "@/lib/plural";-import { createError, createProgress, machineName, realSpaces, spacePlace, spaceState, visibleSpaces, type SpaceFilter } from "@/lib/spaces";+import { cn } from "@/lib/utils";+import { createError, createProgress, machineName, powerButton, realSpaces, spacePlace, spaceState, visibleSpaces, type SpaceFilter } from "@/lib/spaces";export const Route = createFileRoute("/spaces/")({ component: SpacesPage });@@ -100,24 +102,61 @@ function SpacesPage() {function SpaceTile({ space, machine, accessKey }: { space: Space; machine: string; accessKey?: string | null }) {return (- <div className="relative">+ <div className="group/tile relative"><SpaceLink space={space} machine={machine} />- {/* A live Keyvault sign-in is in this Space: the badge opens Access with its row brought forward. */}- {accessKey !== undefined ? (- <Link- to="/keyvault"- search={{ view: "access", focus: accessKey ?? undefined }}- data-signed-in={space.id}- title="A Keyvault sign-in is live in this Space. Open Access."- className="absolute top-3 right-3 inline-flex items-center gap-1 rounded-full border bg-card/90 px-2 py-0.5 text-2xs font-medium text-muted-foreground shadow-xs outline-none backdrop-blur-sm hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60"- >- <KeyRoundIcon className="size-3" /> Signed in- </Link>- ) : null}+ {/* Over the thumbnail, as the SwiftUI sidebar row ends: "Signed in", then power. */}+ <div className="absolute top-3 right-3 flex items-center gap-1.5">+ {/* A live Keyvault sign-in is in this Space: the badge opens Access with its row brought forward. */}+ {accessKey !== undefined ? (+ <Link+ to="/keyvault"+ search={{ view: "access", focus: accessKey ?? undefined }}+ data-signed-in={space.id}+ title="A Keyvault sign-in is live in this Space. Open Access."+ className="inline-flex items-center gap-1 rounded-full border bg-card/90 px-2 py-0.5 text-2xs font-medium text-muted-foreground shadow-xs outline-none backdrop-blur-sm hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60"+ >+ <KeyRoundIcon className="size-3" /> Signed in+ </Link>+ ) : null}+ <TilePower space={space} />+ </div></div>);}+/**+ * The core's power button, while the pointer is on the tile or focus is in+ * it, and always while it runs (the SwiftUI sidebar row's, which shows on+ * hover, on the selected row and while busy).+ */+function TilePower({ space }: { space: Space }) {+ const { core } = useBridge();+ const { startSpace, stopSpace } = useSpaces();+ const button = powerButton(core, space);+ if (!button) return null;+ const press = () => {+ const [act, word] = button.turnOn ? [startSpace, "start"] : [stopSpace, "stop"];+ void act(space.id).catch(toastError(`Couldn't ${word} ${space.name}`));+ };+ return (+ <button+ type="button"+ data-tile-power={button.turnOn ? "on" : "off"}+ data-busy={button.busy || undefined}+ disabled={button.busy}+ title={button.help}+ aria-label={`${button.help} ${space.name}`}+ onClick={press}+ className={cn(+ "inline-flex size-6 items-center justify-center rounded-full border bg-card/90 text-muted-foreground shadow-xs outline-none backdrop-blur-sm hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-default",+ !button.busy && "opacity-0 group-focus-within/tile:opacity-100 group-hover/tile:opacity-100",+ )}+ >+ {button.busy ? <LoaderCircleIcon className="size-3 animate-spin" aria-hidden /> : <PowerIcon className="size-3" aria-hidden />}+ </button>+ );+}+function SpaceLink({ space, machine }: { space: Space; machine: string }) {return (<Link