Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces): never make a hidden Linux Space after the first run (CUA-3622) (#6662)

Francesco Bonaccicd1d6c2ce65d
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 b62f99eacb..1ae4ccfdbb 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 starts getting ready in the background once the first run is over, with no line about it.
+// Space: the nothing is made in the background: a Space exists only when the person chooses one.
import { act, cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
@@ -41,8 +41,8 @@ afterEach(() => {
const click = (sel: string) => fireEvent.click(document.querySelector<HTMLElement>(sel)!);
const heading = () => document.querySelector("[data-onboarding-heading]")?.textContent ?? "";
-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" } });
+async function throughOnboarding(hold?: Promise<void>, calls: { op: string }[] = []) {
+ const { router } = await mountApp("/onboarding", { failsCreates: false, listsGhost: false, hold, intercept: (op) => (calls.push({ op }), undefined), demo: { signedIn: false, onboarded: false, noSpaces: true, keys: "several" } });
// 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]");
@@ -70,39 +70,22 @@ const expectCards = () => {
};
describe.skipIf(!wasmBuilt)("where the first run ends", () => {
- it("lands on Home with the prompt box and the suggestions, and says nothing about the home warming", { timeout: 60_000 }, async () => {
- let release!: () => void;
- const router = await throughOnboarding(new Promise<void>((r) => (release = r)));
+ it("lands on Home with the prompt box and the suggestions, and makes no Space the person did not choose", { timeout: 60_000 }, async () => {
+ const calls: { op: string }[] = [];
+ const router = await throughOnboarding(undefined, calls);
await waitFor(() => expect(router.state.location.pathname).toBe("/home"));
// The prompt box and the suggestions are there, not a Space's page.
expect(await screen.findByLabelText("What should it do?")).not.toBeNull();
expectCards();
expect(document.querySelector("[data-ask-first-home]")).not.toBeNull();
- // Warming is silent: no line, no steps, and the home is not in "Your Spaces".
- await waitFor(() => expect(getDriver()?.state?.pendingId).toBeTruthy());
+ // Nothing is warming in the background: no Space is created and nothing is being prepared.
await act(async () => {
- await new Promise((r) => setTimeout(r, 600));
+ await new Promise((r) => setTimeout(r, 1_500));
});
+ expect(calls.some((c) => c.op === "spaces.create")).toBe(false);
+ expect(getDriver()?.state?.wanted ?? false).toBe(false);
expect(document.querySelector("[data-prepare-line]")).toBeNull();
- 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");
- // A prompt sent now is kept and goes once the agent is ready (the Space's thread says so).
- fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });
- fireEvent.click(screen.getByRole("button", { name: "Start" }));
- await waitFor(() => expect(getDriver()?.state?.messages.map((m) => m.text)).toEqual(["fix the build"]));
- release();
- });
-
- it("when everything is ready nothing is shown and the home is not in Your Spaces", { timeout: 60_000 }, async () => {
- const router = await throughOnboarding();
- await waitFor(() => expect(router.state.location.pathname).toBe("/home"));
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30_000 });
- await waitFor(() => expect(document.querySelector("[data-prepare-line]")).toBeNull());
- expect(screen.getByLabelText("What should it do?")).not.toBeNull();
expect(document.querySelector("[data-home-spaces]")?.textContent ?? "").not.toContain("home-claude-code");
expect(document.body.textContent).not.toContain("home-claude-code");
- // The home that was made meanwhile does not take the suggestions away: nothing was asked yet.
- expectCards();
});
});
diff --git a/apps/cua-spaces-web/src/__tests__/prepare-cant-run.test.tsx b/apps/cua-spaces-web/src/__tests__/prepare-cant-run.test.tsx
deleted file mode 100644
index 22997fe843..0000000000
--- a/apps/cua-spaces-web/src/__tests__/prepare-cant-run.test.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-// SPDX-License-Identifier: FSL-1.1-MIT
-// Copyright (c) 2026 Cua AI, Inc.
-
-// CUA-3193: on a Mac that can't run Spaces itself, the new setup stopped on
-// "Preparing stopped: local runtime: This Mac can't run Spaces itself, ..." with Try again.
-// No raw runtime error reaches Home: the core's sentence shows, with "Add a computer".
-
-import { act, cleanup, fireEvent, 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 { resetConnectState } from "@/hooks/use-connectors";
-import { resetAskTasks } from "@/lib/ask-first";
-import { resetPrepare } from "@/lib/prepare/store";
-import { mountApp, stubBrowserApis } from "./app-harness";
-
-stubBrowserApis();
-beforeEach(() => {
- localStorage.clear();
- resetAskTasks();
- resetConnectState();
- resetPrepare();
- setFlagOverride("spaces_ask_first_home", true);
- setFlagOverride("spaces_new_onboarding", true);
-});
-afterEach(() => {
- cleanup();
- resetPrepare();
- vi.unstubAllEnvs();
-});
-
-/** `cua_create_failure::preflight::MAC_UNSUPPORTED`, the daemon's refusal (#6323). */
-const MAC_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.";
-
-/** What the SDK's errors start with: internal words a person never reads. */
-const RAW = [/local runtime:/i, /\[local\]/i, /config\.\w+:/, /os error/i, /exit(ing)?,? status/i];
-
-describe.skipIf(!wasmBuilt)("preparing on a Mac that can't run Spaces", () => {
- for (const raw of [`local runtime: ${MAC_UNSUPPORTED}`, `local runtime: [local] ${MAC_UNSUPPORTED}`]) {
- it(`says so in plain words with Add a computer (${raw.slice(0, 22)})`, { timeout: 40000 }, async () => {
- const { router } = await mountApp("/home", {
- failsCreates: false,
- listsGhost: false,
- demo: { onboarded: true },
- intercept: (op) => {
- if (op === "spaces.create") throw new Error(raw);
- return undefined;
- },
- });
- const line = await waitFor(
- () => {
- const el = document.querySelector<HTMLElement>("[data-prepare-line]");
- expect(el).not.toBeNull();
- return el!;
- },
- { timeout: 20000 },
- );
- const text = line.textContent ?? "";
- expect(text).toContain("This Mac can't run Spaces itself");
- for (const r of RAW) expect(text).not.toMatch(r);
- const button = line.querySelector<HTMLElement>("[data-prepare-action]")!;
- expect(button.dataset.prepareAction).toBe("add-computer");
- expect(button.textContent).toBe("Add a computer");
- await act(async () => {
- fireEvent.click(button);
- await new Promise((r) => setTimeout(r, 20));
- });
- await waitFor(() => expect(router.state.location.pathname).toBe("/machines"));
- expect(router.state.location.search).toMatchObject({ add: true });
- });
- }
-});
diff --git a/apps/cua-spaces-web/src/__tests__/prepare-launch.test.tsx b/apps/cua-spaces-web/src/__tests__/prepare-launch.test.tsx
index a5571e1de0..d3ada4774f 100644
--- a/apps/cua-spaces-web/src/__tests__/prepare-launch.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/prepare-launch.test.tsx
@@ -1,20 +1,19 @@
// SPDX-License-Identifier: FSL-1.1-MIT
// Copyright (c) 2026 Cua AI, Inc.
-// The ask-first Space is prepared from launch: the home is made while the person is still on the
-// first screens, a message sent while it is being made is kept and goes once when the agent is ready
-// (also after the app was quit), and onboarding ends in that Space with no "Try it" screen.
+// No hidden Space. The app never makes a Space the person did not choose: not after the first run, not when it
+// opens again or updates (an old saved "preparing" record included), and not when a home was removed. A Linux Space
+// is made only when the person targets "New computer" for a job.
-import { act, cleanup, fireEvent, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, 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 { resetConnectState } from "@/hooks/use-connectors";
import { resetAskTasks } from "@/lib/ask-first";
-import { getDriver } from "@/lib/prepare/store";
-import { resetPrepare } from "@/lib/prepare/store";
-import { mountApp, stubBrowserApis } from "./app-harness";
+import { getDriver, resetPrepare } from "@/lib/prepare/store";
+import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";
stubBrowserApis();
beforeEach(() => {
@@ -31,112 +30,51 @@ afterEach(() => {
vi.unstubAllEnvs();
});
-const q = (s: string) => document.querySelector<HTMLElement>(s);
type Call = { op: string; args: Record<string, unknown> };
-
-async function compose(text: string) {
- const box = await waitFor(() => {
- const el = q("[data-composer]") as HTMLTextAreaElement | null;
- expect(el?.disabled).toBe(false);
- return el!;
- });
- fireEvent.change(box, { target: { value: text, selectionStart: text.length } });
- await act(async () => {
- fireEvent.keyDown(box, { key: "Enter" });
- await new Promise((r) => setTimeout(r, 20));
+const record = (calls: Call[]) => (op: string, args: unknown) => (calls.push({ op, args: args as Record<string, unknown> }), undefined);
+const settle = () =>
+ act(async () => {
+ await new Promise((r) => setTimeout(r, 1_500));
});
-}
+const creates = (calls: Call[]) => calls.filter((c) => c.op === "spaces.create");
-describe.skipIf(!wasmBuilt)("preparing the ask-first Space from launch", () => {
- it("makes the home at launch, adds the agent and says ready", { timeout: 40000 }, async () => {
+describe.skipIf(!wasmBuilt)("no Space is made unless the person chooses one", () => {
+ it("makes nothing after the first run, on Spaces or on Home", { timeout: 40_000 }, async () => {
const calls: Call[] = [];
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 20000 });
- const create = calls.find((c) => c.op === "spaces.create");
- expect(create?.args.config).toMatchObject({ name: "home-claude-code" });
- expect(calls.filter((c) => c.op === "spaces.create")).toHaveLength(1);
- expect(calls.find((c) => c.op === "thread.agentAdd")?.args).toMatchObject({ harness: "claude-code" });
- // Nothing was asked of the person.
- expect(calls.some((c) => c.op === "thread.post")).toBe(false);
- });
-
- it("shows the live preparing state on the home's page, keeps a message typed meanwhile and sends it once", { timeout: 60000 }, async () => {
- const calls: Call[] = [];
- let release!: () => void;
- const hold = new Promise<void>((r) => (release = r));
- const { router } = await mountApp("/spaces", { failsCreates: false, listsGhost: false, hold, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await waitFor(() => expect(getDriver()?.state?.pendingId).toBeTruthy());
- const pending = getDriver()!.state!.pendingId!;
- await act(async () => {
- await router.navigate({ to: "/spaces/$spaceId", params: { spaceId: pending } });
- });
- const panel = await waitFor(() => {
- const el = q("[data-prepare]");
- expect(el).not.toBeNull();
- return el!;
- });
- expect(panel.dataset.prepare).toBe("preparing");
- expect(panel.textContent).toContain("Linux runtime");
- expect(panel.textContent).toContain("Your message sends as soon as your agent is ready");
- expect(panel.textContent).not.toContain("·");
- // The box works at once: the message is kept, shown as waiting, and nothing is posted.
- await compose("fix the failing tests");
- await waitFor(() => expect(getDriver()?.state?.messages.map((m) => m.text)).toEqual(["fix the failing tests"]));
- expect(calls.some((c) => c.op === "thread.post")).toBe(false);
- await waitFor(() => expect(document.body.textContent).toContain("Sends when your agent is ready"));
- release();
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30000 });
- await waitFor(() => expect(calls.filter((c) => c.op === "thread.post")).toHaveLength(1), { timeout: 15000 });
- expect(String(calls.find((c) => c.op === "thread.post")?.args.text)).toContain("fix the failing tests");
- await waitFor(() => expect(getDriver()?.state?.messages[0]?.state).toBe("delivered"));
- // Later ticks do not send it again.
- await act(async () => {
- await new Promise((r) => setTimeout(r, 1500));
- });
- expect(calls.filter((c) => c.op === "thread.post")).toHaveLength(1);
+ await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true, noSpaces: true }, intercept: record(calls) });
+ await settle();
+ expect(creates(calls)).toHaveLength(0);
+ expect(getDriver()?.state?.wanted ?? false).toBe(false);
+ cleanup();
+ resetPrepare();
+ await mountApp("/home", { failsCreates: false, listsGhost: false, demo: { onboarded: true, noSpaces: true }, intercept: record(calls) });
+ await screen.findByLabelText("What should it do?");
+ await settle();
+ expect(creates(calls)).toHaveLength(0);
+ expect(calls.some((c) => c.op === "thread.agentAdd")).toBe(false);
});
- it("a message kept when the app was quit is sent once after it opens again", { timeout: 60000 }, async () => {
+ it("makes nothing when the app opens with a record an older version saved, wanted or with its home gone", { timeout: 40_000 }, async () => {
+ localStorage.setItem("cua.prepare.v1", JSON.stringify({ wanted: true, harness: "claude-code", pendingId: "pending:old", homeSpaceId: "local:home-claude-code", readyMs: 1, messages: [], askedMs: null, online: true }));
const calls: Call[] = [];
- // Run 1: the create never ends; a message is typed; the page goes away (the record is in storage).
- const hold = new Promise<void>(() => {});
- const { router } = await mountApp("/spaces", { failsCreates: false, listsGhost: false, hold, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await waitFor(() => expect(getDriver()?.state?.pendingId).toBeTruthy());
- const pending = getDriver()!.state!.pendingId!;
- await act(async () => {
- await router.navigate({ to: "/spaces/$spaceId", params: { spaceId: pending } });
- });
- await compose("keep me");
- await waitFor(() => expect(JSON.parse(localStorage.getItem("cua.prepare.v1") ?? "{}").messages?.length).toBe(1));
- cleanup();
- resetPrepare();
- expect(calls.some((c) => c.op === "thread.post")).toBe(false);
- // Run 2: a new page load with the same storage; the create runs again and finishes.
- calls.length = 0;
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30000 });
- await waitFor(() => expect(calls.filter((c) => c.op === "thread.post")).toHaveLength(1), { timeout: 15000 });
- expect(String(calls.find((c) => c.op === "thread.post")?.args.text)).toContain("keep me");
- expect(calls.filter((c) => c.op === "spaces.create")).toHaveLength(1);
+ await mountApp("/home", { failsCreates: false, listsGhost: false, demo: { onboarded: true, noSpaces: true }, intercept: record(calls) });
+ await screen.findByLabelText("What should it do?");
+ await settle();
+ expect(creates(calls)).toHaveLength(0);
+ expect(calls.some((c) => c.op === "thread.agentAdd")).toBe(false);
});
- it("does not start without the new setup, or without the new Home", { timeout: 30000 }, async () => {
- setFlagOverride("spaces_new_onboarding", false);
+ it("makes one Space when the person targets New computer and sends a job", { timeout: 60_000 }, async () => {
const calls: Call[] = [];
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await act(async () => {
- await new Promise((r) => setTimeout(r, 800));
- });
- expect(calls.some((c) => c.op === "spaces.create")).toBe(false);
- expect(getDriver()?.state?.wanted ?? false).toBe(false);
- cleanup();
- resetPrepare();
- setFlagOverride("spaces_ask_first_home", false);
- setFlagOverride("spaces_new_onboarding", true);
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true }, intercept: (op, args) => (calls.push({ op, args: args as Record<string, unknown> }), undefined) });
- await act(async () => {
- await new Promise((r) => setTimeout(r, 800));
- });
- expect(calls.some((c) => c.op === "spaces.create")).toBe(false);
+ await mountApp("/home", { failsCreates: false, listsGhost: false, demo: { onboarded: true, noSpaces: true }, intercept: record(calls) });
+ await screen.findByLabelText("What should it do?");
+ await settle();
+ expect(creates(calls)).toHaveLength(0);
+ await pickNewLinux();
+ fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });
+ fireEvent.click(screen.getByRole("button", { name: "Start" }));
+ await waitFor(() => expect(creates(calls)).toHaveLength(1), { timeout: 20_000 });
+ // It is the person's Space: it carries no hidden or off-the-relay label.
+ expect(JSON.stringify(creates(calls)[0]!.args)).not.toContain("cua.hidden");
});
});
diff --git a/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx b/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx
deleted file mode 100644
index f1e6a85cce..0000000000
--- a/apps/cua-spaces-web/src/__tests__/warming-home-hidden.test.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-// SPDX-License-Identifier: FSL-1.1-MIT
-// Copyright (c) 2026 Cua AI, Inc.
-
-// The home that warms in the background for Home's prompt box is invisible infrastructure until a person writes
-// into it: not on the Spaces list, in the sidebar or the palette, and not among the agents. Its own page and
-// Home's preparing line still show it. The rule is the core's (`prepare.hidden`).
-
-import { act, cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
-import { afterEach, beforeEach, describe, expect, it } from "vitest";
-
-import { setFlagOverride } from "@/bridge";
-import { wasmBuilt } from "@/bridge/__tests__/testCore";
-import { resetFirstRunCache } from "@/bridge/first-run";
-import { resetSavedOnboardingCache } from "@/bridge/onboarding";
-import { resetConnectedAppsState } from "@/hooks/use-connected-apps";
-import { resetAskTasks } from "@/lib/ask-first";
-import { rememberAgent, resetPickedAgent } from "@/lib/ask-first-model";
-import { getDriver, resetPrepare } from "@/lib/prepare/store";
-import { mountApp, pickNewLinux, stubBrowserApis } from "./app-harness";
-
-stubBrowserApis();
-beforeEach(() => {
- localStorage.clear();
- resetSavedOnboardingCache();
- resetFirstRunCache();
- resetConnectedAppsState();
- resetPrepare();
- resetAskTasks();
- // The agent the first run prepares a home for is the one the person last used.
- resetPickedAgent();
- rememberAgent({ harness: "claude-code" });
- setFlagOverride("spaces_ask_first_home", true);
- setFlagOverride("spaces_new_onboarding", true);
-});
-afterEach(() => {
- cleanup();
- setFlagOverride("spaces_ask_first_home", null);
- setFlagOverride("spaces_new_onboarding", null);
- resetPrepare();
-});
-
-const demo = { onboarded: true, noSpaces: true, keys: "several" as const };
-const listText = () => document.querySelector("main")?.textContent ?? "";
-
-describe.skipIf(!wasmBuilt)("the warming home is not on any list until a person wrote into it", () => {
- it("is not on the Spaces list or in the sidebar count while warm and unasked, and its page is still reachable", { timeout: 60_000 }, async () => {
- const { router } = await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo });
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30_000 });
- // The host has the Space (it still counts toward its budget and usage); no list shows it.
- expect(getDriver()?.state?.homeSpaceId).toBe("local:home-claude-code");
- expect(listText()).not.toContain("home-claude-code");
- // Nowhere on the page: not the list, the sidebar's "Making" item, nor a tip about it.
- expect(document.body.textContent).not.toContain("home-claude-code");
- // Its own page is there (Home's Details link opens it).
- await act(async () => {
- await router.navigate({ to: "/spaces/$spaceId", params: { spaceId: "local:home-claude-code" } });
- });
- await waitFor(() => expect(document.body.textContent).toContain("home-claude-code"));
- });
-
- it("stays hidden after the app quits and opens again with the warm home and no message", { timeout: 60_000 }, async () => {
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo });
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30_000 });
- expect(JSON.parse(localStorage.getItem("cua.prepare.v1") ?? "{}").askedMs).toBeNull();
- cleanup();
- resetPrepare();
- // A new page load with the same storage; the host (the demo) still has the home.
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo });
- await waitFor(() => expect(getDriver()?.state?.wanted).toBe(true));
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("ready"), { timeout: 30_000 });
- expect(listText()).not.toContain("home-claude-code");
- });
-
- it("shows up once the first message is sent, even while that message is only queued", { timeout: 60_000 }, async () => {
- let release!: () => void;
- const hold = new Promise<void>((r) => (release = r));
- const { router } = await mountApp("/home", { failsCreates: false, listsGhost: false, hold, demo });
- await screen.findByLabelText("What should it do?");
- await waitFor(() => expect(getDriver()?.state?.pendingId).toBeTruthy());
- expect(getDriver()?.state?.askedMs).toBeNull();
- await pickNewLinux();
- fireEvent.change(screen.getByLabelText("What should it do?"), { target: { value: "fix the build" } });
- fireEvent.click(screen.getByRole("button", { name: "Start" }));
- await waitFor(() => expect(getDriver()?.state?.askedMs).not.toBeNull());
- await waitFor(() => expect(router.state.location.pathname).toMatch(/^\/spaces\//));
- release();
- await act(async () => {
- await router.navigate({ to: "/spaces" });
- });
- await waitFor(() => expect(listText()).toContain("home-claude-code"), { timeout: 30_000 });
- });
-
- it("a home that cannot be made yet is not on a list and Home stays silent", { timeout: 60_000 }, async () => {
- await mountApp("/home", { failsCreates: true, listsGhost: false, demo });
- await screen.findByLabelText("What should it do?");
- // A dropped connection is retried by itself: Home stays silent and the home stays off every list.
- await waitFor(() => expect(getDriver()?.view()?.phase).toBe("waiting"), { timeout: 30_000 });
- expect(document.querySelector("[data-prepare-line]")).toBeNull();
- expect(document.querySelector("[data-home-spaces]")?.textContent ?? "").not.toContain("home-claude-code");
- expect(listText()).not.toContain("home-claude-code");
- });
-
- it("a Space that is not the warming home is listed as before", { timeout: 60_000 }, async () => {
- await mountApp("/spaces", { failsCreates: false, listsGhost: false, demo: { onboarded: true, keys: "several" } });
- await waitFor(() => expect(listText()).toContain("ubuntu-build"), { timeout: 20_000 });
- });
-});
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 0e4d601456..ff06507616 100644
--- a/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx
+++ b/apps/cua-spaces-web/src/lib/prepare/use-prepare.tsx
@@ -3,18 +3,15 @@
import { useEffect, useRef } from "react";
-import { firstMessage, newPendingId, useBridge, useFirstSpaceOffers, useSavedOnboarding, useSession, useSpaces } from "@/bridge";
-import { useNewOnboarding } from "@/bridge/flags";
+import { firstMessage, newPendingId, useBridge, useFirstSpaceOffers, useSpaces } from "@/bridge";
import { useSummonIn } from "@/components/ask-first/use-summon-in";
import { setPrepareSink } from "@/components/space-thread/queued";
import { updateAskTask } from "@/lib/ask-first";
import { spaceState } from "@/lib/spaces";
-import { useInstalledAgents } from "@/components/ask-first/use-installed-agents";
-
import { localPrepareStorage, PrepareDriver, type PrepareEnv } from "./driver";
import { homeCreateRequest } from "./home-request";
-import { getDriver, markResumed, resumedThisLoad, setDriver, usePrepare } from "./store";
+import { getDriver, setDriver } from "./store";
/** The coding app the first Space is for when it is on this computer: the first installed one otherwise. */
export const DEFAULT_HARNESS = "claude-code";
@@ -30,11 +27,10 @@ const POLL_MS = 800;
const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
/**
- * Mounted once at the root: starts preparing at launch (while the person is in
- * onboarding), carries on after a quit, and keeps the driver's view of the host
- * current. It runs only with the new setup on (Settings, Advanced, Labs), which
- * also turns on the "Ask first" Home. The Space it prepares is a fresh Linux
- * Space, the one Home's first Linux job goes to, with the coding agent in it.
+ * Mounted once at the root: keeps the driver's view of the host current. It does not tick or follow the connection: nothing it holds can carry on by itself. It never
+ * starts, resumes or repairs a home by itself: the app makes no Space a person did
+ * not choose (not after the first run, not on an update, not when a home was removed).
+ * A Linux Space is made only when the person picks "New computer" for a job.
*/
export function PrepareRoot(): null {
const { core, data: host } = useBridge();
@@ -43,15 +39,6 @@ export function PrepareRoot(): null {
const { offers, known } = useFirstSpaceOffers();
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);
const { summonInput, summonIn, canSummon } = useSummonIn();
const latestSpaces = useRef(spaces);
latestSpaces.current = spaces;
@@ -134,24 +121,7 @@ export function PrepareRoot(): null {
}, [core]);
// The offers must be read first: before that there is no image to make the home from.
- const ready = Boolean(core && host && spaces && on && known);
-
- // Start at launch; a saved record resumes once.
- const driverNow = usePrepare().driver;
- useEffect(() => {
- const d = driverNow;
- if (!ready || !d) return;
- if (d.state?.wanted) {
- // A saved record resumes once per page load, however often the layout mounts.
- if (!resumedThisLoad()) {
- markResumed();
- d.resume();
- }
- } else if (harness && firstRunOver) {
- markResumed();
- d.start(harness);
- }
- }, [ready, driverNow, harness, firstRunOver]);
+ const ready = Boolean(core && host && spaces && known);
// The home's composer sends here while it is being made: kept, then delivered once.
useEffect(() => {
@@ -179,28 +149,5 @@ export function PrepareRoot(): null {
});
}, [ready, host]);
- // The connection: the browser says when it goes and comes back.
- useEffect(() => {
- if (!ready) return;
- const on = () => getDriver()?.online(true);
- const off = () => getDriver()?.online(false);
- globalThis.addEventListener?.("online", on);
- globalThis.addEventListener?.("offline", off);
- return () => {
- globalThis.removeEventListener?.("online", on);
- globalThis.removeEventListener?.("offline", off);
- };
- }, [ready]);
-
- // The list changed: a home that was removed is made again. A second a tick while it is waiting.
- useEffect(() => {
- if (ready) getDriver()?.checkHome();
- }, [ready, spaces]);
- useEffect(() => {
- if (!ready) return;
- const t = setInterval(() => getDriver()?.tick(), 1_000);
- return () => clearInterval(t);
- }, [ready]);
-
return null;
}