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): right OS and name for this computer on Windows and Linux, dark first-run title bar, no ghost after Remove (CUA-3525) (#6552)

cua-agents[bot]287cdf9a5656
diff --git a/apps/cua-spaces-desktop/src/bridge/machines.ts b/apps/cua-spaces-desktop/src/bridge/machines.ts
index a76142064e..1208245fdb 100644
--- a/apps/cua-spaces-desktop/src/bridge/machines.ts
+++ b/apps/cua-spaces-desktop/src/bridge/machines.ts
@@ -26,6 +26,32 @@ export function hostStatus(model: AppModel): unknown {
return out;
}
+/** Whether `spaceId` is the removed machine's own row (`relay:<machine>`) or a Space on it (`relay:<machine>/<name>`). */
+export function isOnMachine(spaceId: string | null | undefined, machine: string): boolean {
+ return spaceId === `relay:${machine}` || (spaceId?.startsWith(`relay:${machine}/`) ?? false);
+}
+
+/**
+ * After a machine leaves the account: if the saved default Space (or a
+ * fallback) was on it, the setting stops pointing at it, so nothing names a
+ * removed computer (`cua spaces default` printed its raw id). Best-effort:
+ * the removal itself has already happened.
+ */
+async function forgetRemovedDefault(model: AppModel, machine: string): Promise<void> {
+ if (!model.servicesIn || !model.devices.signedIn) return;
+ try {
+ const d = model.devices.devices();
+ if (!d) return;
+ const settings = await d.spacesSettings();
+ const fallback = settings.fallback.filter((id) => !isOnMachine(id, machine));
+ const cleared = isOnMachine(settings.defaultSpace, machine);
+ if (!cleared && fallback.length === settings.fallback.length) return;
+ await d.setSpacesSettings({ ...settings, defaultSpace: cleared ? undefined : settings.defaultSpace, fallback });
+ } catch {
+ // The setting is read again on the next visit; a failed clear must not fail the removal.
+ }
+}
+
/** `relay:<machine>` rows' reported hostnames, by machine id. */
export function relayHostnames(model: AppModel): Record<string, string> {
return model.relayHostnames;
@@ -142,7 +168,10 @@ export function machinesMethods({ model }: BridgeContext): Handlers {
const device = optionalString(args, "device");
const deleteSpaces = args.deleteSpaces === true;
if (!machine && !device) throw Failure.badArgs("machine or device");
- if (machine) await relayCall(model, () => model.backend.relayUnregister(machine, deleteSpaces));
+ if (machine) {
+ await relayCall(model, () => model.backend.relayUnregister(machine, deleteSpaces));
+ await forgetRemovedDefault(model, machine);
+ }
if (device) await relayCall(model, () => model.devices.revoke(device));
else await model.devices.refresh();
await model.refresh();
diff --git a/apps/cua-spaces-desktop/src/main.ts b/apps/cua-spaces-desktop/src/main.ts
index 1758746679..ed77d654b8 100644
--- a/apps/cua-spaces-desktop/src/main.ts
+++ b/apps/cua-spaces-desktop/src/main.ts
@@ -36,7 +36,7 @@ import { closesToTray, installTray, isQuitting } from "./tray";
import { countsVideo, startVideoBench, videoBenchEnv } from "./video-bench";
import { createViewerWindows } from "./viewer";
import { LinuxRuntime, nodeLinuxSystem } from "./model/linux-runtime";
-import { applyThemeToWindow, createMainWindow, handleOverlayDim, handleViewerKeyboard, setWindowBackground } from "./window";
+import { applyThemeToWindow, createMainWindow, handleOverlayDim, handleOverlaySurface, handleViewerKeyboard, setWindowBackground } from "./window";
import { WindowDropTargets, windowNumberOf, type DropWindow } from "./window-drop";
// Must match `appId` (Windows; macOS has the Swift app's bundle id) and the
@@ -353,7 +353,10 @@ if (!app.requestSingleInstanceLock()) {
initTheme();
installMenu({ newSpace, settings: openSettings, gettingStarted });
handleViewerKeyboard();
- if (process.platform !== "darwin") handleOverlayDim();
+ if (process.platform !== "darwin") {
+ handleOverlayDim();
+ handleOverlaySurface();
+ }
const { webRoot } = handleAppProtocol();
if (process.env.CUA_SPACES_LOG_STARTUP) console.log(`[cua-spaces] serving ${webRoot}`);
diff --git a/apps/cua-spaces-desktop/src/overlay.ts b/apps/cua-spaces-desktop/src/overlay.ts
index ff0758ac60..10591a4ff5 100644
--- a/apps/cua-spaces-desktop/src/overlay.ts
+++ b/apps/cua-spaces-desktop/src/overlay.ts
@@ -13,6 +13,19 @@ export const DIM_ATTRIBUTE = "data-window-dim";
/** Preload -> main: `true` while any backdrop is on the page. */
export const DIM_CHANNEL = "cua-desktop:dim";
+/** The marker a full-page dark screen puts on its root, valued with its
+ * `#rrggbb` background (the dark first run). While it is on the page the
+ * overlay takes that colour with light symbols, whatever the app theme. */
+export const SURFACE_ATTRIBUTE = "data-window-surface";
+
+/** Preload -> main: the marked surface's `#rrggbb`, or `null` when none is on the page. */
+export const SURFACE_CHANNEL = "cua-desktop:surface";
+
+/** `value` when it is a `#rrggbb` colour, else null. */
+export function parseSurface(value: unknown): string | null {
+ return typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null;
+}
+
// The web UI's `--background` and `--foreground` (index.css), in sRGB.
export const BACKGROUND = { dark: "#16181c", light: "#f7f8fa" } as const;
export const SYMBOL = { dark: "#e9ebef", light: "#181b1f" } as const;
@@ -39,6 +52,19 @@ export function overlayColors(theme: Theme, dimmed: boolean): { color: string; s
return { color: darken(BACKGROUND[theme], a), symbolColor: darken(SYMBOL[theme], a) };
}
+/** The overlay over a dark `surface` (see {@link SURFACE_ATTRIBUTE}) or, with none, the theme's. */
+export function overlayColorsFor(
+ theme: Theme,
+ dimmed: boolean,
+ surface: string | null | undefined,
+): { color: string; symbolColor: string } {
+ if (!surface) return overlayColors(theme, dimmed);
+ const a = BACKDROP_ALPHA.dark;
+ return dimmed
+ ? { color: darken(surface, a), symbolColor: darken(SYMBOL.dark, a) }
+ : { color: surface, symbolColor: SYMBOL.dark };
+}
+
export interface OverlayStyle {
color?: string;
symbolColor?: string;
diff --git a/apps/cua-spaces-desktop/src/preload.ts b/apps/cua-spaces-desktop/src/preload.ts
index 227313cf01..a1de629e31 100644
--- a/apps/cua-spaces-desktop/src/preload.ts
+++ b/apps/cua-spaces-desktop/src/preload.ts
@@ -11,7 +11,7 @@ import { contextBridge, ipcRenderer, webUtils, type IpcRendererEvent } from "ele
import { ELECTRON_BRIDGE_CHANNEL, ELECTRON_EVENT_CHANNEL, PRELOAD_INIT_CHANNEL, type PreloadInit } from "./channels";
import { withDroppedPaths } from "./drop";
import { KEYBOARD_CHANNEL, viewerHasKeyboard } from "./keyboard";
-import { DIM_ATTRIBUTE, DIM_CHANNEL } from "./overlay";
+import { DIM_ATTRIBUTE, DIM_CHANNEL, SURFACE_ATTRIBUTE, SURFACE_CHANNEL } from "./overlay";
const init = ipcRenderer.sendSync(PRELOAD_INIT_CHANNEL) as PreloadInit;
@@ -66,14 +66,23 @@ contextBridge.exposeInMainWorld("cuaDesktop", init.videoStats ? { invoke, on, pl
// dims the overlay to match.
if (init.platform !== "darwin") {
let dimmed = false;
+ // A full-page dark screen (the first run) marks itself with its colour:
+ // the overlay takes it too, instead of staying the app theme's.
+ let surface: string | null = null;
const sync = () => {
const now = document.querySelector(`[${DIM_ATTRIBUTE}]`) !== null;
- if (now === dimmed) return;
- dimmed = now;
- ipcRenderer.send(DIM_CHANNEL, now);
+ if (now !== dimmed) {
+ dimmed = now;
+ ipcRenderer.send(DIM_CHANNEL, now);
+ }
+ const color = document.querySelector(`[${SURFACE_ATTRIBUTE}]`)?.getAttribute(SURFACE_ATTRIBUTE) ?? null;
+ if (color !== surface) {
+ surface = color;
+ ipcRenderer.send(SURFACE_CHANNEL, color);
+ }
};
const watch = () => {
- new MutationObserver(sync).observe(document.documentElement, { childList: true, subtree: true });
+ new MutationObserver(sync).observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: [SURFACE_ATTRIBUTE] });
sync();
};
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", watch, { once: true });
diff --git a/apps/cua-spaces-desktop/src/window.ts b/apps/cua-spaces-desktop/src/window.ts
index 9c35737e86..cf4e6ef1b5 100644
--- a/apps/cua-spaces-desktop/src/window.ts
+++ b/apps/cua-spaces-desktop/src/window.ts
@@ -9,7 +9,7 @@ import { opensOutside } from "./external-url";
import { windowIconPath } from "./icon";
import { APP_ORIGIN } from "./protocol";
import { readSettings, writeSettings, type WindowBounds } from "./settings";
-import { DIM_CHANNEL, overlayColors, overlaySteps } from "./overlay";
+import { DIM_CHANNEL, SURFACE_CHANNEL, overlayColors, overlayColorsFor, overlaySteps, parseSurface } from "./overlay";
import { KEYBOARD_CHANNEL, applyKeyboard } from "./keyboard";
import { BACKGROUND, resolvedTheme } from "./theme";
import { showWhenReady } from "./show-when-ready";
@@ -98,13 +98,16 @@ function syncTitlebarInset(win: BrowserWindow): void {
// Windows whose page shows a dialog backdrop (see overlay.ts).
const dimmed = new WeakSet<BrowserWindow>();
+// The dark surface a window's page marked (see SURFACE_ATTRIBUTE), if any.
+const surfaces = new WeakMap<BrowserWindow, string>();
+
// Each window's pending second overlay step (overlaySteps); a newer style replaces it.
const overlayNext = new WeakMap<BrowserWindow, NodeJS.Timeout>();
/** The title bar overlay (Windows, Linux) in `theme`, dimmed while the page shows a backdrop. */
function applyOverlay(win: BrowserWindow, theme: "dark" | "light"): void {
if (process.platform === "darwin") return;
- const { now, next } = overlaySteps(process.platform, overlayColors(theme, dimmed.has(win)), TITLEBAR_HEIGHT);
+ const { now, next } = overlaySteps(process.platform, overlayColorsFor(theme, dimmed.has(win), surfaces.get(win)), TITLEBAR_HEIGHT);
clearTimeout(overlayNext.get(win));
for (const style of now) win.setTitleBarOverlay(style);
if (next) {
@@ -151,6 +154,19 @@ export function handleOverlayDim(): void {
});
}
+// The preload reports a page's marked dark surface (the first run) and when
+// it goes; the overlay follows it, then the theme again.
+export function handleOverlaySurface(): void {
+ ipcMain.on(SURFACE_CHANNEL, (event, value: unknown) => {
+ const win = BrowserWindow.fromWebContents(event.sender);
+ if (!win || !event.senderFrame?.url.startsWith(`${APP_ORIGIN}/`)) return;
+ const surface = parseSurface(value);
+ if (surface) surfaces.set(win, surface);
+ else surfaces.delete(win);
+ applyThemeToWindow(win);
+ });
+}
+
// The preload reports when a Space's live desktop takes or gives back the
// keyboard; its window's menu shortcuts stand aside meanwhile (keyboard.ts).
export function handleViewerKeyboard(): void {
diff --git a/apps/cua-spaces-desktop/test/machines-view.test.ts b/apps/cua-spaces-desktop/test/machines-view.test.ts
index fc9708dc5a..4a93cb0bf1 100644
--- a/apps/cua-spaces-desktop/test/machines-view.test.ts
+++ b/apps/cua-spaces-desktop/test/machines-view.test.ts
@@ -192,6 +192,16 @@ describe.skipIf(!built)("the Machines page on the app core", () => {
await expect(call("machines.remove", { machine: "m2" })).rejects.toMatchObject({ code: "unsupported" });
});
+ it("clears the saved default when the removed computer was it, and keeps one that was not", async () => {
+ await model.refresh();
+ await call("spaces.setSettings", { defaultSpace: "relay:m2", fallback: ["relay:m2/box", "relay:m3"], fallbackOn: true });
+ await call("machines.remove", { machine: "m2", device: "dev_old" });
+ await expect(call("spaces.settings")).resolves.toMatchObject({ defaultSpace: null, fallback: ["relay:m3"], fallbackOn: true });
+ await call("spaces.setSettings", { defaultSpace: "relay:m3", fallback: [], fallbackOn: true });
+ await call("machines.remove", { machine: "m2" });
+ await expect(call("spaces.settings")).resolves.toMatchObject({ defaultSpace: "relay:m3" });
+ });
+
it("removes a computer with the Spaces made on it when the page asks (CUA-3413)", async () => {
await model.refresh();
await expect(call("machines.remove", { machine: "m2", deleteSpaces: true })).resolves.toBeNull();
diff --git a/apps/cua-spaces-desktop/test/overlay.test.ts b/apps/cua-spaces-desktop/test/overlay.test.ts
index f0f97990d4..3f6214f53a 100644
--- a/apps/cua-spaces-desktop/test/overlay.test.ts
+++ b/apps/cua-spaces-desktop/test/overlay.test.ts
@@ -4,7 +4,7 @@
import { readFileSync } from "node:fs";
import * as path from "node:path";
import { describe, expect, it } from "vitest";
-import { BACKGROUND, DIM_ATTRIBUTE, SYMBOL, darken, overlayColors, overlaySteps } from "../src/overlay";
+import { BACKGROUND, DIM_ATTRIBUTE, SURFACE_ATTRIBUTE, SYMBOL, darken, overlayColors, overlayColorsFor, overlaySteps, parseSurface } from "../src/overlay";
const web = path.join(__dirname, "../../cua-spaces-web/src");
@@ -38,4 +38,23 @@ describe("title bar overlay", () => {
expect(win.now).toEqual([{ ...dimmed, height: 39 }]);
expect(win.next).toEqual({ ...dimmed, height: 40 });
});
+
+ it("follows a dark surface the page marks (the first run), whatever the theme, and the theme again after", () => {
+ expect(overlayColorsFor("light", false, "#050607")).toEqual({ color: "#050607", symbolColor: SYMBOL.dark });
+ expect(overlayColorsFor("light", true, "#050607")).toEqual({ color: darken("#050607", 0.4), symbolColor: darken(SYMBOL.dark, 0.4) });
+ expect(overlayColorsFor("light", false, null)).toEqual(overlayColors("light", false));
+ expect(overlayColorsFor("dark", true, undefined)).toEqual(overlayColors("dark", true));
+ });
+
+ it("accepts only a #rrggbb surface", () => {
+ expect(parseSurface("#050607")).toBe("#050607");
+ expect(parseSurface("#ABCDEF")).toBe("#abcdef");
+ for (const bad of [null, undefined, 5, "red", "#fff", "url(x)", "#05060"]) expect(parseSurface(bad)).toBeNull();
+ });
+
+ it("is marked by the web UI's first run with its own background", () => {
+ const src = readFileSync(path.join(web, "components/first-run-new/first-run-new.tsx"), "utf8");
+ expect(src).toContain(`${SURFACE_ATTRIBUTE}="#050607"`);
+ expect(src).toContain("bg-[#050607]");
+ });
});
diff --git a/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx b/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx
index 56b0aecd7a..a8026123ed 100644
--- a/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx
+++ b/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx
@@ -17,6 +17,7 @@ import { AgentPicker, type AccountActions } from "./agent-picker";
import { RepoChip } from "./repo-chip";
import { TreeWherePicker, whereNode, type TreeWhere } from "./tree-where";
import { TreeIcon } from "@/components/spaces/tree-parts";
+import { thisComputerLabel, thisComputerText } from "@/lib/host-labels";
export type { TaskWhere } from "@/lib/ask-first";
@@ -28,8 +29,8 @@ const OS_WORD: Record<SpaceOs, string> = { linux: "Linux", macos: "Mac", windows
export function whereSpaceLabel(where: TaskWhere): { title: string; detail: string | null } {
if (where.kind === "agent") return { title: where.fresh ? "Agent decides, new Home" : "Agent decides", detail: null };
if (where.kind === "machine") return { title: where.machine.name, detail: null };
- if (where.kind === "new") return { title: "New Space", detail: `${OS_WORD[where.os]} on ${where.on?.name ?? "This Mac"}` };
- return { title: where.kind === "this-mac" ? "This Mac" : where.space.name, detail: null };
+ if (where.kind === "new") return { title: "New Space", detail: `${OS_WORD[where.os]} on ${where.on?.name ?? thisComputerLabel()}` };
+ return { title: where.kind === "this-mac" ? thisComputerLabel() : where.space.name, detail: null };
}
export function AppMark({ agent, size = 32 }: { agent: string; size?: number }) {
@@ -41,7 +42,7 @@ export function AppMark({ agent, size = 32 }: { agent: string; size?: number })
}
/** The trade-off, under the list. */
-export const WHERE_FOOTER = "A new computer keeps yours untouched. This Mac works on your own files and apps.";
+export const whereFooter = (): string => `A new computer keeps yours untouched. ${thisComputerLabel()} works on your own files and apps.`;
/** With agent homes: what the footer adds (the agent can also be told in the text with @). */
export const WHERE_FOOTER_HOME = "You can also name a Space or computer in the text with @.";
@@ -317,7 +318,7 @@ export function WherePicker({
}) {
if (tree) return <TreeWherePicker tw={tree} where={where} onWhere={onWhere} kinds={kinds} trigger={trigger} open={open} onOpenChange={onOpenChange} />;
return (
- <Picker title="Where it runs" trigger={trigger} footer={agentHome ? `${WHERE_FOOTER} ${WHERE_FOOTER_HOME}` : WHERE_FOOTER} open={open} onOpenChange={onOpenChange}>
+ <Picker title="Where it runs" trigger={trigger} footer={agentHome ? `${whereFooter()} ${WHERE_FOOTER_HOME}` : whereFooter()} open={open} onOpenChange={onOpenChange}>
{agentHome ? (
<PickerRow
icon={
@@ -352,7 +353,7 @@ export function WherePicker({
<OsIcon os={k.os} className="size-4" />
</span>
}
- title={`A new ${OS_WORD[k.os]} computer on this Mac`}
+ title={`A new ${OS_WORD[k.os]} computer on ${thisComputerText()}`}
note={k.blocked ?? k.note}
selected={where?.kind === "new" && where.os === k.os}
onSelect={() => onWhere({ kind: "new", os: k.os })}
@@ -365,7 +366,7 @@ export function WherePicker({
<LaptopIcon className="size-4" />
</span>
}
- title="This Mac"
+ title={thisComputerLabel()}
note="Works on your own files and apps"
selected={where?.kind === "this-mac"}
onSelect={() => onWhere({ kind: "this-mac" })}
diff --git a/apps/cua-spaces-web/src/components/ask-first/imported-task.tsx b/apps/cua-spaces-web/src/components/ask-first/imported-task.tsx
index defd13995f..c22a16ea2a 100644
--- a/apps/cua-spaces-web/src/components/ask-first/imported-task.tsx
+++ b/apps/cua-spaces-web/src/components/ask-first/imported-task.tsx
@@ -17,6 +17,7 @@ import { cn } from "@/lib/utils";
import { agentName, AppMark } from "./ask-box";
import { agoLabel } from "./pick-up";
import { StartFailed } from "./task-view";
+import { thisComputerLabel, thisComputerText } from "@/lib/host-labels";
/** The earlier messages as the run's timeline rows, before the run's own. */
export function earlierItems(history: PastThread | null): TranscriptItem[] {
@@ -114,7 +115,7 @@ export function ImportedTaskView({ task }: { task: AskTask & { imported: NonNull
</header>
<div className="flex min-h-0 flex-1 flex-col">
<p className="mx-auto w-full max-w-[720px] shrink-0 px-8 pt-6 text-[12px] font-medium text-muted-foreground" data-earlier-heading="">
- Earlier on this Mac
+ Earlier on {thisComputerText()}
{history?.earlierOmitted ? ` (${history.earlierOmitted} older messages aren't shown)` : ""}
</p>
{loading ? (
@@ -171,7 +172,7 @@ export function ImportedTaskView({ task }: { task: AskTask & { imported: NonNull
</div>
{waiting ? (
<p className="px-1 text-[12px] text-muted-foreground" data-imported-note="">
- Nothing runs until you send. {name} then carries on this chat on this Mac, in its own folder.
+ Nothing runs until you send. {name} then carries on this chat on {thisComputerText()}, in its own folder.
</p>
) : null}
</div>
@@ -196,7 +197,7 @@ export function ContinueOn() {
<MenuPrimitive.Trigger
render={
<button type="button" className="flex h-11 shrink-0 items-center gap-1.5 rounded-lg px-3 text-[13px] outline-none hover:bg-foreground/5 data-popup-open:bg-foreground/[0.07]" data-continue-on="">
- <span className="text-muted-foreground">Continue on:</span> This Mac <ChevronDownIcon className="size-3.5 text-muted-foreground" />
+ <span className="text-muted-foreground">Continue on:</span> {thisComputerLabel()} <ChevronDownIcon className="size-3.5 text-muted-foreground" />
</button>
}
/>
@@ -211,7 +212,7 @@ export function ContinueOn() {
<MenuPrimitive.Item className="flex min-h-12 cursor-default items-center gap-3 rounded-lg bg-foreground/[0.06] px-3 py-2 outline-none">
<LaptopIcon className="size-4" />
<div className="min-w-0 flex-1">
- <div className="text-[14px] font-medium">This Mac</div>
+ <div className="text-[14px] font-medium">{thisComputerLabel()}</div>
<div className="text-[12px] text-muted-foreground">Where this chat's session is</div>
</div>
<CheckIcon className="size-4" />
@@ -221,7 +222,7 @@ export function ContinueOn() {
<MonitorIcon className="size-4" />
<div className="min-w-0 flex-1">
<div className="truncate text-[14px] font-medium">{m.name}</div>
- <div className="text-[12px] text-muted-foreground">Not yet: the chat's session is on this Mac</div>
+ <div className="text-[12px] text-muted-foreground">Not yet: the chat's session is on {thisComputerText()}</div>
</div>
</MenuPrimitive.Item>
))}
diff --git a/apps/cua-spaces-web/src/components/ask-first/task-view.tsx b/apps/cua-spaces-web/src/components/ask-first/task-view.tsx
index 03b0d4e3cc..688b2deffd 100644
--- a/apps/cua-spaces-web/src/components/ask-first/task-view.tsx
+++ b/apps/cua-spaces-web/src/components/ask-first/task-view.tsx
@@ -25,6 +25,7 @@ import { useWherePick } from "./this-mac-confirm";
import { useStartTask } from "./use-start-task";
import { useWhereOptions } from "./where-options";
import { useTreeWhere } from "./tree-where";
+import { hostOs, thisComputerLabel, thisComputerText } from "@/lib/host-labels";
/** What the agent is told when the person hands the computer back. */
/** How long a sent reply may take to show in the run before the thread trusts the run's status again (ms). */
@@ -252,7 +253,7 @@ function CuaLine({ children }: { children: ReactNode }) {
function Starting({ pending, space, name, onHost }: { pending: Space | undefined; space: Space | undefined; name: string; onHost: boolean }) {
const making = pending?.progress;
const steps = onHost
- ? [{ text: `Opening ${name} on this Mac`, done: false, now: true }]
+ ? [{ text: `Opening ${name} on ${thisComputerText()}`, done: false, now: true }]
: [
{ text: "Making the computer", done: Boolean(space), now: !space },
{ text: `Opening ${name} inside it`, done: false, now: Boolean(space) },
@@ -262,7 +263,7 @@ function Starting({ pending, space, name, onHost }: { pending: Space | undefined
<div className="flex items-center gap-3">
<CuaKey size={28} />
<div className="flex-1">
- <div className="text-[15px] font-semibold">{onHost ? "Starting on this Mac" : "Getting a fresh computer ready"}</div>
+ <div className="text-[15px] font-semibold">{onHost ? `Starting on ${thisComputerText()}` : "Getting a fresh computer ready"}</div>
<div className="text-[13px] text-muted-foreground">
{onHost
? "It works with your own files and apps."
@@ -480,7 +481,7 @@ function Screen({
? "Thrown away"
: task.onHost
? state === "working" || state === "stuck"
- ? "Working on this Mac"
+ ? `Working on ${thisComputerText()}`
: TASK_STATE_TEXT[state]
: "Not ready yet"
: state === "needs-you"
@@ -542,7 +543,7 @@ function Screen({
function ComputerCard({ task, space }: { task: AskTask; space: Space | undefined }) {
const os = task.os === "macos" ? "Mac" : task.os === "windows" ? "Windows" : "Linux";
const line = task.onHost
- ? "Your own Mac, with your files and apps"
+ ? `Your own ${{ macos: "Mac", windows: "PC", linux: "computer" }[hostOs()]}, with your files and apps`
: !space
? task.ending === "thrown"
? "Thrown away"
@@ -557,7 +558,7 @@ function ComputerCard({ task, space }: { task: AskTask; space: Space | undefined
<div className="flex min-h-12 items-center gap-3 px-4 py-2">
<OsIcon os={task.os} className="size-4 text-muted-foreground" />
<div className="min-w-0 flex-1">
- <div className="font-medium">{task.onHost ? "This Mac" : space ? space.name : `${os} computer for this task`}</div>
+ <div className="font-medium">{task.onHost ? thisComputerLabel() : space ? space.name : `${os} computer for this task`}</div>
<div className="text-muted-foreground">{line}</div>
</div>
{space ? (
diff --git a/apps/cua-spaces-web/src/components/ask-first/this-mac-confirm.tsx b/apps/cua-spaces-web/src/components/ask-first/this-mac-confirm.tsx
index d64f7d42cf..12dbc5dfb5 100644
--- a/apps/cua-spaces-web/src/components/ask-first/this-mac-confirm.tsx
+++ b/apps/cua-spaces-web/src/components/ask-first/this-mac-confirm.tsx
@@ -5,6 +5,7 @@ import { useRef, useState, type ReactNode } from "react";
import { ConfirmDialog } from "@/components/ui/alert-dialog";
import { setThisMacConfirmed, thisMacConfirmed, thisMacConfirmText, type TaskWhere } from "@/lib/ask-first";
+import { thisComputerText } from "@/lib/host-labels";
/**
* Picking where a task runs. This Mac asks once per device ("Use this Mac"
@@ -38,7 +39,7 @@ export function useWherePick(agent: string): {
}}
title={text.title}
description={text.description}
- confirmLabel="Use this Mac"
+ confirmLabel={`Use ${thisComputerText()}`}
cancelLabel="Pick another"
onConfirm={() => {
const chosen = asking?.onChosen;
diff --git a/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx b/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx
index 7a8a867208..6f553d50e1 100644
--- a/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx
+++ b/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx
@@ -211,7 +211,7 @@ export function WhereScreen({
<Line>{view.line}</Line>
<div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-computers="">
<Row
- icon={<Mark os="macos" />}
+ icon={<Mark os={hostOs()} />}
name={t.name}
sub={
<>
@@ -342,7 +342,7 @@ export function AgentScreen({ view, onPick, onContinue, onInstall, busy }: { vie
{view.agents.length ? (
<div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-agents="">
<div className={cn("flex items-center gap-2 px-3 pt-2 pb-2 text-[12.5px] font-semibold tracking-[0.02em]", GREY)}>
- <OsMark os="macos" className="h-3 w-auto" />
+ <OsMark os={hostOs()} className="h-3 w-auto" />
{view.label}
</div>
{view.agents.map((a) => (
@@ -872,7 +872,7 @@ export function NewFirstRun() {
}
return (
- <div className="dark relative flex h-full flex-col overflow-hidden bg-[#050607] text-white" data-new-first-run="" data-step={s.screen}>
+ <div className="dark relative flex h-full flex-col overflow-hidden bg-[#050607] text-white" data-window-surface="#050607" data-new-first-run="" data-step={s.screen}>
<FloatKeys copyRight={544} />
<header className="relative z-30 flex shrink-0 items-center justify-between pt-[calc(var(--titlebar-height,0px)+12px)] pr-16 pb-2 pl-16">
<span className="flex items-center gap-1.5">
diff --git a/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx b/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx
index 685fbf7c75..e3e13bb3aa 100644
--- a/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx
+++ b/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx
@@ -13,6 +13,7 @@ import { HostSetupForm } from "@/components/this-machine";
import { Button } from "@/components/ui/button";
import { toastError } from "@/components/ui/toast";
import { setThisMacConfirmed, useThisMacConfirmed } from "@/lib/ask-first";
+import { thisComputerText } from "@/lib/host-labels";
/** The host form's profile for your own connection server or Direct (`host::SELF_HOSTED_PROFILE`). */
const SELF_HOSTED = "self-hosted";
@@ -52,8 +53,8 @@ export function AdvancedTab() {
{autoConnect ? <CoreSettingsRow row={{ ...autoConnect, label: "Open a Space’s screen right away" }} onChoose={choose} /> : null}
{overflow ? (
<CoreSettingsRow
- row={{ ...overflow, label: "Use my own cloud when this Mac is busy" }}
- description="New Spaces go to your linked cloud when this Mac is full."
+ row={{ ...overflow, label: `Use my own cloud when ${thisComputerText()} is busy` }}
+ description={`New Spaces go to your linked cloud when ${thisComputerText()} is full.`}
onChoose={choose}
/>
) : null}
@@ -141,7 +142,7 @@ function Sharing() {
/** Whether a task asks before it works on this Mac itself (the answer to "Work on this Mac?" is kept per device). */
function thisMacAskRow(asks: boolean): CoreRow {
- return { ...flagRow("spaces_ask_first_home", "", asks), id: "ask-first:this-mac", label: "Ask before a task uses this Mac", options: [
+ return { ...flagRow("spaces_ask_first_home", "", asks), id: "ask-first:this-mac", label: `Ask before a task uses ${thisComputerText()}`, options: [
{ id: "on", label: "On", active: asks },
{ id: "off", label: "Off", active: !asks },
] };
@@ -191,7 +192,7 @@ function Labs() {
{askFirst ? (
<CoreSettingsRow
row={thisMacAskRow(!thisMacOk)}
- description="Before a task works directly on this Mac, with your files and apps. Turn it on to be asked again."
+ description={`Before a task works directly on ${thisComputerText()}, with your files and apps. Turn it on to be asked again.`}
onChoose={(_, option) => setThisMacConfirmed(option === "off")}
/>
) : null}
diff --git a/apps/cua-spaces-web/src/components/settings/default-space-group.tsx b/apps/cua-spaces-web/src/components/settings/default-space-group.tsx
index 646ba23cc7..9997061fe8 100644
--- a/apps/cua-spaces-web/src/components/settings/default-space-group.tsx
+++ b/apps/cua-spaces-web/src/components/settings/default-space-group.tsx
@@ -14,6 +14,7 @@ import { Switch } from "@/components/ui/switch";
import { toastError } from "@/components/ui/toast";
import { findNode, treeRows, type SpacesTree, type TreeNode } from "@/lib/spaces-tree";
import { cn } from "@/lib/utils";
+import { thisComputerLabel } from "@/lib/host-labels";
/**
* The order to try when the default is offline: the saved one (computers
@@ -84,7 +85,7 @@ export function DefaultSpaceGroup() {
/>
<SettingsRow
label="If it's offline"
- description="Use your next online computer, then This Mac."
+ description={`Use your next online computer, then ${thisComputerLabel()}.`}
control={<Switch aria-label="If it's offline, use your next online computer" checked={fallbackOn} onCheckedChange={(v) => save({ fallbackOn: v })} />}
/>
{fallbackOn && (order.length > 0 || here) ? (
@@ -122,7 +123,7 @@ export function DefaultSpaceGroup() {
{here ? (
<li className="flex h-8 items-center gap-2 px-2.5 text-[13px] text-muted-foreground" data-order-item="here">
<TreeIcon node={here} />
- <span className="truncate">This Mac</span>
+ <span className="truncate">{thisComputerLabel()}</span>
<span className="ml-auto">Last resort</span>
</li>
) : null}
diff --git a/apps/cua-spaces-web/src/components/spaces/spaces-tree-page.tsx b/apps/cua-spaces-web/src/components/spaces/spaces-tree-page.tsx
index dc6ff4b6a7..b29ef6a00b 100644
--- a/apps/cua-spaces-web/src/components/spaces/spaces-tree-page.tsx
+++ b/apps/cua-spaces-web/src/components/spaces/spaces-tree-page.tsx
@@ -5,7 +5,7 @@ import { Link, useNavigate } from "@tanstack/react-router";
import { ChevronRightIcon, HardDriveIcon, MoreHorizontalIcon, PlusIcon } from "lucide-react";
import { useEffect, useRef, useState } from "react";
-import { useMachines, useSpaces } from "@/bridge";
+import { useMachines, useSpaces, useSpacesDefault } from "@/bridge";
import { AddComputerSheet } from "@/components/add-computer-sheet";
import { Page, PageHeader } from "@/components/page";
import { Button } from "@/components/ui/button";
@@ -23,6 +23,7 @@ import { cn } from "@/lib/utils";
import { PeopleFaces, TreeDot, TreeIcon, toggleCollapsed, useCollapsed } from "./tree-parts";
import { useRunningBySpace, useSpacesTreeData } from "./use-spaces-tree";
+import { thisComputerLabel, thisComputerText } from "@/lib/host-labels";
// Name gets the most room; Status shares what is left, so neither is cut to a few letters in a narrow window.
/** How long a click on a name waits for a second one (a double-click renames) before it opens the row. */
@@ -106,10 +107,10 @@ export function SpacesTreePage() {
<Page>
<div className="mx-auto max-w-xl pt-24" data-tree-empty="">
<h1 className="font-heading text-[32px] font-semibold tracking-tight">No Spaces yet</h1>
- <p className="mt-3 text-[15px] text-muted-foreground">A Space is a computer your agents can work on. Add this Mac, or another computer you own, and agents run there while you keep working.</p>
+ <p className="mt-3 text-[15px] text-muted-foreground">A Space is a computer your agents can work on. Add {thisComputerText()}, or another computer you own, and agents run there while you keep working.</p>
<div className="mt-6 flex flex-wrap gap-2">
<Button size="lg" render={<Link to="/machines" />} data-tree-add-this-mac="">
- Add this Mac
+ Add {thisComputerText()}
</Button>
<Button size="lg" variant="outline" onClick={() => setAdding(true)}>
Add another computer
@@ -118,7 +119,7 @@ export function SpacesTreePage() {
<p className="mt-5 text-[13px] text-muted-foreground">
Or{" "}
<button type="button" className="underline underline-offset-2 hover:text-foreground" onClick={newSpace} data-tree-new-local="">
- make a new Linux or Mac computer on this Mac
+ make a new Linux or Mac computer on {thisComputerText()}
</button>
.
</p>
@@ -292,7 +293,7 @@ export function SpacesTreePage() {
<HardDriveIcon className="size-6 shrink-0 text-muted-foreground" strokeWidth={1.5} />
<div className="min-w-0 flex-1">
<div className="text-[15px] font-medium">Add a computer you're not using</div>
- <div className="text-[13px] text-muted-foreground">A Mac mini or PC you own. Agents work there and This Mac stays yours.</div>
+ <div className="text-[13px] text-muted-foreground">A Mac mini or PC you own. Agents work there and {thisComputerLabel()} stays yours.</div>
</div>
<Button variant="outline" onClick={() => setAdding(true)}>
Add a computer
@@ -328,6 +329,7 @@ export function SpacesTreePage() {
*/
export function RemoveComputerDialog({ node, onClose }: { node: TreeNode; onClose: () => void }) {
const machines = useMachines();
+ const defaults = useSpacesDefault();
const [alsoDelete, setAlsoDelete] = useState(false);
const [busy, setBusy] = useState(false);
const text = removeText(node, alsoDelete);
@@ -336,6 +338,8 @@ export function RemoveComputerDialog({ node, onClose }: { node: TreeNode; onClos
setBusy(true);
try {
await machines.remove(r?.machine ?? node.machine!.id, r?.device ?? null, alsoDelete);
+ // The default setting may have named it (the host clears it): read it again, so the tree has no ghost of it.
+ await defaults.refresh().catch(() => {});
toast(`Removed ${node.name}`, { type: "success" });
onClose();
} catch (e) {
diff --git a/apps/cua-spaces-web/src/lib/ask-first.ts b/apps/cua-spaces-web/src/lib/ask-first.ts
index 5426c3cb9e..cde84f3aca 100644
--- a/apps/cua-spaces-web/src/lib/ask-first.ts
+++ b/apps/cua-spaces-web/src/lib/ask-first.ts
@@ -19,6 +19,7 @@ import type { DataAdapter } from "@/bridge/adapter";
import { threadOpAvailable } from "@/bridge/ops/thread";
import { isMachineDesktop, orderSpaces, spaceState } from "./spaces";
+import { thisComputerLabel, thisComputerText } from "./host-labels";
export type TaskEnding = "kept" | "thrown";
@@ -362,8 +363,8 @@ export function useThisMacConfirmed(): boolean {
/** What the person is told, once, before a task works on this Mac itself. */
export function thisMacConfirmText(agent: string): { title: string; description: string } {
return {
- title: "Work on this Mac?",
- description: `${agent} will work directly on this Mac, with your files and apps. It can't be undone by throwing the computer away. ${agent} doesn't ask before each step here, the same as on a new computer.`,
+ title: `Work on ${thisComputerText()}?`,
+ description: `${agent} will work directly on ${thisComputerText()}, with your files and apps. It can't be undone by throwing the computer away. ${agent} doesn't ask before each step here, the same as on a new computer.`,
};
}
@@ -388,16 +389,16 @@ export function startErrorView(raw: string, agent: string): StartErrorView {
const e = raw.toLowerCase();
if (e.includes("isn't shared"))
return {
- title: "This Mac isn't set up for tasks yet",
- body: "Turn on sharing for this Mac on the Machines page, then try again. Or pick another machine.",
+ title: `${thisComputerLabel()} isn't set up for tasks yet`,
+ body: `Turn on sharing for ${thisComputerText()} on the Machines page, then try again. Or pick another machine.`,
action: "set-up-host",
retry: true,
};
// A task from before this Mac was turned into its own Space id: trying again now works.
if (e.includes(`"${THIS_MAC_ID}"`))
- return { title: "Couldn't start on this Mac", body: "Try again to start it on this Mac, or pick another machine.", action: "retry", retry: true };
+ return { title: `Couldn't start on ${thisComputerText()}`, body: `Try again to start it on ${thisComputerText()}, or pick another machine.`, action: "retry", retry: true };
if (/cloud has ended/.test(e))
- return { title: "That computer is no longer available", body: "Cua Cloud has ended. Pick a computer on this Mac instead.", action: "change-computer", retry: false };
+ return { title: "That computer is no longer available", body: `Cua Cloud has ended. Pick a computer on ${thisComputerText()} instead.`, action: "change-computer", retry: false };
if (/more than one|ambiguous/.test(e))
return { title: "More than one computer has that name", body: "Pick the one you mean.", action: "change-computer", retry: false };
if (/not found|no such|unknown space|add_space/.test(e))
@@ -407,7 +408,7 @@ export function startErrorView(raw: string, agent: string): StartErrorView {
if (/not running|space_off|stopped|suspended|offline|unreachable|timed out|timeout|connection|refused/.test(e))
return { title: "Couldn't reach that computer", body: "Check it's on, then try again. Or pick another one.", action: "retry", retry: true };
if (/disk|space left|no room|memory|quota|limit/.test(e))
- return { title: "This Mac doesn't have room for a new computer", body: "Free some disk space or turn off a computer you're not using, then try again.", action: "retry", retry: true };
+ return { title: `${thisComputerLabel()} doesn't have room for a new computer`, body: "Free some disk space or turn off a computer you're not using, then try again.", action: "retry", retry: true };
return { title: `${agent} couldn't start`, body: "Something went wrong. Try again, or pick another machine.", action: "retry", retry: true };
}
diff --git a/apps/cua-spaces-web/src/lib/default-where.ts b/apps/cua-spaces-web/src/lib/default-where.ts
index 816f1bad90..31c27d0708 100644
--- a/apps/cua-spaces-web/src/lib/default-where.ts
+++ b/apps/cua-spaces-web/src/lib/default-where.ts
@@ -16,6 +16,7 @@ import { resolveDefaultSpace, type DefaultSpace, type DefaultSpaceStep, type Spa
import type { NewKind, TaskWhere } from "./ask-first";
import { defaultCandidates, findNode, type SpacesTree, type TreeNode } from "./spaces-tree";
+import { thisComputerLabel } from "./host-labels";
/** How a computer in "Where a task goes" stands: it runs the task, it could, it's online but has no desktop to run in, or it's offline. */
export type WhereStepState = "used" | "ready" | "no-desktop" | "offline";
@@ -72,9 +73,9 @@ const PROBLEM: Record<DefaultProblem, string> = { offline: "is offline", "no-des
/** The line under Home's box, built from its parts so a name or a phrase is never said twice. */
export function fallbackSentence({ defaultName, problem, usedName, othersOnline }: FallbackParts): string {
const why = `${defaultName}, your default, ${PROBLEM[problem]}`;
- if (usedName) return `${why}. This runs on ${usedName}, the next computer that can take it. If none can, it runs on This Mac.`;
+ if (usedName) return `${why}. This runs on ${usedName}, the next computer that can take it. If none can, it runs on ${thisComputerLabel()}.`;
const others = othersOnline ? "no other computer can take it now" : "no other computer is online";
- return `${why}, and ${others}. This runs on This Mac.`;
+ return `${why}, and ${others}. This runs on ${thisComputerLabel()}.`;
}
const stepNote = (role: string, state: WhereStepState): string => {
@@ -123,7 +124,7 @@ export function treeDefault(tree: SpacesTree, settings: SpacesSettings | null, r
const steps: WhereStep[] = order.map(({ o, n }, i) => {
const used = o.role === "here" ? usedHere : i === usedAt && !usedHere;
const state: WhereStepState = used ? "used" : states[i]!;
- const name = o.role === "here" ? "This Mac" : (n?.name ?? o.name);
+ const name = o.role === "here" ? thisComputerLabel() : (n?.name ?? o.name);
return { name, note: stepNote(o.role, state), online: state !== "offline", used, state, node: n };
});
const line = fallbackSentence({
diff --git a/apps/cua-spaces-web/src/lib/spaces-tree.test.ts b/apps/cua-spaces-web/src/lib/spaces-tree.test.ts
index 260f03e143..7a3e59a09d 100644
--- a/apps/cua-spaces-web/src/lib/spaces-tree.test.ts
+++ b/apps/cua-spaces-web/src/lib/spaces-tree.test.ts
@@ -320,3 +320,25 @@ describe("currentTreeWhere", () => {
expect(findNode(t, "relay:mac-here")?.name).toBe("This Mac");
});
});
+
+describe("a removed computer", () => {
+ const ghost = space({ id: "relay:a77e7c1777f98e7", name: "a77e7c1777f98e7", status: "running" });
+ const ghostChild = space({ id: "relay:a77e7c1777f98e7/box", name: "Build box", host: "a77e7c1777f98e7" });
+
+ it("leaves no computer named by its raw id, nor its Spaces, when its machine is gone", () => {
+ const t = tree({ spaces: [...SPACES, ghost, ghostChild] });
+ expect(t.roots.map((r) => r.name)).toEqual(["This Mac", "Studio Mac mini", "Dillon's PC"]);
+ expect([t.computers, t.spaces]).toEqual([3, 4]);
+ });
+
+ it("is not the default even when the setting still names it", () => {
+ const t = tree({ spaces: [...SPACES, ghost, ghostChild], defaultSpace: ghost.id });
+ expect(t.defaultKey).not.toBe(ghost.id);
+ expect(t.roots.some((r) => r.isDefault && r.key === ghost.id)).toBe(false);
+ });
+
+ it("does not hide a teammate's Space whose own name is shown", () => {
+ const t = tree({ spaces: [...SPACES, space({ id: "relay:space-sam-qa", name: "Sam's QA" })] });
+ expect(t.roots.map((r) => r.name)).toContain("Sam's QA");
+ });
+});
diff --git a/apps/cua-spaces-web/src/lib/spaces-tree.ts b/apps/cua-spaces-web/src/lib/spaces-tree.ts
index d288d6bf67..7821cb8c10 100644
--- a/apps/cua-spaces-web/src/lib/spaces-tree.ts
+++ b/apps/cua-spaces-web/src/lib/spaces-tree.ts
@@ -17,6 +17,7 @@ import { machineOs, reachable } from "@/lib/machines";
import { plural } from "@/lib/plural";
import { isMachineDesktop, spaceState, type SpaceState } from "@/lib/spaces";
import { relativeTime } from "@/lib/utils";
+import { thisComputerLabel } from "./host-labels";
/** How a row reads in the Status column (and its dot). */
export type TreeTone = "online" | "offline" | "stopped" | "waits" | "busy";
@@ -89,6 +90,22 @@ export function computerSpaceId(m: Pick<Machine, "id" | "current" | "relayId" |
return m.connection === "direct" ? null : `relay:${m.id}`;
}
+/**
+ * A computer row left in the Spaces list after its machine went (Remove from
+ * account, or a machine the relay forgot): `relay:<machine>` named by its raw
+ * id, with no machine in the list. It is not a computer to show, and nothing
+ * under it is either.
+ */
+function ghostMachineIds(spaces: readonly Space[], machines: readonly Machine[]): Set<string> {
+ const known = new Set(machines.flatMap((m) => [m.id, ...(m.relayId ? [m.relayId] : [])]));
+ const ghosts = new Set<string>();
+ for (const s of spaces) {
+ const m = /^relay:([^/]+)$/.exec(s.id);
+ if (m && !known.has(m[1]!) && (s.name === s.id || s.name === m[1])) ghosts.add(m[1]!);
+ }
+ return ghosts;
+}
+
/** A Space id the relay knows (`relay:<machine>` or `relay:<machine>/<name>`): one that can be the default. */
const relayId = (id: string): string | null => (id.startsWith("relay:") ? id : null);
@@ -122,7 +139,9 @@ const isComputer = (m: Machine) => !m.device;
* read "Paused".
*/
export function buildSpacesTree({ spaces, machines, defaultSpace, running = new Map(), me = null, now = Date.now(), relayOnline }: TreeInput): SpacesTree {
- const listed = spaces.filter((s) => !isMachineDesktop(s));
+ const ghosts = ghostMachineIds(spaces, machines);
+ const onGhost = (s: Space) => [...ghosts].some((g) => s.id === `relay:${g}` || s.id.startsWith(`relay:${g}/`) || s.host === g);
+ const listed = spaces.filter((s) => !isMachineDesktop(s) && !onGhost(s));
const placed = new Set<string>();
const here = machines.find((m) => m.current && isComputer(m)) ?? null;
const others = machines.filter((m) => !m.current && isComputer(m));
@@ -188,7 +207,7 @@ export function buildSpacesTree({ spaces, machines, defaultSpace, running = new
const node: TreeNode = {
key,
kind: "computer",
- name: m.current ? "This Mac" : m.name,
+ name: m.current ? thisComputerLabel() : m.name,
os: machineOs(m),
settingsId: id,
space: own,
diff --git a/apps/cua-spaces-web/src/lib/this-computer-words.test.ts b/apps/cua-spaces-web/src/lib/this-computer-words.test.ts
new file mode 100644
index 0000000000..df9dfc1665
--- /dev/null
+++ b/apps/cua-spaces-web/src/lib/this-computer-words.test.ts
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+// The new Home and the Spaces tree name the computer they run on after its
+// system: "This Mac", "This PC" on Windows, "This machine" on Linux.
+
+import { afterEach, describe, expect, it } from "vitest";
+
+import { whereFooter } from "@/components/ask-first/ask-box";
+import type { Machine, Space } from "@/bridge";
+
+import { fallbackSentence } from "./default-where";
+import { startErrorView, thisMacConfirmText } from "./ask-first";
+import { buildSpacesTree } from "./spaces-tree";
+
+type Host = Window & { cuaDesktop?: { invoke: () => Promise<null>; platform: string } };
+const runOn = (platform: string) => {
+ (window as Host).cuaDesktop = { invoke: async () => null, platform };
+};
+afterEach(() => {
+ delete (window as Host).cuaDesktop;
+});
+
+const machine = (over: Partial<Machine>): Machine => ({ id: "m", name: "M", os: "macos", via: "relay", connection: "relay", online: true, current: false, spaceIds: [], limits: [], ...over });
+const here = machine({ id: "this-mac", name: "Ada's computer", current: true, via: "local", relayId: "here-1" });
+const spaces: Space[] = [{ id: "this-mac", name: "This Mac", os: "macos", status: "local", detail: "", lastUsedAt: 0, scene: "blank", provider: "local" } as Space];
+
+const WORDS = [
+ ["darwin", "This Mac", "this Mac"],
+ ["win32", "This PC", "this PC"],
+ ["linux", "This machine", "this machine"],
+] as const;
+
+describe.each(WORDS)("on %s", (platform, label, text) => {
+ it("names this computer in the tree", () => {
+ runOn(platform);
+ const t = buildSpacesTree({ spaces, machines: [here], defaultSpace: null });
+ expect(t.roots[0]!.name).toBe(label);
+ });
+
+ it("names it in the line under Home's box", () => {
+ runOn(platform);
+ expect(fallbackSentence({ defaultName: "Studio", problem: "offline", usedName: null, othersOnline: false })).toContain(`This runs on ${label}.`);
+ expect(fallbackSentence({ defaultName: "Studio", problem: "offline", usedName: "Dell", othersOnline: true })).toContain(`it runs on ${label}.`);
+ });
+
+ it("names it in the picker footer, the confirmation and the start errors", () => {
+ runOn(platform);
+ expect(whereFooter()).toContain(`${label} works on your own files and apps.`);
+ expect(thisMacConfirmText("Codex").title).toBe(`Work on ${text}?`);
+ expect(startErrorView("this-mac: this Mac isn't shared", "Codex").title).toBe(`${label} isn't set up for tasks yet`);
+ expect(startErrorView("disk full", "Codex").title).toBe(`${label} doesn't have room for a new computer`);
+ });
+});