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): this Mac's own desktop says why instead of loading forever (CUA-2072) (#5735)

dduponteac64d72828a
diff --git a/.github/scripts/spaces_build_manifest.py b/.github/scripts/spaces_build_manifest.py
index 42d14c5f08..c1dde1c435 100755
--- a/.github/scripts/spaces_build_manifest.py
+++ b/.github/scripts/spaces_build_manifest.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
-# SPDX-License-Identifier: FSL-1.1-MIT
-# Copyright (c) 2026 Cua AI, Inc.
"""Write build-manifest.json for a Cua Spaces shadow build (CUA-2066).
Lists every file in DIR (except the manifest itself) with its sha256, size,
diff --git a/.github/scripts/spaces_build_summary.py b/.github/scripts/spaces_build_summary.py
index ec413d1d53..3da25a72a9 100755
--- a/.github/scripts/spaces_build_summary.py
+++ b/.github/scripts/spaces_build_summary.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
-# SPDX-License-Identifier: FSL-1.1-MIT
-# Copyright (c) 2026 Cua AI, Inc.
"""Cost summary of a workflow run (CUA-2066, phase 1 of CUA-1991).
Reads the run's jobs and artifacts through `gh api` and prints Markdown: wall
diff --git a/apps/cua-spaces-web/src/__tests__/space-detail-device.test.tsx b/apps/cua-spaces-web/src/__tests__/space-detail-device.test.tsx
index 251fd1f7e9..4951189920 100644
--- a/apps/cua-spaces-web/src/__tests__/space-detail-device.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/space-detail-device.test.tsx
@@ -41,6 +41,43 @@ function host(rows: unknown[], over: { access?: boolean; sharing?: boolean } = {
};
}
+describe.skipIf(!wasmBuilt)("this machine's own desktop opened as a Space page (real routes, wasm core)", () => {
+ // Regression: the Computers page's "This computer · Desktop" row opened a
+ // Space page that said "Loading the desktop…" forever, "No windows: the
+ // Space's window host is not up" and "Could not read this Space's agents":
+ // nothing streams this machine's own screen here, and it is not a Space to
+ // ask for windows or agents. Its page now says why, with one action.
+ it("says why instead of loading forever, asks it for no windows or agents, and links to Computers", async () => {
+ // As the SwiftUI app sends This Mac while it shares its desktop (`spaceToRow`).
+ const thisMac = { id: "this-mac", name: "This computer", provider: "local", os: "macos", spacesdVersion: "", features: [], reachable: true, powerState: "running" };
+ const asked: string[] = [];
+ const { router } = await mountApp("/spaces", {
+ ...host([thisMac]),
+ intercept: (op, args) => {
+ const id = (args as { spaceId?: string } | undefined)?.spaceId;
+ if (id === "this-mac") asked.push(op);
+ return undefined;
+ },
+ });
+ await act(() => router.navigate({ to: "/spaces/$spaceId", params: { spaceId: "this-mac" } }));
+ const note = await waitFor(() => {
+ const n = document.querySelector("[data-machine-desktop-note]");
+ expect(n).not.toBeNull();
+ return n!;
+ });
+ expect(note.textContent).toContain("This is this Mac’s own screen");
+ expect(screen.queryByText("Loading the desktop…")).toBeNull();
+ expect(document.querySelector("[data-stream-surface]")).toBeNull();
+ expect(document.querySelector('[data-section="agents"]')).toBeNull();
+ expect(screen.queryByText(/window host is not up/)).toBeNull();
+ // Give the page's polls a chance to run: none asks This Mac.
+ await new Promise((r) => setTimeout(r, 50));
+ expect(asked.filter((op) => op === "spaces.windows" || op === "agents.runs")).toEqual([]);
+ fireEvent.click(screen.getByRole("link", { name: "Open Computers" }));
+ await waitFor(() => expect(router.state.location.pathname).toBe("/machines"));
+ });
+});
+
describe.skipIf(!wasmBuilt)("a Space's detail as this device sees it (real routes, wasm core)", () => {
it("greys out a machine's Connect, Teleport and Share while this device is not enrolled, and its action opens the enroll sheet", async () => {
const { router, hooks } = await mountApp("/spaces", host([machine(["desktop_stream", "window_stream", "host_spaces", "relay_attach"])], { access: true, sharing: true }));
diff --git a/apps/cua-spaces-web/src/bridge/space-detail.ts b/apps/cua-spaces-web/src/bridge/space-detail.ts
index bc05d00014..1195a679e1 100644
--- a/apps/cua-spaces-web/src/bridge/space-detail.ts
+++ b/apps/cua-spaces-web/src/bridge/space-detail.ts
@@ -36,6 +36,9 @@ import type {
export type * from "./ops/space-detail";
+/** This machine's own roster entry (the core's `host::THIS_MACHINE_ID`). */
+export const THIS_MACHINE_ID = "this-mac";
+
export const USAGE_REFRESH_MS = 10_000;
export const WINDOWS_REFRESH_MS = 5_000;
/** How often a shown Space's agent runs are read (`AgentRunsModel.poll`). */
@@ -377,7 +380,11 @@ export function useSpaceDetail(space: Space | undefined, hostArch: string | null
// windows: it is not asked (the core's detail says why in its note).
// Nor is a machine on the relay while this device is not enrolled (the
// relay refuses it; the detail says why).
- const noDesktop = space ? sharesDesktop(ctx.core, space) === false || Boolean(seen.access && space.id.startsWith("relay:")) : false;
+ // Nor is this machine's own screen: it is not a Space, and nothing here
+ // streams it (the core's detail says so in its note).
+ const noDesktop = space
+ ? space.id === THIS_MACHINE_ID || sharesDesktop(ctx.core, space) === false || Boolean(seen.access && space.id.startsWith("relay:"))
+ : false;
useEffect(() => {
if (!details || !id || id.startsWith("pending:") || noDesktop) return;
return details.watch(id);
diff --git a/apps/cua-spaces-web/src/bridge/store.ts b/apps/cua-spaces-web/src/bridge/store.ts
index 745852c04d..07be27b06e 100644
--- a/apps/cua-spaces-web/src/bridge/store.ts
+++ b/apps/cua-spaces-web/src/bridge/store.ts
@@ -49,7 +49,7 @@ import {
import type { HostEvent, HostSignIn, HostSignInFailure, SessionSnapshot, SettingKey, SettingsSnapshot, SettingsValues } from "./protocol";
import { signInFailedFromError, signInFailedPhase, type FailedPhase } from "./sign-in";
import { createSettingsFeature, type SettingsFeature } from "./settings-feature";
-import { SpaceDetailStore } from "./space-detail";
+import { SpaceDetailStore, THIS_MACHINE_ID } from "./space-detail";
import {
HOST_RECORDS_LAUNCH,
TelemetryForwarder,
@@ -1094,9 +1094,11 @@ export class BridgeStore {
const spaces = (this.resources.spaces.data as Space[] | undefined) ?? [];
// A machine that does not share its desktop (a spare Mac that only
// provides Spaces) refuses the processes a run list starts: not asked.
+ // Nor is this machine's own entry: it is not a Space with runs.
const live = spaces.filter(
(s) =>
!s.id.startsWith("pending:") &&
+ s.id !== THIS_MACHINE_ID &&
(s.status === "running" || s.status === "approval" || s.status === "local") &&
!s.power?.off &&
sharesDesktop(this.core, s) !== false,
diff --git a/apps/cua-spaces-web/src/components/space-detail/agents-section.tsx b/apps/cua-spaces-web/src/components/space-detail/agents-section.tsx
index ea128a2e65..851929f440 100644
--- a/apps/cua-spaces-web/src/components/space-detail/agents-section.tsx
+++ b/apps/cua-spaces-web/src/components/space-detail/agents-section.tsx
@@ -20,9 +20,15 @@ export function AgentsSection({
failed: string | null;
copy: { loading: string; empty: string; failed: string };
}) {
- const note = (text: string, hint?: string) => (
- <li data-agents-status="" title={hint} className="px-4 py-2.5 text-[13px] text-muted-foreground">
+ // "Could not read" says why on the line itself, not only in a tooltip.
+ const note = (text: string, why?: string) => (
+ <li data-agents-status="" title={why} className="px-4 py-2.5 text-[13px] text-muted-foreground">
{text}
+ {why ? (
+ <span data-agents-reason="" className="mt-0.5 block truncate text-xs">
+ {why}
+ </span>
+ ) : null}
</li>
);
return (
diff --git a/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx b/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx
index eeea93499a..8757ed4fae 100644
--- a/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx
+++ b/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx
@@ -59,6 +59,25 @@ export interface StreamSurfaceProps {
className?: string;
}
+/** How long the desktop may take to send its first picture. After that the
+ * cover says it didn't, why, and offers Try again: the viewer never waits
+ * silently. */
+export const CONNECT_TIMEOUT_MS = 20_000;
+/** Why, when it timed out. */
+export const CONNECT_TIMEOUT_REASON = "No picture arrived from the desktop within 20 seconds.";
+
+/** True once `waiting` has held for `ms` without a break; a new `key` (another
+ * Space, or Try again) starts the wait over. */
+function useTimedOut(waiting: boolean, ms: number, key: string): boolean {
+ const [over, setOver] = useState<string | null>(null);
+ useEffect(() => {
+ if (!waiting) return;
+ const t = setTimeout(() => setOver(key), ms);
+ return () => clearTimeout(t);
+ }, [waiting, ms, key]);
+ return waiting && over === key;
+}
+
/** The root's radius (`rounded-xl`) and border, for the native layer's clip. */
const SURFACE_RADIUS = 12;
const SURFACE_BORDER = 1;
@@ -89,7 +108,10 @@ export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, p
inset: SURFACE_BORDER,
os,
});
- const phase: StreamPhase = !slot ? "nosession" : slot.phase === "live" ? "streaming" : slot.phase === "failed" ? "failed" : "connecting";
+ // Still no picture after CONNECT_TIMEOUT_MS: failed, with the reason and
+ // Try again (a picture that arrives later still shows).
+ const timedOut = useTimedOut(slot?.phase === "connecting", CONNECT_TIMEOUT_MS, `${spaceId}:${attempt}`);
+ const phase: StreamPhase = !slot ? "nosession" : slot.phase === "live" ? "streaming" : slot.phase === "failed" || timedOut ? "failed" : "connecting";
const cover = useDesktopCover({ canStream, previewText, autoConnect, connectRequested: requested, stream: phase, access });
const thumbnail = useSpaceThumbnail(spaceId, videoHere && canStream && !replaced && !access);
const press = () => setPressed({ spaceId, attempt: attempt + (cover.kind === "status" ? 1 : 0) });
@@ -116,7 +138,9 @@ export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, p
// cua, sample data), so the placeholder after all.
const noVideoHere = wanted && slot === null;
const covered = !replaced && (Boolean(access) || (videoHere && !noVideoHere));
- const state = slot ? slot.phase : covered && cover.kind === "connecting" ? "connecting" : "placeholder";
+ const state = slot ? (timedOut ? "failed" : slot.phase) : covered && cover.kind === "connecting" ? "connecting" : "placeholder";
+ // Why the cover says it could not connect, on the cover itself.
+ const reason = timedOut ? CONNECT_TIMEOUT_REASON : slot?.phase === "failed" ? (slot.reason ?? null) : null;
const dark = covered && (Boolean(thumbnail) || cover.kind !== "status");
return (
<>
@@ -133,6 +157,7 @@ export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, p
os={os}
cover={cover}
thumbnail={access ? null : thumbnail}
+ reason={cover.kind === "status" ? reason : null}
onButton={press}
onAction={onAccessAction}
onOpen={slot?.phase === "failed" ? () => void open() : undefined}
@@ -210,6 +235,7 @@ function DesktopCoverView({
os,
cover,
thumbnail,
+ reason,
onButton,
onAction,
onOpen,
@@ -217,6 +243,8 @@ function DesktopCoverView({
os: SpaceOs;
cover: DesktopCover;
thumbnail: string | null;
+ /** Why it could not connect, under the line. */
+ reason?: string | null;
onButton: () => void;
onAction?: () => void;
/** The stream failed here: its own window instead. */
@@ -242,6 +270,11 @@ function DesktopCoverView({
{cover.text}
</p>
) : null}
+ {reason ? (
+ <p data-cover-reason="" className={cn("mt-1 max-w-md text-xs", dark ? "text-white/60" : "text-muted-foreground")}>
+ {reason}
+ </p>
+ ) : null}
{cover.action ? (
<button
type="button"
diff --git a/apps/cua-spaces-web/src/components/video/webcodecs-slots.test.tsx b/apps/cua-spaces-web/src/components/video/webcodecs-slots.test.tsx
index 902c32e944..8b08f3f9dd 100644
--- a/apps/cua-spaces-web/src/components/video/webcodecs-slots.test.tsx
+++ b/apps/cua-spaces-web/src/components/video/webcodecs-slots.test.tsx
@@ -384,7 +384,8 @@ describe("<StreamSurface> in the Electron shell", () => {
await waitFor(() => expect(view.container.querySelector('[data-stream-state="failed"]')).toBeTruthy());
expect(calls).toHaveLength(1);
await waitFor(() => expect(toasts()).toBe(1));
- expect(view.getByText("scripted provider failure")).toBeTruthy();
+ // In the toast, and on the cover under "Could not connect".
+ expect(view.getAllByText("scripted provider failure")).toHaveLength(2);
// A poll (the page drawn again) does not try again.
view.rerender(ui());
await new Promise((r) => setTimeout(r, 20));
diff --git a/apps/cua-spaces-web/src/lib/stream-surface.test.tsx b/apps/cua-spaces-web/src/lib/stream-surface.test.tsx
index 4aad437fd6..9d2daadfb7 100644
--- a/apps/cua-spaces-web/src/lib/stream-surface.test.tsx
+++ b/apps/cua-spaces-web/src/lib/stream-surface.test.tsx
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createDemoAdapter } from "@/bridge/adapters/demo";
import { noCore } from "@/bridge/__tests__/testCore";
import { BridgeProvider, type Space } from "@/bridge";
-import { StreamSurface } from "@/components/space-detail/stream-surface";
+import { CONNECT_TIMEOUT_MS, CONNECT_TIMEOUT_REASON, StreamSurface } from "@/components/space-detail/stream-surface";
import { ToastProvider } from "@/components/ui/toast";
import { canStreamTile } from "@/components/video/tile-video";
import { resetVideoSlotLoader } from "@/components/video/use-video-slot";
@@ -51,6 +51,7 @@ beforeEach(() => {
});
afterEach(() => {
+ vi.useRealTimers();
cleanup();
delete (window as Win).webkit;
vi.unstubAllGlobals();
@@ -277,9 +278,53 @@ describe("<StreamSurface> native video", () => {
expect(container.querySelector('[data-stream-state="connecting"]')).toBeTruthy();
});
+ // Regression: the viewer waited on "Loading the desktop…" / "Connecting…"
+ // forever. With no picture after CONNECT_TIMEOUT_MS it says it could not
+ // connect, why, and offers one action (Try again); a late picture still shows.
+ it("never waits silently: no picture within the timeout says why, with Try again", async () => {
+ expect(CONNECT_TIMEOUT_MS).toBeGreaterThanOrEqual(15_000);
+ expect(CONNECT_TIMEOUT_MS).toBeLessThanOrEqual(30_000);
+ vi.useFakeTimers({ shouldAdvanceTime: true });
+ hostDrawsVideo();
+ const { container, getByText, queryByText } = mount();
+ await waitFor(() => expect(updates()).not.toHaveLength(0));
+ const first = updates()[0]!;
+ act(() => void vi.advanceTimersByTime(CONNECT_TIMEOUT_MS - 1_000));
+ expect(container.querySelector('[data-stream-state="connecting"]')).toBeTruthy();
+ expect(queryByText("Could not connect to the desktop")).toBeNull();
+ act(() => void vi.advanceTimersByTime(1_000));
+ expect(container.querySelector('[data-stream-state="failed"]')).toBeTruthy();
+ expect(getByText("Could not connect to the desktop")).toBeTruthy();
+ expect(container.querySelector("[data-cover-reason]")?.textContent).toBe(CONNECT_TIMEOUT_REASON);
+ // One action: Try again (no second button for a stall).
+ expect(container.querySelectorAll("[data-desktop-cover] button")).toHaveLength(1);
+ expect(getByText("Try again")).toBeTruthy();
+ // A picture that arrives late still shows.
+ act(() => hostEvent("video.surface", { surfaceId: first.surfaceId, state: "live" }));
+ expect(container.querySelector('[data-stream-state="live"]')).toBeTruthy();
+ expect(container.querySelector("[data-desktop-cover]")).toBeNull();
+ });
+
+ it("starts the wait over on Try again after a timeout", async () => {
+ vi.useFakeTimers({ shouldAdvanceTime: true });
+ hostDrawsVideo();
+ const { container, getByText } = mount();
+ await waitFor(() => expect(updates()).not.toHaveLength(0));
+ const first = updates()[0]!;
+ act(() => void vi.advanceTimersByTime(CONNECT_TIMEOUT_MS));
+ expect(container.querySelector('[data-stream-state="failed"]')).toBeTruthy();
+ act(() => getByText("Try again").click());
+ await waitFor(() => expect(updates().some((u) => u.surfaceId !== first.surfaceId)).toBe(true));
+ expect(container.querySelector('[data-stream-state="connecting"]')).toBeTruthy();
+ act(() => void vi.advanceTimersByTime(CONNECT_TIMEOUT_MS - 1_000));
+ expect(container.querySelector('[data-stream-state="connecting"]')).toBeTruthy();
+ act(() => void vi.advanceTimersByTime(1_000));
+ expect(container.querySelector('[data-stream-state="failed"]')).toBeTruthy();
+ });
+
it("says why once when the host could not open a stream, and not for one that failed once open", async () => {
hostDrawsVideo();
- const { getByText, queryByText } = render(
+ const { getByText, getAllByText, queryByText } = render(
<BridgeProvider adapter={createDemoAdapter({ latencyMs: 1 })} core={noCore}>
<ToastProvider>
<StreamSurface spaceId="sp-1" os="macos" canStream previewText="Not reachable" />
@@ -295,7 +340,9 @@ describe("<StreamSurface> native video", () => {
const second = updates().find((u) => u.surfaceId !== first.surfaceId)!;
act(() => hostEvent("video.surface", { surfaceId: second.surfaceId, state: "failed", reason: "scripted provider failure", opening: true }));
await waitFor(() => expect(getByText("Could not open sp-1")).toBeTruthy());
- expect(getByText("scripted provider failure")).toBeTruthy();
+ // In the toast, and on the cover under "Could not connect".
+ expect(getAllByText("scripted provider failure")).toHaveLength(2);
+ expect(document.querySelector("[data-cover-reason]")?.textContent).toBe("scripted provider failure");
});
/** The demo host, answering `settings.get` with auto-connect off and
diff --git a/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx b/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
index e09a8ea908..b30ac82471 100644
--- a/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
+++ b/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
@@ -270,7 +270,19 @@ function SpaceDetailPage() {
// One of your machines that keeps its desktop private: why, in place
// of the desktop, then the Spaces it provides (no New Space button
// beside the note).
- <MachineSpaces note={detail.desktopNote} listSpaces={Boolean(detail.newSpace)} spaces={hostedSpaces(spaces ?? [], space.id)} />
+ <MachineSpaces
+ note={detail.desktopNote}
+ listSpaces={Boolean(detail.newSpace)}
+ spaces={hostedSpaces(spaces ?? [], space.id)}
+ // This machine's own screen: its switches live on its Computers page.
+ action={
+ detail.isHost ? (
+ <Button variant="outline" size="sm" data-host-desktop-action="" render={<Link to="/machines" />}>
+ Open Computers
+ </Button>
+ ) : null
+ }
+ />
) : (
<StreamSurface
spaceId={space.id}
@@ -376,12 +388,16 @@ function hostedSpaces(spaces: readonly Space[], machineSpaceId: string): Space[]
return spaces.filter((s) => s.host === machine);
}
-/** A machine that does not share its desktop: the core's line, then the
- * Spaces it provides when it provides any. */
-function MachineSpaces({ note, listSpaces, spaces }: { note: string; listSpaces: boolean; spaces: Space[] }) {
+/** A machine that does not share its desktop, or this machine's own
+ * screen (never streamed here): the core's line and its one action, then
+ * the Spaces it provides when it provides any. */
+function MachineSpaces({ note, listSpaces, spaces, action }: { note: string; listSpaces: boolean; spaces: Space[]; action?: ReactNode }) {
return (
<section data-machine-desktop-note="">
- <p className="rounded-xl border px-4 py-3 text-[13px] text-muted-foreground">{note}</p>
+ <div className="flex items-center justify-between gap-4 rounded-xl border px-4 py-3">
+ <p className="text-[13px] text-muted-foreground">{note}</p>
+ {action}
+ </div>
{listSpaces ? (
<div data-machine-spaces="" className="mt-6">
<h2 className="mb-2 px-1 text-[13px] font-semibold">Spaces</h2>
diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json
index fe99fdbf4a..9625f4d70f 100644
--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json
+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/main-window.json
@@ -187,7 +187,7 @@
"System: macOS"
],
"isHost": true,
- "previewText": "Not reachable",
+ "previewText": "This is this Mac’s own screen, so it isn’t shown here. Your other devices see and control it while Share this desktop is on.",
"sections": [],
"title": "This computer"
}
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 416f7c263c..aa4e9c6fab 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
@@ -574,6 +574,17 @@ pub fn desktop_note(space: &Space) -> Option<String> {
})
}
+/// The line in place of this machine's own desktop on its page: it is
+/// the screen in front of you, so it is never streamed here, and it is
+/// seen from your other devices.
+pub fn host_desktop_note(os: crate::model::SpaceOs) -> String {
+ format!(
+ "This is {}\u{2019}s own screen, so it isn\u{2019}t shown here. \
+ Your other devices see and control it while Share this desktop is on.",
+ os.this_machine_lower()
+ )
+}
+
/// The roster without this machine's own relay entry
/// (`relay:<this_machine_id>`, listed once it shares its desktop or
/// provides Spaces): this machine has its own place ("This machine"), not
@@ -997,6 +1008,10 @@ pub fn detail_live(
_ => status_text(space),
};
let preview_text = match (creating, &failed) {
+ // This machine's own screen is never streamed here: a stream of
+ // the screen you are looking at only mirrors itself. Its page says
+ // so instead of waiting for a desktop that never comes.
+ _ if is_host => host_desktop_note(space.os),
_ if deleting => status_text(space),
(_, Some(e)) => e.clone(),
(Some(p), None) => p.label.clone(),
@@ -1106,7 +1121,8 @@ pub fn detail_live(
can_stream,
));
}
- let show_sections = space.sdk.is_some() && reachable && !deleting;
+ // This machine is not a Space: no windows or agents to ask it for.
+ let show_sections = !is_host && space.sdk.is_some() && reachable && !deleting;
SpaceDetail {
id: space.id.clone(),
title: space.name.clone(),
@@ -1132,7 +1148,7 @@ pub fn detail_live(
remove_only,
power_error: power_error(space),
access: None,
- desktop_note: None,
+ desktop_note: is_host.then(|| host_desktop_note(space.os)),
new_space: None,
actions,
confirm: delete_confirm(space, remove_only, delete_label),
@@ -1260,6 +1276,95 @@ mod tests {
);
}
+ /// This machine's own desktop, opened as a Space page (the Computers
+ /// page's "This computer · Desktop" row) while the host shares it: the
+ /// shell's roster marks it reachable, yet nothing ever streams it here.
+ /// Its page says why instead of "Loading the desktop…" forever, and
+ /// asks it for no windows or agents ("window host is not up", "Could
+ /// not read this Space's agents").
+ #[test]
+ fn this_machines_desktop_says_why_instead_of_loading_forever() {
+ use crate::experiments::Experiments;
+ use crate::host::{HostSummaryInput, this_machine_space};
+ use crate::model::{SpaceOs, SpaceSdkRef};
+ let sharing = HostSummaryInput {
+ configured: true,
+ service_running: true,
+ sharing: true,
+ online: Some(true),
+ mode: Some("relay".into()),
+ ..Default::default()
+ };
+ for os in [SpaceOs::Macos, SpaceOs::Windows, SpaceOs::Linux] {
+ let mut host = this_machine_space(Some(&sharing), 0, os);
+ host.sdk = Some(SpaceSdkRef {
+ features: vec![],
+ spacesd_version: String::new(),
+ reachable: true,
+ error: None,
+ });
+ for d in [
+ detail(&host),
+ detail_for(&host, None, None, &Experiments::default(), None),
+ ] {
+ assert!(d.is_host);
+ assert!(!d.can_stream);
+ assert!(!d.show_sections, "no Stream or Agents for {os:?}");
+ assert!(d.sections.is_empty());
+ assert_eq!(d.preview_text, host_desktop_note(os));
+ assert_eq!(d.desktop_note.as_deref(), Some(d.preview_text.as_str()));
+ assert!(d.preview_text.contains(os.this_machine_lower()));
+ }
+ }
+ }
+
+ /// Drift guard: "Loading the desktop…" is a wait for a stream, so it
+ /// only ever shows where a stream can open. A page that cannot stream
+ /// says why (or what it waits for) in its own words.
+ #[test]
+ fn loading_the_desktop_only_shows_where_a_stream_can_open() {
+ use crate::host::{HostSummaryInput, this_machine_space};
+ use crate::model::{SpaceOs, SpaceSdkRef, SpaceStatus};
+ let sdk = |reachable| SpaceSdkRef {
+ features: vec![],
+ spacesd_version: String::new(),
+ reachable,
+ error: None,
+ };
+ let mut spaces = vec![];
+ for status in [None, Some(HostSummaryInput::default())] {
+ let mut host = this_machine_space(status.as_ref(), 0, SpaceOs::Macos);
+ spaces.push(host.clone());
+ host.sdk = Some(sdk(true));
+ spaces.push(host);
+ }
+ let base = super::super::row_to_space(&local_row("local:a", None, None, None), 0);
+ for st in [
+ SpaceStatus::Running,
+ SpaceStatus::Local,
+ SpaceStatus::Suspended,
+ SpaceStatus::Provisioning,
+ SpaceStatus::Deleting,
+ ] {
+ for reachable in [true, false] {
+ let mut s = base.clone();
+ s.status = st;
+ s.sdk = Some(sdk(reachable));
+ spaces.push(s);
+ }
+ }
+ for s in &spaces {
+ let d = detail(s);
+ if !d.can_stream {
+ assert_ne!(
+ d.preview_text, "Loading the desktop\u{2026}",
+ "{} ({:?}) cannot stream but says it is loading",
+ s.id, s.status
+ );
+ }
+ }
+ }
+
/// Sharing on (the default): Share, between
/// Picture in picture and Delete as before; off: no Share button.
#[test]