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.

feat(spaces): the new first run, phase 1, behind Labs "Try the new setup" (CUA-3318) (#6462)

cua-agents[bot]166726686a8a
diff --git a/apps/cua-spaces-web/public/onboarding/float/NOTICE b/apps/cua-spaces-web/public/onboarding/float/NOTICE
new file mode 100644
index 0000000000..b8619aff34
--- /dev/null
+++ b/apps/cua-spaces-web/public/onboarding/float/NOTICE
@@ -0,0 +1,7 @@
+Floating keycaps and starfield
+
+Cua's own artwork, copied unchanged from the public spaces.cua.ai hero
+(https://spaces.cua.ai/_spaces/img/float/) on 4 Nov 2026. The new first run
+(src/components/first-run-new/float-keys.tsx) places them as the site's wide
+layout does. The Apple, Windows and Linux marks on the keys are drawn in code
+from the site's download menu (src/components/first-run-new/os-marks.tsx).
diff --git a/apps/cua-spaces-web/public/onboarding/float/far-1.webp b/apps/cua-spaces-web/public/onboarding/float/far-1.webp
new file mode 100644
index 0000000000..46c3bb1145
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/far-1.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/far-2.webp b/apps/cua-spaces-web/public/onboarding/float/far-2.webp
new file mode 100644
index 0000000000..deec7f35bc
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/far-2.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/far-3.webp b/apps/cua-spaces-web/public/onboarding/float/far-3.webp
new file mode 100644
index 0000000000..1165c84ab8
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/far-3.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/far-4.webp b/apps/cua-spaces-web/public/onboarding/float/far-4.webp
new file mode 100644
index 0000000000..fe1c116eed
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/far-4.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/ivory-1.webp b/apps/cua-spaces-web/public/onboarding/float/ivory-1.webp
new file mode 100644
index 0000000000..3cdf357dd0
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/ivory-1.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/ivory-3.webp b/apps/cua-spaces-web/public/onboarding/float/ivory-3.webp
new file mode 100644
index 0000000000..cc24a135a8
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/ivory-3.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/ivory-5.webp b/apps/cua-spaces-web/public/onboarding/float/ivory-5.webp
new file mode 100644
index 0000000000..61565ef64c
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/ivory-5.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/ivory-6.webp b/apps/cua-spaces-web/public/onboarding/float/ivory-6.webp
new file mode 100644
index 0000000000..bd717ce614
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/ivory-6.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/near-1.webp b/apps/cua-spaces-web/public/onboarding/float/near-1.webp
new file mode 100644
index 0000000000..5f4551f135
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/near-1.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/near-2.webp b/apps/cua-spaces-web/public/onboarding/float/near-2.webp
new file mode 100644
index 0000000000..d632f497a5
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/near-2.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/near-3.webp b/apps/cua-spaces-web/public/onboarding/float/near-3.webp
new file mode 100644
index 0000000000..e2a332d72f
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/near-3.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/product-1.webp b/apps/cua-spaces-web/public/onboarding/float/product-1.webp
new file mode 100644
index 0000000000..4d607dd70c
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/product-1.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/product-2.webp b/apps/cua-spaces-web/public/onboarding/float/product-2.webp
new file mode 100644
index 0000000000..77b0cef1af
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/product-2.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/product-3.webp b/apps/cua-spaces-web/public/onboarding/float/product-3.webp
new file mode 100644
index 0000000000..d71a67463f
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/product-3.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/product-4.webp b/apps/cua-spaces-web/public/onboarding/float/product-4.webp
new file mode 100644
index 0000000000..9bd45d2194
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/product-4.webp differ
diff --git a/apps/cua-spaces-web/public/onboarding/float/space-1920.webp b/apps/cua-spaces-web/public/onboarding/float/space-1920.webp
new file mode 100644
index 0000000000..34e757817a
Binary files /dev/null and b/apps/cua-spaces-web/public/onboarding/float/space-1920.webp differ
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.tsx
new file mode 100644
index 0000000000..1a07162b7d
--- /dev/null
+++ b/apps/cua-spaces-web/src/__tests__/first-run-new.test.tsx
@@ -0,0 +1,373 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+// The new first run (Labs, "Try the new setup"; CUA-3318), phase 1: each screen's words and choices in
+// every state the storyboard draws (signed out, signed in, an offline computer, no coding agent, a Mac
+// that can't make a separate computer, a sign-in that didn't finish), then the whole run on its real
+// route with the wasm core.
+
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { setFlagOverride } from "@/bridge";
+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 { 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 { getDriver, resetPrepare } from "@/lib/prepare/store";
+import { mountApp, stubBrowserApis } from "./app-harness";
+
+stubBrowserApis();
+afterEach(cleanup);
+
+const NOW = 1_800_000_000_000;
+const base: WhereInput = {
+ os: "macos",
+ signedIn: true,
+ thisState: "added",
+ addedInRun: true,
+ addError: null,
+ model: "MacBook Pro",
+ machines: [
+ { id: "here", name: "Francesco's MacBook", os: "macos", online: true, current: true },
+ { id: "mini", name: "Mac mini", os: "macos", online: true, current: false },
+ { id: "pc", name: "Gaming PC", os: "windows", online: false, lastSeen: NOW / 1000 - 2 * 3600, current: false },
+ { id: "build", name: "Build server", os: "linux", online: true, current: false },
+ { id: "phone", name: "iPhone", os: "ios", online: true, current: false, device: true },
+ ],
+ picks: ["this"],
+ canMakeSeparate: true,
+ separateBlocked: null,
+ separate: { phase: "none", name: null, error: null },
+ now: NOW,
+};
+const noop = () => {};
+const drawWhere = (input: WhereInput, handlers: Partial<Parameters<typeof WhereScreen>[0]> = {}) =>
+ render(<WhereScreen view={whereView(input)} onToggle={noop} onAddThis={noop} onSignIn={noop} onAddAnother={noop} onSeparate={noop} onContinue={noop} {...handlers} />);
+const text = () => document.body.textContent ?? "";
+
+describe("screen 2, signed in", () => {
+ it("says this Mac was added just now, lists the account's other computers and Add another computer you own", () => {
+ drawWhere(base);
+ expect(screen.getByRole("heading").textContent).toBe("Pick where your agents work");
+ expect(text()).toContain("You're signed in, and this Mac is now in your account. Your agents can start here, or on your other computers while you keep working on this one.");
+ expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("Added to your account just now");
+ expect(document.querySelector("[data-new-run-computer=this]")!.textContent).toContain("MacBook Pro");
+ expect(text()).toContain("Other computers in your account");
+ // This computer and devices that are not computers are not in the list.
+ const ids = [...document.querySelectorAll<HTMLElement>("[data-new-run-computer]")].map((e) => e.dataset.newRunComputer);
+ expect(ids).toEqual(["this", "mini", "pc", "build"]);
+ expect(document.querySelector("[data-new-run-computer=mini]")!.textContent).toContain("macOS · ready");
+ expect(text()).toContain("Add another computer you own");
+ expect(text()).toContain("Install Cua Spaces on it and sign in. It shows up here.");
+ expect(text()).toContain("Or make a separate computer on this Mac");
+ expect(text()).toContain("A Linux computer just for your agents, away from your files. About 2 minutes.");
+ expect(screen.getByRole("button", { name: "Continue" }).hasAttribute("disabled")).toBe(false);
+ });
+
+ it("with no other computers says so", () => {
+ drawWhere({ ...base, machines: [base.machines![0]!] });
+ expect(document.querySelector("[data-new-run-none]")!.textContent).toBe("None yet. Computers you or your team sign in on show up here.");
+ });
+
+ it("a computer already in the account says so, not 'just now'", () => {
+ drawWhere({ ...base, addedInRun: false });
+ expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("In your account");
+ });
+
+ it("when adding this Mac failed, says so with Try again", () => {
+ const onAddThis = vi.fn();
+ drawWhere({ ...base, thisState: "failed", addError: "The relay didn't answer." }, { onAddThis });
+ expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("Couldn't add it to your account. The relay didn't answer.");
+ fireEvent.click(document.querySelector("[data-new-run-add-this=retry-add]")!);
+ expect(onAddThis).toHaveBeenCalled();
+ });
+});
+
+describe("screen 2, an offline computer", () => {
+ it("is greyed with 'Offline, last seen 2 hours ago', has no check circle and can't be picked", () => {
+ const onToggle = vi.fn();
+ drawWhere(base, { onToggle });
+ const pc = document.querySelector<HTMLElement>("[data-new-run-computer=pc]")!;
+ expect(pc.textContent).toContain("Offline, last seen 2 hours ago");
+ expect(pc.getAttribute("aria-disabled")).toBe("true");
+ expect(pc.className).toContain("opacity-40");
+ expect(pc.querySelector("[data-check]")).toBeNull();
+ fireEvent.click(pc);
+ expect(onToggle).not.toHaveBeenCalled();
+ // The online ones can be picked.
+ fireEvent.click(document.querySelector("[data-new-run-computer=mini]")!);
+ expect(onToggle).toHaveBeenCalledWith("mini");
+ });
+
+ it("is never added to the picks, even when asked", () => {
+ const rows = whereView(base).others!;
+ expect(togglePick(["this"], "pc", rows)).toEqual(["this"]);
+ expect(togglePick(["this"], "mini", rows)).toEqual(["this", "mini"]);
+ expect(togglePick(["this", "mini"], "mini", rows)).toEqual(["this"]);
+ });
+});
+
+describe("screen 2, signed out (after Skip for now)", () => {
+ it("shows this Mac not added yet with Add, 'Sign in to see your other computers', and no Add another computer", () => {
+ const onAddThis = vi.fn();
+ const onSignIn = vi.fn();
+ drawWhere({ ...base, signedIn: false, thisState: "signed-out" }, { onAddThis, onSignIn });
+ expect(text()).toContain("Your agents can work on this Mac without an account. Add this Mac to an account when you want them on your other computers too.");
+ expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("not added yet");
+ expect(document.querySelector("[data-new-run-sign-in-line]")!.textContent).toBe("Sign in to see your other computers.");
+ expect(text()).not.toContain("Other computers in your account");
+ expect(text()).not.toContain("Add another computer you own");
+ expect(text()).not.toContain("Mac mini");
+ // The separate computer needs no account: still offered.
+ expect(document.querySelector("[data-new-run-separate-open]")).not.toBeNull();
+ fireEvent.click(document.querySelector("[data-new-run-add-this=add]")!);
+ fireEvent.click(screen.getByRole("button", { name: "Sign in" }));
+ expect(onAddThis).toHaveBeenCalled();
+ expect(onSignIn).toHaveBeenCalled();
+ });
+});
+
+describe("screen 2, this Mac can't make a separate computer", () => {
+ it("greys only that option, with one plain sentence; this Mac and the other computers still work", () => {
+ drawWhere({ ...base, canMakeSeparate: false, separateBlocked: "Needs Apple silicon." });
+ const sep = document.querySelector<HTMLElement>("[data-new-run-separate]")!;
+ expect(sep.dataset.disabled).toBe("");
+ expect(sep.textContent).toContain("This Mac can't make one. Older Intel Macs can't, for example. Your agents can still work on this Mac or on another computer you add.");
+ expect(document.querySelector("[data-new-run-separate-open]")).toBeNull();
+ expect(screen.getByRole("button", { name: "Continue" }).hasAttribute("disabled")).toBe(false);
+ expect(document.querySelector("[data-new-run-computer=mini]")!.getAttribute("aria-disabled")).toBeNull();
+ });
+
+ it("on a PC, says the host's reason", () => {
+ const v = whereView({ ...base, os: "windows", canMakeSeparate: false, separateBlocked: "Docker Desktop isn't running." });
+ expect(v.separate.sub).toBe("Docker Desktop isn't running. Your agents can still work on this PC or on another computer you add.");
+ });
+
+ it("explains the Local Network ask before the create, then follows it", () => {
+ expect(whereView({ ...base, separate: { phase: "explain", name: null, error: null } }).separate).toMatchObject({
+ state: "explain",
+ action: "Make it",
+ sub: "If macOS asks to let Cua Spaces find devices on your local network, choose Allow. Cua uses it to reach the new computer.",
+ });
+ expect(whereView({ ...base, separate: { phase: "making", name: "Linux 1", error: null } }).separate.sub).toBe("Making Linux 1 now. You can continue; it keeps going.");
+ expect(whereView({ ...base, separate: { phase: "failed", name: "Linux 1", error: "Not enough memory." } }).separate).toMatchObject({ sub: "Couldn't make it. Not enough memory.", action: "Try again" });
+ });
+});
+
+describe("1b, sign-in", () => {
+ it("waits for the browser with Try again and Use a code instead", () => {
+ const v = signInView({ kind: "waiting" }, null);
+ render(<SignInScreen view={v} onTryAgain={noop} onUseCode={noop} onOpen={noop} />);
+ expect(screen.getByRole("heading").textContent).toBe("Finish signing in in your browser");
+ expect(text()).toContain("Cua opened in your browser. Create your account there, or sign in if you already have one. This window moves on by itself when you're done.");
+ expect(screen.getByRole("status").textContent).toBe("Waiting for your browser");
+ expect(screen.getByRole("button", { name: "Try again" })).not.toBeNull();
+ expect(screen.getByRole("button", { name: "Use a code instead" })).not.toBeNull();
+ });
+
+ it("says 'Sign-in didn't finish' with its reason, and Try again becomes the white button", () => {
+ const v = signInView({ kind: "failed", reason: "notConfirmed", message: "x" }, null);
+ expect(v).toMatchObject({ title: "Sign-in didn't finish", line: "The browser didn't confirm in time. Try again, or use a code if your browser is on another device.", tryAgainPrimary: true, waiting: null });
+ // Other reasons keep the core's own line.
+ expect(signInView({ kind: "failed", reason: "offline", message: "You're offline." }, null).line).toBe("You're offline.");
+ });
+
+ it("with a code shows the code and the page to enter it on", () => {
+ const onOpen = vi.fn();
+ render(<SignInScreen view={signInView({ kind: "waiting", userCode: "WXYZ-1234" }, "https://cua.ai/device")} onTryAgain={noop} onUseCode={noop} onOpen={onOpen} />);
+ expect(document.querySelector("[data-new-run-code]")!.textContent).toContain("WXYZ-1234");
+ fireEvent.click(screen.getByRole("button", { name: "Open the sign-in page" }));
+ expect(onOpen).toHaveBeenCalledWith("https://cua.ai/device");
+ expect(screen.queryByRole("button", { name: "Use a code instead" })).toBeNull();
+ });
+});
+
+describe("screen 3, the coding agent", () => {
+ const draw = (found: string[] | null, picked: string | null = null) => {
+ const onInstall = vi.fn();
+ const onPick = vi.fn();
+ render(<AgentScreen view={agentView({ os: "macos", found, picked, error: null })} onPick={onPick} onContinue={noop} onInstall={onInstall} busy={false} />);
+ return { onInstall, onPick };
+ };
+
+ it("one found: it is picked", () => {
+ draw(["claude-code", "cursor"]);
+ expect(screen.getByRole("heading").textContent).toBe("Your agents will use Claude Code");
+ expect(text()).toContain("We found Claude Code on this Mac. Your agents will use it to do the work while you keep working on other things.");
+ expect(text()).toContain("Found on this Mac");
+ expect(document.querySelector("[data-new-run-agent=claude-code]")!.textContent).toContain("By Anthropic");
+ expect(document.querySelector("[data-new-run-agent=claude-code] [data-check=on]")).not.toBeNull();
+ expect(chosenAgent(["claude-code"], null)).toBe("claude-code");
+ });
+
+ it("several found: nothing is picked for them, and Continue waits", () => {
+ const { onPick } = draw(["claude-code", "codex"]);
+ expect(screen.getByRole("heading").textContent).toBe("Pick the coding agent to use");
+ expect(text()).toContain("We found two on this Mac.");
+ expect(document.querySelectorAll("[data-check=on]").length).toBe(0);
+ expect(screen.getByRole("button", { name: "Continue" }).hasAttribute("disabled")).toBe(true);
+ fireEvent.click(document.querySelector("[data-new-run-agent=codex]")!);
+ expect(onPick).toHaveBeenCalledWith("codex");
+ expect(chosenAgent(["claude-code", "codex"], null)).toBeNull();
+ expect(chosenAgent(["claude-code", "codex"], "codex")).toBe("codex");
+ });
+
+ it("none found: Install Claude Code, or Install Codex instead (the official pages)", () => {
+ const { onInstall } = draw([]);
+ expect(screen.getByRole("heading").textContent).toBe("Install a coding agent");
+ expect(text()).toContain("Cua doesn't come with its own, and we didn't find one on this Mac. Install Claude Code, then sign in to it once.");
+ expect(screen.queryByRole("button", { name: "Continue" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Install Claude Code" }));
+ fireEvent.click(screen.getByRole("button", { name: "Install Codex instead" }));
+ expect(onInstall.mock.calls).toEqual([["claude-code"], ["codex"]]);
+ });
+});
+
+describe("screen 4, Ready", () => {
+ it("names the agent and the picked computers, with a line to try and Copy", () => {
+ const v = readyView({ os: "macos", agent: "claude-code", computers: ["Mac mini", "Build server"] });
+ render(<ReadyScreen view={v} agent="claude-code" onDone={noop} />);
+ expect(screen.getByRole("heading").textContent).toBe("Claude Code can now use Mac mini and Build server");
+ expect(text()).toContain("Try it from your own terminal. Nothing runs until you do.");
+ expect(document.querySelector("[data-new-run-command]")!.textContent).toContain('claude "Build this branch on Mac mini"');
+ expect(screen.getByRole("button", { name: "Copy" })).not.toBeNull();
+ // Phase 1: no "Pick up where you left off".
+ expect(text()).not.toContain("Pick up where you left off");
+ });
+
+ it("with only this Mac picked, says this Mac", () => {
+ expect(readyView({ os: "macos", agent: "codex", computers: ["this"] })).toMatchObject({
+ title: "Codex can now use this Mac",
+ command: 'codex "Make a separate Linux computer on this Mac and run this repo\'s tests in it"',
+ });
+ });
+});
+
+describe("screen 6, next steps", () => {
+ it("offers to invite a teammate, add another computer and let agents use apps on this Mac", () => {
+ const onRow = vi.fn();
+ render(<NextScreen view={nextView({ os: "macos" })} onRow={onRow} onDone={noop} />);
+ expect(screen.getByRole("heading").textContent).toBe("Now bring the rest in");
+ const rows = [...document.querySelectorAll<HTMLElement>("[data-new-run-next-row]")].map((r) => r.textContent);
+ expect(rows[0]).toContain("Invite a teammate");
+ expect(rows[1]).toContain("Add another computer");
+ expect(rows[2]).toContain("Let agents use apps on this Mac");
+ fireEvent.click(document.querySelector("[data-new-run-next-row=apps]")!);
+ expect(onRow).toHaveBeenCalledWith("apps");
+ });
+
+ it("has no apps row away from a Mac", () => {
+ expect(nextView({ os: "windows" }).rows.map((r) => r.id)).toEqual(["invite", "add-computer"]);
+ });
+});
+
+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);
+ expect(keys.filter((k) => k.mark).map((k) => [k.src, k.mark])).toEqual([
+ ["product-1", "windows"],
+ ["product-2", "macos"],
+ ["product-3", "linux"],
+ ]);
+ // Only the soft near key (bottom left, behind the dots) sits left of the copy's edge.
+ expect(keys.filter((k) => !k.soft && k.left + k.width * 0.1 < 544).map((k) => k.src)).toEqual([]);
+ });
+});
+
+/* ---- The real route, with the wasm core ------------------------------------------------- */
+
+beforeEach(() => {
+ localStorage.clear();
+ resetSavedOnboardingCache();
+ resetFirstRunCache();
+ resetConnectedAppsState();
+ resetPrepare();
+ setFlagOverride("spaces_ask_first_home", true);
+ setFlagOverride("spaces_new_onboarding", true);
+});
+afterEach(() => {
+ setFlagOverride("spaces_ask_first_home", null);
+ setFlagOverride("spaces_new_onboarding", null);
+ resetPrepare();
+});
+
+const heading = () => document.querySelector("[data-onboarding-heading]")?.textContent ?? "";
+const click = (sel: string) => fireEvent.click(document.querySelector<HTMLElement>(sel)!);
+const onlyCodex = (rows: AgentSetupRow[]) => rows.map((r) => ({ ...r, installed: r.agent === "codex" }));
+type Calls = { op: string; args: unknown }[];
+
+describe.skipIf(!wasmBuilt)("the new first run on its route", () => {
+ it("signed out: Skip for now, this Mac only, the agent found here, Ready, next steps, then Home; nothing is made meanwhile", { timeout: 60_000 }, async () => {
+ const calls: Calls = [];
+ const { router } = await mountApp("/onboarding", {
+ failsCreates: false,
+ listsGhost: false,
+ demo: { signedIn: false, onboarded: false, noSpaces: true },
+ intercept: (op, args) => (calls.push({ op, args }), undefined),
+ answer: (op, out) => (op === "agents.setup" || op === "agents.configure" ? onlyCodex(out as AgentSetupRow[]) : out),
+ });
+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));
+ expect(document.querySelector("[data-float-keys]")).not.toBeNull();
+ click("[data-onboarding-later]");
+ await waitFor(() => expect(heading()).toBe("Pick where your agents work"));
+ expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("not added yet");
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Your agents will use Codex"), { timeout: 15_000 });
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Codex can now use this Mac"), { timeout: 15_000 });
+ expect(calls.some((c) => c.op === "agents.connect" || c.op === "agents.configure")).toBe(true);
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Now bring the rest in"));
+ // No Space was made while the first run showed.
+ expect(calls.some((c) => c.op === "spaces.create")).toBe(false);
+ expect(getDriver()?.state?.wanted ?? false).toBe(false);
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(calls.find((c) => c.op === "session.completeOnboarding")).toBeTruthy());
+ await waitFor(() => expect(router.state.location.pathname).toBe("/home"));
+ });
+
+ it("signed in: Add this computer opens the sign-in, then this Mac was added just now and the account's computers are listed", { timeout: 60_000 }, async () => {
+ const calls: Calls = [];
+ await mountApp("/onboarding", {
+ failsCreates: false,
+ listsGhost: false,
+ demo: { signedIn: false, onboarded: false, noSpaces: true },
+ intercept: (op, args) => (calls.push({ op, args }), undefined),
+ });
+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Finish signing in in your browser"));
+ expect(calls.some((c) => c.op === "session.signIn")).toBe(true);
+ await waitFor(() => expect(heading()).toBe("Pick where your agents work"), { timeout: 15_000 });
+ await waitFor(() => expect(document.querySelector("[data-new-run-this-status]")!.textContent).toBe("Added to your account just now"), { timeout: 15_000 });
+ expect(document.body.textContent).toContain("Other computers in your account");
+ expect(document.body.textContent).toContain("Add another computer you own");
+ expect(readFirstRun().newRun?.addedInRun).toBe(true);
+ });
+ it("a Mac that can't run virtual computers: the explainer, the create, then only the separate-computer option turns grey", { timeout: 60_000 }, async () => {
+ const calls: Calls = [];
+ await mountApp("/onboarding", {
+ failsCreates: false,
+ listsGhost: false,
+ demo: { signedIn: false, onboarded: false, noSpaces: true, failCreates: "unsupported" },
+ intercept: (op, args) => (calls.push({ op, args }), undefined),
+ });
+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));
+ click("[data-onboarding-later]");
+ await waitFor(() => expect(document.querySelector("[data-new-run-separate-open]")).not.toBeNull(), { timeout: 15_000 });
+ click("[data-new-run-separate-open]");
+ // Our one line comes first; nothing is made until "Make it".
+ await waitFor(() => expect(document.querySelector("[data-new-run-separate=explain]")).not.toBeNull());
+ expect(calls.some((c) => c.op === "spaces.create")).toBe(false);
+ click("[data-new-run-separate-action]");
+ await waitFor(() => expect(document.querySelector("[data-new-run-separate]")!.textContent).toContain("This Mac can't make one."), { timeout: 15_000 });
+ expect((document.querySelector("[data-new-run-separate]") as HTMLElement).dataset.disabled).toBe("");
+ expect(document.body.textContent).not.toMatch(/local runtime:|exit status/i);
+ expect(screen.getByRole("button", { name: "Continue" }).hasAttribute("disabled")).toBe(false);
+ });
+});
diff --git a/apps/cua-spaces-web/src/__tests__/first-run.test.tsx b/apps/cua-spaces-web/src/__tests__/first-run.test.tsx
index d2ce86e013..bfd9933d48 100644
--- a/apps/cua-spaces-web/src/__tests__/first-run.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/first-run.test.tsx
@@ -20,7 +20,7 @@ import { readFirstRun, resetFirstRunCache, useFirstRun, writeFirstRun } from "@/
import { CLOSED_NEW_SPACE, updateNewSpaceSession } from "@/bridge/new-space";
import { resetSavedOnboardingCache } from "@/bridge/onboarding";
import { connectedAppsState, resetConnectedAppsState } from "@/hooks/use-connected-apps";
-import { getDriver, resetPrepare } from "@/lib/prepare/store";
+import { resetPrepare } from "@/lib/prepare/store";
import { mountApp, stubBrowserApis } from "./app-harness";
stubBrowserApis();
@@ -222,68 +222,7 @@ describe.skipIf(!wasmBuilt)("the first run (real route, wasm core)", () => {
await waitFor(() => expect(calls.find((c) => c.op === "session.completeOnboarding")).toBeTruthy());
});
- it("with the new setup on there is no Try it screen: the last screen ends the run on Home while the Space is prepared", { timeout: 40_000 }, async () => {
- setFlagOverride("spaces_ask_first_home", true);
- setFlagOverride("spaces_new_onboarding", true);
- resetPrepare();
- const calls: Calls = [];
- const { router } = await mountApp("/onboarding", {
- failsCreates: false,
- listsGhost: false,
- demo: { signedIn: false, onboarded: false },
- intercept: (op, args) => (calls.push({ op, args }), undefined),
- answer: (op, out) => (op === "agents.setup" || op === "agents.signIn" || op === "agents.configure" ? onlyCodex(out as AgentSetupRow[]) : out),
- });
- // Preparing started with the app, before any screen was answered.
- await waitFor(() => expect(getDriver()?.state?.wanted).toBe(true), { timeout: 15_000 });
- await waitFor(() => expect(heading()).toBe("Your computers, shared by your team and its agents."));
- click("[data-onboarding-primary]");
- await waitFor(() => expect(heading()).toBe("Let OpenAI Codex use Cua?"));
- click("[data-first-run-set-up]");
- await waitFor(() => expect(heading()).toBe("OpenAI Codex can use Cua."));
- click("[data-onboarding-primary]");
- await waitFor(() => expect(heading()).toBe("Add your other computers."));
- // The dots say three screens: Welcome, Pick your agent, Add your other computers.
- expect(document.querySelector("ol[aria-label]")!.getAttribute("aria-label")).toBe("Step 3 of 3");
- click("[data-first-run-secondary]");
- await waitFor(() => expect(calls.find((c) => c.op === "session.completeOnboarding")).toBeTruthy());
- // No "Try it" screen and no prompt to copy; the person lands on Home.
- expect(document.body.textContent).not.toMatch(/Try it in/);
- expect(document.querySelector("textarea[data-first-run-prompt]")).toBeNull();
- await waitFor(() => expect(router.state.location.pathname).toBe("/home"));
- // The clock for "onboarding finished to ready" started when the last button was pressed.
- expect(getDriver()?.state?.onboardingDoneMs).not.toBeNull();
- });
-
- it("every page of the run shows its buttons: Welcome, Pick your agent (Set up, Not now, Back), Add your other machines (Sign in, Not now, Back)", { timeout: 40_000 }, async () => {
- setFlagOverride("spaces_ask_first_home", true);
- setFlagOverride("spaces_new_onboarding", true);
- resetPrepare();
- await mountApp("/onboarding", {
- failsCreates: false,
- listsGhost: false,
- demo: { signedIn: false, onboarded: false },
- answer: (op, out) => (op === "agents.setup" || op === "agents.signIn" || op === "agents.configure" ? onlyCodex(out as AgentSetupRow[]) : out),
- });
- const buttons = () => [...document.querySelectorAll("button")].map((b) => (b.textContent ?? "").trim()).filter(Boolean);
- // Page 1.
- await waitFor(() => expect(heading()).toBe("Your computers, shared by your team and its agents."));
- expect(buttons()).toEqual(expect.arrayContaining(["Get started", "Skip for now"]));
- expect(document.querySelector("[data-first-run-back]")).toBeNull();
- click("[data-onboarding-primary]");
- // Page 2: the agent rows with the one Set up and Not now, Back, and the page flow still going to Continue.
- await waitFor(() => expect(heading()).toBe("Let OpenAI Codex use Cua?"));
- expect(document.querySelector("[data-first-run-agent=codex]")).not.toBeNull();
- expect(buttons()).toEqual(expect.arrayContaining(["Set up", "Not now", "Back", "Skip for now"]));
- click("[data-first-run-set-up]");
- await waitFor(() => expect(heading()).toBe("OpenAI Codex can use Cua."));
- expect(document.querySelector("[data-first-run-agent=codex]")!.textContent).toContain("Ready");
- expect(buttons()).toEqual(expect.arrayContaining(["Continue", "Back"]));
- click("[data-onboarding-primary]");
- // The last page.
- await waitFor(() => expect(heading()).toBe("Add your other computers."));
- expect(buttons()).toEqual(expect.arrayContaining(["Sign in", "Not now", "Back"]));
- });
+ // With the new setup on, /onboarding is the new first run (CUA-3318): first-run-new.test.tsx.
it("with the new setup off the Try it screen is still last", async () => {
setFlagOverride("spaces_new_onboarding", false);
diff --git a/apps/cua-spaces-web/src/__tests__/onboarding-lands-on-home.test.tsx b/apps/cua-spaces-web/src/__tests__/onboarding-lands-on-home.test.tsx
index 6c9fea23f1..069dd79c9b 100644
--- a/apps/cua-spaces-web/src/__tests__/onboarding-lands-on-home.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/onboarding-lands-on-home.test.tsx
@@ -2,7 +2,7 @@
// Copyright (c) 2026 Cua AI, Inc.
// The last onboarding page of an ask-first run ends on Home (the prompt box and the suggestions), not inside a
-// Space: the first agent keeps getting ready in the background, with one quiet line on that page.
+// Space: the first agent starts getting ready in the background once the first run is over, with no line about it.
import { act, cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
@@ -39,12 +39,21 @@ const heading = () => document.querySelector("[data-onboarding-heading]")?.textC
async function throughOnboarding(hold?: Promise<void>) {
const { router } = await mountApp("/onboarding", { failsCreates: false, listsGhost: false, hold, demo: { signedIn: false, onboarded: false, noSpaces: true, keys: "several" } });
- await waitFor(() => expect(heading()).toBe("Your computers, shared by your team and its agents."));
+ // The new first run (CUA-3318): Skip for now, this computer, the agent found here, Ready, next steps.
+ await waitFor(() => expect(heading()).toBe("Bring all your computers under one account"));
+ click("[data-onboarding-later]");
+ await waitFor(() => expect(heading()).toBe("Pick where your agents work"));
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(document.querySelector("[data-new-run=agent]:not([data-state=looking])")).not.toBeNull(), { timeout: 15_000 });
+ const several = document.querySelector("[data-new-run=agent][data-state=several]");
+ if (several) click("[data-new-run-agent=claude-code]");
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(document.querySelector("[data-new-run=ready]")).not.toBeNull(), { timeout: 15_000 });
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Now bring the rest in"));
+ // Nothing is made while the first run shows.
+ expect(getDriver()?.state?.wanted ?? false).toBe(false);
click("[data-onboarding-primary]");
- await waitFor(() => expect(document.querySelector("[data-first-run-set-up]")).not.toBeNull(), { timeout: 15_000 });
- fireEvent.click(screen.getAllByRole("button", { name: "Not now" })[0]!);
- await waitFor(() => expect(heading()).toBe("Add your other computers."));
- fireEvent.click(screen.getByRole("button", { name: "Not now" }));
return router;
}
@@ -71,7 +80,6 @@ describe.skipIf(!wasmBuilt)("where the first run ends", () => {
expect(document.querySelector("[data-prepare-steps]")).toBeNull();
expect(document.body.textContent).not.toContain("Getting your agent ready");
expect(document.querySelector("[data-home-spaces]")?.textContent ?? "").not.toContain("home-claude-code");
- expect(getDriver()?.state?.onboardingDoneMs).not.toBeNull();
// A prompt sent now is kept and goes once the agent is ready (the Space's thread says so).
fireEvent.change(screen.getByLabelText("What do you want to do?"), { target: { value: "fix the build" } });
fireEvent.click(screen.getByRole("button", { name: "Start" }));
diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo.ts b/apps/cua-spaces-web/src/bridge/adapters/demo.ts
index 9f2fc360ed..62c2968780 100644
--- a/apps/cua-spaces-web/src/bridge/adapters/demo.ts
+++ b/apps/cua-spaces-web/src/bridge/adapters/demo.ts
@@ -85,6 +85,8 @@ export interface DemoOptions {
noVault?: boolean;
/** Machines that are only signed in (`?demo=signed-in-machines`): rows in the one list, "Signed in, not sharing", and the two that wait to be added. */
signedInMachines?: boolean;
+ /** A sign-in that never finishes (`wait`: the browser never confirms) or fails at once as not confirmed in time (`timeout`). */
+ signIn?: "wait" | "timeout";
/** Saved credentials the provider refuses (`?demo=rejected-key`: the OpenAI key): a check marks them as needing a reconnect. */
rejectedKeys?: string[];
/** Claude Code's sign-in on this Mac: imported already (`?demo=claude-signed-in`), imported and run out (`?demo=claude-expired`),
@@ -141,7 +143,7 @@ export interface DemoOptions {
* built-in Linux runtime does not start; later attempts work,
* `?demo=create-fail-runtime`) or `disk` (every create is short of disk
* space, `?demo=create-fail-disk`). */
- failCreates?: "runtime-once" | "disk";
+ failCreates?: "runtime-once" | "disk" | "unsupported";
/** The CLI the demo host reports: the released app's `cua` on PATH unless
* set; `local` is a Local build's (`?demo=cli-local`), `missing` one
* not installed (`?demo=cli-missing`). */
@@ -194,6 +196,9 @@ export const DEMO_CREATING_ELSEWHERE: CreatingElsewhere[] = [
/** The SDK's words for the failures `failCreates` plays. */
export const DEMO_CREATE_FAILURES = {
runtime: "local runtime: the built-in Linux runtime did not start: exiting, status 1",
+ /** The daemon's refusal on a Mac that can't run virtual computers (#6323, `?demo=create-fail-unsupported`). */
+ unsupported:
+ "This Mac can't run Spaces itself, because it can't run virtual computers. That happens when the Mac is itself a virtual machine, or is an older Intel Mac. Add another computer to your account, or link your own cloud, and create the Space there.",
disk: "not enough disk space to pull ghcr.io/trycua/macos:26: it needs about 30.0 GB and cua keeps 5.0 GB free, but only 12.4 GB is available on /Users/me/.lume (run `cua cache prune` to free space, or lower CUA_DISK_MIN_FREE)",
} as const;
@@ -264,6 +269,7 @@ export function demoOptionsFromSearch(search: string): DemoOptions {
keyvaultLocked: flags.has("locked"),
noVault: flags.has("novault"),
...(flags.has("signed-in-machines") ? { signedInMachines: true } : {}),
+ ...(flags.has("signin-wait") ? { signIn: "wait" as const } : flags.has("signin-timeout") ? { signIn: "timeout" as const } : {}),
...(flags.has("rejected-key") ? { rejectedKeys: ["OPENAI_API_KEY"] } : {}),
...(flags.has("no-keys") ? { keys: "none" as const } : flags.has("connections") ? { keys: "several" as const, rejectedKeys: ["DEEPSEEK_API_KEY"] } : {}),
...(flags.has("claude-expired") ? { claudeLogin: "expired" as const } : flags.has("claude-signed-in") ? { claudeLogin: "signed-in" as const } : flags.has("claude-none") ? { claudeLogin: "none" as const } : {}),
@@ -325,7 +331,7 @@ export function demoOptionsFromSearch(search: string): DemoOptions {
...(flags.has("slow-create") ? { stepMs: 5000 } : {}),
...(flags.has("slow-home") ? { slowHome: true } : {}),
creatingElsewhere: flags.has("creating-elsewhere"),
- failCreates: flags.has("create-fail-runtime") ? "runtime-once" : flags.has("create-fail-disk") ? "disk" : undefined,
+ failCreates: flags.has("create-fail-runtime") ? "runtime-once" : flags.has("create-fail-disk") ? "disk" : flags.has("create-fail-unsupported") ? "unsupported" : undefined,
...(flags.has("intel-mac") ? { platform: { os: "macos" as const, arch: "amd64" as const } } : {}),
...(flags.has("linux-pc") ? { platform: { os: "linux" as const, arch: "amd64" as const } } : {}),
...(flags.has("update-ready")
@@ -533,7 +539,7 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { re
try {
// A failure the options ask for, after the create starts preparing.
const failure =
- options.failCreates === "disk" ? DEMO_CREATE_FAILURES.disk : options.failCreates === "runtime-once" && createAttempts++ === 0 ? DEMO_CREATE_FAILURES.runtime : null;
+ options.failCreates === "disk" ? DEMO_CREATE_FAILURES.disk : options.failCreates === "unsupported" ? DEMO_CREATE_FAILURES.unsupported : options.failCreates === "runtime-once" && createAttempts++ === 0 ? DEMO_CREATE_FAILURES.runtime : null;
if (failure) {
for (const fraction of [0, 0.3]) {
emit({ type: "spaces.createProgress", progress: { pendingId, phase: "preparing", fraction, detail: "preparing", space: id } });
@@ -813,6 +819,8 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { re
"session.get": () => session(),
"session.signIn": () => {
+ if (options.signIn === "timeout") throw Object.assign(new Error("The sign-in was not completed in time."), { tag: "Timeout" });
+ if (options.signIn === "wait") return { method: "browser", verificationUri: "https://cua.ai/signin" };
later(step * 3, () => {
state.identity = DEMO_IDENTITY;
emit({ type: "session.signedIn", identity: DEMO_IDENTITY });
diff --git a/apps/cua-spaces-web/src/bridge/first-run.ts b/apps/cua-spaces-web/src/bridge/first-run.ts
index 71090ae5e7..36a109d811 100644
--- a/apps/cua-spaces-web/src/bridge/first-run.ts
+++ b/apps/cua-spaces-web/src/bridge/first-run.ts
@@ -86,6 +86,7 @@ function withExtraFix(view: FirstRunView, fix: CreateFix | null): FirstRunView {
return { ...view, setup: { ...view.setup, extra: { ...card, note: `${card.note} ${fix.text}`, action: { id: "fix", label: fix.label } } } };
}
import { spaceState } from "../lib/spaces";
+import type { NewRunSaved } from "../lib/first-run-new";
@@ -322,6 +323,8 @@ export interface FirstRunSaved {
todosClosed: boolean;
/** Advanced setup on Pick your agent (CUA-2267). */
advanced?: boolean;
+ /** The new first run's progress (Labs, "Try the new setup"; `lib/first-run-new.ts`). Kept here so Reset & Show forgets it too. */
+ newRun?: Partial<NewRunSaved>;
}
const KEY = "cua-spaces:first-run";
diff --git a/apps/cua-spaces-web/src/bridge/flags.ts b/apps/cua-spaces-web/src/bridge/flags.ts
index 943f4f6dec..6b9d84254c 100644
--- a/apps/cua-spaces-web/src/bridge/flags.ts
+++ b/apps/cua-spaces-web/src/bridge/flags.ts
@@ -24,11 +24,13 @@ import { useSyncExternalStore } from "react";
* Home page that asks what you want done, starts it on a fresh computer and
* follows it as a conversation. Settings → Advanced → Labs turns it on for
* this device.
- * - `spaces_new_onboarding`: the new setup (CUA-2851): the first Linux Space
- * and its coding agent get ready while the person goes through the first
- * run, which has no "Try it" screen and ends on the "Ask first" Home. It
- * needs that Home, so it counts only while `spaces_ask_first_home` is on
- * too (Labs turns both on). Off by default: the first run stays as it is.
+ * - `spaces_new_onboarding`: the new setup (CUA-2851, CUA-3318): the new
+ * first run (`components/first-run-new`): add this computer to the account,
+ * pick where agents work, use the coding agent already here, then Ready. It
+ * ends on the "Ask first" Home, whose first Linux Space starts getting ready
+ * once the first run is over. It needs that Home, so it counts only while
+ * `spaces_ask_first_home` is on too (Labs turns both on). Off by default:
+ * the first run stays as it is.
*/
export type FlagName = "upsell_cards" | "spaces_ask_first_home" | "spaces_new_onboarding";
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
new file mode 100644
index 0000000000..14216d02d0
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx
@@ -0,0 +1,810 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+/**
+ * The new first run (Labs, "Try the new setup"; CUA-3318), phase 1 of the approved storyboard
+ * (CUA-3193): drawn on the spaces.cua.ai hero (its starfield, keys, Outfit title, white button and
+ * the Cua lockup). The words and choices are `lib/first-run-new.ts`; this file reads the app's state
+ * (sign-in, the account's computers, this computer's agents and whether it can make a separate
+ * computer) and draws the screens.
+ */
+
+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 { newPendingId, useMachines, useSession, useSettings, useSpaces, type SignInPhase } from "@/bridge";
+import { BridgeContext } from "@/bridge/BridgeProvider";
+import type { HostStatus } from "@/bridge/contracts/host";
+import { readFirstRun, useFirstRunSaved, writeFirstRun } from "@/bridge/first-run";
+import { hostOs } from "@/bridge/host-os";
+import { useFirstSpaceOffers } from "@/bridge/new-space-hooks";
+import { readSavedOnboarding, writeSavedOnboarding } from "@/bridge/onboarding";
+import { extraName, spokenName } from "@/bridge/space-names";
+import { AddComputerSheet } from "@/components/add-computer-sheet";
+import { AppMarkImage } from "@/components/agents/harness-mark";
+import { CuaLogo } from "@/components/cua-logo";
+import {
+ agentView,
+ chosenAgent,
+ dotFor,
+ INSTALL_PAGES,
+ NEW_RUN_EMPTY,
+ nextView,
+ readyView,
+ signInView,
+ togglePick,
+ WELCOME,
+ whereView,
+ type AgentView,
+ type ComputerRow,
+ type NewRunSaved,
+ type NextView,
+ type ReadyView,
+ type SignInView,
+ type WhereView,
+} from "@/lib/first-run-new";
+import { spaceState } from "@/lib/spaces";
+import { cn } from "@/lib/utils";
+
+import { FloatKeys } from "./float-keys";
+import { OsMark } from "./os-marks";
+
+/* ---- The site's pieces ------------------------------------------------------------------ */
+
+/** The hero's grey for second lines. */
+const GREY = "text-[#8d8d8d]";
+/** The site's white button (the dark hero's Download pill). */
+const WHITE_BUTTON =
+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+ "inline-flex h-12 items-center justify-center rounded-full bg-white px-7 text-[15px] font-semibold text-[#0a152d] outline-none transition-transform hover:scale-[1.04] active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-[#5ec0e8] disabled:pointer-events-none disabled:opacity-40 motion-reduce:transition-none";
+/** The site's Sign up glass at the white button's height. */
+const GLASS_BUTTON =
+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+ "inline-flex h-12 items-center justify-center rounded-full bg-white/[0.08] px-6 text-[15px] font-semibold text-white shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)] backdrop-blur-md outline-none hover:bg-white/[0.14] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]";
+/** The site's Sign up chip (Skip for now, a row's Add). */
+const GLASS_CHIP =
+ "inline-flex items-center justify-center rounded-full bg-white/[0.08] font-semibold text-white shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)] backdrop-blur-md outline-none hover:bg-white/[0.14] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]";
+/** The site's underlined text link, in white. */
+// design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+const LINK = "font-semibold text-white underline decoration-white/50 underline-offset-[3px] outline-none hover:decoration-white focus-visible:ring-2 focus-visible:ring-[#5ec0e8] rounded-sm";
+/** The list card: the Sign up glass with the download menu's corners. */
+// design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+const CARD = "w-full max-w-[480px] rounded-[20px] bg-white/[0.08] p-1.5 shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)] backdrop-blur-md";
+
+function Title({ children }: { children: ReactNode }) {
+ return (
+ <h1 tabIndex={-1} data-onboarding-heading="" className="font-display text-[clamp(34px,min(4.9vw,6.6vh),76px)] leading-[0.98] font-semibold tracking-[-0.045em] text-balance text-white outline-none">
+ {children}
+ </h1>
+ );
+}
+
+function Line({ children }: { children: ReactNode }) {
+ return <p className={cn("mt-[min(20px,2.2vh)] max-w-[430px] text-[16px] leading-[1.55] font-medium", GREY)}>{children}</p>;
+}
+
+function Check({ on }: { on: boolean }) {
+ return on ? (
+ <span className="flex size-[22px] shrink-0 items-center justify-center rounded-full bg-white text-[#0a152d]" data-check="on">
+ <CheckIcon className="size-[13px]" strokeWidth={3} />
+ </span>
+ ) : (
+ <span className="size-[22px] shrink-0 rounded-full shadow-[inset_0_0_0_1.5px_rgb(255_255_255/0.35)]" data-check="off" />
+ );
+}
+
+function Mark({ os }: { os: ComputerRow["os"] }) {
+ return <span className="flex size-7 shrink-0 items-center justify-center text-white">{os ? <OsMark os={os} className="h-[17px] w-auto" /> : <MonitorIcon className="size-4" />}</span>;
+}
+
+/** A row in the card: picked rows are lit; `disabled` rows are greyed, with no check and no hover. */
+function Row({ icon, name, sub, picked, disabled, onClick, extra, check = true, ...rest }: { icon: ReactNode; name: string; sub: ReactNode; picked?: boolean; disabled?: boolean; onClick?: () => void; extra?: ReactNode; check?: boolean } & Record<`data-${string}`, string | undefined>) {
+ const body = (
+ <>
+ {icon}
+ <span className="min-w-0 flex-1 text-left">
+ <span className="block text-[15px] leading-5 font-medium text-white">{name}</span>
+ <span className={cn("flex items-center gap-1.5 text-[13.5px] leading-[19px] font-medium", GREY)}>{sub}</span>
+ </span>
+ {extra}
+ {check && !disabled ? <Check on={Boolean(picked)} /> : null}
+ </>
+ );
+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+ const cls = cn("flex w-full items-center gap-3 rounded-[14px] px-3 py-[7px]", picked && "bg-white/10 shadow-[inset_0_0_0_1px_rgb(255_255_255/0.5)]", disabled && "pointer-events-none cursor-not-allowed opacity-40");
+ if (!onClick || disabled)
+ return (
+ <div className={cls} aria-disabled={disabled || undefined} {...rest}>
+ {body}
+ </div>
+ );
+ return (
+ <div role="checkbox" aria-checked={Boolean(picked)} tabIndex={0} className={cn(cls, "cursor-pointer outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]")} onClick={onClick} onKeyDown={(e) => (e.key === " " || e.key === "Enter") && (e.preventDefault(), onClick())} {...rest}>
+ {body}
+ </div>
+ );
+}
+
+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>;
+
+/* ---- The screens (drawn from their views, so tests draw every state) --------------------- */
+
+export function WelcomeScreen({ onAdd }: { onAdd: () => void }) {
+ return (
+ <div data-new-run="welcome">
+ <Title>{WELCOME.title}</Title>
+ <Line>{WELCOME.line}</Line>
+ <div className="mt-9">
+ <button type="button" className={WHITE_BUTTON} onClick={onAdd} data-onboarding-primary="">
+ {WELCOME.primary}
+ </button>
+ </div>
+ </div>
+ );
+}
+
+export function SignInScreen({ view, onTryAgain, onUseCode, onOpen }: { view: SignInView; onTryAgain: () => void; onUseCode: () => void; onOpen: (url: string) => void }) {
+ return (
+ <div data-new-run="signin" data-state={view.state}>
+ <Title>{view.title}</Title>
+ <Line>{view.line}</Line>
+ {view.code ? (
+ <div className="mt-6 flex flex-col gap-2" data-new-run-code="">
+ <span className="font-mono text-[28px] font-semibold tracking-[0.12em] text-white select-text">{view.code.code}</span>
+ {view.code.url ? (
+ <button type="button" className={cn(LINK, "self-start text-[14px]")} onClick={() => onOpen(view.code!.url!)}>
+ Open the sign-in page
+ </button>
+ ) : null}
+ </div>
+ ) : null}
+ {view.waiting ? (
+ <div className="mt-6 flex items-center gap-3 text-[15px] font-medium text-white" role="status" data-new-run-waiting="">
+ <LoaderCircleIcon aria-hidden className="size-4 animate-spin motion-reduce:animate-none" />
+ {view.waiting}
+ </div>
+ ) : null}
+ <div className="mt-6 flex flex-wrap items-center gap-3">
+ <button type="button" className={view.tryAgainPrimary ? WHITE_BUTTON : GLASS_BUTTON} onClick={onTryAgain} data-new-run-try-again="">
+ {view.tryAgain}
+ </button>
+ {view.useCode ? (
+ <button type="button" className={GLASS_BUTTON} onClick={onUseCode} data-new-run-use-code="">
+ {view.useCode}
+ </button>
+ ) : null}
+ </div>
+ </div>
+ );
+}
+
+export function WhereScreen({
+ view,
+ onToggle,
+ onAddThis,
+ onSignIn,
+ onAddAnother,
+ onSeparate,
+ onContinue,
+}: {
+ view: WhereView;
+ onToggle: (id: string) => void;
+ onAddThis: () => void;
+ onSignIn: () => void;
+ onAddAnother: () => void;
+ onSeparate: () => void;
+ onContinue: () => void;
+}) {
+ const t = view.thisRow;
+ const sep = view.separate;
+ 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="macos" />}
+ 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 ? (
+ <>
+ <Label>{view.othersLabel}</Label>
+ {view.others.length ? (
+ view.others.map((o) => <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} />)
+ ) : (
+ <p className={cn("px-3 pt-1 pb-2 text-[13.5px] leading-[19px] font-medium", GREY)} data-new-run-none="">
+ {view.emptyLine}
+ </p>
+ )}
+ </>
+ ) : 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}
+ </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>
+ <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>
+ <div className="mt-[min(28px,3vh)]">
+ <button type="button" className={WHITE_BUTTON} disabled={!view.continueEnabled} onClick={onContinue} data-onboarding-primary="">
+ Continue
+ </button>
+ </div>
+ </div>
+ );
+}
+
+export function AgentScreen({ view, onPick, onContinue, onInstall, busy }: { view: AgentView; onPick: (id: string) => void; onContinue: () => void; onInstall: (agent: "claude-code" | "codex") => void; busy: boolean }) {
+ return (
+ <div data-new-run="agent" data-state={view.state}>
+ <Title>{view.title}</Title>
+ {view.line ? <Line>{view.line}</Line> : null}
+ {view.agents.length ? (
+ <div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-agents="">
+ <div className={cn("flex items-center gap-2 px-3 pt-2 pb-2 text-[12.5px] font-semibold tracking-[0.02em]", GREY)}>
+ <OsMark os="macos" className="h-3 w-auto" />
+ {view.label}
+ </div>
+ {view.agents.map((a) => (
+ <Row
+ key={a.id}
+ icon={<span className="flex size-7 shrink-0 items-center justify-center">{<AppMarkImage agent={a.id} className="size-5" />}</span>}
+ name={a.name}
+ sub={a.maker}
+ picked={a.picked}
+ onClick={view.state === "several" ? () => onPick(a.id) : undefined}
+ data-new-run-agent={a.id}
+ />
+ ))}
+ </div>
+ ) : null}
+ {view.error ? (
+ <p role="alert" className="mt-3 max-w-[480px] text-[13.5px] font-medium text-white" data-new-run-agent-error="">
+ {view.error}
+ </p>
+ ) : null}
+ {view.install ? (
+ <>
+ <div className="mt-9 flex flex-wrap items-center gap-6">
+ <button type="button" className={WHITE_BUTTON} onClick={() => onInstall("claude-code")} data-new-run-install="claude-code">
+ {view.install.primary}
+ </button>
+ <button type="button" className={cn(LINK, "text-[15px]")} onClick={() => onInstall("codex")} data-new-run-install="codex">
+ {view.install.secondary}
+ </button>
+ </div>
+ <p className={cn("mt-4 max-w-[480px] text-[13.5px] font-medium", GREY)}>{view.install.note}</p>
+ </>
+ ) : view.state !== "looking" ? (
+ <div className="mt-[min(28px,3vh)]">
+ <button type="button" className={WHITE_BUTTON} disabled={!view.continueEnabled || busy} onClick={onContinue} data-onboarding-primary="">
+ {busy ? "Setting up…" : "Continue"}
+ </button>
+ </div>
+ ) : null}
+ </div>
+ );
+}
+
+export function ReadyScreen({ view, agent, onDone }: { view: ReadyView; agent: string; onDone: () => void }) {
+ const [copied, setCopied] = useState(false);
+ const copy = () => {
+ void navigator.clipboard?.writeText(view.command).catch(() => {});
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ };
+ return (
+ <div data-new-run="ready">
+ <Title>{view.title}</Title>
+ <Line>{view.line}</Line>
+ {/* design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages */}
+ <div className="mt-7 flex w-full max-w-[600px] items-center gap-3 rounded-[20px] bg-white/[0.08] py-2.5 pr-2.5 pl-4 shadow-[inset_0_0_0_1px_rgb(255_255_255/0.28)] backdrop-blur-md" data-new-run-command="">
+ <AppMarkImage agent={agent} className="size-4 shrink-0" />
+ <code className="min-w-0 flex-1 truncate font-mono text-[14.5px] text-white select-text">
+ <span className={GREY}>$ </span>
+ {view.command}
+ </code>
+ <button type="button" className={cn(GLASS_CHIP, "h-[30px] shrink-0 gap-1.5 px-3 text-[13.5px]")} onClick={copy} data-new-run-copy="">
+ {copied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />}
+ {copied ? "Copied" : view.copy}
+ </button>
+ </div>
+ <div className="mt-6">
+ <button type="button" className={WHITE_BUTTON} onClick={onDone} data-onboarding-primary="">
+ {view.done}
+ </button>
+ </div>
+ </div>
+ );
+}
+
+export function NextScreen({ view, onRow, onDone, apps }: { view: NextView; onRow: (id: NextView["rows"][number]["id"]) => void; onDone: () => void; apps?: ReactNode }) {
+ const ICON = { invite: UserPlusIcon, "add-computer": MonitorIcon, apps: ShieldIcon } as const;
+ return (
+ <div data-new-run="next">
+ <Title>{view.title}</Title>
+ <Line>{view.line}</Line>
+ <div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-next="">
+ {view.rows.map((r) => {
+ const Icon = ICON[r.id];
+ return (
+ <div key={r.id}>
+ {/* 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.5 text-left outline-none hover:bg-white/[0.06] focus-visible:ring-2 focus-visible:ring-[#5ec0e8]" onClick={() => onRow(r.id)} data-new-run-next-row={r.id}>
+ <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)]">
+ <Icon className="size-3.5" />
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block text-[15px] leading-5 font-medium text-white">{r.title}</span>
+ <span className={cn("block text-[13.5px] leading-[19px] font-medium", GREY)}>{r.sub}</span>
+ </span>
+ <ChevronRightIcon className={cn("size-4 shrink-0", GREY)} />
+ </button>
+ {r.id === "apps" ? apps : null}
+ </div>
+ );
+ })}
+ </div>
+ <div className="mt-[min(28px,3vh)]">
+ <button type="button" className={WHITE_BUTTON} onClick={onDone} data-onboarding-primary="">
+ {view.done}
+ </button>
+ </div>
+ </div>
+ );
+}
+
+/** "Let agents use apps on this Mac", opened: the two permissions, each through the app's guide (PermissionGuide). */
+export function AppsPermissions({ rows, onAllow }: { rows: { id: string; title: string; granted: boolean; url: string }[]; onAllow: (url: string) => void }) {
+ // design-ok: the first run is drawn from the spaces.cua.ai hero (storyboard CUA-3193), not the app's pages
+ const box = "mx-3 mb-2 flex flex-col gap-1 border-t border-white/[0.14] pt-2 pl-10";
+ return (
+ <div className={box} data-new-run-apps="">
+ {rows.map((r) => (
+ <div key={r.id} className="flex min-h-9 items-center gap-3" data-new-run-permission={r.id} data-granted={String(r.granted)}>
+ <span className="min-w-0 flex-1 text-[14px] font-medium text-white">{r.title}</span>
+ {r.granted ? (
+ <span className="flex items-center gap-1 text-[13.5px] font-medium text-white">
+ <CheckIcon className="size-3.5" /> Allowed
+ </span>
+ ) : (
+ <button type="button" className={cn(GLASS_CHIP, "h-[30px] px-3.5 text-[13.5px]")} onClick={() => onAllow(r.url)}>
+ Allow
+ </button>
+ )}
+ </div>
+ ))}
+ <p className={cn("pb-1 text-[12.5px] font-medium", GREY)}>Allow opens System Settings, where you turn on Cua Spaces.</p>
+ </div>
+ );
+}
+
+/* ---- The page ------------------------------------------------------------------------- */
+
+/** The daemon's refusal on a Mac that can't run virtual computers (`cua_create_failure::preflight::MAC_UNSUPPORTED`). */
+const CANT_RUN = /can['\u2019]t run (Spaces itself|virtual computers)/i;
+
+const PERMISSIONS = [
+ { id: "screen-recording", title: "See the screen", url: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture" },
+ { id: "accessibility", title: "Use the mouse and keyboard", url: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility" },
+];
+
+/** The new first run's whole page. */
+export function NewFirstRun() {
+ const navigate = useNavigate();
+ const ctx = useContext(BridgeContext);
+ const adapter = ctx?.adapter ?? null;
+ const store = ctx?.store ?? null;
+ const os = hostOs();
+ const session = useSession();
+ const machines = useMachines();
+ const settings = useSettings();
+ const spaces = useSpaces();
+ 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 go = (screen: NewRunScreenName) => save({ screen });
+
+ const signedIn = Boolean(session.data?.signedIn);
+ const phase: SignInPhase = session.data?.signIn ?? { kind: "idle" };
+ const [now, setNow] = useState(() => Date.now());
+ const [found, setFound] = useState<string[] | null>(null);
+ const [agentPick, setAgentPick] = useState<string | null>(s.agent);
+ const [connecting, setConnecting] = useState(false);
+ const [connectError, setConnectError] = useState<string | null>(null);
+ const [thisState, setThisState] = useState<"adding" | "added" | "failed">("adding");
+ const [addError, setAddError] = useState<string | null>(null);
+ const [explain, setExplain] = useState(false);
+ const [addOpen, setAddOpen] = useState(false);
+ 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.
+ useEffect(() => {
+ document.querySelector<HTMLElement>("[data-onboarding-heading]")?.focus();
+ }, [s.screen]);
+
+ // Sign-in: started when 1b opens, and over once the session says signed in.
+ const started = useRef(false);
+ useEffect(() => {
+ if (s.screen !== "signin") {
+ started.current = false;
+ return;
+ }
+ if (signedIn) {
+ save({ screen: "where", addedInRun: true });
+ return;
+ }
+ if (!started.current && phase.kind === "idle") {
+ started.current = true;
+ void session.signIn().catch(() => {});
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [s.screen, signedIn, phase.kind]);
+
+ // Screen 2, signed in: this computer joins the account (once; the store also does it on sign-in).
+ const addRun = useRef(0);
+ const addThis = async () => {
+ if (!store) return setThisState("added");
+ const n = ++addRun.current;
+ setThisState("adding");
+ setAddError(null);
+ const ok = await store.addThisComputer(session.data?.identity ?? null).catch(() => false);
+ if (n !== addRun.current) return;
+ setThisState(ok ? "added" : "failed");
+ if (!ok) setAddError(store.thisMachine.get().setupError?.message ?? null);
+ };
+ useEffect(() => {
+ if (s.screen === "where" && signedIn) void addThis();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [s.screen, signedIn]);
+
+ // The account's computers, read again while screen 2 shows.
+ useEffect(() => {
+ if (s.screen !== "where" || !signedIn) return;
+ void machines.refresh().catch(() => {});
+ const t = setInterval(() => {
+ setNow(Date.now());
+ void machines.refresh().catch(() => {});
+ }, 10_000);
+ return () => clearInterval(t);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [s.screen, signedIn]);
+
+ // Screen 3: the coding agents on this computer (`agents.setup`: the app itself, never a file Cua wrote), read now and again.
+ useEffect(() => {
+ if (s.screen !== "agent" || !adapter) return;
+ let live = true;
+ const read = () =>
+ void adapter
+ .call("agents.setup", {})
+ .then((rows) => live && setFound(rows.filter((r) => r.installed).map((r) => r.agent)))
+ .catch(() => live && setFound((f) => f ?? []));
+ read();
+ const t = setInterval(read, 3_000);
+ window.addEventListener("focus", read);
+ return () => {
+ live = false;
+ clearInterval(t);
+ window.removeEventListener("focus", read);
+ };
+ }, [s.screen, adapter]);
+
+ // Screen 6's permissions, read while they show.
+ useEffect(() => {
+ if (!appsOpen || !adapter) return;
+ let live = true;
+ const read = () =>
+ void adapter
+ .call("host.status", {})
+ .then((h) => live && setHost(h))
+ .catch(() => {});
+ read();
+ const t = setInterval(read, 2_500);
+ window.addEventListener("focus", read);
+ return () => {
+ live = false;
+ clearInterval(t);
+ window.removeEventListener("focus", read);
+ };
+ }, [appsOpen, adapter]);
+
+ // The separate computer: this page's create, followed in the Spaces list.
+ const linux = offers.offers.find((o) => o.id === "linux") ?? null;
+ const made = useMemo(() => {
+ if (explain) return { phase: "explain" as const, name: null, error: null, id: null };
+ if (!s.separatePendingId) return { phase: "none" as const, name: null, error: null, id: null };
+ const id = store?.createdId(s.separatePendingId) ?? s.separatePendingId;
+ const row = spaces.data?.find((x) => x.id === id);
+ if (!row) return { phase: "making" as const, name: null, error: null, id: null };
+ const st = spaceState(row);
+ const name = spokenName(row.name);
+ if (st === "failed") return { phase: "failed" as const, name, error: row.progress?.error ?? null, id: row.id };
+ return { phase: st === "creating" ? ("making" as const) : ("ready" as const), name, error: null, id: row.id };
+ }, [explain, s.separatePendingId, spaces.data, store]);
+ // A Mac that can't run virtual computers is only known when the daemon refuses the create (#6323): then
+ // the option turns grey with the plain sentence, instead of a failure.
+ const cantRun = made.phase === "failed" && CANT_RUN.test(made.error ?? "");
+ const canMakeSeparate = cantRun ? false : !offers.known ? null : Boolean(linux && !linux.blocked);
+ const separate = cantRun ? { phase: "none" as const, name: null, error: null, id: null } : made;
+
+ const makeSeparate = () => {
+ if (!linux || linux.blocked) return;
+ // On a Mac, our one line first; the ask itself is the daemon's, before the create (#6009).
+ if (os === "macos" && !explain && separate.phase !== "failed") return setExplain(true);
+ setExplain(false);
+ const pendingId = newPendingId();
+ save({ separatePendingId: pendingId, picks: [...new Set([...s.picks, `pending:${pendingId}`])] });
+ spaces.createSpace({ ...linux.args, name: extraName("linux", spaces.data ?? []), os: linux.os, notifyWhenReady: true }, pendingId).catch(() => {
+ // The Spaces list shows the failure; the line reads it from there.
+ });
+ };
+
+ const whereInput = {
+ os,
+ signedIn,
+ thisState: signedIn ? thisState : ("signed-out" as const),
+ addedInRun: s.addedInRun,
+ addError,
+ model: machines.data?.find((m) => m.current)?.model ?? null,
+ machines: machines.data ?? null,
+ picks: s.picks,
+ canMakeSeparate,
+ separateBlocked: linux?.blocked ?? null,
+ separate,
+ now,
+ };
+ const where = whereView(whereInput);
+
+ /** The picked computers' names for screen 4: this computer, the others, then the separate computer. */
+ const pickedNames = (): string[] => {
+ const out: string[] = [];
+ for (const p of s.picks) {
+ if (p === "this") out.push("this");
+ else if (p.startsWith("pending:")) {
+ if (separate.name) out.push(separate.name);
+ } else {
+ const m = machines.data?.find((x) => x.id === p);
+ if (m?.online) out.push(m.name);
+ }
+ }
+ return out.length ? out : ["this"];
+ };
+
+ const agent = chosenAgent(found, agentPick);
+ const agentScreen = agentView({ os, found, picked: agentPick, error: connectError });
+ const continueAgent = async () => {
+ if (!agent || !adapter || connecting) return;
+ setConnecting(true);
+ setConnectError(null);
+ try {
+ // The same connect as Settings and the old first run: Cua's tools in the agent's settings, and its sign-in kept.
+ const viaConnect = await adapter.call("agents.connect", { agents: [agent], signIn: true }).then(
+ () => true,
+ () => false,
+ );
+ const rows = viaConnect ? await adapter.call("agents.setup", {}) : await adapter.call("agents.configure", { agents: [agent] });
+ const row = rows.find((r) => r.agent === agent);
+ if (!row?.configured) {
+ setConnectError(`Cua couldn't add itself to ${row?.name ?? "the agent"}'s settings.${row?.detail ? ` ${row.detail}` : ""}`);
+ return;
+ }
+ save({ agent, screen: "ready" });
+ } catch (e) {
+ setConnectError(e instanceof Error ? e.message : String(e));
+ } finally {
+ setConnecting(false);
+ }
+ };
+
+ const open = (url: string) => void session.openExternal(url).catch(() => {});
+
+ const leave = () => {
+ session.cancelSignIn();
+ writeSavedOnboarding({ ...readSavedOnboarding(), skipped: true });
+ writeFirstRun({ finishedLater: true });
+ void navigate({ to: "/spaces" });
+ };
+ const skip = () => {
+ if (s.screen === "welcome" || s.screen === "signin") {
+ session.cancelSignIn();
+ go("where");
+ } else leave();
+ };
+ const finish = async () => {
+ await session.completeOnboarding(thisState === "added" && signedIn ? "host" : "client").catch(() => {});
+ writeFirstRun({ finishedLater: false, todosClosed: false });
+ await navigate({ to: "/home" });
+ };
+
+ const startSignIn = () => {
+ started.current = true;
+ go("signin");
+ void session.signIn().catch(() => {});
+ };
+
+ const accountUrl = settings.data?.accountUrl ?? "https://app.cua.ai";
+ const dot = dotFor(s.screen);
+ const showSkip = s.screen === "welcome" || s.screen === "signin" || s.screen === "where" || s.screen === "agent";
+
+ let body: ReactNode = null;
+ switch (s.screen) {
+ case "welcome":
+ body = <WelcomeScreen onAdd={startSignIn} />;
+ break;
+ case "signin":
+ body = (
+ <SignInScreen
+ view={signInView(phase, session.data?.signInUrl ?? null)}
+ onTryAgain={() => {
+ session.cancelSignIn();
+ void session.signIn().catch(() => {});
+ }}
+ onUseCode={() => {
+ session.cancelSignIn();
+ void session.signIn({ code: true }).catch(() => {});
+ }}
+ onOpen={open}
+ />
+ );
+ break;
+ case "where":
+ body = (
+ <WhereScreen
+ view={where}
+ onToggle={(id) => save({ picks: togglePick(s.picks, id, where.others ?? []) })}
+ onAddThis={() => (signedIn ? void addThis() : startSignIn())}
+ onSignIn={startSignIn}
+ onAddAnother={() => setAddOpen(true)}
+ onSeparate={makeSeparate}
+ onContinue={() => go("agent")}
+ />
+ );
+ break;
+ case "agent":
+ body = (
+ <AgentScreen
+ view={agentScreen}
+ busy={connecting}
+ onPick={(id) => {
+ setAgentPick(id);
+ save({ agent: id });
+ }}
+ onContinue={() => void continueAgent()}
+ onInstall={(a) => open(INSTALL_PAGES[a])}
+ />
+ );
+ break;
+ case "ready":
+ body = s.agent ? <ReadyScreen view={readyView({ os, agent: s.agent, computers: pickedNames() })} agent={s.agent} onDone={() => go("next")} /> : null;
+ break;
+ case "next": {
+ const granted = (id: string) => Boolean(host?.permissions.find((p) => p.id === id)?.granted);
+ body = (
+ <NextScreen
+ view={nextView({ os })}
+ onRow={(id) => {
+ if (id === "invite") open(`${accountUrl}/team`);
+ else if (id === "add-computer") setAddOpen(true);
+ else setAppsOpen((o) => !o);
+ }}
+ onDone={() => void finish()}
+ apps={
+ appsOpen ? (
+ <AppsPermissions
+ rows={PERMISSIONS.map((p) => ({ ...p, granted: granted(p.id), url: host?.permissions.find((x) => x.id === p.id)?.settingsUrl ?? p.url }))}
+ onAllow={(url) => void adapter?.call("host.openSettings", { url }).catch(() => {})}
+ />
+ ) : null
+ }
+ />
+ );
+ break;
+ }
+ }
+
+ return (
+ <div className="dark relative flex h-full flex-col overflow-hidden bg-[#050607] text-white" data-new-first-run="" data-step={s.screen}>
+ <FloatKeys copyRight={544} />
+ <header className="relative z-30 flex shrink-0 items-center justify-between pt-[calc(var(--titlebar-height,0px)+12px)] pr-16 pb-2 pl-16">
+ <span className="flex items-center gap-1.5">
+ <CuaLogo className="size-5" />
+ <span className="font-display text-[19px] font-medium tracking-[-0.01em] text-white">Cua</span>
+ </span>
+ {showSkip ? (
+ <button type="button" className={cn(GLASS_CHIP, "h-9 px-4 text-[14px]")} onClick={skip} data-onboarding-later="">
+ Skip for now
+ </button>
+ ) : null}
+ </header>
+ <main className="relative z-20 flex min-h-0 flex-1 flex-col overflow-y-auto px-16">
+ <div aria-hidden className="min-h-0 shrink-0 grow basis-0" />
+ <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>
+ ) : (
+ <div className="h-8 shrink-0" />
+ )}
+ <AddComputerSheet open={addOpen} onOpenChange={setAddOpen} />
+ </div>
+ );
+}
+
+type NewRunScreenName = NewRunSaved["screen"];
diff --git a/apps/cua-spaces-web/src/components/first-run-new/float-keys.tsx b/apps/cua-spaces-web/src/components/first-run-new/float-keys.tsx
new file mode 100644
index 0000000000..8e7ab446d4
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/first-run-new/float-keys.tsx
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+/**
+ * The spaces.cua.ai hero behind the new first run: the site's starfield photo, its twinkling stars and
+ * its floating keycaps, at the places the site's wide layout gives them. The images are the site's own
+ * public renders (public/onboarding/float, copied unchanged from spaces.cua.ai/_spaces/img/float).
+ * The three product keys carry the Apple, Windows and Linux marks from the site's download menu, set on
+ * each key's top face the way the site sets its product marks (a projective map onto the face's four
+ * corners). Keys drift slowly; with reduced motion they stay still.
+ */
+
+import { useEffect, useRef, useState, type CSSProperties } from "react";
+
+import { OS_MARKS, type MarkOs } from "./os-marks";
+
+/** A key's centre (% of the frame), its width (% of the frame's width), depth (0 far, 1 near) and tilt. */
+type Place = { src: string; x: number; y: number; size: number; depth: number; rot: number; soft?: boolean; mark?: MarkOs };
+
+/** The site's WIDE layout (spaces-site float-layout.ts), with the OS marks on its product keys. */
+export const KEYS: Place[] = [
+ { src: "far-2", x: 54, y: 47, size: 5.2, depth: 0.1, rot: -8 },
+ { src: "far-4", x: 46, y: 74, size: 5, depth: 0.1, rot: 12 },
+ { src: "far-1", x: 58, y: 90, size: 5.6, depth: 0.12, rot: 4 },
+ { src: "far-3", x: 97, y: 50, size: 5, depth: 0.1, rot: 6 },
+ { src: "ivory-3", x: 85, y: 13, size: 9.5, depth: 0.45, rot: 4 },
+ { src: "ivory-1", x: 64, y: 60, size: 13.5, depth: 0.5, rot: -6 },
+ { src: "ivory-5", x: 95, y: 68, size: 10, depth: 0.45, rot: 8 },
+ { src: "ivory-6", x: 70, y: 86, size: 9, depth: 0.45, rot: -3 },
+ { src: "product-4", x: 61, y: 30, size: 14, depth: 0.55, rot: -4 },
+ { src: "product-1", x: 78, y: 40, size: 15, depth: 0.6, rot: 6, mark: "windows" },
+ { src: "product-2", x: 93, y: 27, size: 13, depth: 0.55, rot: -9, mark: "macos" },
+ { src: "product-3", x: 77, y: 66, size: 14, depth: 0.6, rot: 3, mark: "linux" },
+ { src: "near-2", x: 56, y: 6, size: 15, depth: 0.9, rot: 0 },
+ { src: "near-1", x: 3, y: 92, size: 19, depth: 1, rot: 0, soft: true },
+ { src: "near-3", x: 92, y: 96, size: 19, depth: 0.95, rot: 0 },
+];
+
+/** Each render's size in px and, for the product keys, its top face's corners (spaces-site float-sprites.json). */
+const SPRITES: Record<string, { w: number; h: number; quad?: number[][] }> = {
+ "far-1": { w: 236, h: 220 },
+ "far-2": { w: 225, h: 212 },
+ "far-3": { w: 220, h: 220 },
+ "far-4": { w: 237, h: 226 },
+ "ivory-1": { w: 397, h: 383 },
+ "ivory-3": { w: 392, h: 393 },
+ "ivory-5": { w: 352, h: 350 },
+ "ivory-6": { w: 365, h: 398 },
+ "product-1": { w: 486, h: 470, quad: [[105, 78], [325, 22], [415, 215], [165, 268]] },
+ "product-2": { w: 494, h: 481, quad: [[100, 92], [300, 15], [408, 222], [185, 298]] },
+ "product-3": { w: 491, h: 477, quad: [[95, 82], [318, 12], [410, 210], [172, 282]] },
+ "product-4": { w: 484, h: 469 },
+ "near-1": { w: 473, h: 397 },
+ "near-2": { w: 467, h: 471 },
+ "near-3": { w: 463, h: 459 },
+};
+
+/** The blue key's face is printed dark, the way the site prints its template mark there; the navy and copper keys in white. */
+const MARK_STYLE: Record<MarkOs, CSSProperties> = {
+ windows: { color: "#000", opacity: 0.8, mixBlendMode: "multiply" },
+ macos: { color: "#fff", opacity: 0.88 },
+ linux: { color: "#fff", opacity: 0.88 },
+};
+
+/** The site's frame for windows near 3:2 (1512 x 982): its layout is drawn on it and scaled to cover. */
+const FRAME = { w: 1486, h: 956 };
+
+/** CSS matrix3d that maps a 100 x 100 box onto four points (the site's `homography`). */
+export function homography(q: number[][]): string {
+ const [[x0, y0], [x1, y1], [x2, y2], [x3, y3]] = q as unknown as [[number, number], [number, number], [number, number], [number, number]];
+ const dx1 = x1 - x2, dx2 = x3 - x2, dy1 = y1 - y2, dy2 = y3 - y2, sx = x0 - x1 + x2 - x3, sy = y0 - y1 + y2 - y3;
+ const den = dx1 * dy2 - dx2 * dy1;
+ const g = (sx * dy2 - dx2 * sy) / den, h = (dx1 * sy - sx * dy1) / den;
+ const a = x1 - x0 + g * x1, b = x3 - x0 + h * x3, d = y1 - y0 + g * y1, e = y3 - y0 + h * y3;
+ return `matrix3d(${a / 100},${d / 100},0,${g / 100},${b / 100},${e / 100},0,${h / 100},0,0,1,0,${x0},${y0},0,1)`;
+}
+
+/**
+ * Where each key goes in a box of `w` x `h` whose copy ends `copyRight` px from the left: the frame
+ * scaled to cover the box, then (like the site's `wide`) the keys right of centre pressed into the
+ * space right of the copy when the copy runs past the middle.
+ */
+export function placeKeys(w: number, h: number, copyRight: number): (Place & { left: number; top: number; width: number; height: number })[] {
+ const s = Math.max(w / FRAME.w, h / FRAME.h);
+ const ox = (w - FRAME.w * s) / 2, oy = (h - FRAME.h * s) / 2;
+ const edge = (copyRight / w) * 100 + 3;
+ const k = edge <= 50 ? 1 : (100 - Math.min(edge, 70)) / 50;
+ return KEYS.map((p) => {
+ const sp = SPRITES[p.src]!;
+ let x = ((ox + (p.x / 100) * FRAME.w * s) / w) * 100;
+ let size = (p.size * FRAME.w * s) / w;
+ const y = ((oy + (p.y / 100) * FRAME.h * s) / h) * 100;
+ if (k < 1 && x >= 40) {
+ x = 100 - (100 - x) * k;
+ size *= Math.max(0.8, k);
+ }
+ const width = (size / 100) * w;
+ const height = (width * sp.h) / sp.w;
+ return { ...p, x, y, size, width, height, left: (x / 100) * w - width / 2, top: (y / 100) * h - height / 2 };
+ });
+}
+
+/** The site's 56 twinkling stars (same seed). */
+const STARS = (() => {
+ let s = 7;
+ const r = () => ((s = (s * 16807) % 2147483647) - 1) / 2147483646;
+ return Array.from({ length: 56 }, () => ({ x: r() * 100, y: r() * 100, d: 1.2 + r() * 1.1, o: 0.55 + r() ** 2 * 0.45, t: 2.4 + r() * 4, delay: -r() * 6 }));
+})();
+
+/** Each key's idle loop (the site's): a slow drift and a slight tumble. */
+const loop = (i: number) => ({ dur: 8 + ((i * 2.7) % 6), delay: -((i * 1.9) % 8), dx: 3 + (i % 4) * 2, dy: 4 + ((i + 1) % 3) * 3, dr: 2 + (i % 3) });
+
+/** The starfield and keys, filling the page. `copyRight`: where the page's text column ends, in px. */
+export function FloatKeys({ copyRight }: { copyRight: number }) {
+ const box = useRef<HTMLDivElement>(null);
+ const [size, setSize] = useState<{ w: number; h: number } | null>(null);
+ useEffect(() => {
+ const el = box.current;
+ if (!el) return;
+ const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });
+ measure();
+ if (typeof ResizeObserver === "undefined") return;
+ const ro = new ResizeObserver(measure);
+ ro.observe(el);
+ return () => ro.disconnect();
+ }, []);
+ // Too narrow for keys beside the copy: the starfield alone.
+ const keys = size && size.w >= 860 ? placeKeys(size.w, size.h, copyRight) : [];
+ return (
+ <div ref={box} aria-hidden className="pointer-events-none absolute inset-0 overflow-hidden bg-[#050607]" data-float-keys="">
+ <div className="absolute -inset-3">
+ <img src="/onboarding/float/space-1920.webp" alt="" draggable={false} className="absolute inset-0 size-full object-cover brightness-[1.7] contrast-[1.08] select-none" />
+ {STARS.map((s, i) => (
+ <span
+ key={i}
+ className="first-run-star"
+ style={{ left: `${s.x.toFixed(2)}%`, top: `${s.y.toFixed(2)}%`, width: s.d, height: s.d, "--o": s.o.toFixed(2), "--t": `${s.t.toFixed(1)}s`, "--d": `${s.delay.toFixed(1)}s` } as CSSProperties}
+ />
+ ))}
+ </div>
+ {keys.map((k, i) => {
+ const sp = SPRITES[k.src]!;
+ const sc = k.width / sp.w;
+ const l = loop(i);
+ return (
+ <div key={k.src} className="absolute" style={{ left: k.left, top: k.top, width: k.width, height: k.height, zIndex: Math.round(k.depth * 10) }} data-key={k.src} data-mark={k.mark}>
+ <div
+ className="first-run-key absolute inset-0"
+ style={{ "--r": `${k.rot}deg`, "--dx": `${l.dx}px`, "--dy": `${l.dy}px`, "--dr": `${l.dr}deg`, "--dur": `${l.dur}s`, "--delay": `${l.delay}s` } as CSSProperties}
+ >
+ <img src={`/onboarding/float/${k.src}.webp`} alt="" draggable={false} className="absolute inset-0 size-full select-none" style={k.soft ? { opacity: 0.72 } : undefined} />
+ {k.mark && sp.quad ? (
+ <div className="absolute top-0 left-0 size-[100px]" style={{ transformOrigin: "0 0", transform: homography(sp.quad.map(([x, y]) => [x! * sc, y! * sc])) }}>
+ <svg viewBox={OS_MARKS[k.mark].viewBox} fill="currentColor" className="absolute inset-[24%] size-[52%]" style={MARK_STYLE[k.mark]}>
+ <path d={OS_MARKS[k.mark].d} />
+ </svg>
+ </div>
+ ) : null}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/apps/cua-spaces-web/src/components/first-run-new/os-marks.tsx b/apps/cua-spaces-web/src/components/first-run-new/os-marks.tsx
new file mode 100644
index 0000000000..790cf34bec
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/first-run-new/os-marks.tsx
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+/**
+ * The Apple, Windows and Linux marks from the spaces.cua.ai download menu, paths unchanged: Apple's
+ * official mark (svgl.app, apple.svg), the four-pane Windows window, and Tux from Simple Icons (CC0,
+ * icons/linux.svg). The new first run puts them on its keys and beside its computers.
+ */
+
+import type { SVGProps } from "react";
+
+export type MarkOs = "macos" | "windows" | "linux";
+
+export const OS_MARKS: Record<MarkOs, { viewBox: string; d: string }> = {
+ macos: { viewBox: "0 0 814 1000", d: "M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z" },
+ windows: { viewBox: "0 0 24 24", d: "M0 0h11.4v11.4H0zM12.6 0H24v11.4H12.6zM0 12.6h11.4V24H0zM12.6 12.6H24V24H12.6z" },
+ linux: { viewBox: "0 0 24 24", d: "M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 00-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 01-.004-.021l-.004-.024a1.807 1.807 0 01-.15.706.953.953 0 01-.213.335.71.71 0 00-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 00-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 00-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 00-.205.334 1.18 1.18 0 00-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 01-.018-.2v-.02a1.772 1.772 0 01.15-.768c.082-.22.232-.406.43-.533a.985.985 0 01.594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 00-.166-.267.248.248 0 00-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 00-.12.27.944.944 0 00-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 01-.131.068 2.62 2.62 0 01-.275-.402 1.772 1.772 0 01-.155-.667 1.759 1.759 0 01.08-.668 1.43 1.43 0 01.283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 01.016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 01-.448-.067 3.566 3.566 0 01-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 00-.402-.533 1.45 1.45 0 00-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 00.314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 01.647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 01-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z" },
+};
+
+/** One mark, filled with the text colour. */
+export function OsMark({ os, ...rest }: { os: MarkOs } & SVGProps<SVGSVGElement>) {
+ const m = OS_MARKS[os];
+ return (
+ <svg aria-hidden="true" viewBox={m.viewBox} fill="currentColor" {...rest}>
+ <path d={m.d} />
+ </svg>
+ );
+}
diff --git a/apps/cua-spaces-web/src/index.css b/apps/cua-spaces-web/src/index.css
index 4c0fff77d7..47ed666eb4 100644
--- a/apps/cua-spaces-web/src/index.css
+++ b/apps/cua-spaces-web/src/index.css
@@ -121,6 +121,18 @@
@font-face { font-family: "Outfit"; font-weight: 600; font-display: swap; src: url(/onboarding/fonts/outfit-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url(/onboarding/fonts/instrument-serif-latin-400-italic.woff2) format("woff2"); }
+/* The new first run's floating keys and twinkling stars (the spaces.cua.ai hero's loops); still with reduced motion. */
+.first-run-key { transform: rotate(var(--r)); animation: first-run-drift var(--dur) ease-in-out var(--delay) infinite alternate; will-change: transform; }
+@keyframes first-run-drift {
+ from { transform: translate3d(calc(var(--dx) * -1), calc(var(--dy) * -1), 0) rotate(calc(var(--r) - var(--dr))); }
+ to { transform: translate3d(var(--dx), var(--dy), 0) rotate(calc(var(--r) + var(--dr))); }
+}
+.first-run-star { position: absolute; border-radius: 9999px; background: rgb(240 243 250); box-shadow: 0 0 3px rgb(240 243 250 / 0.7); opacity: var(--o); animation: first-run-twinkle var(--t) ease-in-out var(--d) infinite alternate; }
+@keyframes first-run-twinkle { from { opacity: calc(var(--o) * 0.3); } }
+@media (prefers-reduced-motion: reduce) {
+ .first-run-key, .first-run-star { animation: none; }
+}
+
@theme {
--font-display: "Outfit", var(--font-sans);
--font-accent: "Instrument Serif", ui-serif, Georgia, serif;
diff --git a/apps/cua-spaces-web/src/lib/first-run-new.ts b/apps/cua-spaces-web/src/lib/first-run-new.ts
new file mode 100644
index 0000000000..9684e7562a
--- /dev/null
+++ b/apps/cua-spaces-web/src/lib/first-run-new.ts
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+/**
+ * The new first run (Labs, "Try the new setup"; CUA-3318, storyboard CUA-3193), phase 1: what each
+ * screen says and which choices it offers, from what the app knows. Pure, so every state is tested
+ * without a host. The page (`components/first-run-new`) draws it.
+ *
+ * 1 Bring all your computers under one account: Add this computer (sign in) or Skip for now.
+ * 1b Finish signing in in your browser: Try again, Use a code instead; "Sign-in didn't finish".
+ * 2 Pick where your agents work: this Mac, the account's other computers (offline ones can't be
+ * picked), Add another computer you own, and a separate computer on this Mac.
+ * 3 The coding agent found on this Mac, or Install Claude Code / Install Codex instead.
+ * 4 Ready: "<agent> can now use <computers>", one line to try in their own terminal.
+ * 6 Next steps: invite a teammate, add another computer, let agents use apps on this Mac.
+ */
+
+import type { Machine, SignInPhase } from "@/bridge";
+import { relativeTime } from "@/lib/utils";
+
+export type NewRunScreen = "welcome" | "signin" | "where" | "agent" | "ready" | "next";
+
+export const NEW_RUN_SCREENS: NewRunScreen[] = ["welcome", "signin", "where", "agent", "ready", "next"];
+
+/** What the run keeps between launches (inside the first run's saved record, so Reset & Show clears it). */
+export interface NewRunSaved {
+ screen: NewRunScreen;
+ /** The computers picked on screen 2: `this` for this computer, else a machine id or the separate computer's Space id. */
+ picks: string[];
+ /** The coding agent picked on screen 3 (setup id). */
+ agent: string | null;
+ /** This run asked to add this computer and the sign-in finished: its row says "just now". */
+ addedInRun: boolean;
+ /** The separate computer's create (its pending row id), once asked for. */
+ separatePendingId: string | null;
+}
+
+export const NEW_RUN_EMPTY: NewRunSaved = { screen: "welcome", picks: ["this"], agent: null, addedInRun: false, separatePendingId: null };
+
+/** "this Mac", "this PC", "this machine" (the app's THIS_MACHINE). */
+export function placeName(os: string): string {
+ return os === "macos" ? "this Mac" : os === "windows" ? "this PC" : "this machine";
+}
+
+const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
+
+/** "Mac mini", "Mac mini and Build server", "Mac mini, Gaming PC and Build server". */
+export function listNames(names: string[]): string {
+ return names.length < 2 ? (names[0] ?? "") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
+}
+
+/* ---- 1 ---------------------------------------------------------------------------------- */
+
+export const WELCOME = {
+ title: "Bring all your computers under one account",
+ line: "Sign in on each Mac, PC or Linux machine you own. Then you, your team and your coding agents can use any of them from here.",
+ primary: "Add this computer",
+ skip: "Skip for now",
+} as const;
+
+/* ---- 1b --------------------------------------------------------------------------------- */
+
+export interface SignInView {
+ state: "waiting" | "code" | "failed";
+ title: string;
+ line: string;
+ /** The waiting row's words (none once it failed). */
+ waiting: string | null;
+ /** The code to enter, and the page to enter it on, when signing in with a code. */
+ code: { code: string; url: string | null } | null;
+ /** Which button is the white one: Try again only once sign-in failed. */
+ tryAgainPrimary: boolean;
+ tryAgain: string;
+ useCode: string | null;
+}
+
+/** Why a sign-in didn't finish, in the words of #6408 for a browser that never confirmed; the core's own line otherwise. */
+export function signInView(phase: SignInPhase, url: string | null): SignInView {
+ const base = { tryAgain: "Try again", useCode: "Use a code instead" as string | null };
+ if (phase.kind === "failed") {
+ const line =
+ !phase.reason || phase.reason === "notConfirmed"
+ ? "The browser didn't confirm in time. Try again, or use a code if your browser is on another device."
+ : phase.message;
+ return { ...base, state: "failed", title: "Sign-in didn't finish", line, waiting: null, code: null, tryAgainPrimary: true };
+ }
+ if (phase.kind === "waiting" && phase.userCode) {
+ return {
+ ...base,
+ state: "code",
+ title: "Finish signing in in your browser",
+ line: "Open the sign-in page on any device and enter this code. This window moves on by itself when you're done.",
+ waiting: "Waiting for the code",
+ code: { code: phase.userCode, url },
+ tryAgainPrimary: false,
+ useCode: null,
+ };
+ }
+ return {
+ ...base,
+ state: "waiting",
+ title: "Finish signing in in your browser",
+ line: "Cua opened in your browser. Create your account there, or sign in if you already have one. This window moves on by itself when you're done.",
+ waiting: "Waiting for your browser",
+ code: null,
+ tryAgainPrimary: false,
+ };
+}
+
+/* ---- 2 ---------------------------------------------------------------------------------- */
+
+export interface ComputerRow {
+ id: string;
+ name: string;
+ os: "macos" | "windows" | "linux" | null;
+ sub: string;
+ picked: boolean;
+ /** Offline: shown greyed, with no check circle, and it can't be picked. */
+ disabled: boolean;
+}
+
+export interface WhereView {
+ title: string;
+ line: string;
+ thisRow: {
+ name: string;
+ /** "Added to your account just now", "In your account", "not added yet" ... */
+ status: string;
+ /** The white tick before the status (added in this run). */
+ tick: boolean;
+ model: string | null;
+ /** Signed out, the frame reads "MacBook Pro · not added yet": the model comes first. */
+ modelFirst: boolean;
+ picked: boolean;
+ /** Signed out: Add (opens 1b). Adding failed: Try again. */
+ action: { id: "add" | "retry-add"; label: string } | null;
+ };
+ /** Signed in: the account's other computers (empty: `emptyLine`). Signed out: null, and `signInLine` shows instead. */
+ others: ComputerRow[] | null;
+ othersLabel: string;
+ emptyLine: string;
+ signInLine: { link: string; rest: string } | null;
+ /** Signed in only: it needs an account. */
+ addAnother: { title: string; sub: string } | null;
+ separate: { title: string; sub: string; disabled: boolean; state: "offer" | "checking" | "explain" | "making" | "ready" | "failed"; action: string | null };
+ continueEnabled: boolean;
+}
+
+export interface WhereInput {
+ os: string;
+ signedIn: boolean;
+ /** This computer: being added, added (`addedInRun`: in this run), or the add failed. */
+ thisState: "adding" | "added" | "failed" | "signed-out";
+ addedInRun: boolean;
+ addError: string | null;
+ model: string | null;
+ machines: Pick<Machine, "id" | "name" | "os" | "online" | "lastSeen" | "current" | "device" | "notSharing">[] | null;
+ picks: string[];
+ /** Whether this computer can make a separate computer: null while still checking. */
+ canMakeSeparate: boolean | null;
+ /** Why not, in the host's words (used where the frame's sentence doesn't fit: not a Mac). */
+ separateBlocked: string | null;
+ separate: { phase: "none" | "explain" | "making" | "ready" | "failed"; name: string | null; error: string | null };
+ now: number;
+}
+
+function machineOs(os: string): ComputerRow["os"] {
+ const o = os.toLowerCase();
+ if (o === "macos" || o === "darwin" || o === "mac") return "macos";
+ if (o === "windows" || o === "win32") return "windows";
+ if (o === "linux") return "linux";
+ return null;
+}
+
+const OS_WORD: Record<NonNullable<ComputerRow["os"]>, string> = { macos: "macOS", windows: "Windows", linux: "Linux" };
+
+/** The account's other computers: ones the app can reach are offered, offline ones shown greyed. */
+export function otherComputers(input: Pick<WhereInput, "machines" | "picks" | "now">): ComputerRow[] {
+ return (input.machines ?? [])
+ .filter((m) => !m.current && !m.device)
+ .map((m) => {
+ const os = machineOs(m.os);
+ const offline = !m.online;
+ const sub = offline
+ ? m.lastSeen
+ ? `Offline, last seen ${relativeTime(m.lastSeen * 1000, input.now)}`
+ : "Offline"
+ : m.notSharing
+ ? "Not sharing"
+ : `${os ? OS_WORD[os] : "Computer"} · ready`;
+ const disabled = offline || Boolean(m.notSharing);
+ return { id: m.id, name: m.name, os, sub, picked: !disabled && input.picks.includes(m.id), disabled };
+ });
+}
+
+export function whereView(input: WhereInput): WhereView {
+ const place = placeName(input.os);
+ const Place = cap(place);
+ const thisPicked = input.picks.includes("this");
+ const separate = (() => {
+ const title = `Or make a separate computer on ${place}`;
+ if (input.canMakeSeparate === false) {
+ const sub =
+ input.os === "macos"
+ ? "This Mac can't make one. Older Intel Macs can't, for example. Your agents can still work on this Mac or on another computer you add."
+ : `${input.separateBlocked ? `${input.separateBlocked} ` : `${Place} can't make one. `}Your agents can still work on ${place} or on another computer you add.`;
+ return { title, sub, disabled: true, state: "offer" as const, action: null };
+ }
+ const s = input.separate;
+ if (s.phase === "explain")
+ return {
+ title,
+ sub: "If macOS asks to let Cua Spaces find devices on your local network, choose Allow. Cua uses it to reach the new computer.",
+ disabled: false,
+ state: "explain" as const,
+ action: "Make it",
+ };
+ if (s.phase === "making") return { title, sub: `Making ${s.name ?? "it"} now. You can continue; it keeps going.`, disabled: false, state: "making" as const, action: null };
+ if (s.phase === "ready") return { title, sub: `${s.name ?? "It"} is ready.`, disabled: false, state: "ready" as const, action: null };
+ if (s.phase === "failed") return { title, sub: `Couldn't make it. ${s.error ?? ""}`.trim(), disabled: false, state: "failed" as const, action: "Try again" };
+ if (input.canMakeSeparate === null) return { title, sub: "Checking whether this computer can make one…", disabled: true, state: "checking" as const, action: null };
+ return { title, sub: "A Linux computer just for your agents, away from your files. About 2 minutes.", disabled: false, state: "offer" as const, action: null };
+ })();
+
+ if (!input.signedIn) {
+ return {
+ title: "Pick where your agents work",
+ line: `Your agents can work on ${place} without an account. Add ${place} to an account when you want them on your other computers too.`,
+ thisRow: { name: Place, status: "not added yet", tick: false, model: input.model, modelFirst: true, picked: thisPicked, action: { id: "add", label: "Add" } },
+ others: null,
+ othersLabel: "Other computers in your account",
+ emptyLine: "",
+ signInLine: { link: "Sign in", rest: " to see your other computers." },
+ addAnother: null,
+ separate,
+ continueEnabled: input.picks.length > 0,
+ };
+ }
+ const status =
+ input.thisState === "adding"
+ ? "Adding to your account…"
+ : input.thisState === "failed"
+ ? `Couldn't add it to your account.${input.addError ? ` ${input.addError}` : ""}`
+ : input.addedInRun
+ ? "Added to your account just now"
+ : "In your account";
+ return {
+ title: "Pick where your agents work",
+ line: `You're signed in, and ${place} is now in your account. Your agents can start here, or on your other computers while you keep working on this one.`,
+ thisRow: {
+ name: Place,
+ status,
+ tick: input.thisState === "added",
+ model: input.model,
+ modelFirst: false,
+ picked: thisPicked,
+ action: input.thisState === "failed" ? { id: "retry-add", label: "Try again" } : null,
+ },
+ others: otherComputers(input),
+ othersLabel: "Other computers in your account",
+ emptyLine: "None yet. Computers you or your team sign in on show up here.",
+ signInLine: null,
+ addAnother: { title: "Add another computer you own", sub: "Install Cua Spaces on it and sign in. It shows up here." },
+ separate,
+ continueEnabled: input.picks.length > 0,
+ };
+}
+
+/** Picks a computer, or unpicks it. Offline computers never change. */
+export function togglePick(picks: string[], id: string, rows: ComputerRow[]): string[] {
+ if (rows.find((r) => r.id === id)?.disabled) return picks;
+ return picks.includes(id) ? picks.filter((p) => p !== id) : [...picks, id];
+}
+
+/* ---- 3 ---------------------------------------------------------------------------------- */
+
+/** The coding agents the first run looks for, in this order, with who makes them. */
+export const CODING_AGENTS: { id: string; name: string; maker: string; command: string | null }[] = [
+ { id: "claude-code", name: "Claude Code", maker: "By Anthropic", command: "claude" },
+ { id: "codex", name: "Codex", maker: "By OpenAI", command: "codex" },
+ { id: "gemini-cli", name: "Gemini CLI", maker: "By Google", command: "gemini" },
+ { id: "opencode", name: "OpenCode", maker: "By SST", command: "opencode" },
+ { id: "goose", name: "Goose", maker: "By Block", command: "goose" },
+ { id: "hermes", name: "Hermes", maker: "By Nous Research", command: null },
+];
+
+export const agentInfo = (id: string) => CODING_AGENTS.find((a) => a.id === id) ?? { id, name: id, maker: "", command: null };
+
+/** The official pages "Install" opens (phase 1: the page, not the installer). */
+export const INSTALL_PAGES = { "claude-code": "https://claude.com/product/claude-code", codex: "https://developers.openai.com/codex" } as const;
+
+const COUNT = ["", "one", "two", "three", "four", "five", "six"];
+
+export interface AgentView {
+ state: "looking" | "one" | "several" | "none";
+ title: string;
+ line: string;
+ /** "Found on this Mac". */
+ label: string;
+ agents: { id: string; name: string; maker: string; picked: boolean }[];
+ continueEnabled: boolean;
+ install: { primary: string; secondary: string; note: string } | null;
+ error: string | null;
+}
+
+/** `found`: the coding agents installed on this computer (setup ids); null while still looking. */
+export function agentView(input: { os: string; found: string[] | null; picked: string | null; error: string | null }): AgentView {
+ const place = placeName(input.os);
+ const label = `Found on ${place}`;
+ if (input.found === null)
+ return { state: "looking", title: "Looking for your coding agent…", line: "", label, agents: [], continueEnabled: false, install: null, error: null };
+ const found = CODING_AGENTS.filter((a) => input.found!.includes(a.id));
+ if (found.length === 0) {
+ return {
+ state: "none",
+ title: "Install a coding agent",
+ line: `Cua doesn't come with its own, and we didn't find one on ${place}. Install Claude Code, then sign in to it once.`,
+ label,
+ agents: [],
+ continueEnabled: false,
+ install: { primary: "Install Claude Code", secondary: "Install Codex instead", note: "This opens the official Claude Code install page in your browser. Come back here when it's installed." },
+ error: null,
+ };
+ }
+ if (found.length === 1) {
+ const a = found[0]!;
+ return {
+ state: "one",
+ title: `Your agents will use ${a.name}`,
+ line: `We found ${a.name} on ${place}. Your agents will use it to do the work while you keep working on other things.`,
+ label,
+ agents: [{ id: a.id, name: a.name, maker: a.maker, picked: true }],
+ continueEnabled: true,
+ install: null,
+ error: input.error,
+ };
+ }
+ const picked = found.some((a) => a.id === input.picked) ? input.picked : null;
+ return {
+ state: "several",
+ title: "Pick the coding agent to use",
+ line: `We found ${COUNT[found.length] ?? found.length} on ${place}. Pick the one your agents should use. You can change it for any job later.`,
+ label,
+ agents: found.map((a) => ({ id: a.id, name: a.name, maker: a.maker, picked: a.id === picked })),
+ continueEnabled: picked !== null,
+ install: null,
+ error: input.error,
+ };
+}
+
+/** The agent screen 3 settles on: the only one found, or the one picked among several. */
+export function chosenAgent(found: string[] | null, picked: string | null): string | null {
+ const list = CODING_AGENTS.filter((a) => (found ?? []).includes(a.id));
+ if (list.length === 1) return list[0]!.id;
+ return list.some((a) => a.id === picked) ? picked : null;
+}
+
+/* ---- 4 ---------------------------------------------------------------------------------- */
+
+export interface ReadyView {
+ title: string;
+ line: string;
+ command: string;
+ copy: string;
+ done: string;
+}
+
+/** `computers`: the picked computers' names, this computer first as `this` (written "this Mac"). */
+export function readyView(input: { os: string; agent: string; computers: string[] }): ReadyView {
+ const place = placeName(input.os);
+ const a = agentInfo(input.agent);
+ const names = input.computers.map((c) => (c === "this" ? place : c));
+ const elsewhere = input.computers.find((c) => c !== "this");
+ const task = elsewhere ? `Build this branch on ${elsewhere}` : `Make a separate Linux computer on ${place} and run this repo's tests in it`;
+ const command = a.command ? `${a.command} "${task}"` : task;
+ return {
+ title: `${a.name} can now use ${listNames(names)}`,
+ line: a.command ? "Try it from your own terminal. Nothing runs until you do." : `Paste this into ${a.name}. Nothing runs until you do.`,
+ command,
+ copy: "Copy",
+ done: "Done",
+ };
+}
+
+/* ---- 6 ---------------------------------------------------------------------------------- */
+
+export interface NextView {
+ title: string;
+ line: string;
+ rows: { id: "invite" | "add-computer" | "apps"; title: string; sub: string }[];
+ done: string;
+}
+
+export function nextView(input: { os: string }): NextView {
+ const place = placeName(input.os);
+ const apps = input.os === "macos";
+ return {
+ title: "Now bring the rest in",
+ line: apps
+ ? `When you're ready, add your team and your other computers, and let agents use apps on ${place}.`
+ : "When you're ready, add your team and your other computers.",
+ rows: [
+ { id: "invite", title: "Invite a teammate", sub: "They can use these computers and agents too." },
+ { id: "add-computer", title: "Add another computer", sub: "Install Cua Spaces on it and sign in." },
+ ...(apps ? [{ id: "apps" as const, title: `Let agents use apps on ${place}`, sub: "They can see the screen and use the mouse and keyboard, after you allow it." }] : []),
+ ],
+ done: "Done",
+ };
+}
+
+/** Which progress dot is lit (screens 1 to 3 have dots; 4 and 6 none). */
+export function dotFor(screen: NewRunScreen): number | null {
+ return screen === "welcome" || screen === "signin" ? 0 : screen === "where" ? 1 : screen === "agent" ? 2 : null;
+}
diff --git a/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx b/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx
index eeab874824..0e4d601456 100644
--- a/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx
+++ b/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx
@@ -3,7 +3,7 @@
import { useEffect, useRef } from "react";
-import { firstMessage, newPendingId, useBridge, useFirstSpaceOffers, useSpaces } from "@/bridge";
+import { firstMessage, newPendingId, useBridge, useFirstSpaceOffers, useSavedOnboarding, useSession, useSpaces } from "@/bridge";
import { useNewOnboarding } from "@/bridge/flags";
import { useSummonIn } from "@/components/ask-first/use-summon-in";
import { setPrepareSink } from "@/components/space-thread/queued";
@@ -44,6 +44,11 @@ export function PrepareRoot(): null {
const latestOffers = useRef(offers);
latestOffers.current = offers;
const on = useNewOnboarding();
+ // The new first run (CUA-3318) makes nothing the person didn't ask for: the home starts warming only once
+ // the first run is done or skipped, not while it shows. A separate computer is the first run's own choice.
+ const session = useSession();
+ const savedOnboarding = useSavedOnboarding();
+ const firstRunOver = Boolean(session.data?.onboarding.completed || savedOnboarding.skipped);
// Only an agent found on this computer is prepared: one Cua only wrote files for has no sign-in to bring.
const installed = useInstalledAgents();
const harness = installed === null ? null : installed.has(DEFAULT_HARNESS) ? DEFAULT_HARNESS : (installed.values().next().value ?? null);
@@ -142,11 +147,11 @@ export function PrepareRoot(): null {
markResumed();
d.resume();
}
- } else if (harness) {
+ } else if (harness && firstRunOver) {
markResumed();
d.start(harness);
}
- }, [ready, driverNow, harness]);
+ }, [ready, driverNow, harness, firstRunOver]);
// The home's composer sends here while it is being made: kept, then delivered once.
useEffect(() => {
diff --git a/apps/cua-spaces-web/src/routes/onboarding/index.tsx b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
index 76f387b824..28d85f0c3f 100644
--- a/apps/cua-spaces-web/src/routes/onboarding/index.tsx
+++ b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
@@ -5,11 +5,12 @@ import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
import { ArrowLeftIcon, CheckIcon, CopyIcon, ExternalLinkIcon } from "lucide-react";
import { useEffect, useState, type ReactNode } from "react";
-import { useAgentKeys, useBridge, useFirstRun, useSpaces, type FirstRunArt, type FirstRunCredential, type FirstRunExtraView, type FirstRunHook, type FirstRunRow, type FirstRunView } from "@/bridge";
+import { useAgentKeys, useBridge, useFirstRun, useNewOnboarding, useSpaces, type FirstRunArt, type FirstRunCredential, type FirstRunExtraView, type FirstRunHook, type FirstRunRow, type FirstRunView } from "@/bridge";
import { readSavedOnboarding, writeSavedOnboarding } from "@/bridge/onboarding";
import { AddAgentSheet } from "@/components/add-agent/add-agent-sheet";
import { APP_MARKS, AppMarkImage } from "@/components/agents/harness-mark";
import { CuaLogo } from "@/components/cua-logo";
+import { NewFirstRun } from "@/components/first-run-new/first-run-new";
import { OsIcon } from "@/components/os-icon";
import { Button } from "@/components/ui/button";
import { Segmented } from "@/components/ui/segmented";
@@ -41,9 +42,14 @@ export const Route = createFileRoute("/onboarding/")({
if (search.fresh) writeSavedOnboarding(null);
else if (search.due && readSavedOnboarding().skipped) throw redirect({ to: "/spaces" });
},
- component: OnboardingPage,
+ component: OnboardingRoute,
});
+/** With the new setup on (Settings, Advanced, Labs), the new first run (CUA-3318); otherwise the first run every install has. */
+function OnboardingRoute() {
+ return useNewOnboarding() ? <NewFirstRun /> : <OnboardingPage />;
+}
+
/**
* The first run, the same on macOS, Windows and Linux: Welcome, Pick your
* agent, Install the Cua CLI (only while the app's CLI is not on this