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): onboarding Back on every step, and a try request per system (#5885)

ddupontf59e242271cd
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 93f69fb250..cc02532ef5 100644
--- a/apps/cua-spaces-web/src/__tests__/first-run.test.tsx
+++ b/apps/cua-spaces-web/src/__tests__/first-run.test.tsx
@@ -128,7 +128,7 @@ describe.skipIf(!wasmBuilt)("the first run (real route, wasm core)", () => {
expect(calls.some((c) => c.op === "session.signIn")).toBe(false);
const prompt = document.querySelector<HTMLTextAreaElement>("textarea[data-first-run-prompt]")!;
expect(prompt.readOnly).toBe(true);
- expect(prompt.value).toMatch(/^Make a Linux Space on this (Mac|PC|computer) and run my tests there\.$/);
+ expect(prompt.value).toMatch(/^Make a Linux Space on this (Mac|PC|computer) and stream the desktop in a new window\.$/);
expect(document.querySelector("[data-first-run-copy]")).toBeTruthy();
// A Codex user never sees Claude or its key first.
expect(document.body.textContent).not.toMatch(/Claude|Anthropic/);
@@ -139,6 +139,31 @@ describe.skipIf(!wasmBuilt)("the first run (real route, wasm core)", () => {
await waitFor(() => expect(calls.find((c) => c.op === "session.completeOnboarding")).toBeTruthy());
});
+ it("Back works from every step after Welcome, all the way to Welcome, keeping what was picked", async () => {
+ const calls = await mount();
+ await waitFor(() => expect(heading()).toBe("Your agents get their own computer."));
+ expect(document.querySelector("[data-first-run-back]")).toBeNull();
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Pick your agent."));
+ click('[data-first-run-connect="codex"]');
+ await waitFor(() => expect(readFirstRun().picked).toEqual(["codex"]));
+ click("[data-onboarding-primary]");
+ await waitFor(() => expect(heading()).toBe("Connect your other devices."));
+ click("[data-first-run-secondary]");
+ await waitFor(() => expect(heading()).toBe("Try it in OpenAI Codex."));
+ // Try it → Connect your devices → Pick your agent → Welcome.
+ click("[data-first-run-back]");
+ await waitFor(() => expect(heading()).toBe("Connect your other devices."));
+ click("[data-first-run-back]");
+ await waitFor(() => expect(heading()).toBe("Pick your agent."));
+ expect(document.querySelector<HTMLElement>('[data-first-run-agent="codex"]')!.dataset.connected).toBe("true");
+ click("[data-first-run-back]");
+ await waitFor(() => expect(heading()).toBe("Your agents get their own computer."));
+ // Going back only navigates: nothing was connected again or undone.
+ expect(readFirstRun().picked).toEqual(["codex"]);
+ expect(calls.filter((c) => c.op === "agents.configure")).toHaveLength(1);
+ });
+
it("Codex: its ChatGPT sign-in and OpenAI key follow it, and the sign-in starts on this computer", async () => {
writeFirstRun({ step: "connect" });
const calls = await mount({ agents: (rows) => rows.map((r) => ({ ...r, installed: r.agent === "codex" })) });
diff --git a/apps/cua-spaces-web/src/bridge/contracts/first-run.ts b/apps/cua-spaces-web/src/bridge/contracts/first-run.ts
index 594c79b55a..c17735cad4 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/first-run.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/first-run.ts
@@ -179,11 +179,24 @@ export interface FirstRunRow {
settingsUrl: string | null;
}
+export interface FirstRunPromptTab {
+ /** `macos`, `linux`, `omarchy`. */
+ id: string;
+ /** "macOS", "Linux", "Omarchy". */
+ label: string;
+ text: string;
+}
+
export interface FirstRunPromptView {
heading: string;
+ /** The selected tab's request (or the only one). */
text: string;
note: string;
copy: string | null;
+ /** The request per system a first Space can run here (macOS only on a Mac). */
+ tabs?: FirstRunPromptTab[];
+ /** The tab `text` shows. */
+ selected?: string | null;
}
export interface FirstRunExtraChoice {
diff --git a/apps/cua-spaces-web/src/bridge/first-run.ts b/apps/cua-spaces-web/src/bridge/first-run.ts
index 4ac9d5936c..fa41e98dc0 100644
--- a/apps/cua-spaces-web/src/bridge/first-run.ts
+++ b/apps/cua-spaces-web/src/bridge/first-run.ts
@@ -176,7 +176,7 @@ function fallbackView(input: FirstRunInput): FirstRunView {
? {
title: `Try it in ${lead.name}.`,
lede: `Paste this. ${lead.name} makes the Space itself.`,
- prompt: { heading: `Paste this in ${lead.name}`, text: `Make a Linux Space on ${place} and run my tests there.`, note: `It runs on ${place}.`, copy: "Copy" },
+ prompt: { heading: `Paste this in ${lead.name}`, text: `Make a Linux Space on ${place} and stream the desktop in a new window.`, note: `It runs on ${place}.`, copy: "Copy" },
status: { id: "agent", state: input.agentUsedAt ? "ok" : "checking", title: input.agentUsedAt ? `${lead.name} used Cua at ${input.agentUsedAt}.` : `Waiting for ${lead.name}…`, note: "", action: null, settingsUrl: null },
extra: null,
primary: { id: "done", label: "Done", enabled: true, note: null },
@@ -350,7 +350,8 @@ export interface FirstRunHook {
signIn(agent: string): Promise<void>;
/** A screen's button: `start`, `continue`, `skip`, `not-now` (next screen), `sign-in`, `set-up`, `open-settings`, `copy`, `add`. */
act(id: string, settingsUrl?: string | null): Promise<void>;
- copyPrompt(): Promise<void>;
+ /** Copies `text` (the tab shown), else the selected request. */
+ copyPrompt(text?: string): Promise<void>;
/** Opens a page in the browser (installing an agent). */
openUrl(url: string): Promise<void>;
/** The first Space card: `macos`/`linux` start it; `cancel`, `not-now`, `add`, `retry`, `fix`. */
@@ -610,8 +611,8 @@ export function useFirstRun(active = true, pollMs = FIRST_RUN_POLL_MS): FirstRun
}
};
- const copyPrompt = async () => {
- const text = view.setup?.prompt?.text ?? firstRunView(core, { ...input, step: "setup" }).setup?.prompt?.text ?? "";
+ const copyPrompt = async (shown?: string) => {
+ const text = shown ?? view.setup?.prompt?.text ?? firstRunView(core, { ...input, step: "setup" }).setup?.prompt?.text ?? "";
await navigator.clipboard?.writeText(text).catch(() => {});
};
diff --git a/apps/cua-spaces-web/src/routes/onboarding/index.tsx b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
index dc028389e1..1f53e58fd3 100644
--- a/apps/cua-spaces-web/src/routes/onboarding/index.tsx
+++ b/apps/cua-spaces-web/src/routes/onboarding/index.tsx
@@ -10,6 +10,7 @@ import { KeySheet } from "@/components/agents/key-sheet";
import { CuaLogo } from "@/components/cua-logo";
import { OsIcon } from "@/components/os-icon";
import { Button } from "@/components/ui/button";
+import { Segmented } from "@/components/ui/segmented";
import { Switch } from "@/components/ui/switch";
import { toast } from "@/components/ui/toast";
import { RuntimeFixRow } from "@/components/new-space/runtime-fix";
@@ -259,6 +260,7 @@ function Connect({ fr, view }: { fr: FirstRunHook; view: FirstRunView }) {
<div className="mt-6 flex items-center gap-4">
<Primary label={c.primary.label} onClick={() => void fr.act(c.primary.id)} />
{c.secondary ? <Quiet label={c.secondary.label} onClick={() => void fr.act(c.secondary!.id)} data-first-run-secondary="" /> : null}
+ <Quiet label="Back" onClick={fr.back} data-first-run-back="" />
</div>
{fr.usage ? (
<label className="mt-5 flex items-center gap-2.5 text-[13px] text-muted-foreground" data-first-run-usage="">
@@ -322,6 +324,7 @@ function Devices({ fr, view }: { fr: FirstRunHook; view: FirstRunView }) {
<div className="mt-7 flex items-center gap-4">
<Primary label={d.primary.label} onClick={() => void fr.act(d.primary.id)} data-first-run-devices-primary={d.primary.id} />
{d.secondary ? <Quiet label={d.secondary.label} onClick={() => void fr.act(d.secondary!.id)} data-first-run-secondary="" /> : null}
+ <Quiet label="Back" onClick={fr.back} data-first-run-back="" />
</div>
{d.note ? <p className="mt-4 text-[13px] text-muted-foreground">{d.note}</p> : null}
</div>
@@ -333,8 +336,12 @@ function Devices({ fr, view }: { fr: FirstRunHook; view: FirstRunView }) {
function Setup({ fr, view, onFinish }: { fr: FirstRunHook; view: FirstRunView; onFinish: () => void }) {
const s = view.setup!;
const [copied, setCopied] = useState(false);
+ const [tab, setTab] = useState<string | null>(null);
+ const tabs = s.prompt?.tabs ?? [];
+ const shownTab = tabs.find((t) => t.id === (tab ?? s.prompt?.selected));
+ const promptText = shownTab?.text ?? s.prompt?.text ?? "";
const copy = async () => {
- await fr.copyPrompt();
+ await fr.copyPrompt(promptText);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
};
@@ -342,12 +349,25 @@ function Setup({ fr, view, onFinish }: { fr: FirstRunHook; view: FirstRunView; o
<div data-first-run="setup">
<Heading>{s.title}</Heading>
<Lede>{s.lede}</Lede>
+ {s.prompt && tabs.length > 1 ? (
+ <div className="mt-6" data-first-run-prompt-tabs="">
+ <Segmented
+ aria-label="System"
+ value={shownTab?.id ?? tabs[0]!.id}
+ options={tabs.map((t) => ({ value: t.id, label: t.label }))}
+ onValueChange={(v) => {
+ setTab(v);
+ setCopied(false);
+ }}
+ />
+ </div>
+ ) : null}
{s.prompt ? (
- <div className="mt-6 flex items-start gap-3">
+ <div className={cn("flex items-start gap-3", tabs.length > 1 ? "mt-3" : "mt-6")}>
<textarea
readOnly
rows={2}
- value={s.prompt.text}
+ value={promptText}
aria-label={s.prompt.heading}
onFocus={(e) => e.currentTarget.select()}
className="min-w-0 flex-1 resize-none rounded-lg border border-foreground/15 bg-transparent px-3 py-2 font-mono text-[13px] leading-relaxed outline-none select-text focus-visible:ring-2 focus-visible:ring-ring/60"
diff --git a/docs/content/docs/spaces/guides/connect-your-agent.mdx b/docs/content/docs/spaces/guides/connect-your-agent.mdx
index d4478d88eb..f1781358e0 100644
--- a/docs/content/docs/spaces/guides/connect-your-agent.mdx
+++ b/docs/content/docs/spaces/guides/connect-your-agent.mdx
@@ -91,7 +91,7 @@ this computer shares the same Spaces, sandboxes and streams.
Then try the request the app offers at the end of its first run. The agent makes
a Space on this computer:
-> Make a Linux Space on this Mac and run my tests there.
+> Make a Linux Space on this Mac and stream the desktop in a new window.
On Windows the request says "this PC", and on Linux "this computer". When
that works, try a bigger task:
diff --git a/docs/content/docs/spaces/quickstart.mdx b/docs/content/docs/spaces/quickstart.mdx
index 262afd51c6..fd5fdfd655 100644
--- a/docs/content/docs/spaces/quickstart.mdx
+++ b/docs/content/docs/spaces/quickstart.mdx
@@ -85,7 +85,7 @@ without an account, and **Sign in** at the bottom of the sidebar does it later.
The app names the agent you connected and gives you a request to paste into it:
-> Make a Linux Space on this Mac and run my tests there.
+> Make a Linux Space on this Mac and stream the desktop in a new window.
Press **Copy**, paste it into your agent, and the agent makes the Space itself.
The line under it turns green when your agent has used Cua. On Windows and
diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/first-run.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/first-run.json
index fd7c435921..fcc4dad853 100644
--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/first-run.json
+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/first-run.json
@@ -193,7 +193,7 @@
"extra": null,
"lede": "Paste this. Hermes makes the Space itself.",
"primary": "done:Done",
- "prompt": "Paste this in Hermes: Make a Linux Space on this Mac and run my tests there. / It runs on this Mac.",
+ "prompt": "Paste this in Hermes: Make a Linux Space on this Mac and stream the desktop in a new window. / It runs on this Mac.",
"status": "[checking] Waiting for Hermes… — If Hermes was already open, restart it.",
"title": "Try it in Hermes."
},
@@ -206,7 +206,7 @@
"extra": null,
"lede": "Paste this. Hermes makes the Space itself.",
"primary": "done:Done",
- "prompt": "Paste this in Hermes: Make a Linux Space on this Mac and run my tests there. / It runs on this Mac.",
+ "prompt": "Paste this in Hermes: Make a Linux Space on this Mac and stream the desktop in a new window. / It runs on this Mac.",
"status": "[ok] Hermes used Cua at 18:12. — Ask it anything else.",
"title": "Try it in Hermes."
},
@@ -216,7 +216,7 @@
"items": [
"[ ] Connect Hermes and Claude Code — Cua isn't in Hermes and Claude Code's settings yet. (connect:Connect)",
"[ ] Make this Mac your first Space — After you sign in.",
- "[x] Try your first request — Ask Hermes or Claude Code: “Make a Linux Space on this Mac and run my tests there.”",
+ "[x] Try your first request — Ask Hermes or Claude Code: “Make a Linux Space on this Mac and stream the desktop in a new window.”",
"[ ] Give your agent its own Space (optional) — A fresh computer inside this Mac, away from your files and your mouse. (add:Add a Space)",
"[ ] Connect your other devices (optional) — Sign in, and your other computers reach this Mac's Spaces. (sign-in:Sign in)"
],
@@ -231,7 +231,7 @@
"extra": null,
"lede": "Paste this. OpenAI Codex makes the Space itself.",
"primary": "done:Done",
- "prompt": "Paste this in OpenAI Codex: Make a Linux Space on this PC and run my tests there. / It runs on this PC.",
+ "prompt": "Paste this in OpenAI Codex: Make a Linux Space on this PC and stream the desktop in a new window. / It runs on this PC.",
"status": "[checking] Waiting for OpenAI Codex… — If OpenAI Codex was already open, restart it.",
"title": "Try it in OpenAI Codex."
},
@@ -319,7 +319,7 @@
"extra": null,
"lede": "Paste this. Claude Code makes the Space itself.",
"primary": "done:Done",
- "prompt": "Paste this in Claude Code: Make a Linux Space on this Mac and run my tests there. / It runs on this Mac.",
+ "prompt": "Paste this in Claude Code: Make a Linux Space on this Mac and stream the desktop in a new window. / It runs on this Mac.",
"status": "[checking] Waiting for Claude Code… — If Claude Code was already open, restart it.",
"title": "Try it in Claude Code."
},
@@ -329,7 +329,7 @@
"items": [
"[ ] Connect Claude Code — Cua isn't in Claude Code's settings yet. (connect:Connect)",
"[ ] Let Cua control this Mac — So your agent can click and type. macOS asks you once. (open-settings:Open Settings)",
- "[ ] Try your first request — Ask Claude Code: “Make a Linux Space on this Mac and run my tests there.” (copy:Copy)",
+ "[ ] Try your first request — Ask Claude Code: “Make a Linux Space on this Mac and stream the desktop in a new window.” (copy:Copy)",
"[ ] Give your agent its own Space (optional) — A fresh computer inside this Mac, away from your files and your mouse. (add:Add a Space)",
"[x] Connect your other devices (optional) — Signed in to Cua."
],
diff --git a/libs/cua/crates/cua-spaces-app-core/src/first_run.rs b/libs/cua/crates/cua-spaces-app-core/src/first_run.rs
index f3cf1f76db..f71015eb9f 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/first_run.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/first_run.rs
@@ -55,9 +55,11 @@ const FIRST_PROMPT_OTHER: &str = "List my computers and tell me what's on this c
const FIRST_PROMPT_PC: &str = "List my computers and tell me what's on this PC";
/// The try screen's request: the agent makes a Space on this computer.
-pub const TRY_PROMPT: &str = "Make a Linux Space on this Mac and run my tests there.";
-const TRY_PROMPT_OTHER: &str = "Make a Linux Space on this computer and run my tests there.";
-const TRY_PROMPT_PC: &str = "Make a Linux Space on this PC and run my tests there.";
+pub const TRY_PROMPT: &str =
+ "Make a Linux Space on this Mac and stream the desktop in a new window.";
+const TRY_PROMPT_OTHER: &str =
+ "Make a Linux Space on this computer and stream the desktop in a new window.";
+const TRY_PROMPT_PC: &str = "Make a Linux Space on this PC and stream the desktop in a new window.";
/// The same first Space from a terminal (no agent found).
pub const CLI_FIRST_SPACE: &str = "cua spaces create linux";
@@ -402,6 +404,24 @@ pub struct PromptView {
pub note: String,
/// "Copy".
pub copy: Option<String>,
+ /// The same request for each system a first Space can run (macOS only
+ /// on a Mac), shown as tabs over the text; `text` is the selected one.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub tabs: Vec<PromptTab>,
+ /// The tab `text` shows (`linux`).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub selected: Option<String>,
+}
+
+/// One system's version of the try request.
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PromptTab {
+ /// `macos`, `linux`, `omarchy`.
+ pub id: String,
+ /// "macOS", "Linux", "Omarchy".
+ pub label: String,
+ pub text: String,
}
/// A choice on the first Space card.
@@ -580,6 +600,25 @@ pub fn try_prompt(os: &str) -> &'static str {
}
}
+/// The try request for each system a first Space can run here: macOS (on a
+/// Mac only), Linux and Omarchy. Linux comes selected: it is ready fastest.
+pub fn try_prompt_tabs(os: &str) -> Vec<PromptTab> {
+ let place = this_computer(os);
+ let mut tabs = Vec::new();
+ if os == "macos" {
+ tabs.push(("macos", "macOS", "a macOS"));
+ }
+ tabs.push(("linux", "Linux", "a Linux"));
+ tabs.push(("omarchy", "Omarchy", "an Omarchy"));
+ tabs.into_iter()
+ .map(|(id, label, kind)| PromptTab {
+ id: id.into(),
+ label: label.into(),
+ text: format!("Make {kind} Space on {place} and stream the desktop in a new window."),
+ })
+ .collect()
+}
+
fn default_name(agent: &str) -> &'static str {
match agent {
"claude-code" => "Claude Code",
@@ -1258,6 +1297,8 @@ fn setup_view(input: &FirstRunInput) -> SetupView {
text: try_prompt(&input.host_os).into(),
note: format!("It runs on {place}."),
copy: Some("Copy".into()),
+ tabs: try_prompt_tabs(&input.host_os),
+ selected: Some("linux".into()),
}),
status: Some(status),
extra: None,
@@ -1879,6 +1920,50 @@ mod tests {
assert_eq!(view(&i).setup.unwrap().prompt.unwrap().text, TRY_PROMPT_PC);
}
+ #[test]
+ fn the_try_request_has_a_tab_per_system_with_linux_selected() {
+ let i = FirstRunInput {
+ picked: Some(vec!["hermes".into()]),
+ ..input(FirstRunStep::Setup, vec![hermes()])
+ };
+ let p = view(&i).setup.unwrap().prompt.unwrap();
+ let tabs: Vec<(&str, &str)> = p
+ .tabs
+ .iter()
+ .map(|t| (t.id.as_str(), t.text.as_str()))
+ .collect();
+ assert_eq!(
+ tabs,
+ [
+ (
+ "macos",
+ "Make a macOS Space on this Mac and stream the desktop in a new window."
+ ),
+ (
+ "linux",
+ "Make a Linux Space on this Mac and stream the desktop in a new window."
+ ),
+ (
+ "omarchy",
+ "Make an Omarchy Space on this Mac and stream the desktop in a new window."
+ ),
+ ]
+ );
+ assert_eq!(p.selected.as_deref(), Some("linux"));
+ assert_eq!(p.text, p.tabs[1].text);
+ // macOS Spaces need a Mac: no macOS tab elsewhere.
+ let i = FirstRunInput {
+ host_os: "windows".into(),
+ ..i
+ };
+ let p = view(&i).setup.unwrap().prompt.unwrap();
+ assert_eq!(
+ p.tabs.iter().map(|t| t.label.as_str()).collect::<Vec<_>>(),
+ ["Linux", "Omarchy"]
+ );
+ assert_eq!(p.text, TRY_PROMPT_PC);
+ }
+
#[test]
fn with_no_agent_the_try_screen_offers_a_first_space() {
let mut i = FirstRunInput {