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): say This PC (not This Mac) for the current computer on Windows (#6735)

ddupont35407b58467c
diff --git a/apps/cua-spaces-desktop/src/bridge/space-ready.ts b/apps/cua-spaces-desktop/src/bridge/space-ready.ts
index b6f77f0e6b..cc8b0b7bb8 100644
--- a/apps/cua-spaces-desktop/src/bridge/space-ready.ts
+++ b/apps/cua-spaces-desktop/src/bridge/space-ready.ts
@@ -5,6 +5,7 @@
// ("<Space> is ready", `spaces.create` with `notifyWhenReady`): the SwiftUI
// host's `SpaceReadyNote`. It carries the Cua key and a click opens the
// Space's page.
+import { thisComputer } from "../model/host-failure";
import type { SystemNote } from "./system";
/** The Cua key in the web build's directory (`public/cua-key-128.png`). */
@@ -12,9 +13,9 @@ export const SPACE_READY_ICON = "cua-key-128.png";
const OS_WORDS: Record<string, string> = { macos: "macOS ", linux: "Linux ", windows: "Windows " };
-/** What the notification says: no OS word for a Space whose OS is not known, "this Mac" only on a Mac. */
+/** What the notification says: no OS word for a Space whose OS is not known, "this Mac" on a Mac, "this PC" on Windows. */
export function spaceReadyNote(space: { id: string; name: string; os: string }, platform: NodeJS.Platform): SystemNote {
- const where = platform === "darwin" ? "this Mac" : "this machine";
+ const where = thisComputer(platform);
return {
id: `space-ready-${space.id}`,
title: `${space.name} is ready`,
diff --git a/apps/cua-spaces-desktop/test/space-ready.test.ts b/apps/cua-spaces-desktop/test/space-ready.test.ts
index c0b2ee9223..b69ee84d8e 100644
--- a/apps/cua-spaces-desktop/test/space-ready.test.ts
+++ b/apps/cua-spaces-desktop/test/space-ready.test.ts
@@ -24,10 +24,9 @@ describe("the Space ready note", () => {
expect(spaceReadyNote({ id: "a", name: "a", os: "unknown" }, "darwin").body).toBe("A fresh computer inside this Mac. Your agent can use it now.");
});
- it("says this machine where the app does not run on a Mac", () => {
- for (const platform of ["win32", "linux"] as const) {
- expect(spaceReadyNote({ id: "a", name: "a", os: "linux" }, platform).body).toBe("A fresh Linux computer inside this machine. Your agent can use it now.");
- }
+ it("says this PC on Windows and this machine on Linux", () => {
+ expect(spaceReadyNote({ id: "a", name: "a", os: "linux" }, "win32").body).toBe("A fresh Linux computer inside this PC. Your agent can use it now.");
+ expect(spaceReadyNote({ id: "a", name: "a", os: "linux" }, "linux").body).toBe("A fresh Linux computer inside this machine. Your agent can use it now.");
});
it("carries the Cua key from the web build", () => {
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/host-words.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/host-words.test.ts
new file mode 100644
index 0000000000..f6ff27bca8
--- /dev/null
+++ b/apps/cua-spaces-web/src/bridge/__tests__/host-words.test.ts
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { describe, expect, it, vi } from "vitest";
+import { hostWords, localizeHostWords } from "../host-words";
+import { testCore, wasmBuilt } from "./testCore";
+
+describe("host words: this computer in the words of its own system", () => {
+ const lines = ["This Mac is almost out of space.", "Uses about 4 GB on this Mac", "Connect Claude Code on your Mac"];
+
+ it("keeps the Mac's words on a Mac", () => {
+ for (const l of lines) expect(hostWords(l, "macos")).toBe(l);
+ });
+
+ it("says This PC on Windows", () => {
+ expect(hostWords(lines[0]!, "windows")).toBe("This PC is almost out of space.");
+ expect(hostWords(lines[1]!, "windows")).toBe("Uses about 4 GB on this PC");
+ expect(hostWords(lines[2]!, "windows")).toBe("Connect Claude Code on your PC");
+ });
+
+ it("says This machine on Linux (the app's convention)", () => {
+ expect(hostWords(lines[0]!, "linux")).toBe("This machine is almost out of space.");
+ expect(hostWords(lines[2]!, "linux")).toBe("Connect Claude Code on your computer");
+ });
+
+ it("leaves other Macs and text about macOS itself alone", () => {
+ expect(hostWords("Sam's Mac mini", "windows")).toBe("Sam's Mac mini");
+ expect(hostWords("Macs older than this Mac can't", "windows")).toBe("Macs older than this PC can't");
+ expect(hostWords("Lume is not installed on this Mac", "windows")).toBe("Lume is not installed on this Mac");
+ expect(hostWords("Keychain on this Mac", "windows")).toBe("Keychain on this Mac");
+ expect(hostWords("this-mac", "windows")).toBe("this-mac");
+ });
+
+ it("walks a core answer: values, not keys, and never mutates it", () => {
+ const answer = { "This Mac": 1, rows: [{ name: "This Mac", detail: "ok" }, 3, null], note: "on this Mac" };
+ const out = localizeHostWords(answer, "windows");
+ expect(out).toEqual({ "This Mac": 1, rows: [{ name: "This PC", detail: "ok" }, 3, null], note: "on this PC" });
+ expect((answer.rows[0] as { name: string }).name).toBe("This Mac");
+ expect(localizeHostWords(answer, "macos")).toBe(answer);
+ });
+});
+
+describe("host words through the real core", () => {
+ it.skipIf(!wasmBuilt)("words the core's answers for the host the shell reports", async () => {
+ const core = await testCore();
+ const warning = { warning: { level: "low", free: 1, total: 100, threshold: 10 } };
+ const ask = (platform: string) => {
+ vi.spyOn(navigator, "platform", "get").mockReturnValue(platform);
+ return core.call<{ text: string }>("resources.warning", warning).text;
+ };
+ expect(ask("MacIntel")).toBe("This Mac is almost out of space. Delete old Spaces or snapshots.");
+ expect(ask("Win32")).toBe("This PC is almost out of space. Delete old Spaces or snapshots.");
+ expect(ask("Linux x86_64")).toBe("This machine is almost out of space. Delete old Spaces or snapshots.");
+ vi.restoreAllMocks();
+ });
+});
diff --git a/apps/cua-spaces-web/src/bridge/core/index.ts b/apps/cua-spaces-web/src/bridge/core/index.ts
index 63b40b59b3..ec4cc6d817 100644
--- a/apps/cua-spaces-web/src/bridge/core/index.ts
+++ b/apps/cua-spaces-web/src/bridge/core/index.ts
@@ -12,6 +12,8 @@
* the bridge falls back to its TypeScript stand-ins (see `../derive.ts`).
*/
+import { localizeHostWords } from "../host-words";
+
/** The wasm-bindgen module (`core.js`, `--target web`). */
export interface CoreWasmModule {
default: (input?: unknown) => Promise<unknown>;
@@ -81,7 +83,7 @@ export function wasmCore(mod: Pick<CoreWasmModule, "call" | "methods" | "flows"
const methods = JSON.parse(mod.methods()) as string[];
const known = new Set(methods);
const call = <T>(method: string, args: Record<string, unknown> = {}): T =>
- JSON.parse(mod.call(method, JSON.stringify(args))) as T;
+ localizeHostWords(JSON.parse(mod.call(method, JSON.stringify(args))) as T);
return {
status: "ready",
methods,
diff --git a/apps/cua-spaces-web/src/bridge/host-words.ts b/apps/cua-spaces-web/src/bridge/host-words.ts
new file mode 100644
index 0000000000..427555c6a5
--- /dev/null
+++ b/apps/cua-spaces-web/src/bridge/host-words.ts
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+/**
+ * The app core words the computer it runs on as "this Mac" wherever it has no
+ * system to go by. On a PC or a Linux machine the page says what the host
+ * actually is ("This PC", "This machine") at the one place the core's answers
+ * enter the page, from the system the shell reports ({@link hostOs}).
+ *
+ * Display only: nothing is written back, so a stored name keeps its text and
+ * shows in its host's words (a Windows user's old "This Mac" reads "This PC";
+ * a Mac user's names are untouched). Text that is about macOS itself (Lume,
+ * Keychain, Finder, ...) is left alone, and so are "Mac mini" and other
+ * people's Macs: only the phrases that mean this computer are replaced.
+ */
+
+import { hostOs, THIS_MACHINE, type HostOs } from "./host-os";
+
+/** Copy that is about macOS itself: left as the core wrote it. */
+const MAC_ONLY = /macOS|Lume|Keychain|Finder|Xcode|Intel|Touch ID|Apple/;
+
+const LOWER: Record<HostOs, string> = { macos: "this Mac", windows: "this PC", linux: "this machine" };
+const YOUR: Record<HostOs, string> = { macos: "your Mac", windows: "your PC", linux: "your computer" };
+
+/** One string in the words of `os`. */
+export function hostWords(text: string, os: HostOs = hostOs()): string {
+ if (os === "macos" || !/\b(?:this|your) Mac\b/i.test(text) || MAC_ONLY.test(text)) return text;
+ return text
+ .replace(/\bThis Mac\b/g, THIS_MACHINE[os])
+ .replace(/\bthis Mac\b/g, LOWER[os])
+ .replace(/\bYour Mac\b/g, capital(YOUR[os]))
+ .replace(/\byour Mac\b/g, YOUR[os]);
+}
+
+const capital = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
+
+/** Every string of a core answer (keys are never touched) in the words of `os`. */
+export function localizeHostWords<T>(value: T, os: HostOs = hostOs()): T {
+ if (os === "macos") return value;
+ return walk(value, os) as T;
+}
+
+function walk(value: unknown, os: HostOs): unknown {
+ if (typeof value === "string") return hostWords(value, os);
+ if (Array.isArray(value)) return value.map((v) => walk(v, os));
+ if (value && typeof value === "object") {
+ const out: Record<string, unknown> = {};
+ for (const [k, v] of Object.entries(value)) out[k] = walk(v, os);
+ return out;
+ }
+ return value;
+}
diff --git a/apps/cua-spaces-web/src/components/add-computer-sheet.tsx b/apps/cua-spaces-web/src/components/add-computer-sheet.tsx
index 434525fd07..8021c91b77 100644
--- a/apps/cua-spaces-web/src/components/add-computer-sheet.tsx
+++ b/apps/cua-spaces-web/src/components/add-computer-sheet.tsx
@@ -32,6 +32,7 @@ import { Segmented } from "@/components/ui/segmented";
import { Select } from "@/components/ui/select";
import { UpgradeCard } from "@/components/upgrade-card";
import { cn } from "@/lib/utils";
+import { THIS_MACHINE } from "@/bridge/host-os";
/** Where Cua Spaces is downloaded; the page picks the download for the computer that opens it. */
export const INSTALL_URL = "https://cua.ai/install";
@@ -251,9 +252,10 @@ function computerIds(list: readonly Machine[]): Set<string> {
return new Set(list.filter((m) => !m.device).map((m) => m.id));
}
-/** "This Mac" on a Mac, else "This computer". */
+/** What this computer is called, in the words of its own system ("This Mac", "This PC", "This machine"). */
function thisComputerName(list: readonly Machine[]): string {
- return list.find((m) => m.current)?.os === "macos" ? "This Mac" : "This machine";
+ const os = list.find((m) => m.current)?.os;
+ return os === "macos" || os === "windows" || os === "linux" ? THIS_MACHINE[os] : "This machine";
}
/* ---- The first page: the methods -------------------------------------------------- */
diff --git a/apps/cua-spaces-web/src/components/agents/agent-chat.tsx b/apps/cua-spaces-web/src/components/agents/agent-chat.tsx
index 6b3219f725..3ff0d39dee 100644
--- a/apps/cua-spaces-web/src/components/agents/agent-chat.tsx
+++ b/apps/cua-spaces-web/src/components/agents/agent-chat.tsx
@@ -29,6 +29,7 @@ import { Segmented } from "@/components/ui/segmented";
import { Select } from "@/components/ui/select";
import { toast } from "@/components/ui/toast";
import { cn } from "@/lib/utils";
+import { thisComputerLabel } from "@/lib/host-labels";
const TONE: Record<AgentChat["tone"], string> = {
you: "bg-warning",
@@ -496,7 +497,7 @@ export function AgentsEmpty({ onStart, onConnect }: { onStart: () => void; onCon
<p className="mt-1 text-center text-[13px] text-muted-foreground">Add an agent, then message it here.</p>
<div className="mt-5">
{(found ?? []).slice(0, 3).map((f) => (
- <EmptyRow key={f.agent} data={`connect-mac-${f.agent}`} icon={<AppMark agent={f.agent} name={f.name} />} title={`Connect ${f.name}`} detail="On This Mac" onClick={() => connect(f.agent)} />
+ <EmptyRow key={f.agent} data={`connect-mac-${f.agent}`} icon={<AppMark agent={f.agent} name={f.name} />} title={`Connect ${f.name}`} detail={`On ${thisComputerLabel()}`} onClick={() => connect(f.agent)} />
))}
<EmptyRow data="start" icon={<PlayIcon className="size-3.5" />} title="Start one in a Space" detail="Runs inside the Space" onClick={onStart} />
<EmptyRow data="connect" icon={<LinkIcon className="size-3.5" />} title="Connect your own agent" detail="With a prompt" onClick={onConnect} />
diff --git a/apps/cua-spaces-web/src/components/agents/agents-empty.tsx b/apps/cua-spaces-web/src/components/agents/agents-empty.tsx
index 0cbe814608..85e590f68a 100644
--- a/apps/cua-spaces-web/src/components/agents/agents-empty.tsx
+++ b/apps/cua-spaces-web/src/components/agents/agents-empty.tsx
@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
import { useAgents, type AgentSetupRow } from "@/bridge";
import { HarnessMark } from "@/components/agents/harness-mark";
import { Button } from "@/components/ui/button";
+import { thisComputerText } from "@/lib/host-labels";
const MAIN_PROMPT = "Reproduce the crash from issue #4821 on a fresh Windows 11 Space and show me a recording.";
const MORE_PROMPTS = ["Run our tests on Ubuntu and macOS at the same time and tell me which ones fail.", "Check that the installer works on a clean Windows machine."];
@@ -60,7 +61,7 @@ export function AgentsEmpty() {
{state === "ready"
? "Open Claude Code, Codex or Cursor and ask it for something that needs a clean computer. It makes the Space, works in it and shows you the result here."
: state === "setup"
- ? `${nameList(todo.map((r) => r.name))} ${todo.length === 1 ? "is" : "are"} on this Mac. Let ${todo.length === 1 ? "it" : "them"} use Cua, then ask one to work in a Space.`
+ ? `${nameList(todo.map((r) => r.name))} ${todo.length === 1 ? "is" : "are"} on ${thisComputerText()}. Let ${todo.length === 1 ? "it" : "them"} use Cua, then ask one to work in a Space.`
: "Install Claude Code, Codex or Cursor and Cua will notice. Spaces work without one."}
</p>
{state === "setup" ? (
diff --git a/apps/cua-spaces-web/src/components/driver/copy.ts b/apps/cua-spaces-web/src/components/driver/copy.ts
index 37d86e5a58..1359a8d95e 100644
--- a/apps/cua-spaces-web/src/components/driver/copy.ts
+++ b/apps/cua-spaces-web/src/components/driver/copy.ts
@@ -4,10 +4,11 @@
/** The Cua Driver page's words. Plain words only. */
import { sinceText, type DriverStatus } from "@/bridge";
+import { thisComputerText } from "@/lib/host-labels";
-export const DRIVER_LINE = "Lets agents see and use the apps on this Mac.";
+export const driverLine = () => `Lets agents see and use the apps on ${thisComputerText()}.`;
-const place = (s: DriverStatus) => (s.thisMachine ? "this Mac" : s.machineName);
+const place = (s: DriverStatus) => (s.thisMachine ? thisComputerText() : s.machineName);
/** "Working on this Mac." and friends: the status in one sentence. */
export function stateText(s: DriverStatus): string {
@@ -15,7 +16,7 @@ export function stateText(s: DriverStatus): string {
case "ready":
return `Working on ${place(s)}.`;
case "paused":
- return "Off. Agents can't use apps on this Mac.";
+ return `Off. Agents can't use apps on ${thisComputerText()}.`;
case "needs-permission":
return "A permission is missing. Allow it below.";
case "starting":
diff --git a/apps/cua-spaces-web/src/components/driver/driver-page.tsx b/apps/cua-spaces-web/src/components/driver/driver-page.tsx
index 5151675c5e..b20443e57e 100644
--- a/apps/cua-spaces-web/src/components/driver/driver-page.tsx
+++ b/apps/cua-spaces-web/src/components/driver/driver-page.tsx
@@ -20,8 +20,9 @@ import { Switch } from "@/components/ui/switch";
import { toast, toastError } from "@/components/ui/toast";
import { driverUsesAppPermissions } from "@/lib/app-permissions";
import { cn } from "@/lib/utils";
-import { DRIVER_LINE, markFor, stateText, testText, versionText } from "./copy";
+import { driverLine, markFor, stateText, testText, versionText } from "./copy";
import { PointerPreview } from "./pointer-preview";
+import { thisComputerLabel, thisComputerText } from "@/lib/host-labels";
/**
* The Cua Driver page (CUA-2706, design A): what it is in one line, its
@@ -113,7 +114,7 @@ function Hero({ driver, status, settings }: { driver: DriverHook; status: Driver
<CuaKey size={56} className="mt-1 size-14 self-start" />
<div className="min-w-0">
<h1 className="font-display text-[28px] leading-tight font-semibold tracking-[-0.02em]">Cua Driver</h1>
- <p className="mt-1 text-[14px] text-muted-foreground">{status.thisMachine ? DRIVER_LINE : `Lets agents see and use the apps on ${status.machineName}.`}</p>
+ <p className="mt-1 text-[14px] text-muted-foreground">{status.thisMachine ? driverLine() : `Lets agents see and use the apps on ${status.machineName}.`}</p>
<p className="mt-4 flex items-start gap-2 text-[13px]" data-driver-state={status.state}>
{ok ? (
<span className="mt-px flex size-4 shrink-0 items-center justify-center rounded-full bg-[#1f9d55] text-white" aria-hidden>
@@ -150,21 +151,21 @@ function Hero({ driver, status, settings }: { driver: DriverHook; status: Driver
) : null}
</div>
</div>
- {status.thisMachine ? <PointerPreview settings={settings} caption="Live: the agent pointer as it looks on this Mac" /> : null}
+ {status.thisMachine ? <PointerPreview settings={settings} caption={`Live: the agent pointer as it looks on ${thisComputerText()}`} /> : null}
</section>
);
}
-/* ---- Let agents use this Mac ---------------------------------------------------- */
+/* ---- Let agents use this computer ---------------------------------------------------- */
function AllowSection({ driver, status }: { driver: DriverHook; status: DriverStatus }) {
const on = status.state !== "paused";
return (
<GroupedSection title="Agents" className="mt-8 mb-8" data-driver-allow="">
<SettingRow
- label="Let agents use apps on this Mac"
+ label={`Let agents use apps on ${thisComputerText()}`}
help={on ? "Coding agents you connect can see your screen and use your apps. Your own pointer never moves." : "Off. Agents can't see your screen or use your apps until you turn this on."}
- control={<Switch checked={on} onCheckedChange={(next) => void driver.pause(!next).catch(toastError(next ? "Couldn't turn agents on" : "Couldn't turn agents off"))} aria-label="Let agents use apps on this Mac" />}
+ control={<Switch checked={on} onCheckedChange={(next) => void driver.pause(!next).catch(toastError(next ? "Couldn't turn agents on" : "Couldn't turn agents off"))} aria-label={`Let agents use apps on ${thisComputerText()}`} />}
/>
</GroupedSection>
);
@@ -177,7 +178,7 @@ function PointerSection({ driver, settings }: { driver: DriverHook; settings: Po
void driver.setConfig(pointerChange(key, value)).catch(toastError("Couldn't change the pointer"));
const off = settings.show === false;
return (
- <GroupedSection title="Agent pointer" className="mb-8 min-w-0" data-driver-pointer="" footer="Applies to every agent on this Mac.">
+ <GroupedSection title="Agent pointer" className="mb-8 min-w-0" data-driver-pointer="" footer={`Applies to every agent on ${thisComputerText()}.`}>
{settings.show !== null ? (
<SettingRow
label="Show the agent's pointer"
@@ -291,7 +292,7 @@ function Computers({ current }: { current: string }) {
data-driver-computer={m.machineId}
>
<OsIcon os={m.os} className="size-4 text-muted-foreground" />
- <span className="flex-1 truncate">{m.thisMachine ? "This Mac" : m.name}</span>
+ <span className="flex-1 truncate">{m.thisMachine ? thisComputerLabel() : m.name}</span>
<span className="truncate text-xs text-muted-foreground">{line}</span>
<ChevronRightIcon className="size-3.5 text-muted-foreground" />
</Link>
diff --git a/apps/cua-spaces-web/src/components/empty-home.tsx b/apps/cua-spaces-web/src/components/empty-home.tsx
index c610d2cb5c..af8242c7c6 100644
--- a/apps/cua-spaces-web/src/components/empty-home.tsx
+++ b/apps/cua-spaces-web/src/components/empty-home.tsx
@@ -18,6 +18,7 @@ import { CliHintLine, useCliName } from "@/components/cli-hint";
import { useFirstRunStep } from "@/components/first-run-guide";
import { OsIcon } from "@/components/os-icon";
import { createAliasCommand } from "@/lib/cli-commands";
+import { thisComputerLabel } from "@/lib/host-labels";
/** The first of the core's figures ("About 4 minutes" of "About 4 minutes · 1.0–2.0 GB of disk"): one muted detail, no dot-chain. */
export const firstFigure = (detail: string) => detail.split(" \u00b7 ")[0]!.trim();
@@ -43,7 +44,7 @@ export function EmptyHome({ home, unread = false }: { home: EmptyHomeView; unrea
</h2>
{unread ? null : (
<>
- <p className="mt-1.5 text-[13px] text-muted-foreground">A separate computer on This Mac, for you and your agents.</p>
+ <p className="mt-1.5 text-[13px] text-muted-foreground">A separate computer on {thisComputerLabel()}, for you and your agents.</p>
<div className="mt-6 flex flex-wrap justify-center gap-3">
{home.tiles.map((tile) => (
<SystemButton key={tile.os} tile={tile} onStart={start} />
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 ac416479f8..f9965d47da 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
@@ -59,6 +59,7 @@ import { cn } from "@/lib/utils";
import { FloatKeys } from "./float-keys";
import { CARD, GLASS_CHIP, GREY } from "./hero";
import { OsMark } from "./os-marks";
+import { thisComputerText } from "@/lib/host-labels";
/* ---- The site's pieces ------------------------------------------------------------------ */
@@ -508,7 +509,7 @@ export function AgentScreen({ view, onPick, onContinue, onInstall, busy }: { vie
* so far. Nothing runs until they send. Hidden when there are none. Only each chat's title, folder
* and time are read here; its messages are read when it is picked.
*/
-export function PickUpWhereYouLeftOff({ onContinue, place = "this Mac", className }: { onContinue: (task: AskTask) => void; place?: string; className?: string }) {
+export function PickUpWhereYouLeftOff({ onContinue, place = thisComputerText(), className }: { onContinue: (task: AskTask) => void; place?: string; className?: string }) {
const threads = useRecentThreads();
if (!threads?.length) return null;
return (
diff --git a/apps/cua-spaces-web/src/components/settings/general-tab.tsx b/apps/cua-spaces-web/src/components/settings/general-tab.tsx
index 8173d322d5..d468307dcc 100644
--- a/apps/cua-spaces-web/src/components/settings/general-tab.tsx
+++ b/apps/cua-spaces-web/src/components/settings/general-tab.tsx
@@ -17,7 +17,7 @@ import { Input } from "@/components/ui/input";
import { Segmented } from "@/components/ui/segmented";
import { Switch } from "@/components/ui/switch";
import { toastError } from "@/components/ui/toast";
-import { globalShortcutLine, showsMacShellSettings, thisComputerLabel } from "@/lib/host-labels";
+import { globalShortcutLine, showsMacShellSettings, thisComputerLabel, thisComputerText } from "@/lib/host-labels";
import { LAUNCH_HELP, LAUNCH_LABEL } from "@/lib/settings-copy";
import { acceleratorOf } from "@/lib/shortcut-keys";
import { useTheme, type ThemePreference } from "@/lib/theme";
@@ -160,7 +160,7 @@ function SharingGroup() {
void (async () => {
try {
if (!panel.configured) {
- if (next && !(await host.quickSetUp())) throw new Error(host.setupError?.message ?? "Couldn't set this Mac up.");
+ if (next && !(await host.quickSetUp())) throw new Error(host.setupError?.message ?? `Couldn't set ${thisComputerText()} up.`);
return;
}
if (!toggle) return;
diff --git a/apps/cua-spaces-web/src/components/space-detail/this-mac-desktop.tsx b/apps/cua-spaces-web/src/components/space-detail/this-mac-desktop.tsx
index 72ff318e37..91ab41c0fd 100644
--- a/apps/cua-spaces-web/src/components/space-detail/this-mac-desktop.tsx
+++ b/apps/cua-spaces-web/src/components/space-detail/this-mac-desktop.tsx
@@ -98,7 +98,7 @@ export function ThisMacCall({
setNudge((n) => n + 1);
throw new Error(NOT_SHARING_CHAT);
}
- if (noThread) throw new Error("Chat isn't available on this Mac's own desktop yet.");
+ if (noThread) throw new Error(`Chat isn't available on ${thisComputerText()}'s own desktop yet.`);
return live.post(text, view);
},
}),
diff --git a/apps/cua-spaces-web/src/components/this-mac-nudges.tsx b/apps/cua-spaces-web/src/components/this-mac-nudges.tsx
index ce4ff5341f..6441fc0b5b 100644
--- a/apps/cua-spaces-web/src/components/this-mac-nudges.tsx
+++ b/apps/cua-spaces-web/src/components/this-mac-nudges.tsx
@@ -7,6 +7,7 @@ import { useAddSpaceWhenReady, useRiskyNudge, useSecondAgentNudge, type Nudge }
import { CuaKey } from "@/components/cua-key";
import { Button } from "@/components/ui/button";
import { toast } from "@/components/ui/toast";
+import { thisComputerLabel } from "@/lib/host-labels";
/**
* The two This Mac prompts, in the top-right corner over whatever page is
@@ -22,7 +23,7 @@ export function ThisMacNudges() {
const started = useCallback((os: "macos" | "linux" | null) => {
setWantSpace(false);
if (os) toast(`Making a ${os === "macos" ? "macOS" : "Linux"} Space`, { description: "It shows in Spaces with its progress. You can keep working." });
- else toast("This Mac can't make a Space right now", { description: "Open New Space to see why." });
+ else toast(`${thisComputerLabel()} can't make a Space right now`, { description: "Open New Space to see why." });
}, []);
// The risky question waits on an agent: it goes first.
diff --git a/apps/cua-spaces-web/src/lib/resources.ts b/apps/cua-spaces-web/src/lib/resources.ts
index 8d35b80be3..e78b5b8972 100644
--- a/apps/cua-spaces-web/src/lib/resources.ts
+++ b/apps/cua-spaces-web/src/lib/resources.ts
@@ -8,6 +8,7 @@
*/
import type { ComputerResources, SharedBase, SpaceResources } from "@/bridge";
+import { thisComputerLabel, thisComputerText } from "./host-labels";
export const LABELS = { cpu: "Processor", memory: "Memory", disk: "Space for files" } as const;
@@ -98,7 +99,7 @@ export const isRunning = (s: SpaceResources) => s.powerState === "running";
* "Shares space with other copies" when it couldn't be measured; null when
* there's nothing to say.
*/
-export function onHostLine(s: SpaceResources, computer = "this Mac"): string | null {
+export function onHostLine(s: SpaceResources, computer = thisComputerText()): string | null {
const d = s.diskOnHost;
if (!d) return null;
if (d.bytes == null) return d.sharesSpace ? "Shares space with other copies." : null;
@@ -187,7 +188,7 @@ export interface SpacePanelInput {
space: SpaceResources;
name: string;
host: ComputerResources | null;
- /** "this Mac", or the other computer's name. */
+ /** "this Mac" (in this computer's words), or the other computer's name. */
computer: string;
/** Every Space on that computer. */
spaces: SpaceResources[];
@@ -256,8 +257,8 @@ export function diskFit(host: ComputerResources, me: SpaceResources, name: strin
: {
text:
level === "critical"
- ? "This Mac is out of space, so new Spaces can’t be created. Delete old Spaces or snapshots."
- : "This Mac is almost out of space. Delete old Spaces or snapshots.",
+ ? `${thisComputerLabel()} is out of space, so new Spaces can’t be created. Delete old Spaces or snapshots.`
+ : `${thisComputerLabel()} is almost out of space. Delete old Spaces or snapshots.`,
button: "See what’s using space",
critical: level === "critical",
};
@@ -268,7 +269,7 @@ export function diskFit(host: ComputerResources, me: SpaceResources, name: strin
export function spacePanel(i: SpacePanelInput): SpacePanelView {
const s = i.space;
const u = s.powerState === "running" ? s.usage : null;
- const whose = `${i.computer || "this Mac"}’s`;
+ const whose = `${i.computer || thisComputerText()}’s`;
const host = i.host;
const processor: SpacePanelCard = {
label: LABELS.cpu,
diff --git a/apps/cua-spaces-web/src/routes/agents/all.tsx b/apps/cua-spaces-web/src/routes/agents/all.tsx
index 1baa6ab728..c73edf6fe5 100644
--- a/apps/cua-spaces-web/src/routes/agents/all.tsx
+++ b/apps/cua-spaces-web/src/routes/agents/all.tsx
@@ -41,6 +41,7 @@ import {
} from "@/lib/agents";
import { needsAgentKey } from "@/lib/agent-keys";
import { relativeTime, cn } from "@/lib/utils";
+import { thisComputerLabel } from "@/lib/host-labels";
export const Route = createFileRoute("/agents/all")({
component: AgentsPage,
@@ -164,7 +165,7 @@ function Overview({ data, onSelect, connections }: { data: AgentsData; onSelect:
) : null}
{connections.rows.length > 0 ? (
- <Block title="On This Mac" count={connections.rows.length} id="connections">
+ <Block title={`On ${thisComputerLabel()}`} count={connections.rows.length} id="connections">
{connections.rows.map((c) => (
<ConnectionListRow key={c.id} row={c} busy={connections.busy === c.id} note={connections.notes[c.id] ?? null} onAct={(a) => (a === "connect" ? void navigate({ to: "/settings/connections", search: { app: c.id } }) : void connections.act(c.id, a))} />
))}
diff --git a/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx b/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx
index be5a04e3e8..807c1ba77e 100644
--- a/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx
+++ b/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx
@@ -67,7 +67,7 @@ cua spaces [OPTIONS] <COMMAND>
Registered Spaces and your computers on the relay.
-CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it
+CPU, MEMORY and the DISK column (on this computer) show what each Space was given and what it
uses now (the numbers the Cua Spaces app shows); for another of your
computers they show what it last reported. Numbers only: no file names.
diff --git a/libs/cua/crates/cua-cli/src/host.rs b/libs/cua/crates/cua-cli/src/host.rs
index 2ca21babe4..e04c5390ed 100644
--- a/libs/cua/crates/cua-cli/src/host.rs
+++ b/libs/cua/crates/cua-cli/src/host.rs
@@ -348,7 +348,7 @@ pub enum SpacesCmd {
/// Registered Spaces and your computers on the relay.
#[command(
visible_alias = "list",
- after_help = "CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it
+ after_help = "CPU, MEMORY and the DISK column (on this computer) show what each Space was given and what it
uses now (the numbers the Cua Spaces app shows); for another of your
computers they show what it last reported. Numbers only: no file names.
@@ -5529,7 +5529,14 @@ mod tests {
assert!(text.contains("lab-box") && text.contains("relay"), "{text}");
// The new columns, and this machine's own row shows this Mac.
assert!(text.starts_with("ID "), "{text}");
- for column in ["CPU", "MEMORY", "DISK ON THIS MAC"] {
+ for column in [
+ "CPU",
+ "MEMORY",
+ &format!(
+ "DISK ON {}",
+ cua_spaces::resources::words::Host::current().this_upper()
+ ),
+ ] {
assert!(text.lines().next().unwrap().contains(column), "{text}");
}
let row = text.lines().find(|l| l.contains("lab-box")).unwrap();
diff --git a/libs/cua/crates/cua-cli/src/resources_view.rs b/libs/cua/crates/cua-cli/src/resources_view.rs
index 4d2f0704e7..419f8f7ac8 100644
--- a/libs/cua/crates/cua-cli/src/resources_view.rs
+++ b/libs/cua/crates/cua-cli/src/resources_view.rs
@@ -65,7 +65,7 @@ pub struct Cells {
pub cpu: String,
/// MEMORY.
pub memory: String,
- /// DISK ON THIS MAC.
+ /// DISK ON THIS MAC (PC).
pub disk: String,
}
@@ -102,9 +102,20 @@ pub const MEMORY_WIDTH: usize = 15;
/// The header of the table the extra columns make.
pub fn header(id_width: usize) -> String {
+ header_on(id_width, words::Host::current())
+}
+
+/// [`header`] naming the computer in the words of `host` (DISK ON THIS PC).
+pub fn header_on(id_width: usize, host: words::Host) -> String {
format!(
- "{:<id_width$} {:<24} {:<8} {:<9} {:<CPU_WIDTH$} {:<MEMORY_WIDTH$} DISK ON THIS MAC",
- "ID", "NAME", "PROVIDER", "VERSION", "CPU", "MEMORY"
+ "{:<id_width$} {:<24} {:<8} {:<9} {:<CPU_WIDTH$} {:<MEMORY_WIDTH$} DISK ON {}",
+ "ID",
+ "NAME",
+ "PROVIDER",
+ "VERSION",
+ "CPU",
+ "MEMORY",
+ host.this_upper()
)
}
@@ -166,10 +177,15 @@ impl Columns<'_> {
}
}
-/// The "This Mac" block of `cua host status`.
+/// The "This Mac" ("This PC") block of `cua host status`.
pub fn this_mac_lines(r: &Resources) -> Vec<String> {
+ this_mac_lines_on(r, words::Host::current())
+}
+
+/// [`this_mac_lines`] naming the computer in the words of `host`.
+pub fn this_mac_lines_on(r: &Resources, host: words::Host) -> Vec<String> {
let m = &r.this_mac;
- let mut out = vec!["This Mac".to_string()];
+ let mut out = vec![host.this().to_string()];
if m.cpu_count > 0 {
out.push(format!(
" Processor: {}",
@@ -191,7 +207,7 @@ pub fn this_mac_lines(r: &Resources) -> Vec<String> {
if let Some(extra) = words::extra_spaces_use(m) {
out.push(format!(" {extra}"));
}
- if let Some(w) = words::warning(&m.warning) {
+ if let Some(w) = words::warning_on(&m.warning, host) {
out.push(format!(" {w}"));
}
out
@@ -399,7 +415,7 @@ mod tests {
"VERSION",
"CPU",
"MEMORY",
- "DISK ON THIS MAC",
+ &format!("DISK ON {}", words::Host::current().this_upper()),
] {
let at = h.find(column).unwrap();
assert!(at > 0);
@@ -437,7 +453,7 @@ mod tests {
fn this_mac_in_words() {
let r = resources();
assert_eq!(
- this_mac_lines(&r),
+ this_mac_lines_on(&r, words::Host::Mac),
[
"This Mac",
" Processor: 12 cores \u{b7} 38% busy",
@@ -448,11 +464,21 @@ mod tests {
);
let mut low = resources();
low.this_mac.warning = DiskWarning::assess(10 * GIB, TB, 5 * GIB, DiskLevel::Ok);
- let lines = this_mac_lines(&low);
+ let lines = this_mac_lines_on(&low, words::Host::Mac);
assert_eq!(
lines.last().unwrap(),
" This Mac is almost out of space. Delete old Spaces or snapshots."
);
+ // On a PC the block, the warning and the column say so.
+ let pc = this_mac_lines_on(&low, words::Host::Pc);
+ assert_eq!(pc[0], "This PC");
+ assert_eq!(
+ pc.last().unwrap(),
+ " This PC is almost out of space. Delete old Spaces or snapshots."
+ );
+ assert!(header_on(48, words::Host::Mac).ends_with("DISK ON THIS MAC"));
+ assert!(header_on(48, words::Host::Pc).ends_with("DISK ON THIS PC"));
+ assert_eq!(this_mac_lines(&low)[0], words::Host::current().this());
let c = Columns {
resources: &low,
own_machine: None,
diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs
index bbf21f8826..ba2ebf1ae8 100644
--- a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs
+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs
@@ -3689,7 +3689,7 @@ mod resources_tests {
assert_eq!(v.this_mac.extra_spaces, rt::words::extra_spaces_use(m));
assert_eq!(
v.this_mac.warning.as_ref().map(|w| w.text.as_str()),
- rt::words::warning(&runtime.warning)
+ rt::words::warning_on(&runtime.warning, rt::words::Host::Mac)
);
// A running Space.
let s = &runtime.spaces[0];
diff --git a/libs/cua/crates/cua-spaces/src/resources/words.rs b/libs/cua/crates/cua-spaces/src/resources/words.rs
index b137f4bc79..2d1e064e1d 100644
--- a/libs/cua/crates/cua-spaces/src/resources/words.rs
+++ b/libs/cua/crates/cua-spaces/src/resources/words.rs
@@ -96,14 +96,76 @@ pub fn extra_spaces_use(c: &ComputerResources) -> Option<String> {
))
}
-/// The warning's sentence, when there is one.
+/// The computer the CLI runs on, in the words of its system: "This Mac",
+/// "This PC" on Windows, "This machine" elsewhere (the app's convention).
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Host {
+ /// macOS.
+ Mac,
+ /// Windows.
+ Pc,
+ /// Linux and the rest.
+ Other,
+}
+
+impl Host {
+ /// The system this binary runs on.
+ pub fn current() -> Self {
+ if cfg!(target_os = "macos") {
+ Host::Mac
+ } else if cfg!(windows) {
+ Host::Pc
+ } else {
+ Host::Other
+ }
+ }
+
+ /// "This Mac", "This PC", "This machine".
+ pub fn this(self) -> &'static str {
+ match self {
+ Host::Mac => "This Mac",
+ Host::Pc => "This PC",
+ Host::Other => "This machine",
+ }
+ }
+
+ /// [`Self::this`] for a column header: "THIS MAC", "THIS PC", "THIS MACHINE".
+ pub fn this_upper(self) -> &'static str {
+ match self {
+ Host::Mac => "THIS MAC",
+ Host::Pc => "THIS PC",
+ Host::Other => "THIS MACHINE",
+ }
+ }
+}
+
+/// The warning's sentence, when there is one, for the system this runs on.
pub fn warning(w: &DiskWarning) -> Option<&'static str> {
- match w.level {
- DiskLevel::Ok => None,
- DiskLevel::Low => Some("This Mac is almost out of space. Delete old Spaces or snapshots."),
- DiskLevel::Critical => Some(
+ warning_on(w, Host::current())
+}
+
+/// [`warning`] for `host`.
+pub fn warning_on(w: &DiskWarning, host: Host) -> Option<&'static str> {
+ match (w.level, host) {
+ (DiskLevel::Ok, _) => None,
+ (DiskLevel::Low, Host::Mac) => {
+ Some("This Mac is almost out of space. Delete old Spaces or snapshots.")
+ }
+ (DiskLevel::Low, Host::Pc) => {
+ Some("This PC is almost out of space. Delete old Spaces or snapshots.")
+ }
+ (DiskLevel::Low, Host::Other) => {
+ Some("This machine is almost out of space. Delete old Spaces or snapshots.")
+ }
+ (DiskLevel::Critical, Host::Mac) => Some(
"This Mac is out of space, so new Spaces can't be created. Delete old Spaces or snapshots.",
),
+ (DiskLevel::Critical, Host::Pc) => Some(
+ "This PC is out of space, so new Spaces can't be created. Delete old Spaces or snapshots.",
+ ),
+ (DiskLevel::Critical, Host::Other) => Some(
+ "This machine is out of space, so new Spaces can't be created. Delete old Spaces or snapshots.",
+ ),
}
}
@@ -342,13 +404,32 @@ mod tests {
let low = DiskWarning::assess(10 * GIB, TB, 5 * GIB, DiskLevel::Ok);
assert_eq!(
- warning(&low),
+ warning_on(&low, Host::Mac),
Some("This Mac is almost out of space. Delete old Spaces or snapshots.")
);
+ assert_eq!(
+ warning_on(&low, Host::Pc),
+ Some("This PC is almost out of space. Delete old Spaces or snapshots.")
+ );
+ assert_eq!(
+ warning_on(&low, Host::Other),
+ Some("This machine is almost out of space. Delete old Spaces or snapshots.")
+ );
+ // The CLI words it for the system it runs on.
+ assert_eq!(warning(&low), warning_on(&low, Host::current()));
let ok = DiskWarning::assess(500 * GIB, TB, 5 * GIB, DiskLevel::Ok);
assert_eq!(warning(&ok), None);
let crit = DiskWarning::assess(GIB, TB, 5 * GIB, DiskLevel::Ok);
assert!(warning(&crit).unwrap().contains("out of space"));
+ for (host, this) in [
+ (Host::Mac, "This Mac"),
+ (Host::Pc, "This PC"),
+ (Host::Other, "This machine"),
+ ] {
+ assert!(warning_on(&crit, host).unwrap().starts_with(this));
+ assert_eq!(host.this(), this);
+ assert_eq!(host.this_upper(), this.to_uppercase());
+ }
}
#[test]
diff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.json
index 73ee84d7fd..7acc137161 100644
--- a/scripts/docs-generators/cli-specs/cua.json
+++ b/scripts/docs-generators/cli-specs/cua.json
@@ -14639,7 +14639,7 @@
"subcommands": [
{
"abstract": "Registered Spaces and your computers on the relay",
- "after_help": "CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it\nuses now (the numbers the Cua Spaces app shows); for another of your\ncomputers they show what it last reported. Numbers only: no file names.\n\nExamples:\n cua spaces ls\n cua spaces ls --no-size\n cua spaces ls --json\n # Only the Spaces created with these labels\n cua spaces ls --label team=research --label run=7",
+ "after_help": "CPU, MEMORY and the DISK column (on this computer) show what each Space was given and what it\nuses now (the numbers the Cua Spaces app shows); for another of your\ncomputers they show what it last reported. Numbers only: no file names.\n\nExamples:\n cua spaces ls\n cua spaces ls --no-size\n cua spaces ls --json\n # Only the Spaces created with these labels\n cua spaces ls --label team=research --label run=7",
"aliases": [
"list"
],