Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(spaces-web): new setup footer blends in, step dots navigate, Home starts on This Mac (CUA-3553) (#6580)
Francesco Bonacci3d99a6c0649e
diff --git a/apps/cua-spaces-web/src/__tests__/app-harness.tsx b/apps/cua-spaces-web/src/__tests__/app-harness.tsxindex db1bd26c6e..7ff6873de8 100644--- a/apps/cua-spaces-web/src/__tests__/app-harness.tsx+++ b/apps/cua-spaces-web/src/__tests__/app-harness.tsx@@ -7,7 +7,7 @@// and lists that machine's half-created Space as a record of its own.import { createMemoryHistory, createRouter, RouterProvider } from "@tanstack/react-router";-import { render } from "@testing-library/react";+import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, beforeAll, beforeEach } from "vitest";import type { DataAdapter } from "@/bridge/adapter";import type { MachinesView } from "@/bridge/contracts/host";@@ -150,3 +150,22 @@ export async function mountApp(path: string, host: TestHost = { failsCreates: trconst emit = (event: HostEvent) => listeners.forEach((l) => l(event));return { router, hooks, host, demo, emit };}++/**+ * Home's box starts on This Mac once it's in the account (5 Nov 2026). A test about a job that makes+ * a new Space picks that first, as a person would.+ */+export async function pickNewLinux(): Promise<void> {+ const trigger = await waitFor(() => {+ const el = document.querySelector<HTMLElement>('[data-picker="where"]');+ if (!el) throw new Error("no where picker yet");+ return el;+ });+ await act(async () => {+ fireEvent.click(trigger);+ });+ const item = await screen.findByRole("menuitem", { name: /A new Linux computer on/ });+ await act(async () => {+ fireEvent.click(item);+ });+}diff --git a/apps/cua-spaces-web/src/__tests__/ask-box.test.tsx b/apps/cua-spaces-web/src/__tests__/ask-box.test.tsxindex 90d732028e..a1c933b23d 100644--- a/apps/cua-spaces-web/src/__tests__/ask-box.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/ask-box.test.tsx@@ -16,7 +16,7 @@ import { resetConnectState } from "@/hooks/use-connectors";import { askTasks, resetAskTasks } from "@/lib/ask-first";import { resetPickedAgent } from "@/lib/ask-first-model";import { resetRepos } from "@/lib/ask-first-repo";-import { mountApp, stubBrowserApis } from "./app-harness";+import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";stubBrowserApis();beforeEach(() => {@@ -176,6 +176,7 @@ describe.skipIf(!wasmBuilt)("the prompt box", () => {await act(async () => {fireEvent.click(q('[data-agent-group="claude-code"] [data-agent-account="kwork"]')!);});+ await pickNewLinux();fireEvent.change(box, { target: { value: "fix the build" } });await act(async () => {fireEvent.keyDown(box, { key: "Enter", shiftKey: true });@@ -219,6 +220,7 @@ describe.skipIf(!wasmBuilt)("the prompt box", () => {fireEvent.keyDown(field, { key: "Enter" });});await waitFor(() => expect(q("[data-ask-repo]")!.dataset.askRepo).toBe("trycua/demo-failing-tests"));+ await pickNewLinux();fireEvent.change(box, { target: { value: "find out why the tests fail" } });await act(async () => {fireEvent.keyDown(box, { key: "Enter" });diff --git a/apps/cua-spaces-web/src/__tests__/ask-first-in-space.test.tsx b/apps/cua-spaces-web/src/__tests__/ask-first-in-space.test.tsxindex aa0f736917..eb440fd35c 100644--- a/apps/cua-spaces-web/src/__tests__/ask-first-in-space.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/ask-first-in-space.test.tsx@@ -19,7 +19,7 @@ import { resetWakeNotes } from "@/components/space-thread/summon";import { resetConnectedAppsState } from "@/hooks/use-connected-apps";import { resetConnectState } from "@/hooks/use-connectors";import { askTasks, resetAskTasks } from "@/lib/ask-first";-import { mountApp, stubBrowserApis } from "./app-harness";+import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";stubBrowserApis();beforeEach(() => {@@ -49,7 +49,9 @@ const found = (s: string, timeout = 8000) =>/** A Space the person's own job made (no agent in it yet): Home, a job, then its page. */async function inAFreshSpace(host: Parameters<typeof mountApp>[1]) {const { router } = await mountApp("/home", host);- fireEvent.change(await screen.findByLabelText("What should it do?"), { target: { value: "look around" } });+ await screen.findByLabelText("What should it do?");+ await pickNewLinux();+ fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "look around" } });await act(async () => {fireEvent.click(screen.getByRole("button", { name: "Start" }));});@@ -80,7 +82,9 @@ describe.skipIf(!wasmBuilt)("Ask first in the Space (both flags)", () => {listsGhost: false,intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined),});- fireEvent.change(await screen.findByLabelText("What should it do?"), { target: { value: "fix the build" } });+ await screen.findByLabelText("What should it do?");+ await pickNewLinux();+ fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });await act(async () => {fireEvent.click(screen.getByRole("button", { name: "Start" }));});@@ -190,7 +194,9 @@ describe.skipIf(!wasmBuilt)("notes only you see", () => {let release!: () => void;const hold = new Promise<void>((r) => (release = r));await mountApp("/home", { failsCreates: false, listsGhost: false, hold, intercept: (op, args) => (calls.push({ op, args }), undefined) });- fireEvent.change(await screen.findByLabelText("What should it do?"), { target: { value: "fix the build" } });+ await screen.findByLabelText("What should it do?");+ await pickNewLinux();+ fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });await act(async () => {fireEvent.click(screen.getByRole("button", { name: "Start" }));});diff --git a/apps/cua-spaces-web/src/__tests__/ask-first-start-failed.test.tsx b/apps/cua-spaces-web/src/__tests__/ask-first-start-failed.test.tsxindex 7fa9a5bce0..c83786a6d8 100644--- a/apps/cua-spaces-web/src/__tests__/ask-first-start-failed.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/ask-first-start-failed.test.tsx@@ -49,20 +49,19 @@ async function startJob(text: string) {}describe.skipIf(!wasmBuilt)("This Mac as a task's computer (real routes, wasm core)", () => {- it("defaults to a new Linux computer, and This Mac asks once, then starts on this Mac's Space id", async () => {+ it("defaults to This Mac once it's in the account, asks once on the first Start, then starts on this Mac's Space id", async () => {await mountApp("/home", HOST);await screen.findByText("What do you want to do?");- expect(document.querySelector('[data-picker="where"]')!.textContent).toContain("New Space");- await pickThisMac();+ await waitFor(() => expect(document.querySelector('[data-picker="where"]')!.textContent).toContain("This Mac"));+ await startJob("Tidy my Downloads folder");await screen.findByText("Work on this Mac?");+ expect(askTasks()).toHaveLength(0);expect(screen.getByText(/Codex will work directly on this Mac, with your files and apps\. It can't be undone by throwing the computer away\./)).toBeTruthy();await act(async () => {fireEvent.click(screen.getByRole("button", { name: "Use this Mac" }));});expect(thisMacConfirmed()).toBe(true);- await waitFor(() => expect(document.querySelector('[data-picker="where"]')!.textContent).toContain("This Mac"));- await startJob("Tidy my Downloads folder");- const id = askTasks()[0]!.id;+ const id = await waitFor(() => askTasks()[0]!.id);// The job goes to this Mac's own Space, as the first message of its thread.await waitFor(() => expect(askTask(id)).toMatchObject({ spaceId: HOST_SPACE, onHost: true, error: null }), { timeout: 5000 });});@@ -79,16 +78,17 @@ describe.skipIf(!wasmBuilt)("This Mac as a task's computer (real routes, wasm coexpect(screen.getAllByText("This Mac").length).toBeGreaterThan(0);});- it("Pick another keeps the default and reopens the picker", async () => {+ it("Pick another starts nothing and reopens the picker", async () => {await mountApp("/home", HOST);await screen.findByText("What do you want to do?");- await pickThisMac();+ await waitFor(() => expect(document.querySelector('[data-picker="where"]')!.textContent).toContain("This Mac"));+ await startJob("Tidy my Downloads folder");await act(async () => {fireEvent.click(await screen.findByRole("button", { name: "Pick another" }));});await screen.findByRole("menuitem", { name: /A new Linux computer on this Mac/ });expect(thisMacConfirmed()).toBe(false);- expect(document.querySelector('[data-picker="where"]')!.textContent).toContain("New Space");+ expect(askTasks()).toHaveLength(0);});it("doesn't ask again once answered on this device", async () => {diff --git a/apps/cua-spaces-web/src/__tests__/first-run-new.test.tsx b/apps/cua-spaces-web/src/__tests__/first-run-new.test.tsxindex 2dc32025fd..e456487200 100644--- a/apps/cua-spaces-web/src/__tests__/first-run-new.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/first-run-new.test.tsx@@ -14,10 +14,10 @@ import { wasmBuilt } from "@/bridge/__tests__/testCore";import type { AgentSetupRow } from "@/bridge/contracts/agents";import { readFirstRun, resetFirstRunCache } from "@/bridge/first-run";import { resetSavedOnboardingCache } from "@/bridge/onboarding";-import { AgentScreen, NextScreen, ReadyScreen, SignInScreen, WhereScreen } from "@/components/first-run-new/first-run-new";+import { AgentScreen, NextScreen, ReadyScreen, SignInScreen, StepDots, WhereScreen } from "@/components/first-run-new/first-run-new";import { placeKeys } from "@/components/first-run-new/float-keys";import { resetConnectedAppsState } from "@/hooks/use-connected-apps";-import { agentView, chosenAgent, nextView, readyView, signInView, togglePick, whereView, type WhereInput } from "@/lib/first-run-new";+import { agentView, chosenAgent, dotStep, nextView, reachedAfter, readyView, signInView, stepDots, togglePick, whereView, type WhereInput } from "@/lib/first-run-new";import { getDriver, resetPrepare } from "@/lib/prepare/store";import { mountApp, stubBrowserApis } from "./app-harness";@@ -145,6 +145,9 @@ describe("screen 2, a long list", () => {expect(footer.className).toContain("sticky");expect(footer.className).toContain("bottom-0");expect(footer.contains(screen.getByRole("button", { name: "Continue" }))).toBe(true);+ // No background of its own (5 Nov: it drew a black box over the stars and cut the keys); the list fades instead.+ expect(footer.className).not.toMatch(/\bbg-|from-\[/);+ expect(footer.contains(document.querySelector("[data-new-run-content]"))).toBe(false);});});@@ -312,6 +315,53 @@ describe("screen 6, next steps", () => {});});+describe("the step dots", () => {+ it("name each step and go back to any earlier one, but forward only to a step already reached", () => {+ const where = stepDots("where", 1)!;+ expect(where.map((d) => d.label)).toEqual(["Step 1 of 3: Bring all your computers under one account", "Step 2 of 3: Pick where your agents work", "Step 3 of 3: Pick your coding agent"]);+ expect(where.map((d) => d.to)).toEqual(["welcome", null, null]);+ expect(where.map((d) => d.current)).toEqual([false, true, false]);+ // Back on screen 1 after reaching screen 3: both later steps open again.+ expect(stepDots("welcome", 2)!.map((d) => d.to)).toEqual([null, "where", "agent"]);+ // On the sign-in, the first dot goes back to its start; nothing past it opens (a dot never skips the sign-in).+ expect(stepDots("signin", 0)!.map((d) => d.to)).toEqual(["welcome", null, null]);+ expect(stepDots("ready", 2)).toBeNull();+ });++ it("count Ready and Next steps as past the last dot, and never go back on how far a run got", () => {+ expect(reachedAfter(0, "signin")).toBe(0);+ expect(reachedAfter(0, "where")).toBe(1);+ expect(reachedAfter(1, "ready")).toBe(2);+ expect(reachedAfter(2, "welcome")).toBe(2);+ });++ it("move with the arrow keys to the nearest step that opens", () => {+ const dots = stepDots("agent", 2)!;+ expect(dotStep(dots, 2, -1)).toBe(1);+ expect(dotStep(dots, 2, 1)).toBeNull();+ expect(dotStep(stepDots("welcome", 0)!, 0, 1)).toBeNull();+ });++ it("are buttons with their step's name: a click or an arrow key opens a step, a step not reached yet can't be pressed", () => {+ const onGo = vi.fn();+ render(<StepDots dots={stepDots("where", 1)!} onGo={onGo} />);+ const first = screen.getByRole("button", { name: "Step 1 of 3: Bring all your computers under one account" });+ const second = screen.getByRole("button", { name: "Step 2 of 3: Pick where your agents work" });+ const third = screen.getByRole("button", { name: "Step 3 of 3: Pick your coding agent" });+ expect(second.getAttribute("aria-current")).toBe("step");+ expect(third.hasAttribute("disabled")).toBe(true);+ fireEvent.click(third);+ expect(onGo).not.toHaveBeenCalled();+ fireEvent.click(first);+ expect(onGo).toHaveBeenLastCalledWith(0, false);+ fireEvent.keyDown(second, { key: "ArrowLeft" });+ expect(onGo).toHaveBeenLastCalledWith(0, true);+ onGo.mockClear();+ fireEvent.keyDown(second, { key: "ArrowRight" });+ expect(onGo).not.toHaveBeenCalled();+ });+});+describe("the keys", () => {it("put the Apple, Windows and Linux marks on the product keys and keep the keys right of the copy", () => {const keys = placeKeys(1366, 982, 544);@@ -416,4 +466,18 @@ describe.skipIf(!wasmBuilt)("the new first run on its route", () => {expect(document.body.textContent).not.toMatch(/local runtime:|exit status/i);expect(screen.getByRole("button", { name: "Continue" }).hasAttribute("disabled")).toBe(false);});++ it("the step dots go back to screen 1 and forward again to screen 2, but never past the sign-in", { timeout: 60_000 }, async () => {+ await mountApp("/onboarding", { failsCreates: false, listsGhost: false, demo: { signedIn: false, onboarded: false, noSpaces: true } });+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));+ // Screen 2 isn't reached yet: its dot can't be pressed, so it can't skip the sign-in.+ expect(screen.getByRole("button", { name: "Step 2 of 3: Pick where your agents work" }).hasAttribute("disabled")).toBe(true);+ click("[data-onboarding-later]");+ await waitFor(() => expect(heading()).toBe("Pick where your agents work"));+ fireEvent.click(screen.getByRole("button", { name: "Step 1 of 3: Bring all your computers under one account" }));+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));+ fireEvent.click(screen.getByRole("button", { name: "Step 2 of 3: Pick where your agents work" }));+ await waitFor(() => expect(heading()).toBe("Pick where your agents work"));+ expect(screen.getByRole("button", { name: "Step 3 of 3: Pick your coding agent" }).hasAttribute("disabled")).toBe(true);+ });});diff --git a/apps/cua-spaces-web/src/__tests__/home-agents.test.tsx b/apps/cua-spaces-web/src/__tests__/home-agents.test.tsxindex bf0715b814..2f083653e8 100644--- a/apps/cua-spaces-web/src/__tests__/home-agents.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/home-agents.test.tsx@@ -15,7 +15,7 @@ import { resetWakeNotes } from "@/components/space-thread/summon";import { resetConnectedAppsState } from "@/hooks/use-connected-apps";import { resetConnectState } from "@/hooks/use-connectors";import { addAskTask, askTasks, resetAskTasks } from "@/lib/ask-first";-import { mountApp, stubBrowserApis } from "./app-harness";+import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";stubBrowserApis();beforeEach(() => {@@ -58,7 +58,9 @@ async function compose(text: string) {}async function start(job: string) {- fireEvent.change(await screen.findByLabelText("What should it do?"), { target: { value: job } });+ await screen.findByLabelText("What should it do?");+ await pickNewLinux();+ fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: job } });await act(async () => {fireEvent.click(screen.getByRole("button", { name: "Start" }));});@@ -132,9 +134,9 @@ describe.skipIf(!wasmBuilt)("Your agents and the Agents page: one list", () => {expect(q("[data-home-spaces] h2")?.textContent).not.toMatch(/\bon\b/);// The Spaces page's tiles.expect(qa("[data-home-spaces] [data-space-id]").length).toBeGreaterThan(0);- // The composer: the agent and its account (the demo has an OpenAI key saved), where as a Space.+ // The composer: the agent and its account (the demo has an OpenAI key saved), and This Mac, already in the account.expect(q("[data-ask-agent]")?.textContent).toBe("OpenAI Codex");- expect(q("[data-ask-where]")?.textContent).toBe("New SpaceLinux on This Mac");+ await waitFor(() => expect(q("[data-ask-where]")?.textContent).toBe("This Mac"));});it("a task whose Space is gone leaves nothing to list: Home is the welcome, not a bare box", async () => {diff --git a/apps/cua-spaces-web/src/__tests__/home-this-mac-target.test.tsx b/apps/cua-spaces-web/src/__tests__/home-this-mac-target.test.tsxnew file mode 100644index 0000000000..405c210972--- /dev/null+++ b/apps/cua-spaces-web/src/__tests__/home-this-mac-target.test.tsx@@ -0,0 +1,75 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++// Home's box starts on this computer once it's in the account (5 Nov 2026), shown as a chip with a+// switcher; when this computer isn't set up yet, the chip says so and offers one Set up.++import { cleanup, screen, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it } from "vitest";++import { setFlagOverride } from "@/bridge";+import { wasmBuilt } from "@/bridge/__tests__/testCore";+import { resetConnectedAppsState } from "@/hooks/use-connected-apps";+import { resetConnectState } from "@/hooks/use-connectors";+import { resetAskTasks } from "@/lib/ask-first";+import { resetPickedAgent } from "@/lib/ask-first-model";+import { resetRepos } from "@/lib/ask-first-repo";+import { mountApp, stubBrowserApis } from "./app-harness";++stubBrowserApis();+beforeEach(() => {+ localStorage.clear();+ resetAskTasks();+ resetPickedAgent();+ resetRepos();+ resetConnectState();+ resetConnectedAppsState();+ setFlagOverride("spaces_ask_first_home", true);+});+afterEach(() => {+ cleanup();+ setFlagOverride("spaces_ask_first_home", null);+});++const q = (s: string) => document.querySelector<HTMLElement>(s);++describe.skipIf(!wasmBuilt)("Home's box, where it runs", () => {+ it("starts on This Mac once it's in the account, as a chip, with no Space made first", { timeout: 30_000 }, async () => {+ await mountApp("/home", { failsCreates: false, listsGhost: false, demo: { noSpaces: true } });+ await screen.findByLabelText("What should it do?");+ await waitFor(() => expect(q("[data-ask-where-chip]")?.dataset.askWhereChip).toBe("this-mac"));+ expect(q("[data-ask-where]")!.textContent).toBe("This Mac");+ expect(q("[data-ask-where-setup]")).toBeNull();+ });++ it("signed in on a Mac that isn't set up yet: the chip says so, with one Set up that sets it up", { timeout: 30_000 }, async () => {+ const calls: string[] = [];+ // This Mac is in the account but doesn't share its desktop yet (what signing in sets up).+ let shared = false;+ await mountApp("/home", {+ failsCreates: false,+ listsGhost: false,+ demo: { noSpaces: true },+ intercept: (op, args) => {+ calls.push(op);+ if (op === "host.action" && (args as { action: string }).action === "share-desktop") shared = true;+ return undefined;+ },+ answer: (op, out) => (op === "host.status" ? { ...(out as object), shareDesktop: shared } : out),+ });+ await screen.findByLabelText("What should it do?");+ await waitFor(() => expect(q("[data-ask-where-chip]")?.dataset.askWhereChip).toBe("needs-setup"));+ expect(q("[data-ask-where]")!.textContent).toContain("not set up for agents yet");+ const setUp = screen.getByRole("button", { name: "Set up This Mac so agents can work on it" });+ setUp.click();+ await waitFor(() => expect(calls).toContain("host.action"), { timeout: 15_000 });+ await waitFor(() => expect(q("[data-ask-where-chip]")?.dataset.askWhereChip).toBe("this-mac"), { timeout: 15_000 });+ expect(calls).not.toContain("spaces.create");+ });++ it("signed out: starts on a new computer, as before", { timeout: 30_000 }, async () => {+ await mountApp("/home", { failsCreates: false, listsGhost: false, demo: { signedIn: false, onboarded: true, noSpaces: true } });+ await screen.findByLabelText("What should it do?");+ await waitFor(() => expect(q("[data-ask-where-chip]")?.dataset.askWhereChip).toBe("new"));+ });+});diff --git a/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx b/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsxindex b33807a00b..f1e6a85cce 100644--- a/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx@@ -16,7 +16,7 @@ import { resetConnectedAppsState } from "@/hooks/use-connected-apps";import { resetAskTasks } from "@/lib/ask-first";import { rememberAgent, resetPickedAgent } from "@/lib/ask-first-model";import { getDriver, resetPrepare } from "@/lib/prepare/store";-import { mountApp, stubBrowserApis } from "./app-harness";+import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";stubBrowserApis();beforeEach(() => {@@ -78,6 +78,7 @@ describe.skipIf(!wasmBuilt)("the warming home is not on any list until a personawait screen.findByLabelText("What should it do?");await waitFor(() => expect(getDriver()?.state?.pendingId).toBeTruthy());expect(getDriver()?.state?.askedMs).toBeNull();+ await pickNewLinux();fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });fireEvent.click(screen.getByRole("button", { name: "Start" }));await waitFor(() => expect(getDriver()?.state?.askedMs).not.toBeNull());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.tsxindex a8026123ed..227e37790a 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@@ -2,7 +2,7 @@// Copyright (c) 2026 Cua AI, Inc.import { Menu as MenuPrimitive } from "@base-ui/react/menu";-import { ArrowUpIcon, CheckIcon, ChevronDownIcon, EllipsisIcon, LaptopIcon, MonitorIcon, SparklesIcon } from "lucide-react";+import { ArrowUpIcon, CheckIcon, ChevronDownIcon, EllipsisIcon, LaptopIcon, LoaderCircleIcon, MonitorIcon, SparklesIcon } from "lucide-react";import { useEffect, useRef, type ReactElement, type ReactNode } from "react";import type { AgentAccount, AgentGroup, AgentsView, Space, SpaceOs } from "@/bridge";@@ -18,6 +18,7 @@ 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";+import { thisMacChipText, type ThisMacReadiness } from "@/lib/this-mac-target";export type { TaskWhere } from "@/lib/ask-first";@@ -102,7 +103,11 @@ function PickerRow({ icon, title, note, selected, onSelect }: { icon: ReactNode;);}-const whereButton = "flex h-9 items-center gap-2 rounded-lg px-2.5 text-[13px] outline-none hover:bg-foreground/5 focus-visible:ring-2 focus-visible:ring-ring/60 data-popup-open:bg-foreground/[0.07]";+/** Where it runs, as a chip like the repo's: the place, then a switcher for your other computers and Spaces. */+const whereChip = "flex h-9 min-w-0 items-center rounded-lg bg-foreground/[0.06]";+const SectionLabel = ({ children }: { children: ReactNode }) => <p className="px-3 pt-3 pb-1 text-[12px] font-medium text-muted-foreground">{children}</p>;++const whereButton = "flex h-9 min-w-0 items-center gap-2 rounded-lg px-2.5 text-[13px] outline-none hover:bg-foreground/[0.05] focus-visible:ring-2 focus-visible:ring-ring/60 data-popup-open:bg-foreground/[0.07]";/*** Home's box, like the first prompt of a chat app: the job in your own words,@@ -127,7 +132,9 @@ export function AskBox({onWhereOpen,kinds,spaces,+ computers = [],machines,+ thisMac = null,agentHome,hasHome,busy,@@ -161,6 +168,10 @@ export function AskBox({kinds: NewKind[];/** Running Spaces to use instead (never this Mac's own desktop: `pickableSpaces`). */spaces: Space[];+ /** Your other computers that are online and share their desktop (`otherComputerDesktops`). */+ computers?: Space[];+ /** How this computer stands as a place to run, and its one Set up action (`useThisMacTarget`). */+ thisMac?: { readiness: ThisMacReadiness; busy: boolean; onSetUp: () => void } | null;/** With agent homes (Child Spaces on): the computers the person can name, this one first. */machines?: NameableMachine[];/** The job goes to the agent's Home Space, which makes the Spaces it needs: no where picker until a place is named. */@@ -179,7 +190,10 @@ export function AskBox({useEffect(() => {if (autoFocus) ref.current?.focus();}, [autoFocus]);- const ready = text.trim().length > 0 && !busy && selected !== null;+ // This computer picked but not set up yet: the chip says so, with Set up; the job can't start on it until then.+ const needsSetUp = where.kind === "this-mac" && thisMac?.readiness === "needs-setup";+ const ready = text.trim().length > 0 && !busy && selected !== null && !needsSetUp;+ const chip = thisMacChipText(thisComputerLabel());const label = whereSpaceLabel(where);// With agent homes the agent decides where, so nothing about it shows until the person names a place: with @ in the// text, or by picking one (the "..." button then shows).@@ -211,38 +225,59 @@ export function AskBox({</span>) : null}{agentHome ? null : (- <WherePicker- where={where}- onWhere={onWhere}- open={whereOpen}- onOpenChange={onWhereOpen}- kinds={kinds}- spaces={spaces}- tree={tree}- trigger={- <button type="button" className={whereButton} data-picker="where">- {treeNode ? (- <TreeIcon node={treeNode} />- ) : where.kind === "new" ? (- <OsIcon os={where.os} className="size-3.5" />- ) : where.kind === "this-mac" ? (- <LaptopIcon className="size-3.5" />- ) : (- <MonitorIcon className="size-3.5" />- )}- <span className="max-w-64 truncate" data-ask-where="">- {treeNode?.name ?? label.title}- {treeNode ? null : label.detail ? <span className="ml-1.5 text-muted-foreground">{label.detail}</span> : null}- {treeNode?.isDefault ? (- <span className="ml-2 text-[13px] text-muted-foreground" data-ask-where-default="">- Default- </span>- ) : null}- </span>- <ChevronDownIcon className="size-3.5 text-muted-foreground" />+ <span className={whereChip} data-ask-where-chip={needsSetUp ? "needs-setup" : where.kind}>+ <WherePicker+ where={where}+ onWhere={onWhere}+ open={whereOpen}+ onOpenChange={onWhereOpen}+ kinds={kinds}+ spaces={spaces}+ computers={computers}+ tree={tree}+ trigger={+ <button type="button" className={whereButton} data-picker="where" aria-label={`Where it runs: ${treeNode?.name ?? label.title}${needsSetUp ? `, ${chip.note}` : ""}`}>+ {treeNode ? (+ <TreeIcon node={treeNode} />+ ) : where.kind === "new" ? (+ <OsIcon os={where.os} className="size-3.5" />+ ) : where.kind === "this-mac" ? (+ <LaptopIcon className="size-3.5" />+ ) : (+ <MonitorIcon className="size-3.5" />+ )}+ <span className="max-w-64 truncate" data-ask-where="">+ {treeNode?.name ?? label.title}+ {treeNode ? null : label.detail ? <span className="ml-1.5 text-muted-foreground">{label.detail}</span> : null}+ {treeNode?.isDefault ? (+ <span className="ml-2 text-[13px] text-muted-foreground" data-ask-where-default="">+ Default+ </span>+ ) : null}+ {needsSetUp ? (+ <span className="ml-1.5 text-muted-foreground" data-ask-where-note="">+ {chip.note}+ </span>+ ) : null}+ </span>+ <ChevronDownIcon className="size-3.5 shrink-0 text-muted-foreground" />+ </button>+ }+ />+ {needsSetUp && thisMac ? (+ <button+ type="button"+ onClick={thisMac.onSetUp}+ disabled={thisMac.busy}+ aria-label={chip.actionLabel}+ className="mr-1 flex h-7 shrink-0 items-center gap-1.5 rounded-lg bg-background px-2.5 text-[12.5px] font-medium shadow-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/60 disabled:opacity-70 dark:bg-white/10 dark:hover:bg-white/15"+ data-ask-where-setup=""+ >+ {thisMac.busy ? <LoaderCircleIcon aria-hidden className="size-3.5 animate-spin motion-reduce:animate-none" /> : null}+ {thisMac.busy ? chip.busy : chip.action}</button>- }- />+ ) : null}+ </span>)}<div className="flex-1" />{agentHome && naming ? (@@ -292,6 +327,7 @@ export function WherePicker({onWhere,kinds,spaces,+ computers = [],machines,agentHome,hasHome,@@ -304,6 +340,8 @@ export function WherePicker({onWhere: (w: TaskWhere) => void;kinds: NewKind[];spaces: Space[];+ /** Your other computers that are online and share their desktop (without agent homes, which name `machines`). */+ computers?: Space[];/** With agent homes: the computers the person can name (other than this one, which has its own row). */machines?: NameableMachine[];/** Leads with "Let the agent decide". */@@ -317,6 +355,47 @@ export function WherePicker({tree?: TreeWhere | null;}) {if (tree) return <TreeWherePicker tw={tree} where={where} onWhere={onWhere} kinds={kinds} trigger={trigger} open={open} onOpenChange={onOpenChange} />;+ const newRows = kinds.map((k) => (+ <PickerRow+ key={k.os}+ icon={+ <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">+ <OsIcon os={k.os} className="size-4" />+ </span>+ }+ 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 })}+ />+ ));+ const thisRow = (+ <PickerRow+ icon={+ <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">+ <LaptopIcon className="size-4" />+ </span>+ }+ title={thisComputerLabel()}+ note="Works on your own files and apps"+ selected={where?.kind === "this-mac"}+ onSelect={() => onWhere({ kind: "this-mac" })}+ />+ );+ const spaceRows = spaces.slice(0, 5).map((s) => (+ <PickerRow+ key={s.id}+ icon={+ <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">+ {s.provider === "local" ? <LaptopIcon className="size-4" /> : <OsIcon os={s.os} className="size-4" />}+ </span>+ }+ title={s.name}+ note="On now"+ selected={where?.kind === "space" && where.space.id === s.id}+ onSelect={() => onWhere({ kind: "space", space: s })}+ />+ ));return (<Picker title="Where it runs" trigger={trigger} footer={agentHome ? `${whereFooter()} ${WHERE_FOOTER_HOME}` : whereFooter()} open={open} onOpenChange={onOpenChange}>{agentHome ? (@@ -345,35 +424,13 @@ export function WherePicker({onSelect={() => onWhere({ kind: "agent", fresh: true })}/>) : null}- {kinds.map((k) => (- <PickerRow- key={k.os}- icon={- <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">- <OsIcon os={k.os} className="size-4" />- </span>- }- 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 })}- />- ))}- <p className="px-3 pt-3 pb-1 text-[12px] font-medium text-muted-foreground">Or use a computer you already have</p>- <PickerRow- icon={- <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">- <LaptopIcon className="size-4" />- </span>- }- title={thisComputerLabel()}- note="Works on your own files and apps"- selected={where?.kind === "this-mac"}- onSelect={() => onWhere({ kind: "this-mac" })}- />- {agentHome && machines?.some((m) => !m.current) ? <p className="px-3 pt-3 pb-1 text-[12px] font-medium text-muted-foreground">Your computers</p> : null}- {agentHome- ? machines+ {agentHome ? (+ <>+ {newRows}+ <SectionLabel>Or use a computer you already have</SectionLabel>+ {thisRow}+ {machines?.some((m) => !m.current) ? <SectionLabel>Your computers</SectionLabel> : null}+ {machines?.filter((m) => !m.current).slice(0, 5).map((m) => (@@ -389,22 +446,34 @@ export function WherePicker({selected={where?.kind === "machine" && where.machine.id === m.id}onSelect={() => onWhere({ kind: "machine", machine: { id: m.id, name: m.name } })}/>- ))- : null}- {spaces.slice(0, 5).map((s) => (- <PickerRow- key={s.id}- icon={- <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">- {s.provider === "local" ? <LaptopIcon className="size-4" /> : <OsIcon os={s.os} className="size-4" />}- </span>- }- title={s.name}- note="On now"- selected={where?.kind === "space" && where.space.id === s.id}- onSelect={() => onWhere({ kind: "space", space: s })}- />- ))}+ ))}+ {spaceRows}+ </>+ ) : (+ <>+ {/* This computer already counts: your computers first, then your Spaces; a new computer is optional. */}+ <SectionLabel>Your computers</SectionLabel>+ {thisRow}+ {computers.slice(0, 5).map((c) => (+ <PickerRow+ key={c.id}+ icon={+ <span className="flex size-7 items-center justify-center rounded-lg bg-muted text-muted-foreground">+ <OsIcon os={c.os} className="size-4" />+ </span>+ }+ title={c.name}+ note="Online"+ selected={where?.kind === "space" && where.space.id === c.id}+ onSelect={() => onWhere({ kind: "space", space: c })}+ />+ ))}+ {spaces.length > 0 ? <SectionLabel>Your Spaces</SectionLabel> : null}+ {spaceRows}+ <SectionLabel>Or make a new computer</SectionLabel>+ {newRows}+ </>+ )}</Picker>);}diff --git a/apps/cua-spaces-web/src/components/ask-first/home.tsx b/apps/cua-spaces-web/src/components/ask-first/home.tsxindex 7cd48222cc..cc4d11bc9f 100644--- a/apps/cua-spaces-web/src/components/ask-first/home.tsx+++ b/apps/cua-spaces-web/src/components/ask-first/home.tsx@@ -27,7 +27,9 @@ import { useKeepHomeWarm } from "./use-keep-home-warm";import { YourAgents, YourSpaces as YourSpacesRow } from "./home-sections";import { useWherePick } from "./this-mac-confirm";import { useStartTask } from "./use-start-task";+import { useThisMacTarget } from "./use-this-mac-target";import { useWhereOptions } from "./where-options";+import { homeDefaultWhere } from "@/lib/this-mac-target";import { FallbackLine, useTreeWhere } from "./tree-where";import { currentTreeWhere } from "@/lib/default-where";import { PrepareLine } from "@/components/prepare/prepare-line";@@ -58,7 +60,9 @@ export function AskFirstHome() {const tasks = useAskTasks();const { data: spaces } = useSpaces();const listed = useListedSpaces(spaces);- const { kinds, spaces: pickable } = useWhereOptions();+ const { kinds, spaces: pickable, computers } = useWhereOptions();+ // This computer, once it's in the account, is where a job goes unless you pick (no Space needed first).+ const thisMac = useThisMacTarget();const { start } = useStartTask();const { core } = useBridge();// The agent: the last app, account and model picked while they are still there, else the first connected app. The@@ -82,7 +86,8 @@ export function AskFirstHome() {const machines = useMemo(() => (machineRows ?? []).map((m) => ({ id: m.id, name: m.name, current: m.current, online: m.online })), [machineRows]);useKeepHomeWarm(chosenAgent, agentHome);const readiness = useAgentReadiness(chosenAgent, agentHome, agents, selected);- // A new Linux computer unless you pick; a pick that's no longer offered falls back to it.+ // This computer once it's in the account, else a new Linux computer, unless you pick; a pick that's no longer+ // offered falls back to it.const [pickedWhere, setWhere] = useState<TaskWhere | null>(null);// The first Space being prepared since launch (Labs, the new setup): silent unless it fails.const prep = usePrepare();@@ -93,11 +98,12 @@ export function AskFirstHome() {// With agent homes the agent decides where, so the tree's default doesn't apply.const treeWhere = useTreeWhere();const tw = agentHome ? null : treeWhere;- const where = tw ? currentTreeWhere(pickedWhere, tw.def.where, kinds, tw.tree) : currentWhere(pickedWhere ?? (agentHome ? { kind: "agent" } : null), kinds, pickable);+ const where = tw ? currentTreeWhere(pickedWhere, tw.def.where, kinds, tw.tree) : currentWhere(pickedWhere ?? (agentHome ? { kind: "agent" } : homeDefaultWhere(thisMac.readiness, kinds)), kinds, [...pickable, ...computers]);const submit = (prompt = text, w = where) => {if (!prompt.trim() || !selected) return;// The default can be This Mac itself: it asks once, as picking it does.- if (tw && w.kind === "this-mac" && !thisMacConfirmed()) {+ if (w.kind === "this-mac" && thisMac.readiness === "needs-setup") return;+ if (w.kind === "this-mac" && !thisMacConfirmed()) {pick.choose(w, (ok) => submit(prompt, ok), () => setWhereOpen(true));return;}@@ -149,6 +155,8 @@ export function AskFirstHome() {onWhereOpen={setWhereOpen}kinds={kinds}spaces={pickable}+ computers={computers}+ thisMac={{ readiness: thisMac.readiness, busy: thisMac.busy, onSetUp: thisMac.setUp }}machines={machines}agentHome={agentHome}hasHome={agentHome && reusableHome(chosenAgent, spaces, false, children?.homesOf(chosenAgent)) !== null}diff --git a/apps/cua-spaces-web/src/components/ask-first/use-this-mac-target.ts b/apps/cua-spaces-web/src/components/ask-first/use-this-mac-target.tsnew file mode 100644index 0000000000..07f9ef1357--- /dev/null+++ b/apps/cua-spaces-web/src/components/ask-first/use-this-mac-target.ts@@ -0,0 +1,81 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { useCallback, useContext, useEffect, useRef, useState } from "react";++import { useMachines, useSession } from "@/bridge";+import { BridgeContext } from "@/bridge/BridgeProvider";+import type { HostStatus } from "@/bridge/contracts/host";+import { toastError } from "@/components/ui/toast";+import { thisComputerLabel } from "@/lib/host-labels";+import { thisMacReadiness, thisMacSetupSteps, type ThisMacReadiness } from "@/lib/this-mac-target";++export interface ThisMacTarget {+ readiness: ThisMacReadiness;+ /** Set up is running. */+ busy: boolean;+ /** Adds this computer to the account if needed and shares its desktop, so a job can start on it. */+ setUp: () => void;+}++/**+ * How this computer stands as a place for Home's jobs (`thisMacReadiness`), read from its host service+ * when Home opens, when the window comes back, and whenever the account's computers change, plus the+ * one Set up action the box's chip offers when it isn't ready.+ */+export function useThisMacTarget(): ThisMacTarget {+ const ctx = useContext(BridgeContext);+ const adapter = ctx?.adapter ?? null;+ const store = ctx?.store ?? null;+ const session = useSession();+ const signedIn = Boolean(session.data?.signedIn);+ const identity = session.data?.identity ?? null;+ const machines = useMachines();+ const [status, setStatus] = useState<HostStatus | null | undefined>(undefined);+ const [busy, setBusy] = useState(false);+ const live = useRef(true);++ const read = useCallback(async (): Promise<HostStatus | null> => {+ if (!adapter) return null;+ const s = await adapter.call("host.status", {}).catch(() => null);+ if (live.current) setStatus(s);+ return s;+ }, [adapter]);++ useEffect(() => {+ live.current = true;+ return () => {+ live.current = false;+ };+ }, []);++ useEffect(() => {+ if (!signedIn) return;+ void read();+ const again = () => void read();+ window.addEventListener("focus", again);+ return () => window.removeEventListener("focus", again);+ }, [signedIn, read, machines.data]);++ const setUp = () => {+ if (!adapter || busy) return;+ setBusy(true);+ void (async () => {+ try {+ for (const step of thisMacSetupSteps(await read())) {+ if (step === "add") {+ if (!(await (store?.addThisComputer(identity) ?? Promise.resolve(false)))) throw new Error(store?.thisMachine.get().setupError?.message ?? `${thisComputerLabel()} couldn't be added to your account.`);+ } else await adapter.call("host.action", { action: step });+ }+ } catch (e) {+ toastError(`Couldn't set up ${thisComputerLabel()}`)(e);+ } finally {+ await read();+ void machines.refresh().catch(() => {});+ if (live.current) setBusy(false);+ }+ })();+ };++ return { readiness: thisMacReadiness(signedIn, status), busy, setUp };+}diff --git a/apps/cua-spaces-web/src/components/ask-first/where-options.ts b/apps/cua-spaces-web/src/components/ask-first/where-options.tsindex 2c5c3ef378..8bb0dad634 100644--- a/apps/cua-spaces-web/src/components/ask-first/where-options.ts+++ b/apps/cua-spaces-web/src/components/ask-first/where-options.ts@@ -3,13 +3,17 @@import { useMemo } from "react";-import { useBridge, useFirstSpaceOffers, useSpaces, type Space } from "@/bridge";+import { useBridge, useFirstSpaceOffers, useMachines, useSpaces, type Space } from "@/bridge";import { useHiddenSpaceIds } from "@/lib/prepare/store";-import { pickableSpaces, type NewKind } from "@/lib/ask-first";+import { otherComputerDesktops, pickableSpaces, type NewKind } from "@/lib/ask-first";-/** What "Where it runs" offers: the kinds of new computer this Mac can make, and the running Spaces you have. */-export function useWhereOptions(): { kinds: NewKind[]; spaces: Space[] } {+/**+ * What "Where it runs" offers: the kinds of new computer this Mac can make, the running Spaces you have,+ * and your other computers that are online and share their desktop.+ */+export function useWhereOptions(): { kinds: NewKind[]; spaces: Space[]; computers: Space[] } {const { data } = useSpaces();+ const { data: machines } = useMachines();const { offers } = useFirstSpaceOffers();const kinds = useMemo<NewKind[]>(() => {const k = offers.map((o) => ({ os: o.os, note: `Free. Ready in ${o.time}${o.size ? ` (${o.size})` : ""}.`, blocked: o.blocked }));@@ -18,5 +22,7 @@ export function useWhereOptions(): { kinds: NewKind[]; spaces: Space[] } {const { core } = useBridge();const warming = useHiddenSpaceIds(core);const spaces = useMemo(() => pickableSpaces(data?.filter((s) => !warming.has(s.id))), [data, warming]);- return { kinds, spaces };+ const here = machines?.find((m) => m.current)?.id ?? null;+ const computers = useMemo(() => otherComputerDesktops(data, here), [data, here]);+ return { kinds, spaces, computers };}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.tsxindex 6f553d50e1..87cd0b3eb1 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@@ -11,7 +11,7 @@import { useNavigate } from "@tanstack/react-router";import { CheckIcon, ChevronRightIcon, CopyIcon, LoaderCircleIcon, MonitorIcon, PlusIcon, ShieldIcon, UserPlusIcon } from "lucide-react";-import { useContext, useEffect, useMemo, useRef, useState, type ReactNode } from "react";+import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";import { folderLabel, newPendingId, useMachines, useSession, useSettings, useSpaces, type SignInPhase } from "@/bridge";import { BridgeContext } from "@/bridge/BridgeProvider";@@ -29,13 +29,15 @@ import { addImportedTask, type AskTask } from "@/lib/ask-first";import {agentView,chosenAgent,- dotFor,+ dotStep,INSTALL_PAGES,NEW_RUN_EMPTY,nextView,placeName,+ reachedAfter,readyView,signInView,+ stepDots,togglePick,WELCOME,whereView,@@ -45,6 +47,7 @@ import {type NextView,type ReadyView,type SignInView,+ type StepDot,type WhereView,} from "@/lib/first-run-new";import { spaceState } from "@/lib/spaces";@@ -132,6 +135,89 @@ function Row({ icon, name, sub, picked, disabled, onClick, extra, check = true,const Divider = () => <div className="mx-3 my-1.5 h-px bg-white/[0.14]" />;const Label = ({ children }: { children: ReactNode }) => <div className={cn("px-3 pt-3 pb-1 text-[12.5px] font-semibold tracking-[0.02em]", GREY)}>{children}</div>;+/** How far above the footer the list fades out. */+const FADE_PX = 28;++/**+ * Fades `content` out just above `footer` while the window is too short for both, so the list never runs+ * under Continue. A mask on the content, never a background on the footer: nothing covers the stars or keys.+ */+function useFadeUnder(content: RefObject<HTMLElement | null>, footer: RefObject<HTMLElement | null>) {+ useLayoutEffect(() => {+ const c = content.current;+ const f = footer.current;+ if (!c || !f) return;+ const scroller = c.closest("main") ?? c.parentElement;+ let frame = 0;+ const update = () => {+ frame = 0;+ const box = c.getBoundingClientRect();+ const cut = f.getBoundingClientRect().top - box.top;+ const under = box.height > 0 && cut < box.height - 1;+ const mask = under ? `linear-gradient(to bottom, #000 ${Math.max(0, cut - FADE_PX)}px, transparent ${Math.max(0, cut)}px)` : "";+ c.style.setProperty("mask-image", mask);+ c.style.setProperty("-webkit-mask-image", mask);+ if (under) c.dataset.faded = "";+ else delete c.dataset.faded;+ };+ const schedule = () => {+ if (!frame) frame = requestAnimationFrame(update);+ };+ update();+ scroller?.addEventListener("scroll", schedule, { passive: true });+ window.addEventListener("resize", schedule);+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);+ ro?.observe(c);+ if (scroller) ro?.observe(scroller);+ return () => {+ if (frame) cancelAnimationFrame(frame);+ scroller?.removeEventListener("scroll", schedule);+ window.removeEventListener("resize", schedule);+ ro?.disconnect();+ };+ }, [content, footer]);+}++/**+ * The step dots under the page. Each is a button: it opens an earlier step, or a later one already reached+ * (never one past the sign-in). The left and right arrow keys move between the steps that can be opened.+ */+export function StepDots({ dots, onGo }: { dots: StepDot[]; onGo: (i: number, viaKey: boolean) => void }) {+ return (+ <nav aria-label="Setup steps" className="relative z-20 shrink-0 pb-3.5 pl-[60px]" data-new-run-dots="">+ <ol className="flex">+ {dots.map((d, i) => (+ <li key={i}>+ <button+ type="button"+ aria-label={d.label}+ aria-current={d.current ? "step" : undefined}+ disabled={!d.to && !d.current}+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages+ className="group flex h-6 items-center rounded-full px-1 outline-none focus-visible:ring-2 focus-visible:ring-[#5ec0e8] enabled:cursor-pointer disabled:cursor-default"+ onClick={() => d.to && onGo(i, false)}+ onKeyDown={(e) => {+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;+ e.preventDefault();+ const to = dotStep(dots, i, e.key === "ArrowLeft" ? -1 : 1);+ if (to !== null) onGo(to, true);+ }}+ data-step-dot={i}+ >+ <span+ className={cn(+ "block h-1 w-7 rounded-full transition-colors motion-reduce:transition-none",+ d.current ? "bg-white" : d.to ? "bg-white/30 group-hover:bg-white/70" : "bg-white/[0.14]",+ )}+ />+ </button>+ </li>+ ))}+ </ol>+ </nav>+ );+}+/* ---- The screens (drawn from their views, so tests draw every state) --------------------- */export function WelcomeScreen({ onAdd }: { onAdd: () => void }) {@@ -204,128 +290,134 @@ export function WhereScreen({const sep = view.separate;const fold = view.offlineFold;const [showOffline, setShowOffline] = useState(false);+ const content = useRef<HTMLDivElement>(null);+ const footer = useRef<HTMLDivElement>(null);+ useFadeUnder(content, footer);const other = (o: ComputerRow) => <Row key={o.id} icon={<Mark os={o.os} />} name={o.name} sub={o.sub} picked={o.picked} disabled={o.disabled} onClick={() => onToggle(o.id)} data-new-run-computer={o.id} data-offline={o.disabled ? "" : undefined} />;return (<div data-new-run="where">- <Title>{view.title}</Title>- <Line>{view.line}</Line>- <div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-computers="">- <Row- icon={<Mark os={hostOs()} />}- name={t.name}- sub={+ <div ref={content} data-new-run-content="">+ <Title>{view.title}</Title>+ <Line>{view.line}</Line>+ <div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-computers="">+ <Row+ icon={<Mark os={hostOs()} />}+ name={t.name}+ sub={+ <>+ {t.model && t.modelFirst ? <span>{t.model} ·</span> : null}+ {t.tick ? <CheckIcon aria-hidden className="size-[13px] text-white" strokeWidth={2.6} /> : null}+ <span className={t.tick ? "text-white" : undefined} data-new-run-this-status="">+ {t.status}+ </span>+ {t.model && !t.modelFirst ? <span>· {t.model}</span> : null}+ </>+ }+ picked={t.picked}+ onClick={() => onToggle("this")}+ extra={+ t.action ? (+ <button+ type="button"+ className={cn(GLASS_CHIP, "mr-1 h-[30px] px-3.5 text-[13.5px]")}+ onClick={(e) => {+ e.stopPropagation();+ onAddThis();+ }}+ data-new-run-add-this={t.action.id}+ >+ {t.action.label}+ </button>+ ) : null+ }+ data-new-run-computer="this"+ />+ {view.others ? (<>- {t.model && t.modelFirst ? <span>{t.model} ·</span> : null}- {t.tick ? <CheckIcon aria-hidden className="size-[13px] text-white" strokeWidth={2.6} /> : null}- <span className={t.tick ? "text-white" : undefined} data-new-run-this-status="">- {t.status}- </span>- {t.model && !t.modelFirst ? <span>· {t.model}</span> : null}+ <Label>{view.othersLabel}</Label>+ {view.others.length ? (+ <>+ {(fold ? view.others.filter((o) => !o.offline) : view.others).map(other)}+ {fold ? (+ <>+ <button+ type="button"+ aria-expanded={showOffline}+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages+ className="flex w-full items-center gap-3 rounded-[14px] px-3 py-[7px] text-left outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]"+ onClick={() => setShowOffline((v) => !v)}+ data-new-run-offline-fold={fold.rows.length}+ >+ <span className="flex size-7 shrink-0 items-center justify-center text-white">+ <ChevronRightIcon className={cn("size-4 transition-transform motion-reduce:transition-none", showOffline && "rotate-90")} strokeWidth={2.2} />+ </span>+ <span className="min-w-0 flex-1">+ <span className="block text-[15px] leading-5 font-medium text-white">{fold.label}</span>+ <span className={cn("block text-[13.5px] leading-[19px] font-medium", GREY)}>{fold.sub}</span>+ </span>+ </button>+ {showOffline ? fold.rows.map(other) : null}+ </>+ ) : null}+ </>+ ) : (+ <p className={cn("px-3 pt-1 pb-2 text-[13.5px] leading-[19px] font-medium", GREY)} data-new-run-none="">+ {view.emptyLine}+ </p>+ )}</>- }- picked={t.picked}- onClick={() => onToggle("this")}- extra={- t.action ? (- <button- type="button"- className={cn(GLASS_CHIP, "mr-1 h-[30px] px-3.5 text-[13.5px]")}- onClick={(e) => {- e.stopPropagation();- onAddThis();- }}- data-new-run-add-this={t.action.id}- >- {t.action.label}+ ) : null}+ {view.addAnother ? (+ <>+ <Divider />+ {/* design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages */}+ <button type="button" className="flex w-full items-center gap-3 rounded-[14px] px-3 py-2 text-left outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]" onClick={onAddAnother} data-new-run-add-another="">+ <span className="flex size-7 shrink-0 items-center justify-center rounded-full text-white shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)]">+ <PlusIcon className="size-4" strokeWidth={2.2} />+ </span>+ <span className="min-w-0 flex-1">+ <span className="block text-[15px] leading-5 font-medium text-white">{view.addAnother.title}</span>+ <span className={cn("block text-[13.5px] leading-[19px] font-medium", GREY)}>{view.addAnother.sub}</span>+ </span></button>- ) : null- }- data-new-run-computer="this"- />- {view.others ? (- <>- <Label>{view.othersLabel}</Label>- {view.others.length ? (- <>- {(fold ? view.others.filter((o) => !o.offline) : view.others).map(other)}- {fold ? (- <>- <button- type="button"- aria-expanded={showOffline}- // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages- className="flex w-full items-center gap-3 rounded-[14px] px-3 py-[7px] text-left outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]"- onClick={() => setShowOffline((v) => !v)}- data-new-run-offline-fold={fold.rows.length}- >- <span className="flex size-7 shrink-0 items-center justify-center text-white">- <ChevronRightIcon className={cn("size-4 transition-transform motion-reduce:transition-none", showOffline && "rotate-90")} strokeWidth={2.2} />- </span>- <span className="min-w-0 flex-1">- <span className="block text-[15px] leading-5 font-medium text-white">{fold.label}</span>- <span className={cn("block text-[13.5px] leading-[19px] font-medium", GREY)}>{fold.sub}</span>- </span>- </button>- {showOffline ? fold.rows.map(other) : null}- </>- ) : null}- </>- ) : (- <p className={cn("px-3 pt-1 pb-2 text-[13.5px] leading-[19px] font-medium", GREY)} data-new-run-none="">- {view.emptyLine}+ </>+ ) : null}+ {view.signInLine ? (+ <>+ <Divider />+ <p className={cn("px-3 pt-2.5 pb-3 text-[14px] leading-5 font-medium", GREY)} data-new-run-sign-in-line="">+ <button type="button" className={LINK} onClick={onSignIn}>+ {view.signInLine.link}+ </button>+ {view.signInLine.rest}</p>+ </>+ ) : null}+ </div>+ <div className="mt-[min(18px,2vh)] max-w-[480px] px-[18px]" data-new-run-separate={sep.state} data-disabled={sep.disabled ? "" : undefined}>+ <div className={cn("flex items-center gap-2 text-[14px] leading-5 font-semibold", sep.disabled ? GREY : "text-white")}>+ <OsMark os="linux" className="h-[15px] w-4 shrink-0" />+ {sep.disabled || sep.state !== "offer" ? (+ <span>{sep.title}</span>+ ) : (+ <button type="button" className={LINK} onClick={onSeparate} data-new-run-separate-open="">+ {sep.title}+ </button>)}- </>- ) : null}- {view.addAnother ? (- <>- <Divider />- {/* design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages */}- <button type="button" className="flex w-full items-center gap-3 rounded-[14px] px-3 py-2 text-left outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]" onClick={onAddAnother} data-new-run-add-another="">- <span className="flex size-7 shrink-0 items-center justify-center rounded-full text-white shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)]">- <PlusIcon className="size-4" strokeWidth={2.2} />- </span>- <span className="min-w-0 flex-1">- <span className="block text-[15px] leading-5 font-medium text-white">{view.addAnother.title}</span>- <span className={cn("block text-[13.5px] leading-[19px] font-medium", GREY)}>{view.addAnother.sub}</span>- </span>- </button>- </>- ) : null}- {view.signInLine ? (- <>- <Divider />- <p className={cn("px-3 pt-2.5 pb-3 text-[14px] leading-5 font-medium", GREY)} data-new-run-sign-in-line="">- <button type="button" className={LINK} onClick={onSignIn}>- {view.signInLine.link}+ </div>+ <p className={cn("mt-[3px] pl-6 text-[13.5px] leading-[19px] font-medium", GREY)}>{sep.sub}</p>+ {sep.action ? (+ <div className="mt-2 pl-6">+ <button type="button" className={cn(GLASS_CHIP, "h-[30px] px-3.5 text-[13.5px]")} onClick={onSeparate} data-new-run-separate-action="">+ {sep.action}</button>- {view.signInLine.rest}- </p>- </>- ) : null}- </div>- <div className="mt-[min(18px,2vh)] max-w-[480px] px-[18px]" data-new-run-separate={sep.state} data-disabled={sep.disabled ? "" : undefined}>- <div className={cn("flex items-center gap-2 text-[14px] leading-5 font-semibold", sep.disabled ? GREY : "text-white")}>- <OsMark os="linux" className="h-[15px] w-4 shrink-0" />- {sep.disabled || sep.state !== "offer" ? (- <span>{sep.title}</span>- ) : (- <button type="button" className={LINK} onClick={onSeparate} data-new-run-separate-open="">- {sep.title}- </button>- )}+ </div>+ ) : null}</div>- <p className={cn("mt-[3px] pl-6 text-[13.5px] leading-[19px] font-medium", GREY)}>{sep.sub}</p>- {sep.action ? (- <div className="mt-2 pl-6">- <button type="button" className={cn(GLASS_CHIP, "h-[30px] px-3.5 text-[13.5px]")} onClick={onSeparate} data-new-run-separate-action="">- {sep.action}- </button>- </div>- ) : null}</div>- {/* Stays in view at the bottom of the window however long the list is; the fade keeps the list readable under it. */}- <div className="sticky bottom-0 z-10 -mx-4 mt-2 bg-linear-to-t from-[#050607] from-60% to-transparent px-4 pt-[min(20px,2.2vh)] pb-3" data-new-run-footer="">+ {/* Stays in view at the bottom of the window however long the list is. It has no background of its own, so the+ stars and keys show through; the list fades out just above it instead (`useFadeUnder`). */}+ <div ref={footer} className="sticky bottom-0 z-10 mt-2 pt-[min(20px,2.2vh)] pb-3" data-new-run-footer=""><button type="button" className={WHITE_BUTTON} disabled={!view.continueEnabled} onClick={onContinue} data-onboarding-primary="">Continue</button>@@ -544,7 +636,11 @@ export function NewFirstRun() {const offers = useFirstSpaceOffers();const savedAll = useFirstRunSaved();const s: NewRunSaved = { ...NEW_RUN_EMPTY, ...(savedAll.newRun ?? {}) };- const save = (patch: Partial<NewRunSaved>) => writeFirstRun({ newRun: { ...NEW_RUN_EMPTY, ...(readFirstRun().newRun ?? {}), ...patch } });+ const save = (patch: Partial<NewRunSaved>) => {+ const prev = { ...NEW_RUN_EMPTY, ...(readFirstRun().newRun ?? {}) };+ const reached = patch.screen ? reachedAfter(reachedAfter(prev.reached, prev.screen), patch.screen) : prev.reached;+ writeFirstRun({ newRun: { ...prev, ...patch, reached } });+ };const go = (screen: NewRunScreenName) => save({ screen });const signedIn = Boolean(session.data?.signedIn);@@ -561,9 +657,14 @@ export function NewFirstRun() {const [appsOpen, setAppsOpen] = useState(false);const [host, setHost] = useState<HostStatus | null>(null);- // A new screen: focus moves to its title, so a screen reader reads it.+ // A new screen: focus moves to its title, so a screen reader reads it. Moved with the arrow keys on the+ // step dots, focus stays on the dots instead.+ const dotFocus = useRef<number | null>(null);useEffect(() => {- document.querySelector<HTMLElement>("[data-onboarding-heading]")?.focus();+ const keep = dotFocus.current;+ dotFocus.current = null;+ const el = keep !== null ? document.querySelector<HTMLElement>(`[data-step-dot="${keep}"]`) : document.querySelector<HTMLElement>("[data-onboarding-heading]");+ el?.focus();}, [s.screen]);// Sign-in: started when 1b opens, and over once the session says signed in.@@ -790,7 +891,14 @@ export function NewFirstRun() {};const accountUrl = settings.data?.accountUrl ?? "https://app.cua.ai";- const dot = dotFor(s.screen);+ const dots = stepDots(s.screen, reachedAfter(s.reached, s.screen));+ const goDot = (i: number, viaKey: boolean) => {+ const to = dots?.[i]?.to;+ if (!to) return;+ if (s.screen === "signin") session.cancelSignIn();+ if (viaKey) dotFocus.current = i;+ go(to);+ };const showSkip = s.screen === "welcome" || s.screen === "signin" || s.screen === "where" || s.screen === "agent";let body: ReactNode = null;@@ -890,12 +998,8 @@ export function NewFirstRun() {<div className="flex w-full max-w-[600px] shrink-0 flex-col py-2">{body}</div><div aria-hidden className="min-h-2 shrink-0 grow-[1.4] basis-0" /></main>- {dot !== null ? (- <ol className="relative z-20 flex shrink-0 gap-2 pt-2 pb-6 pl-16" aria-label={`Step ${dot + 1} of 3`}>- {[0, 1, 2].map((i) => (- <li key={i} aria-current={i === dot ? "step" : undefined} className={cn("h-1 w-7 rounded-full", i === dot ? "bg-white" : "bg-white/30")} />- ))}- </ol>+ {dots ? (+ <StepDots dots={dots} onGo={goDot} />) : (<div className="h-8 shrink-0" />)}diff --git a/apps/cua-spaces-web/src/lib/ask-first.ts b/apps/cua-spaces-web/src/lib/ask-first.tsindex cde84f3aca..7f597c19f8 100644--- a/apps/cua-spaces-web/src/lib/ask-first.ts+++ b/apps/cua-spaces-web/src/lib/ask-first.ts@@ -308,6 +308,13 @@ export function pickableSpaces(spaces: readonly Space[] | undefined): Space[] {return orderSpaces((spaces ?? []).filter((s) => !isMachineDesktop(s) && spaceState(s) === "running"));}+/** Your other computers whose desktops are online to run a job on: never this computer's own (`this-mac` is its row). */+export function otherComputerDesktops(spaces: readonly Space[] | undefined, thisMachineId: string | null): Space[] {+ return (spaces ?? []).filter(+ (s) => isMachineDesktop(s) && s.id !== THIS_MAC_ID && s.status !== "local" && s.id !== `relay:${thisMachineId}` && s.status === "running" && spaceState(s) === "running",+ );+}+/** Where a job runs unless you pick: a new Linux computer on this Mac (or the first kind this Mac can make). */export function defaultWhere(kinds: readonly NewKind[]): TaskWhere {const ok = kinds.filter((k) => !k.blocked);diff --git a/apps/cua-spaces-web/src/lib/first-run-new.ts b/apps/cua-spaces-web/src/lib/first-run-new.tsindex db3cb26b12..1bc0a5f829 100644--- a/apps/cua-spaces-web/src/lib/first-run-new.ts+++ b/apps/cua-spaces-web/src/lib/first-run-new.ts@@ -33,9 +33,11 @@ export interface NewRunSaved {addedInRun: boolean;/** The separate computer's create (its pending row id), once asked for. */separatePendingId: string | null;+ /** The furthest step dot reached (0 to 2), so a dot can go forward again only to a step already reached. */+ reached: number;}-export const NEW_RUN_EMPTY: NewRunSaved = { screen: "welcome", picks: ["this"], agent: null, addedInRun: false, separatePendingId: null };+export const NEW_RUN_EMPTY: NewRunSaved = { screen: "welcome", picks: ["this"], agent: null, addedInRun: false, separatePendingId: null, reached: 0 };/** "this Mac", "this PC", "this machine" (the app's THIS_MACHINE). */export function placeName(os: string): string {@@ -437,3 +439,41 @@ export function nextView(input: { os: string }): NextView {export function dotFor(screen: NewRunScreen): number | null {return screen === "welcome" || screen === "signin" ? 0 : screen === "where" ? 1 : screen === "agent" ? 2 : null;}++/** The screen each step dot opens. */+export const DOT_SCREENS = ["welcome", "where", "agent"] as const satisfies readonly NewRunScreen[];++/** Each step's name, read out with its dot ("Step 2 of 3: Pick where your agents work"). */+export const DOT_NAMES = [WELCOME.title, "Pick where your agents work", "Pick your coding agent"] as const;++/** How far a run has got, once it's on `screen`: Ready and Next steps count as past the last dot. */+export function reachedAfter(reached: number, screen: NewRunScreen): number {+ return Math.max(reached, dotFor(screen) ?? DOT_SCREENS.length - 1);+}++export interface StepDot {+ /** "Step 2 of 3: Pick where your agents work". */+ label: string;+ current: boolean;+ /** The screen a click opens; null: it can't be opened from here (a step not reached yet, or the one showing). */+ to: NewRunScreen | null;+}++/**+ * The step dots on `screen`. A dot opens any earlier step, and a later step only once the run has+ * reached it, so a dot never skips the sign-in. On the sign-in, the first dot goes back to its start.+ */+export function stepDots(screen: NewRunScreen, reached: number): StepDot[] | null {+ const at = dotFor(screen);+ if (at === null) return null;+ return DOT_SCREENS.map((to, i) => {+ const open = to !== screen && (i <= at || i <= reached);+ return { label: `Step ${i + 1} of ${DOT_SCREENS.length}: ${DOT_NAMES[i]}`, current: i === at, to: open ? to : null };+ });+}++/** The step an arrow key moves to from the dot at `from`: the nearest one in that direction that can be opened. */+export function dotStep(dots: readonly StepDot[], from: number, dir: -1 | 1): number | null {+ for (let i = from + dir; i >= 0 && i < dots.length; i += dir) if (dots[i]!.to) return i;+ return null;+}diff --git a/apps/cua-spaces-web/src/lib/this-mac-target.test.ts b/apps/cua-spaces-web/src/lib/this-mac-target.test.tsnew file mode 100644index 0000000000..5b5ac314d7--- /dev/null+++ b/apps/cua-spaces-web/src/lib/this-mac-target.test.ts@@ -0,0 +1,63 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { describe, expect, it } from "vitest";++import type { HostStatus } from "@/bridge/contracts/host";++import { otherComputerDesktops, type NewKind } from "./ask-first";+import { homeDefaultWhere, thisMacReadiness, thisMacSetupSteps } from "./this-mac-target";++const host = (over: Partial<HostStatus> = {}): HostStatus => ({+ configured: true,+ mode: "relay",+ machineId: "m-here",+ sharing: true,+ shareDesktop: true,+ service: { installed: true, running: true, kind: "launchd" },+ clients: [],+ permissions: [],+ ...over,+});+const kinds: NewKind[] = [{ os: "linux", note: "Free. Ready in 2 min.", blocked: null }];++describe("Home's box starts on this computer", () => {+ it("once it's in the account, with no Space made first", () => {+ expect(homeDefaultWhere(thisMacReadiness(true, host()), kinds)).toEqual({ kind: "this-mac" });+ // Still being read, or not set up yet: still this computer, and the chip says what's missing.+ expect(homeDefaultWhere(thisMacReadiness(true, undefined), kinds)).toEqual({ kind: "this-mac" });+ expect(homeDefaultWhere(thisMacReadiness(true, host({ configured: false })), kinds)).toEqual({ kind: "this-mac" });+ });++ it("signed out, starts on a new computer as before", () => {+ expect(thisMacReadiness(false, host())).toBe("signed-out");+ expect(homeDefaultWhere("signed-out", kinds)).toEqual({ kind: "new", os: "linux" });+ });++ it("is ready only when it's set up and shares its desktop", () => {+ expect(thisMacReadiness(true, host())).toBe("ready");+ expect(thisMacReadiness(true, undefined)).toBe("checking");+ expect(thisMacReadiness(true, null)).toBe("needs-setup");+ expect(thisMacReadiness(true, host({ configured: false }))).toBe("needs-setup");+ expect(thisMacReadiness(true, host({ shareDesktop: false }))).toBe("needs-setup");+ expect(thisMacReadiness(true, host({ sharing: false }))).toBe("needs-setup");+ });+});++describe("Set up on the chip", () => {+ it("adds this computer and shares its desktop, or only does the part that's missing", () => {+ expect(thisMacSetupSteps(host({ configured: false }))).toEqual(["add", "share-desktop"]);+ expect(thisMacSetupSteps(null)).toEqual(["add", "share-desktop"]);+ expect(thisMacSetupSteps(host({ shareDesktop: false }))).toEqual(["share-desktop"]);+ expect(thisMacSetupSteps(host({ sharing: false }))).toEqual(["resume-sharing"]);+ expect(thisMacSetupSteps(host())).toEqual([]);+ });+});++describe("the switcher's other computers", () => {+ it("lists your other computers' desktops that are on, never this computer's own", () => {+ const row = (id: string, over: object = {}) => ({ id, name: id, os: "macos", status: "running", provider: "relay", ...over }) as never;+ const list = otherComputerDesktops([row("this-mac", { status: "local" }), row("relay:m-here"), row("relay:mini"), row("relay:space-abc"), row("relay:off", { status: "suspended" })], "m-here");+ expect(list.map((s) => s.id)).toEqual(["relay:mini"]);+ });+});diff --git a/apps/cua-spaces-web/src/lib/this-mac-target.ts b/apps/cua-spaces-web/src/lib/this-mac-target.tsnew file mode 100644index 0000000000..1d8191ce5d--- /dev/null+++ b/apps/cua-spaces-web/src/lib/this-mac-target.ts@@ -0,0 +1,57 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++/**+ * Home's box starts on this computer once it's in the account (5 Nov 2026: "this computer already+ * counts; a new local computer is optional"). Making a Space first is never needed to ask for a job.+ * This file decides how this computer stands as a place to run, what the box starts on, and what the+ * one Set up action does when this computer isn't ready yet. Pure, so every state is tested without a host.+ */++import type { HostStatus } from "@/bridge/contracts/host";++import { defaultWhere, hostSpaceId, type NewKind, type TaskWhere } from "./ask-first";++/**+ * How this computer stands as a place to run a job:+ * - `ready`: it's in the account and shares its desktop, so a job can start on it now;+ * - `needs-setup`: signed in, but it isn't set up yet, or doesn't share its desktop (its own Set up fixes that);+ * - `checking`: signed in, its host service not read yet;+ * - `signed-out`: no account, so the box starts on a new computer as before.+ */+export type ThisMacReadiness = "ready" | "needs-setup" | "checking" | "signed-out";++/** `status`: `host.status`; undefined while it's being read, null when it couldn't be. */+export function thisMacReadiness(signedIn: boolean, status: HostStatus | null | undefined): ThisMacReadiness {+ if (!signedIn) return "signed-out";+ if (status === undefined) return "checking";+ return hostSpaceId(status) ? "ready" : "needs-setup";+}++/** Where the box starts unless the person picks: this computer once signed in, else a new computer (`defaultWhere`). */+export function homeDefaultWhere(readiness: ThisMacReadiness, kinds: readonly NewKind[]): TaskWhere {+ return readiness === "signed-out" ? defaultWhere(kinds) : { kind: "this-mac" };+}++export type ThisMacSetupStep = "add" | "resume-sharing" | "share-desktop";++/**+ * What Set up does, in order: add this computer to the account if it isn't yet (`add`, the same+ * `addThisComputer` a sign-in runs), share again if sharing was stopped, then share its desktop so+ * agents can use it. Empty when there's nothing to do.+ */+export function thisMacSetupSteps(status: HostStatus | null | undefined): ThisMacSetupStep[] {+ if (!status?.configured) return ["add", "share-desktop"];+ const steps: ThisMacSetupStep[] = [];+ if (!status.sharing) steps.push("resume-sharing");+ if (status.shareDesktop === false) steps.push("share-desktop");+ return steps;+}++/** The chip's words when this computer isn't ready: `place` is "This Mac", "This PC" ... */+export const thisMacChipText = (place: string) => ({+ note: "not set up for agents yet",+ action: "Set up",+ actionLabel: `Set up ${place} so agents can work on it`,+ busy: "Setting up…",+});