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-web): send the image's kind from onboarding's first-Space Create (#5255)

Francesco Bonaccida4ee0b3b856
diff --git a/apps/cua-spaces-web/src/__tests__/onboarding-first-space.test.tsx b/apps/cua-spaces-web/src/__tests__/onboarding-first-space.test.tsx
index 62a45df6a7..f66ae6bc2b 100644
--- a/apps/cua-spaces-web/src/__tests__/onboarding-first-space.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/onboarding-first-space.test.tsx
@@ -6,7 +6,7 @@
// and Linux every macOS Create was enabled, and on a Windows box with no
// runtime every Create was.
-import { cleanup, screen, waitFor, within } from "@testing-library/react";
+import { cleanup, fireEvent, screen, waitFor, within } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import type { NewSpaceOptions } from "@/bridge/contracts/new-space";
import { testCore, wasmBuilt } from "@/bridge/__tests__/testCore";
@@ -24,12 +24,13 @@ beforeEach(() => {
afterEach(cleanup);
/** The demo host with `local` changed as `edit` says. */
-async function mountDone(edit: (local: NonNullable<NewSpaceOptions["local"]>) => NewSpaceOptions["local"]) {
+async function mountDone(edit: (local: NonNullable<NewSpaceOptions["local"]>) => NewSpaceOptions["local"], intercept?: (op: string, args: unknown) => unknown) {
const core = await testCore();
writeSavedOnboarding({ state: { ...onboardingInitial(core, null), step: "done" }, skipped: false });
return mountApp("/onboarding", {
failsCreates: false,
listsGhost: false,
+ intercept,
answer: (op, out) => {
if (op !== "spaces.createOptions") return out;
const o = out as NewSpaceOptions;
@@ -57,4 +58,23 @@ describe.skipIf(!wasmBuilt)("the first Space on the last onboarding page (real r
await waitFor(() => expect(card("linux")?.querySelector("[data-first-space-blocked]")).toBeTruthy());
for (const os of ["macos", "linux", "windows"]) expect(createOf(os).disabled, os).toBe(true);
});
+
+ // CUA-1712: Create sent no `kind`, and the Electron host (Linux, Windows)
+ // refused it with "config.kind: container | vm".
+ it("Create sends the image's kind, as the hosts' create needs", async () => {
+ const creates: { config: Record<string, unknown> }[] = [];
+ await mountDone(
+ (local) => ({ ...local, backends: ["docker"], macosImage: null, hostArch: "amd64" }),
+ (op, args) => {
+ if (op === "spaces.create") creates.push(args as { config: Record<string, unknown> });
+ return undefined;
+ },
+ );
+ await screen.findByText("Create your first Space");
+ await waitFor(() => expect(createOf("linux").disabled).toBe(false));
+ fireEvent.click(createOf("linux"));
+ await waitFor(() => expect(creates).toHaveLength(1));
+ expect(creates[0]!.config.kind).toBe("container");
+ expect(creates[0]!.config.image).toBeTruthy();
+ });
});
diff --git a/apps/cua-spaces-web/src/routes/onboarding/index.tsx b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
index 3a6bbd42e6..7cda2e2a70 100644
--- a/apps/cua-spaces-web/src/routes/onboarding/index.tsx
+++ b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
@@ -340,7 +340,9 @@ function FirstSpace({ images }: { images: SandboxImage[] }) {
const [started, setStarted] = useState<SandboxImage | null>(null);
const create = (image: SandboxImage) => {
setStarted(image);
- createSpace({ image: image.ref, os: image.os }).catch((e: unknown) => {
+ // The hosts' create needs the kind (Electron and the SwiftUI bridge
+ // reject a config without one), as New Space's plan sends it.
+ createSpace({ image: image.ref, kind: image.variant, os: image.os }).catch((e: unknown) => {
setStarted(null);
toast(`Couldn't create ${image.name}`, { description: e instanceof Error ? e.message : String(e) });
});