Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(spaces): "Ask first" Home behind the spaces_ask_first_home flag (CUA-2348) (#6008)
cua-agents[bot]d45964f60a6a
diff --git a/apps/cua-spaces-web/src/bridge/flags.ts b/apps/cua-spaces-web/src/bridge/flags.tsindex 1781491e11..9306942123 100644--- a/apps/cua-spaces-web/src/bridge/flags.ts+++ b/apps/cua-spaces-web/src/bridge/flags.ts@@ -18,10 +18,16 @@import { useSyncExternalStore } from "react";-/** `upsell_cards`: the cards that offer Pro or Teams when a limit stops you. */-export type FlagName = "upsell_cards";+/**+ * - `upsell_cards`: the cards that offer Pro or Teams when a limit stops you.+ * - `spaces_ask_first_home`: the "Ask first" Home experiment (CUA-2346): a+ * 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.+ */+export type FlagName = "upsell_cards" | "spaces_ask_first_home";-const DEFAULTS: Record<FlagName, boolean> = { upsell_cards: false };+const DEFAULTS: Record<FlagName, boolean> = { upsell_cards: false, spaces_ask_first_home: false };const key = (name: FlagName) => `cua.flag.${name}`;let remote: Partial<Record<FlagName, boolean>> = {};diff --git a/apps/cua-spaces-web/src/bridge/hooks.ts b/apps/cua-spaces-web/src/bridge/hooks.tsindex 75230d60b7..755bd6966a 100644--- a/apps/cua-spaces-web/src/bridge/hooks.ts+++ b/apps/cua-spaces-web/src/bridge/hooks.ts@@ -5,7 +5,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncEimport type { BridgeMode, DataAdapter } from "./adapter";import { BridgeContext, type BridgeContextValue } from "./BridgeProvider";import type { CoreClient } from "./core";-import type { AgentSetupRow } from "./contracts/agents";+import type { AgentMessageSent, AgentSetupRow, AgentStarted, AgentStartRequest } from "./contracts/agents";import type { MachinesView, OnboardingMode, PermissionHint, SignInStart } from "./contracts/host";import type {OnboardingAction,@@ -354,6 +354,10 @@ export interface AgentsHook extends Resource<AgentsData> {/** Stops the run, saves the agent's home and holds its routines. */pauseAgent(name: string): Promise<void>;resumeAgent(name: string): Promise<void>;+ /** Starts a coding agent in a Space (`agents.start`). */+ startRun(req: AgentStartRequest): Promise<AgentStarted>;+ /** Sends a reply to a run (`agents.message`). */+ sendMessage(run: RunRef, text: string, force?: boolean): Promise<AgentMessageSent>;/** The coding agents on this machine and what cua set up for each. */agentSetup(): Promise<AgentSetupRow[]>;/** Adds the cua skills and MCP server to `agents`, or to every installed agent. */@@ -368,6 +372,8 @@ export function useAgents(): AgentsHook {...r,pauseAgent: (name) => run((s) => s.pauseAgent(name)),resumeAgent: (name) => run((s) => s.resumeAgent(name)),+ startRun: (req) => run((s) => s.startRun(req)),+ sendMessage: (ref, text, force) => run((s) => s.sendToRun(ref, text, force)),agentSetup: () => run((s) => s.agentSetup()),configureAgents: (agents) => run((s) => s.configureAgents(agents ?? null)),};diff --git a/apps/cua-spaces-web/src/bridge/index.ts b/apps/cua-spaces-web/src/bridge/index.tsindex caf115f6f2..d557034354 100644--- a/apps/cua-spaces-web/src/bridge/index.ts+++ b/apps/cua-spaces-web/src/bridge/index.ts@@ -52,6 +52,7 @@ export type {SessionData,SettingsData,} from "./store";+export { newPendingId } from "./store";export type { TranscriptItem, TranscriptStep } from "./transcript";export { GRID_COLUMNS, iconKey, thumbnailKey, useTeleport, type TeleportHook, type TeleportSession, type TeleportStore } from "./teleport";export { useShareSheet, type ShareHook, type ShareSession } from "./share";diff --git a/apps/cua-spaces-web/src/bridge/store.ts b/apps/cua-spaces-web/src/bridge/store.tsindex a08df46bbc..9dc01b11e0 100644--- a/apps/cua-spaces-web/src/bridge/store.ts+++ b/apps/cua-spaces-web/src/bridge/store.ts@@ -12,7 +12,7 @@import { hostOs } from "./host-os";import { spokenName } from "./space-names";import { isUnsupported, type DataAdapter } from "./adapter";-import type { AgentRunStatus, AgentSetupRow, PersistentAgent, SpaceAgentRun } from "./contracts/agents";+import type { AgentMessageSent, AgentRunStatus, AgentSetupRow, AgentStarted, AgentStartRequest, PersistentAgent, SpaceAgentRun } from "./contracts/agents";import type { CoreClient } from "./core";import { withCreateContext } from "./create-context";import { HOST_RUNS_CREATES, loadCreateStreaks, saveCreateStreaks } from "./create-retry";@@ -1266,6 +1266,22 @@ export class BridgeStore {return this.agentAction(() => this.adapter.call("agents.resume", { name }));}+ /** Starts a coding agent in a Space (`agents.start`); the runs are read again. */+ async startRun(req: AgentStartRequest): Promise<AgentStarted> {+ let started: AgentStarted | undefined;+ await this.agentAction(async () => {+ started = await this.adapter.call("agents.start", req);+ });+ return started!;+ }++ /** Sends a reply to a run (`agents.message`); its conversation is read again at once. */+ async sendToRun(ref: RunRef, text: string, force = false): Promise<AgentMessageSent> {+ const sent = await this.adapter.call("agents.message", { spaceId: ref.spaceId, runId: ref.runId, text, ...(force ? { force } : {}) });+ void this.refresh("agents");+ return sent;+ }+agentSetup(): Promise<AgentSetupRow[]> {return this.adapter.call("agents.setup", {});}diff --git a/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx b/apps/cua-spaces-web/src/components/ask-first/ask-box.tsxnew file mode 100644index 0000000000..af8fd2642f--- /dev/null+++ b/apps/cua-spaces-web/src/components/ask-first/ask-box.tsx@@ -0,0 +1,208 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { Menu as MenuPrimitive } from "@base-ui/react/menu";+import { ArrowUpIcon, CheckIcon, ChevronDownIcon, LaptopIcon, MonitorIcon } from "lucide-react";+import { useEffect, useRef, type ReactElement, type ReactNode } from "react";++import type { Space, SpaceOs } from "@/bridge";+import { AppMarkImage } from "@/components/agents/harness-mark";+import { OsIcon } from "@/components/os-icon";+import { cn } from "@/lib/utils";++/** The coding apps a task can run with (`agent_start`'s harnesses), in the picker's order. */+export const TASK_AGENTS: { id: string; name: string; setupId: string }[] = [+ { id: "claude-code", name: "Claude Code", setupId: "claude-code" },+ { id: "openai-codex", name: "Codex", setupId: "codex" },+ { id: "gemini-cli", name: "Gemini CLI", setupId: "gemini-cli" },+ { id: "opencode", name: "OpenCode", setupId: "opencode" },+ { id: "goose", name: "Goose", setupId: "goose" },+ { id: "hermes", name: "Hermes", setupId: "hermes" },+];++export const agentName = (id: string) => TASK_AGENTS.find((a) => a.id === id)?.name ?? id;++/** Where the job runs: a new computer of a kind on this Mac, or a Space you already have. */+export type TaskWhere = { kind: "new"; os: SpaceOs } | { kind: "space"; space: Space };++const OS_WORD: Record<SpaceOs, string> = { linux: "Linux", macos: "Mac", windows: "Windows", unknown: "" };++export function whereLabel(where: TaskWhere): string {+ return where.kind === "new" ? `A new ${OS_WORD[where.os]} computer · this Mac` : where.space.name;+}++export function AppMark({ agent, size = 32 }: { agent: string; size?: number }) {+ return (+ <span className="flex shrink-0 items-center justify-center rounded-lg border bg-card dark:bg-background" style={{ width: size, height: size }}>+ <AppMarkImage agent={agent} className={size >= 40 ? "size-6" : size >= 28 ? "size-5" : "size-3.5"} />+ </span>+ );+}++function Picker({ trigger, title, children, footer }: { trigger: ReactElement; title: string; children: ReactNode; footer?: ReactNode }) {+ return (+ <MenuPrimitive.Root>+ <MenuPrimitive.Trigger render={trigger} />+ <MenuPrimitive.Portal>+ <MenuPrimitive.Positioner sideOffset={6} align="start" className="z-50 outline-none">+ <MenuPrimitive.Popup className="glass w-[420px] origin-(--transform-origin) rounded-xl border p-2 text-popover-foreground shadow-float outline-none transition-[opacity,scale] data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0">+ <p className="px-3 pt-2 pb-1 text-[12px] font-medium text-muted-foreground">{title}</p>+ {children}+ {footer ? <div className="mt-1 border-t px-3 pt-2 pb-1 text-[12px] text-muted-foreground">{footer}</div> : null}+ </MenuPrimitive.Popup>+ </MenuPrimitive.Positioner>+ </MenuPrimitive.Portal>+ </MenuPrimitive.Root>+ );+}++function PickerRow({ icon, title, note, selected, onSelect }: { icon: ReactNode; title: string; note: string; selected: boolean; onSelect: () => void }) {+ return (+ <MenuPrimitive.Item+ onClick={onSelect}+ className={cn("flex min-h-12 cursor-default items-center gap-3 rounded-lg px-3 py-2 outline-none data-highlighted:bg-foreground/[0.06]", selected && "bg-foreground/[0.06]")}+ >+ {icon}+ <div className="min-w-0 flex-1">+ <div className="text-[14px] font-medium">{title}</div>+ <div className="text-[12px] text-muted-foreground">{note}</div>+ </div>+ {selected ? <CheckIcon className="size-4" /> : null}+ </MenuPrimitive.Item>+ );+}++const pickerButton = "flex h-12 items-center gap-2.5 rounded-lg px-3 text-[14px] outline-none hover:bg-foreground/5 data-popup-open:bg-foreground/[0.07]";++/**+ * Home's box: the job in your own words, who does it and where it runs.+ * Enter starts it (Shift+Enter for a new line).+ */+export function AskBox({+ text,+ onText,+ agent,+ onAgent,+ installed,+ mostUsed,+ where,+ onWhere,+ kinds,+ spaces,+ busy,+ onSubmit,+ compact,+ autoFocus,+}: {+ text: string;+ onText: (t: string) => void;+ agent: string;+ onAgent: (a: string) => void;+ /** Harness ids found on this computer. */+ installed: ReadonlySet<string>;+ mostUsed: string | null;+ where: TaskWhere;+ onWhere: (w: TaskWhere) => void;+ /** The kinds of new computer this Mac can make, with a line each ("about 2 min"). */+ kinds: { os: SpaceOs; note: string; blocked: string | null }[];+ /** Running Spaces to use instead. */+ spaces: Space[];+ busy: boolean;+ onSubmit: () => void;+ compact?: boolean;+ autoFocus?: boolean;+}) {+ const ref = useRef<HTMLTextAreaElement>(null);+ useEffect(() => {+ if (autoFocus) ref.current?.focus();+ }, [autoFocus]);+ const ready = text.trim().length > 0 && !busy;+ const agentNote = (id: string) => (id === mostUsed ? "You use it most" : installed.has(id) ? "On this Mac" : "Runs on the new computer with your saved key");+ return (+ <div data-ask-box="" className="rounded-2xl border bg-card shadow-xs dark:bg-white/[0.03]">+ <textarea+ ref={ref}+ value={text}+ onChange={(e) => onText(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {+ e.preventDefault();+ if (ready) onSubmit();+ }+ }}+ rows={compact ? 1 : 3}+ aria-label="What do you want to do?"+ placeholder="Describe the job in your own words, or paste a link to an issue or pull request"+ className={cn("block w-full resize-none bg-transparent px-5 pt-4 text-[16px] leading-relaxed outline-none placeholder:text-muted-foreground", compact ? "min-h-14" : "min-h-24")}+ />+ <div className="flex items-center gap-1 px-2 pt-1 pb-2">+ <Picker+ title="Who does it"+ trigger={+ <button type="button" className={pickerButton} data-picker="who">+ <AppMark agent={agent} size={24} />+ <span>{agentName(agent)}</span>+ <ChevronDownIcon className="size-4 text-muted-foreground" />+ </button>+ }+ footer="It works on the new computer, signed in with the key you saved in Settings → Connected apps."+ >+ {TASK_AGENTS.map((a) => (+ <PickerRow key={a.id} icon={<AppMark agent={a.id} size={28} />} title={a.name} note={agentNote(a.id)} selected={a.id === agent} onSelect={() => onAgent(a.id)} />+ ))}+ </Picker>+ <span className="px-1 text-[14px] text-muted-foreground">on</span>+ <Picker+ title="Where it runs"+ trigger={+ <button type="button" className={pickerButton} data-picker="where">+ {where.kind === "new" ? <OsIcon os={where.os} className="size-4 text-muted-foreground" /> : <MonitorIcon className="size-4 text-muted-foreground" />}+ <span className="max-w-72 truncate">{whereLabel(where)}</span>+ <ChevronDownIcon className="size-4 text-muted-foreground" />+ </button>+ }+ >+ {kinds.map((k) => (+ <PickerRow+ key={k.os}+ icon={+ <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">+ <OsIcon os={k.os} className="size-4" />+ </span>+ }+ title={`A new ${OS_WORD[k.os]} computer on this Mac`}+ note={k.blocked ?? k.note}+ selected={where.kind === "new" && where.os === k.os}+ onSelect={() => onWhere({ kind: "new", os: k.os })}+ />+ ))}+ {spaces.length ? <p className="px-3 pt-3 pb-1 text-[12px] font-medium text-muted-foreground">Or use a computer you already have</p> : null}+ {spaces.slice(0, 5).map((s) => (+ <PickerRow+ key={s.id}+ icon={+ <span className="flex size-7 items-center justify-center rounded-md border text-muted-foreground">+ {s.provider === "local" ? <LaptopIcon className="size-4" /> : <OsIcon os={s.os} className="size-4" />}+ </span>+ }+ title={s.name}+ note="On now"+ selected={where.kind === "space" && where.space.id === s.id}+ onSelect={() => onWhere({ kind: "space", space: s })}+ />+ ))}+ </Picker>+ <div className="flex-1" />+ <button+ type="button"+ disabled={!ready}+ onClick={onSubmit}+ aria-label="Start"+ className={cn("flex size-12 items-center justify-center rounded-full transition-colors", ready ? "bg-primary text-primary-foreground hover:bg-primary/90" : "bg-foreground/10 text-muted-foreground")}+ >+ <ArrowUpIcon className="size-5" />+ </button>+ </div>+ </div>+ );+}diff --git a/apps/cua-spaces-web/src/components/ask-first/home.tsx b/apps/cua-spaces-web/src/components/ask-first/home.tsxnew file mode 100644index 0000000000..2bde486d16--- /dev/null+++ b/apps/cua-spaces-web/src/components/ask-first/home.tsx@@ -0,0 +1,233 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { Link } from "@tanstack/react-router";+import { ChevronRightIcon } from "lucide-react";+import { useEffect, useMemo, useState } from "react";++import { useAgents, useFirstSpaceOffers, useSpaces, useSpaceThumbnail, type AgentRunSummary, type Space, type SpaceOs } from "@/bridge";+import { CuaKey } from "@/components/cua-key";+import { OsIcon } from "@/components/os-icon";+import { SpaceCanvas } from "@/components/space-canvas";+import { Button } from "@/components/ui/button";+import { mostUsedAgent, orderTasks, SUGGESTIONS, taskState, TASK_STATE_TEXT, taskTitle, useAskTasks, type AskTask, type TaskState } from "@/lib/ask-first";+import { spaceState } from "@/lib/spaces";+import { cn } from "@/lib/utils";++import { AppMark, AskBox, TASK_AGENTS, type TaskWhere } from "./ask-box";+import { useStartTask } from "./use-start-task";++/** The run a task follows, from the runs in your running Spaces. */+export function taskRun(runs: readonly AgentRunSummary[] | undefined, task: AskTask): AgentRunSummary | undefined {+ return task.runId ? runs?.find((r) => r.runId === task.runId && r.spaceId === task.spaceId) : undefined;+}++export function StateDot({ state }: { state: TaskState }) {+ const tone =+ state === "working" ? "bg-success" : state === "needs-you" || state === "stuck" ? "bg-warning" : state === "failed" ? "bg-destructive" : state === "done" ? "bg-success" : "bg-muted-foreground/40";+ return (+ <span className={cn("relative inline-flex size-2 shrink-0 rounded-full", tone)}>+ {state === "working" ? <span className="absolute inset-0 animate-ping rounded-full bg-success/60" /> : null}+ </span>+ );+}++/**+ * The "Ask first" Home (CUA-2346): one question and one box. With no tasks+ * yet, three real jobs sit under it; afterwards, the tasks read like+ * conversations (the one that needs you first), and your Spaces underneath.+ */+export function AskFirstHome() {+ const tasks = useAskTasks();+ const { data: spaces } = useSpaces();+ const { data: agents, agentSetup } = useAgents();+ const { offers } = useFirstSpaceOffers();+ const start = useStartTask();+ const [installed, setInstalled] = useState<ReadonlySet<string>>(new Set());+ useEffect(() => {+ let live = true;+ agentSetup()+ .then((rows) => {+ if (!live) return;+ const found = new Set(rows.filter((r) => r.installed).map((r) => r.agent));+ setInstalled(new Set(TASK_AGENTS.filter((a) => found.has(a.setupId)).map((a) => a.id)));+ })+ .catch(() => {});+ return () => {+ live = false;+ };+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);+ const mostUsed = mostUsedAgent(tasks);+ const [text, setText] = useState("");+ const [agent, setAgent] = useState<string | null>(null);+ const chosenAgent = agent ?? mostUsed ?? TASK_AGENTS.find((a) => installed.has(a.id))?.id ?? "claude-code";+ const [where, setWhere] = useState<TaskWhere>({ kind: "new", os: "linux" });+ const kinds = useMemo(() => {+ const k: { os: SpaceOs; note: string; blocked: string | null }[] = offers.map((o) => ({+ os: o.os,+ note: `Free. Ready in ${o.time}${o.size ? ` (${o.size})` : ""}.`,+ blocked: o.blocked,+ }));+ return k.length ? k : [{ os: "linux" as const, note: "Free. Ready in a few minutes.", blocked: null }];+ }, [offers]);+ const running = (spaces ?? []).filter((s) => spaceState(s) === "running");+ const submit = (prompt = text, w = where) => {+ if (!prompt.trim()) return;+ start({ prompt, agent: chosenAgent, where: w });+ setText("");+ };++ const rows = orderTasks(+ tasks.map((task) => {+ const run = taskRun(agents?.runs, task);+ return { task, run, state: taskState(task, run ? { status: run.status, needsYou: Boolean(run.needsYou), lastEventMs: null } : null) };+ }),+ );+ const first = tasks.length === 0;++ return (+ <div className="h-full overflow-y-auto [scrollbar-gutter:stable]" data-ask-first-home="">+ <div className={cn("mx-auto flex w-full flex-col gap-8 px-8 pb-16", first ? "max-w-[880px] pt-24" : "max-w-[1040px] pt-10")}>+ {first ? <h1 className="font-heading text-[40px] font-semibold tracking-tight">What do you want to do?</h1> : null}+ <AskBox+ text={text}+ onText={setText}+ agent={chosenAgent}+ onAgent={setAgent}+ installed={installed}+ mostUsed={mostUsed}+ where={where}+ onWhere={setWhere}+ kinds={kinds}+ spaces={running}+ busy={false}+ onSubmit={() => submit()}+ compact={!first}+ autoFocus+ />+ {first ? (+ <>+ <div className="grid gap-4 sm:grid-cols-3">+ {SUGGESTIONS.filter((s) => kinds.some((k) => k.os === s.os) || s.os === "linux").map((s) => (+ <button+ type="button"+ key={s.title}+ onClick={() => {+ setText(s.prompt);+ setWhere({ kind: "new", os: kinds.some((k) => k.os === s.os) ? s.os : "linux" });+ }}+ className="flex flex-col gap-2 rounded-xl border bg-card/60 px-5 py-4 text-left transition-colors hover:bg-accent dark:bg-white/[0.02]"+ >+ <OsIcon os={s.os} className="size-4 text-muted-foreground" />+ <span className="text-[14px] leading-snug font-medium">{s.title}</span>+ <span className="text-[13px] leading-snug text-muted-foreground">{s.detail}</span>+ </button>+ ))}+ </div>+ <p className="flex items-center gap-3 text-[13px] text-muted-foreground">+ <CuaKey size={24} />A fresh computer does the work, so yours stays untouched. Watch it live, step in any time, and throw it away when you're done.+ </p>+ </>+ ) : (+ <TaskList rows={rows} spaces={spaces ?? []} />+ )}+ {!first && (spaces?.length ?? 0) > 0 ? <YourSpaces spaces={spaces ?? []} /> : null}+ </div>+ </div>+ );+}++function TaskList({ rows, spaces }: { rows: { task: AskTask; run: AgentRunSummary | undefined; state: TaskState }[]; spaces: Space[] }) {+ const live = rows.filter((r) => r.state === "working" || r.state === "starting").length;+ return (+ <section>+ <h2 className="mb-3 flex items-baseline gap-2 text-[17px] font-semibold">+ Tasks {live ? <span className="text-[14px] font-normal text-muted-foreground">{live} running</span> : null}+ </h2>+ <div className="divide-y overflow-hidden rounded-xl border bg-card shadow-xs">+ {rows.map((r) => (+ <TaskRow key={r.task.id} {...r} space={spaces.find((s) => s.id === r.task.spaceId)} />+ ))}+ </div>+ </section>+ );+}++function ago(ms: number, now = Date.now()): string {+ const m = Math.round((now - ms) / 60_000);+ if (m < 2) return "Now";+ if (m < 60) return `${m} min ago`;+ const h = Math.round(m / 60);+ if (h < 24) return `${h} h ago`;+ return h < 48 ? "Yesterday" : `${Math.round(h / 24)} days ago`;+}++function TaskRow({ task, run, state, space }: { task: AskTask; run: AgentRunSummary | undefined; state: TaskState; space: Space | undefined }) {+ const thumb = useSpaceThumbnail(task.spaceId ?? "", Boolean(space) && task.ending !== "thrown");+ const line = state === "needs-you" && run?.needsYou ? run.needsYou.title : state === "failed" && task.error ? `Stopped: ${task.error}` : TASK_STATE_TEXT[state];+ const where = task.ending === "thrown" ? "Thrown away" : (space?.name ?? "");+ return (+ <Link+ to="/home/$taskId"+ params={{ taskId: task.id }}+ data-task-row={task.id}+ className={cn("flex min-h-[72px] items-center gap-4 px-5 py-3 hover:bg-accent/60", (state === "needs-you" || state === "stuck") && "border-l-2 border-l-warning")}+ >+ <AppMark agent={task.agent} size={36} />+ <div className="min-w-0 flex-1">+ <div className="truncate text-[14px] font-medium">{taskTitle(task.prompt)}</div>+ <div className="flex items-center gap-2 text-[13px] text-muted-foreground">+ <StateDot state={state} />+ <span className="truncate">{line}</span>+ </div>+ </div>+ <span className="hidden w-40 truncate text-right text-[13px] text-muted-foreground md:block">{where}</span>+ <span className="w-24 text-right text-[13px] text-muted-foreground">{ago(task.createdMs)}</span>+ <span className="hidden w-24 lg:block">+ {thumb ? <img src={thumb} alt="" className="aspect-[16/10] w-24 rounded-md border object-cover" /> : null}+ </span>+ {state === "needs-you" ? (+ <Button variant="secondary" className="h-10 px-4" render={<span />}>+ Answer+ </Button>+ ) : null}+ </Link>+ );+}++function YourSpaces({ spaces }: { spaces: Space[] }) {+ const on = spaces.filter((s) => spaceState(s) === "running").length;+ return (+ <section>+ <div className="mb-3 flex items-center justify-between">+ <h2 className="flex items-baseline gap-2 text-[17px] font-semibold">+ Your Spaces <span className="text-[14px] font-normal text-muted-foreground">{on} on</span>+ </h2>+ <Link to="/spaces" className="flex items-center gap-1 text-[13px] text-muted-foreground hover:text-foreground">+ See all {spaces.length} <ChevronRightIcon className="size-4" />+ </Link>+ </div>+ <div className="grid grid-cols-2 gap-4 md:grid-cols-4">+ {spaces.slice(0, 4).map((s) => (+ <SpaceCard key={s.id} space={s} />+ ))}+ </div>+ </section>+ );+}++function SpaceCard({ space }: { space: Space }) {+ const thumb = useSpaceThumbnail(space.id, spaceState(space) === "running");+ return (+ <Link to="/spaces/$spaceId" params={{ spaceId: space.id }} className="overflow-hidden rounded-xl border bg-card shadow-xs hover:bg-accent/60">+ <SpaceCanvas className="rounded-none">+ {thumb ? <img src={thumb} alt="" className="absolute inset-0 size-full object-cover" /> : <OsIcon os={space.os} className="size-6 text-muted-foreground" />}+ </SpaceCanvas>+ <div className="px-4 py-3">+ <div className="truncate text-[14px] font-medium">{space.name}</div>+ <div className="text-[12px] text-muted-foreground">{spaceState(space) === "running" ? "On" : "Off"}</div>+ </div>+ </Link>+ );+}diff --git a/apps/cua-spaces-web/src/components/ask-first/task-view.tsx b/apps/cua-spaces-web/src/components/ask-first/task-view.tsxnew file mode 100644index 0000000000..8834245a44--- /dev/null+++ b/apps/cua-spaces-web/src/components/ask-first/task-view.tsx@@ -0,0 +1,463 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { Link } from "@tanstack/react-router";+import { ArrowLeftIcon, ArrowUpIcon, CheckIcon, EyeIcon, HandIcon, Loader2Icon, Maximize2Icon, Minimize2Icon, Trash2Icon, TriangleAlertIcon, UserPlusIcon } from "lucide-react";+import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";++import { useAgents, useAgentTimeline, useSession, useShareSheet, useSpaceDetail, useSpaces, type AgentTimeline, type Space } from "@/bridge";+import { Timeline } from "@/components/agents/timeline";+import { CuaKey } from "@/components/cua-key";+import { OsIcon } from "@/components/os-icon";+import { StreamSurface } from "@/components/space-detail/stream-surface";+import { ConfirmDialog } from "@/components/ui/alert-dialog";+import { Button } from "@/components/ui/button";+import { toastError } from "@/components/ui/toast";+import { keepTranscript, taskState, TASK_STATE_TEXT, taskTitle, updateAskTask, useAskTasks, type AskTask, type TaskState } from "@/lib/ask-first";+import { createProgress, spaceState } from "@/lib/spaces";+import { cn } from "@/lib/utils";++import { agentName, AppMark } from "./ask-box";+import { StateDot, taskRun } from "./home";++/** What the agent is told when the person hands the computer back. */+/** How long a sent reply may take to show in the run before the thread trusts the run's status again (ms). */+const REPLY_GRACE_MS = 15_000;++export const HAND_BACK_TEXT = "I used the computer myself and have handed it back to you. Look at the screen to see what changed, then carry on.";++/**+ * One task's conversation (CUA-2346): the run's `Timeline` beside the+ * computer's live screen. Cua's own lines (getting the computer ready, a+ * failure, the ending) carry the Cua key; the agent asks in the thread when+ * it needs you, and you can take over the screen and hand it back.+ */+export function AskFirstTask({ taskId }: { taskId: string }) {+ const task = useAskTasks().find((t) => t.id === taskId);+ if (!task) {+ return (+ <div className="flex h-full flex-col items-center justify-center gap-3 text-center">+ <p className="text-[14px] text-muted-foreground">This task isn't on this device.</p>+ <Button variant="outline" render={<Link to="/home" />}>+ Back to Home+ </Button>+ </div>+ );+ }+ return <TaskView task={task} />;+}++function TaskView({ task }: { task: AskTask }) {+ const { data: spaces, deleteSpace } = useSpaces();+ const { data: agents, sendMessage } = useAgents();+ const { data: session } = useSession();+ const sharing = useShareSheet();+ const space = spaces?.find((s) => s.id === task.spaceId);+ const pending = task.pendingId ? spaces?.find((s) => s.id === task.pendingId) : undefined;+ const ref = task.runId && task.spaceId && task.ending !== "thrown" ? { spaceId: task.spaceId, runId: task.runId } : null;+ const live = useAgentTimeline(ref);+ const saved = useMemo<AgentTimeline | null>(+ () =>+ task.transcript+ ? { items: task.transcript, status: task.lastStatus, phase: "", caughtUp: true, isLoading: false, error: null, unsupported: false, lastEventMs: null }+ : null,+ [task.transcript, task.lastStatus],+ );+ const timeline = saved ?? live;+ const run = taskRun(agents?.runs, task);+ // A reply just sent reads as working until the run writes its new turn+ // (otherwise the old "done" or ask would show for a moment).+ const [sentMs, setSentMs] = useState<number | null>(null);+ const [, tick] = useState(0);+ const awaiting = sentMs !== null && (timeline.lastEventMs ?? 0) < sentMs && Date.now() - sentMs < REPLY_GRACE_MS;+ useEffect(() => {+ if (!awaiting) return;+ const t = setTimeout(() => tick((n) => n + 1), REPLY_GRACE_MS);+ return () => clearTimeout(t);+ }, [awaiting]);+ const read = taskState(task, ref ? { status: timeline.status ?? run?.status ?? null, needsYou: Boolean(run?.needsYou), lastEventMs: timeline.lastEventMs } : null);+ const state: TaskState = awaiting && (read === "done" || read === "needs-you" || read === "kept") ? "working" : read;+ const [mode, setMode] = useState<"watch" | "control">("watch");+ const [big, setBig] = useState(false);+ const [throwing, setThrowing] = useState(false);+ const [reply, setReply] = useState("");+ const replyRef = useRef<HTMLTextAreaElement>(null);+ const name = agentName(task.agent);++ // A thrown-away or failed task has no screen to control.+ useEffect(() => {+ if (!space && mode === "control") setMode("watch");+ }, [space, mode]);++ const send = async (text: string) => {+ if (!ref || !text.trim()) return;+ setReply("");+ setSentMs(Date.now());+ await sendMessage(ref, text.trim()).catch(toastError(`Couldn't send that to ${name}`));+ };+ const takeOver = () => {+ setMode("control");+ setBig(true);+ };+ const handBack = () => {+ setMode("watch");+ setBig(false);+ void send(HAND_BACK_TEXT);+ };+ const keep = () => updateAskTask(task.id, { ending: "kept", endedMs: Date.now() });+ const throwAway = async () => {+ if (!task.spaceId) return;+ updateAskTask(task.id, { transcript: keepTranscript(timeline.items), lastStatus: timeline.status, ending: "thrown", endedMs: Date.now() });+ await deleteSpace(task.spaceId).catch(toastError("Couldn't throw the computer away"));+ };++ const footer = (+ <ThreadFooter+ task={task}+ state={state}+ timeline={timeline}+ name={name}+ needsYou={run?.needsYou ?? null}+ onTakeOver={space ? takeOver : undefined}+ onAnswer={() => replyRef.current?.focus()}+ onKeep={keep}+ onThrow={() => setThrowing(true)}+ />+ );+ const hasThread = timeline.items.length > 0;++ return (+ <div className="flex h-full flex-col" data-ask-first-task={task.id} data-task-state={state}>+ <header className="flex h-16 shrink-0 items-center gap-3 border-b px-8">+ <Button variant="ghost" className="-ml-2 h-9" render={<Link to="/home" />}>+ <ArrowLeftIcon /> Home+ </Button>+ <AppMark agent={task.agent} size={32} />+ <div className="min-w-0 flex-1">+ <h2 className="truncate text-[15px] font-semibold">{taskTitle(task.prompt)}</h2>+ <p className="flex items-center gap-2 text-[13px] text-muted-foreground">+ <StateDot state={state} /> {TASK_STATE_TEXT[state]}+ </p>+ </div>+ {space ? (+ <Button variant="outline" className="h-10" onClick={() => void sharing.open(space, session?.signedIn ?? false).catch(toastError("Couldn't share"))}>+ <UserPlusIcon /> Share+ </Button>+ ) : null}+ </header>+ {mode === "control" ? (+ <div className="flex min-h-12 shrink-0 items-center gap-3 border-b bg-brand-surface px-8 text-[13px]" role="status">+ <HandIcon className="size-4" />+ <span className="flex-1">You have the controls. {name} waits until you hand it back.</span>+ <Button className="h-9" onClick={handBack}>+ Hand back to {name}+ </Button>+ </div>+ ) : null}+ <div className="flex min-h-0 flex-1">+ <div className={cn("flex min-w-0 flex-col", big ? "w-[420px] shrink-0 border-r" : "flex-1")}>+ {hasThread ? (+ <Timeline className="flex-1" timeline={timeline} footer={footer} />+ ) : (+ <div className="min-h-0 flex-1 overflow-y-auto">+ <div className="mx-auto flex max-w-[720px] flex-col justify-end gap-6 px-8 pt-8 pb-6" style={{ minHeight: "100%" }}>+ <div className="flex justify-end">+ <div className="max-w-[85%] rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-[13px] leading-[1.55] whitespace-pre-wrap">{task.prompt}</div>+ </div>+ {task.error ? null : <Starting pending={pending} space={space} name={name} />}+ {footer}+ </div>+ </div>+ )}+ {task.ending !== "thrown" ? (+ <div className="shrink-0 px-8 pb-6">+ <div className="mx-auto flex min-h-14 max-w-[720px] items-end gap-2 rounded-2xl border bg-card py-1.5 pr-1.5 pl-5 shadow-xs dark:bg-white/[0.03]">+ <textarea+ ref={replyRef}+ value={reply}+ disabled={!ref}+ rows={1}+ onChange={(e) => setReply(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {+ e.preventDefault();+ void send(reply);+ }+ }}+ aria-label={`Reply to ${name}`}+ placeholder={state === "needs-you" ? "Or answer in words" : state === "done" || state === "kept" ? "Ask a follow-up" : `Reply to ${name}`}+ className="min-h-11 flex-1 resize-none self-center bg-transparent py-2.5 text-[14px] outline-none placeholder:text-muted-foreground disabled:opacity-60"+ />+ <button+ type="button"+ aria-label="Send"+ disabled={!ref || !reply.trim()}+ onClick={() => void send(reply)}+ className={cn("flex size-11 shrink-0 items-center justify-center rounded-full", ref && reply.trim() ? "bg-primary text-primary-foreground" : "bg-foreground/10 text-muted-foreground")}+ >+ <ArrowUpIcon className="size-5" />+ </button>+ </div>+ </div>+ ) : null}+ </div>+ <aside className={cn("flex shrink-0 flex-col gap-4 overflow-y-auto px-6 pt-8 pb-6", big ? "min-w-0 flex-1" : "w-[440px] border-l")}>+ <Screen+ task={task}+ space={space}+ state={state}+ mode={mode}+ big={big}+ onMode={(m) => (m === "control" ? takeOver() : mode === "control" ? handBack() : setMode("watch"))}+ onBig={() => setBig((b) => !b)}+ />+ <ComputerCard task={task} space={space} />+ </aside>+ </div>+ <ConfirmDialog+ open={throwing}+ onOpenChange={setThrowing}+ title="Throw the computer away?"+ description="This deletes the computer and everything on it. This conversation stays here."+ confirmLabel="Throw it away"+ destructive+ onConfirm={() => void throwAway()}+ />+ </div>+ );+}++function CuaLine({ children, tone }: { children: ReactNode; tone?: "bad" }) {+ return (+ <div className={cn("flex items-start gap-3 rounded-xl border bg-card px-5 py-4 shadow-xs", tone === "bad" && "border-l-2 border-l-destructive")}>+ <CuaKey size={28} />+ <div className="min-w-0 flex-1 text-[13px] leading-relaxed text-muted-foreground">{children}</div>+ </div>+ );+}++function Starting({ pending, space, name }: { pending: Space | undefined; space: Space | undefined; name: string }) {+ const making = pending?.progress;+ const steps = [+ { text: "Making the computer", done: Boolean(space), now: !space },+ { text: `Opening ${name} inside it`, done: false, now: Boolean(space) },+ ];+ return (+ <div className="rounded-xl border bg-card px-5 py-4 shadow-xs" data-ask-starting="">+ <div className="flex items-center gap-3">+ <CuaKey size={28} />+ <div className="flex-1">+ <div className="text-[15px] font-semibold">Getting a fresh computer ready</div>+ <div className="text-[13px] text-muted-foreground">+ {making?.transfer ?? (making ? `${making.label} ${Math.round(createProgress({ progress: making }) * 100)}%` : "Usually under a minute. The first one takes a few minutes.")}+ </div>+ </div>+ </div>+ <ol className="mt-4 space-y-3">+ {steps.map((s) => (+ <li key={s.text} className="flex items-center gap-3 text-[14px]">+ {s.done ? <CheckIcon className="size-4 text-success" /> : s.now ? <Loader2Icon className="size-4 animate-spin text-brand-strong" /> : <span className="size-4" />}+ <span className={cn(!s.done && !s.now && "text-muted-foreground")}>{s.text}</span>+ </li>+ ))}+ </ol>+ </div>+ );+}++function ThreadFooter({+ task,+ state,+ timeline,+ name,+ needsYou,+ onTakeOver,+ onAnswer,+ onKeep,+ onThrow,+}: {+ task: AskTask;+ state: TaskState;+ timeline: AgentTimeline;+ name: string;+ needsYou: { title: string; detail: string } | null;+ onTakeOver?: () => void;+ onAnswer: () => void;+ onKeep: () => void;+ onThrow: () => void;+}) {+ return (+ <div className="flex flex-col gap-5" data-ask-footer="">+ {task.error ? (+ <CuaLine tone="bad">+ <div className="mb-1 flex items-center gap-2 text-[15px] font-semibold text-foreground">+ <TriangleAlertIcon className="size-4 text-destructive" /> This task couldn't start+ </div>+ {task.error}+ {/key|sign|auth|login|credential/i.test(task.error) ? (+ <p className="mt-2">+ {name} needs your key to work on the new computer. Add it in{" "}+ <Link to="/settings/connected-apps" className="underline">+ Settings → Connected apps+ </Link>+ , then ask again.+ </p>+ ) : null}+ </CuaLine>+ ) : null}+ {state === "working" ? (+ <p className="flex items-center gap-2 text-xs text-muted-foreground" role="status">+ <StateDot state="working" />+ {timeline.phase === "responding" ? "Writing" : timeline.phase === "tool" ? "Using the computer" : "Working"}+ </p>+ ) : null}+ {state === "stuck" ? (+ <CuaLine>+ <div className="mb-1 text-[15px] font-semibold text-foreground">No progress for 10 minutes</div>+ {name} hasn't done anything new for a while. You can nudge it with a reply, or take over the screen.+ {onTakeOver ? (+ <div className="mt-3">+ <Button variant="outline" className="h-10" onClick={onTakeOver}>+ <HandIcon /> Take over+ </Button>+ </div>+ ) : null}+ </CuaLine>+ ) : null}+ {state === "needs-you" && needsYou ? (+ <div className="rounded-xl border border-l-2 border-l-warning bg-card px-5 py-4 shadow-xs" data-ask-needs-you="">+ <div className="flex items-start gap-3">+ <AppMark agent={task.agent} size={28} />+ <div className="min-w-0 flex-1">+ <div className="text-[15px] font-semibold">{needsYou.title}</div>+ <div className="mt-1 text-[13px] leading-relaxed text-muted-foreground">{needsYou.detail}</div>+ <div className="mt-4 flex flex-wrap gap-2">+ {onTakeOver ? (+ <Button className="h-11 px-4" onClick={onTakeOver}>+ <HandIcon /> Do it on the screen+ </Button>+ ) : null}+ <Button variant="outline" className="h-11 px-4" onClick={onAnswer}>+ Answer in words+ </Button>+ </div>+ </div>+ </div>+ </div>+ ) : null}+ {state === "done" ? (+ <div className="rounded-xl border bg-card shadow-xs" data-ask-done="">+ <div className="flex items-start gap-3 px-5 py-4">+ <CheckIcon className="mt-0.5 size-5 text-success" />+ <div>+ <div className="text-[15px] font-semibold">{name} finished</div>+ <div className="mt-1 text-[13px] text-muted-foreground">Ask a follow-up below, or decide what happens to the computer.</div>+ </div>+ </div>+ <div className="flex flex-wrap items-center gap-3 border-t px-5 py-3">+ <span className="flex-1 text-[13px] text-muted-foreground">The computer is still on. What should happen to it?</span>+ <Button variant="outline" className="h-11 px-4" onClick={onKeep}>+ Keep it+ </Button>+ <Button variant="outline" className="h-11 px-4" onClick={onThrow}>+ <Trash2Icon /> Throw it away+ </Button>+ </div>+ </div>+ ) : null}+ {state === "done" ? <p className="text-[12px] text-muted-foreground">Throwing it away deletes the computer. This conversation stays.</p> : null}+ {state === "kept" ? <p className="text-[12px] text-muted-foreground">You kept the computer. It's with your Spaces.</p> : null}+ {state === "thrown" ? <p className="text-[12px] text-muted-foreground">You threw the computer away. This is the conversation as it was.</p> : null}+ </div>+ );+}++function Screen({+ task,+ space,+ state,+ mode,+ big,+ onMode,+ onBig,+}: {+ task: AskTask;+ space: Space | undefined;+ state: TaskState;+ mode: "watch" | "control";+ big: boolean;+ onMode: (m: "watch" | "control") => void;+ onBig: () => void;+}) {+ const detail = useSpaceDetail(space, null).detail;+ const on = space ? spaceState(space) === "running" : false;+ const caption = !space ? (task.ending === "thrown" ? "Thrown away" : "Not ready yet") : state === "needs-you" ? "Waiting for you" : state === "working" ? "Live" : "Finished";+ return (+ <div className={cn("overflow-hidden rounded-xl border bg-card shadow-xs", state === "needs-you" && mode === "watch" && "ring-2 ring-warning/70", mode === "control" && "ring-2 ring-brand")} data-ask-screen={mode}>+ {space && on ? (+ <StreamSurface+ spaceId={space.id}+ os={space.os}+ canStream={detail?.canStream ?? false}+ previewText={detail?.previewText ?? ""}+ interactive={mode === "control"}+ className="aspect-[16/10] w-full rounded-none border-0"+ />+ ) : (+ <div className="flex aspect-[16/10] items-center justify-center bg-thumb text-[13px] text-muted-foreground">+ <OsIcon os={task.os} className="mr-2 size-5" />+ {caption}+ </div>+ )}+ <div className="flex min-h-12 items-center gap-2 px-3">+ <span className="min-w-0 flex-1 truncate text-[13px] text-muted-foreground">{caption}</span>+ {space && on ? (+ <>+ <div className="flex rounded-lg border p-0.5 text-[13px]" role="group" aria-label="Screen">+ <button+ type="button"+ aria-pressed={mode === "watch"}+ onClick={() => onMode("watch")}+ className={cn("flex h-8 items-center gap-1.5 rounded-md px-2.5", mode === "watch" && "bg-foreground/[0.08] font-medium")}+ >+ <EyeIcon className="size-3.5" /> Watch+ </button>+ <button+ type="button"+ aria-pressed={mode === "control"}+ onClick={() => onMode("control")}+ className={cn("flex h-8 items-center gap-1.5 rounded-md px-2.5", mode === "control" && "bg-brand-surface font-medium")}+ >+ <HandIcon className="size-3.5" /> Take over+ </button>+ </div>+ <Button variant="ghost" size="icon" aria-label={big ? "Make smaller" : "Make bigger"} onClick={onBig}>+ {big ? <Minimize2Icon /> : <Maximize2Icon />}+ </Button>+ </>+ ) : null}+ </div>+ </div>+ );+}++function ComputerCard({ task, space }: { task: AskTask; space: Space | undefined }) {+ const os = task.os === "macos" ? "Mac" : task.os === "windows" ? "Windows" : "Linux";+ const line = !space ? (task.ending === "thrown" ? "Thrown away" : task.error ? "Not made" : "Getting ready") : spaceState(space) === "running" ? "On" : "Off";+ return (+ <div className="rounded-xl border bg-card text-[13px] shadow-xs">+ <div className="flex min-h-12 items-center gap-3 px-4 py-2">+ <OsIcon os={task.os} className="size-4 text-muted-foreground" />+ <div className="min-w-0 flex-1">+ <div className="font-medium">{space ? space.name : `${os} computer for this task`}</div>+ <div className="text-muted-foreground">{line}</div>+ </div>+ {space ? (+ <Button variant="ghost" size="sm" render={<Link to="/spaces/$spaceId" params={{ spaceId: space.id }} />}>+ Open+ </Button>+ ) : null}+ </div>+ </div>+ );+}diff --git a/apps/cua-spaces-web/src/components/ask-first/use-start-task.ts b/apps/cua-spaces-web/src/components/ask-first/use-start-task.tsnew file mode 100644index 0000000000..31630710f0--- /dev/null+++ b/apps/cua-spaces-web/src/components/ask-first/use-start-task.ts@@ -0,0 +1,46 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { useNavigate } from "@tanstack/react-router";++import { newPendingId, useAgents, useFeatureRecorder, useFirstSpaceOffers, useSpaces } from "@/bridge";+import { addAskTask, updateAskTask } from "@/lib/ask-first";++import type { TaskWhere } from "./ask-box";++/**+ * Starts a task: records it, opens its conversation at once, makes the+ * computer (or uses the one picked), then starts the coding app on it with+ * the job as its prompt. A failure is kept on the task and shown in its+ * thread.+ */+export function useStartTask(): (job: { prompt: string; agent: string; where: TaskWhere }) => void {+ const navigate = useNavigate();+ const { createSpace } = useSpaces();+ const { startRun } = useAgents();+ const { offers } = useFirstSpaceOffers();+ const record = useFeatureRecorder();+ return ({ prompt, agent, where }) => {+ const os = where.kind === "new" ? where.os : where.space.os;+ const task = addAskTask({ prompt: prompt.trim(), agent, os, spaceId: where.kind === "space" ? where.space.id : null });+ record("ask_first_task_started");+ void navigate({ to: "/home/$taskId", params: { taskId: task.id } });+ void (async () => {+ try {+ let spaceId = task.spaceId;+ if (!spaceId) {+ const pendingId = newPendingId();+ updateAskTask(task.id, { pendingId });+ const offer = offers.find((o) => o.os === os);+ const space = await createSpace(offer ? { ...offer.args, os } : { os }, pendingId);+ spaceId = space.id;+ updateAskTask(task.id, { spaceId, pendingId: null });+ }+ const run = await startRun({ spaceId, agent, prompt: task.prompt });+ updateAskTask(task.id, { runId: run.run_id });+ } catch (e) {+ updateAskTask(task.id, { error: e instanceof Error ? e.message : String(e) });+ }+ })();+ };+}diff --git a/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx b/apps/cua-spaces-web/src/components/settings/advanced-tab.tsxindex 7be24bd62d..fc4d55bb52 100644--- a/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx+++ b/apps/cua-spaces-web/src/components/settings/advanced-tab.tsx@@ -1,7 +1,7 @@// SPDX-License-Identifier: FSL-1.1-MIT// Copyright (c) 2026 Cua AI, Inc.-import { useAbout, useBridge, useExperiments, useMachines, useSession, useSettings, useThisMachine, type SettingsOption, type SettingsRow as CoreRow } from "@/bridge";+import { setFlagOverride, useAbout, useBridge, useExperiments, useFlag, useMachines, useSession, useSettings, useThisMachine, type SettingsOption, type SettingsRow as CoreRow } from "@/bridge";import { aboutView } from "@/bridge/settings-derive";import { SettingsGroup } from "@/components/settings-group";import { CoreSettingsRow } from "@/components/settings/core-section";@@ -101,18 +101,43 @@ function EarlyReleases() {);}-/** Cua Volume and, on the Mac-native app, the previous window. Off hides; nothing set up is undone. */+/** The "Ask first" Home (`spaces_ask_first_home`): a switch for this device only. */+function askFirstRow(on: boolean): CoreRow {+ return {+ id: "flag:spaces_ask_first_home",+ kind: "toggle",+ label: "Try the new Home",+ value: null,+ button: null,+ options: [+ { id: "on", label: "On", active: on },+ { id: "off", label: "Off", active: !on },+ ],+ enabled: true,+ help: null,+ linkLabel: null,+ linkUrl: null,+ placeholder: null,+ };+}++/** Cua Volume, the new Home and, on the Mac-native app, the previous window. Off hides; nothing set up is undone. */function Labs() {const { data, chooseExperiment } = useExperiments();const { mode } = useBridge();+ const askFirst = useFlag("spaces_ask_first_home");const rows = (data?.page?.sections.flatMap((s) => s.rows) ?? []).filter((r) => LABS.has(r.id) && !(mode === "electron" && r.id === "experiment:classic_ui"));- if (rows.length === 0) return null;const note: Record<string, string> = {"experiment:cua_volume": "Memory and files your agents share across every Space.","experiment:classic_ui": "Mac-native app only.",};return (<SettingsGroup title="Labs">+ <CoreSettingsRow+ row={askFirstRow(askFirst)}+ description="Home asks what you want done, then does it on a fresh computer you can watch. On this device only."+ onChoose={(_, option) => setFlagOverride("spaces_ask_first_home", option === "on")}+ />{rows.map((r) => (<CoreSettingsRowkey={r.id}diff --git a/apps/cua-spaces-web/src/components/shell/nav.ts b/apps/cua-spaces-web/src/components/shell/nav.tsindex 59bbcbf7e3..62f4dd9f09 100644--- a/apps/cua-spaces-web/src/components/shell/nav.ts+++ b/apps/cua-spaces-web/src/components/shell/nav.ts@@ -1,13 +1,13 @@// SPDX-License-Identifier: FSL-1.1-MIT// Copyright (c) 2026 Cua AI, Inc.-import { BellIcon, BotIcon, HardDriveIcon, KeyRoundIcon, LayoutGridIcon, ServerIcon, SettingsIcon, type LucideIcon } from "lucide-react";+import { BellIcon, BotIcon, HardDriveIcon, HouseIcon, KeyRoundIcon, LayoutGridIcon, ServerIcon, SettingsIcon, type LucideIcon } from "lucide-react";-import { useExperimentFlags } from "@/bridge";+import { useExperimentFlags, useFlag } from "@/bridge";import type { KeybindingCommand } from "@/lib/keybindings";export interface NavItem {- to: "/spaces" | "/machines" | "/agents" | "/volume" | "/keyvault" | "/notifications" | "/settings";+ to: "/home" | "/spaces" | "/machines" | "/agents" | "/volume" | "/keyvault" | "/notifications" | "/settings";label: string;icon: LucideIcon;/** Its keyboard shortcut, when it has one. */@@ -26,10 +26,17 @@ export const NAV_ITEMS: NavItem[] = [/** The sidebar's Volume entry (the core's `volumeLabel`), after Agents. */const VOLUME_ITEM: NavItem = { to: "/volume", label: "Volume", icon: HardDriveIcon };-/** The nav, with Volume while the Cua Volume experiment is on. */+/** The "Ask first" Home, first while its experiment flag is on (`spaces_ask_first_home`). */+const HOME_ITEM: NavItem = { to: "/home", label: "Home", icon: HouseIcon };++/** The nav, with Volume while the Cua Volume experiment is on, and Home while the Ask-first flag is. */export function useNavItems(): NavItem[] {const experiments = useExperimentFlags();- if (!experiments?.cuaVolume) return NAV_ITEMS;- const i = NAV_ITEMS.findIndex((n) => n.to === "/agents") + 1;- return [...NAV_ITEMS.slice(0, i), VOLUME_ITEM, ...NAV_ITEMS.slice(i)];+ const home = useFlag("spaces_ask_first_home");+ let items = NAV_ITEMS;+ if (experiments?.cuaVolume) {+ const i = NAV_ITEMS.findIndex((n) => n.to === "/agents") + 1;+ items = [...NAV_ITEMS.slice(0, i), VOLUME_ITEM, ...NAV_ITEMS.slice(i)];+ }+ return home ? [HOME_ITEM, ...items] : items;}diff --git a/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx b/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsxindex 8757ed4fae..d5ebd597a3 100644--- a/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx+++ b/apps/cua-spaces-web/src/components/space-detail/stream-surface.tsx@@ -57,6 +57,8 @@ export interface StreamSurfaceProps {/** Shown instead of the stream (progress, stopped). */children?: ReactNode;className?: string;+ /** Pointer and keys go to the Space (default). False only shows it (Watch). */+ interactive?: boolean;}/** How long the desktop may take to send its first picture. After that the@@ -82,7 +84,7 @@ function useTimedOut(waiting: boolean, ms: number, key: string): boolean {const SURFACE_RADIUS = 12;const SURFACE_BORDER = 1;-export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, previewText, access, onAccessAction, children, className }: StreamSurfaceProps) {+export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, previewText, access, onAccessAction, children, className, interactive = true }: StreamSurfaceProps) {const ref = useRef<HTMLDivElement | null>(null);const settings = useSettings();const autoConnect = settings.data?.values.autoConnect ?? true;@@ -103,7 +105,7 @@ export function StreamSurface({ spaceId, os, aspectRatio = 16 / 10, canStream, pattempt,spaceId,tier: "full",- interactive: true,+ interactive,radius: SURFACE_RADIUS,inset: SURFACE_BORDER,os,diff --git a/apps/cua-spaces-web/src/lib/ask-first.test.ts b/apps/cua-spaces-web/src/lib/ask-first.test.tsnew file mode 100644index 0000000000..ddb1d80ff0--- /dev/null+++ b/apps/cua-spaces-web/src/lib/ask-first.test.ts@@ -0,0 +1,66 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { beforeEach, describe, expect, it } from "vitest";++import { flagOn, setFlagOverride } from "@/bridge";++import { addAskTask, askTasks, mostUsedAgent, orderTasks, resetAskTasks, STUCK_MS, taskState, taskTitle, updateAskTask, type AskTask } from "./ask-first";++beforeEach(() => {+ localStorage.clear();+ resetAskTasks();+});++describe("the spaces_ask_first_home flag", () => {+ it("is off unless this device turns it on", () => {+ expect(flagOn("spaces_ask_first_home")).toBe(false);+ setFlagOverride("spaces_ask_first_home", true);+ expect(flagOn("spaces_ask_first_home")).toBe(true);+ setFlagOverride("spaces_ask_first_home", null);+ expect(flagOn("spaces_ask_first_home")).toBe(false);+ });+});++describe("Ask-first tasks", () => {+ it("are kept on this device, newest first, and survive a reload", () => {+ const a = addAskTask({ prompt: "Run the tests", agent: "claude-code", os: "linux" }, 1);+ addAskTask({ prompt: "Check Safari", agent: "openai-codex", os: "macos" }, 2);+ updateAskTask(a.id, { runId: "run-1", spaceId: "local:x" });+ resetAskTasks();+ expect(askTasks().map((t) => t.prompt)).toEqual(["Check Safari", "Run the tests"]);+ expect(askTasks()[1]).toMatchObject({ runId: "run-1", spaceId: "local:x" });+ });++ it("read as starting, working, needs you, stuck, done and thrown away", () => {+ const t = addAskTask({ prompt: "x", agent: "claude-code", os: "linux" });+ const now = 1_000_000_000;+ expect(taskState(t, null)).toBe("starting");+ const running: AskTask = { ...t, runId: "r", spaceId: "s" };+ expect(taskState(running, { status: "running", needsYou: false, lastEventMs: now }, now)).toBe("working");+ expect(taskState(running, { status: "running", needsYou: false, lastEventMs: now - STUCK_MS - 1 }, now)).toBe("stuck");+ expect(taskState(running, { status: "idle", needsYou: true, lastEventMs: now }, now)).toBe("needs-you");+ expect(taskState(running, { status: "idle", needsYou: false, lastEventMs: now }, now)).toBe("done");+ expect(taskState({ ...running, ending: "kept" }, { status: "idle", needsYou: false, lastEventMs: now }, now)).toBe("kept");+ expect(taskState({ ...running, ending: "thrown" }, null)).toBe("thrown");+ expect(taskState({ ...t, error: "no room" }, null)).toBe("failed");+ });++ it("put what needs you first, then running ones, then the rest", () => {+ const mk = (id: string, createdMs: number) => ({ ...addAskTask({ prompt: id, agent: "claude-code", os: "linux" }), createdMs });+ const rows = orderTasks([+ { task: mk("done", 3), state: "done" as const },+ { task: mk("working", 1), state: "working" as const },+ { task: mk("asks", 2), state: "needs-you" as const },+ ]);+ expect(rows.map((r) => r.task.prompt)).toEqual(["asks", "working", "done"]);+ });++ it("pick the coding app used most, and a short title", () => {+ expect(mostUsedAgent([])).toBeNull();+ const t = (agent: string) => ({ agent }) as AskTask;+ expect(mostUsedAgent([t("openai-codex"), t("claude-code"), t("openai-codex")])).toBe("openai-codex");+ expect(taskTitle(" \nFirst line\nsecond")).toBe("First line");+ expect(taskTitle("x".repeat(100), 10)).toBe(`${"x".repeat(9)}…`);+ });+});diff --git a/apps/cua-spaces-web/src/lib/ask-first.ts b/apps/cua-spaces-web/src/lib/ask-first.tsnew file mode 100644index 0000000000..c12befcfc6--- /dev/null+++ b/apps/cua-spaces-web/src/lib/ask-first.ts@@ -0,0 +1,208 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++/**+ * The "Ask first" Home's tasks (CUA-2346, behind `spaces_ask_first_home`):+ * one job asked for on Home, the computer made for it, and the coding+ * agent's run on that computer.+ *+ * A task is kept on this device (`localStorage`), so it outlives the page and+ * the computer: when the person throws the computer away, the conversation+ * so far is copied into the task first. Syncing tasks across devices and+ * teammates needs a task record in the control plane (a follow-up).+ */++import { useSyncExternalStore } from "react";++import type { AgentRunStatus, SpaceOs, TranscriptItem } from "@/bridge";++export type TaskEnding = "kept" | "thrown";++export interface AskTask {+ id: string;+ /** What the person asked for, as typed. */+ prompt: string;+ /** Harness id (`claude-code`, `openai-codex`, ...). */+ agent: string;+ os: SpaceOs;+ createdMs: number;+ /** The create's row while the computer is being made. */+ pendingId: string | null;+ /** The computer, once made (or the one picked). */+ spaceId: string | null;+ /** The agent's run, once started. */+ runId: string | null;+ /** Why making the computer or starting the agent failed. */+ error: string | null;+ ending: TaskEnding | null;+ endedMs: number | null;+ /** The conversation, copied when the computer was thrown away. */+ transcript: TranscriptItem[] | null;+ /** The status the run last had, for a thrown-away task's line. */+ lastStatus: AgentRunStatus | null;+}++const KEY = "cua.askFirst.tasks";+/** The newest tasks kept; older ones drop off. */+const MAX_TASKS = 50;+/** Conversation items kept per thrown-away task. */+const MAX_ITEMS = 300;++let cache: AskTask[] | null = null;+const listeners = new Set<() => void>();++function load(): AskTask[] {+ if (cache) return cache;+ try {+ const raw = globalThis.localStorage?.getItem(KEY);+ const parsed = raw ? (JSON.parse(raw) as unknown) : [];+ cache = Array.isArray(parsed) ? (parsed as AskTask[]) : [];+ } catch {+ cache = [];+ }+ return cache;+}++function save(next: AskTask[]): void {+ cache = next.slice(0, MAX_TASKS);+ try {+ globalThis.localStorage?.setItem(KEY, JSON.stringify(cache));+ } catch {+ // Not kept past this session (storage full or off).+ }+ for (const l of [...listeners]) l();+}++/** Every task, newest first. */+export function askTasks(): AskTask[] {+ return load();+}++export function askTask(id: string): AskTask | undefined {+ return load().find((t) => t.id === id);+}++export function addAskTask(t: Pick<AskTask, "prompt" | "agent" | "os"> & Partial<AskTask>, now = Date.now()): AskTask {+ const task: AskTask = {+ id: `task-${now.toString(36)}-${Math.random().toString(36).slice(2, 6)}`,+ createdMs: now,+ pendingId: null,+ spaceId: null,+ runId: null,+ error: null,+ ending: null,+ endedMs: null,+ transcript: null,+ lastStatus: null,+ ...t,+ };+ save([task, ...load()]);+ return task;+}++export function updateAskTask(id: string, patch: Partial<AskTask> | ((t: AskTask) => Partial<AskTask>)): void {+ save(load().map((t) => (t.id === id ? { ...t, ...(typeof patch === "function" ? patch(t) : patch) } : t)));+}++/** Keeps the conversation with the task before its computer goes. */+export function keepTranscript(items: readonly TranscriptItem[]): TranscriptItem[] {+ return items.slice(-MAX_ITEMS).map((i) => ({ ...i, steps: [...i.steps] }));+}++/** For tests: forget the cached list. */+export function resetAskTasks(): void {+ cache = null;+}++const subscribe = (l: () => void) => {+ listeners.add(l);+ const onStorage = (e: StorageEvent) => {+ if (e.key === null || e.key === KEY) {+ cache = null;+ l();+ }+ };+ globalThis.addEventListener?.("storage", onStorage);+ return () => {+ listeners.delete(l);+ globalThis.removeEventListener?.("storage", onStorage);+ };+};++export function useAskTasks(): AskTask[] {+ return useSyncExternalStore(subscribe, load, load);+}++/** The coding app used most for tasks on this device, or null before the first. */+export function mostUsedAgent(tasks: readonly AskTask[]): string | null {+ const counts = new Map<string, number>();+ for (const t of tasks) counts.set(t.agent, (counts.get(t.agent) ?? 0) + 1);+ let best: string | null = null;+ for (const [agent, n] of counts) if (best === null || n > counts.get(best)!) best = agent;+ return best;+}++/** A task's title: its first line, short. */+export function taskTitle(prompt: string, max = 80): string {+ const line = prompt.split("\n").map((l) => l.trim()).find(Boolean) ?? "";+ return [...line].length <= max ? line : `${[...line].slice(0, max - 1).join("").trimEnd()}…`;+}++/** Where a task stands, in the words Home and the thread use. */+export type TaskState = "starting" | "working" | "needs-you" | "stuck" | "done" | "failed" | "kept" | "thrown";++/** No new event for this long while a turn runs reads as stuck. */+export const STUCK_MS = 10 * 60_000;++export function taskState(+ task: AskTask,+ run: { status: AgentRunStatus | null; needsYou: boolean; lastEventMs: number | null } | null,+ now = Date.now(),+): TaskState {+ if (task.ending === "thrown") return "thrown";+ if (task.error) return "failed";+ if (!task.runId || !run || run.status === null) return task.ending === "kept" ? "kept" : "starting";+ if (run.needsYou) return "needs-you";+ if (run.status === "running") return run.lastEventMs !== null && now - run.lastEventMs > STUCK_MS ? "stuck" : "working";+ if (run.status === "failed" || run.status === "crashed") return "failed";+ return task.ending === "kept" ? "kept" : "done";+}++export const TASK_STATE_TEXT: Record<TaskState, string> = {+ starting: "Getting a computer ready",+ working: "Working",+ "needs-you": "Needs you",+ stuck: "No progress for 10 minutes",+ done: "Done",+ failed: "Stopped",+ kept: "Done. Computer kept",+ thrown: "Done. Computer thrown away",+};++/** Home's order: needs you first, then running, then the rest, newest first. */+export function orderTasks<T extends { state: TaskState; task: AskTask }>(rows: T[]): T[] {+ const rank = (s: TaskState) => (s === "needs-you" || s === "stuck" ? 0 : s === "working" || s === "starting" ? 1 : 2);+ return [...rows].sort((a, b) => rank(a.state) - rank(b.state) || b.task.createdMs - a.task.createdMs);+}++/** The jobs offered on an empty Home: real dev work where a fresh computer matters. */+export const SUGGESTIONS: { title: string; detail: string; os: SpaceOs; prompt: string }[] = [+ {+ title: "Run my project's tests on a clean Linux computer",+ detail: "Find out if it works on a computer that has never seen your code.",+ os: "linux",+ prompt: "Copy my project onto this computer, install what it needs and run its tests. Tell me what passed and what failed: ",+ },+ {+ title: "Try a pull request before merging",+ detail: "Paste the link. It builds the branch and tells you what breaks.",+ os: "linux",+ prompt: "Check out this pull request, build it and run its tests, then tell me if it's safe to merge: ",+ },+ {+ title: "Check my site works on Safari",+ detail: "It clicks through your pages on a Mac and shows you what looks wrong.",+ os: "macos",+ prompt: "Open my site in Safari, click through the main pages and tell me what looks or works wrong: ",+ },+];diff --git a/apps/cua-spaces-web/src/routeTree.gen.ts b/apps/cua-spaces-web/src/routeTree.gen.tsindex 7dcc3c4583..4bbf6afc46 100644--- a/apps/cua-spaces-web/src/routeTree.gen.ts+++ b/apps/cua-spaces-web/src/routeTree.gen.ts@@ -15,6 +15,8 @@ import { Route as rootRouteImport } from './routes/__root'import { Route as IndexRouteImport } from './routes/index'import { Route as SettingsRouteRouteImport } from './routes/settings/route'import { Route as AgentsIndexRouteImport } from './routes/agents/index'+import { Route as HomeIndexRouteImport } from './routes/home/index'+import { Route as HomeTaskIdRouteImport } from './routes/home/$taskId'import { Route as KeyvaultIndexRouteImport } from './routes/keyvault/index'import { Route as MachinesIndexRouteImport } from './routes/machines/index'import { Route as NotificationsIndexRouteImport } from './routes/notifications/index'@@ -46,6 +48,16 @@ const AgentsIndexRoute = AgentsIndexRouteImport.update({path: '/agents/',getParentRoute: () => rootRouteImport,} as any)+const HomeIndexRoute = HomeIndexRouteImport.update({+ id: '/home/',+ path: '/home/',+ getParentRoute: () => rootRouteImport,+} as any)+const HomeTaskIdRoute = HomeTaskIdRouteImport.update({+ id: '/home/$taskId',+ path: '/home/$taskId',+ getParentRoute: () => rootRouteImport,+} as any)const KeyvaultIndexRoute = KeyvaultIndexRouteImport.update({id: '/keyvault/',path: '/keyvault/',@@ -125,6 +137,7 @@ const VolumeIndexRoute = VolumeIndexRouteImport.update({export interface FileRoutesByFullPath {'/': typeof IndexRoute'/settings': typeof SettingsRouteRouteWithChildren+ '/home/$taskId': typeof HomeTaskIdRoute'/settings/about': typeof SettingsAboutRoute'/settings/advanced': typeof SettingsAdvancedRoute'/settings/agents': typeof SettingsAgentsRoute@@ -134,6 +147,7 @@ export interface FileRoutesByFullPath {'/settings/general': typeof SettingsGeneralRoute'/spaces/$spaceId': typeof SpacesSpaceIdRoute'/agents/': typeof AgentsIndexRoute+ '/home/': typeof HomeIndexRoute'/keyvault/': typeof KeyvaultIndexRoute'/machines/': typeof MachinesIndexRoute'/notifications/': typeof NotificationsIndexRoute@@ -144,6 +158,7 @@ export interface FileRoutesByFullPath {}export interface FileRoutesByTo {'/': typeof IndexRoute+ '/home/$taskId': typeof HomeTaskIdRoute'/settings/about': typeof SettingsAboutRoute'/settings/advanced': typeof SettingsAdvancedRoute'/settings/agents': typeof SettingsAgentsRoute@@ -153,6 +168,7 @@ export interface FileRoutesByTo {'/settings/general': typeof SettingsGeneralRoute'/spaces/$spaceId': typeof SpacesSpaceIdRoute'/agents': typeof AgentsIndexRoute+ '/home': typeof HomeIndexRoute'/keyvault': typeof KeyvaultIndexRoute'/machines': typeof MachinesIndexRoute'/notifications': typeof NotificationsIndexRoute@@ -165,6 +181,7 @@ export interface FileRoutesById {__root__: typeof rootRouteImport'/': typeof IndexRoute'/settings': typeof SettingsRouteRouteWithChildren+ '/home/$taskId': typeof HomeTaskIdRoute'/settings/about': typeof SettingsAboutRoute'/settings/advanced': typeof SettingsAdvancedRoute'/settings/agents': typeof SettingsAgentsRoute@@ -174,6 +191,7 @@ export interface FileRoutesById {'/settings/general': typeof SettingsGeneralRoute'/spaces/$spaceId': typeof SpacesSpaceIdRoute'/agents/': typeof AgentsIndexRoute+ '/home/': typeof HomeIndexRoute'/keyvault/': typeof KeyvaultIndexRoute'/machines/': typeof MachinesIndexRoute'/notifications/': typeof NotificationsIndexRoute@@ -187,6 +205,7 @@ export interface FileRouteTypes {fullPaths:| '/'| '/settings'+ | '/home/$taskId'| '/settings/about'| '/settings/advanced'| '/settings/agents'@@ -196,6 +215,7 @@ export interface FileRouteTypes {| '/settings/general'| '/spaces/$spaceId'| '/agents/'+ | '/home/'| '/keyvault/'| '/machines/'| '/notifications/'@@ -206,6 +226,7 @@ export interface FileRouteTypes {fileRoutesByTo: FileRoutesByToto:| '/'+ | '/home/$taskId'| '/settings/about'| '/settings/advanced'| '/settings/agents'@@ -215,6 +236,7 @@ export interface FileRouteTypes {| '/settings/general'| '/spaces/$spaceId'| '/agents'+ | '/home'| '/keyvault'| '/machines'| '/notifications'@@ -226,6 +248,7 @@ export interface FileRouteTypes {| '__root__'| '/'| '/settings'+ | '/home/$taskId'| '/settings/about'| '/settings/advanced'| '/settings/agents'@@ -235,6 +258,7 @@ export interface FileRouteTypes {| '/settings/general'| '/spaces/$spaceId'| '/agents/'+ | '/home/'| '/keyvault/'| '/machines/'| '/notifications/'@@ -247,8 +271,10 @@ export interface FileRouteTypes {export interface RootRouteChildren {IndexRoute: typeof IndexRouteSettingsRouteRoute: typeof SettingsRouteRouteWithChildren+ HomeTaskIdRoute: typeof HomeTaskIdRouteSpacesSpaceIdRoute: typeof SpacesSpaceIdRouteAgentsIndexRoute: typeof AgentsIndexRoute+ HomeIndexRoute: typeof HomeIndexRouteKeyvaultIndexRoute: typeof KeyvaultIndexRouteMachinesIndexRoute: typeof MachinesIndexRouteNotificationsIndexRoute: typeof NotificationsIndexRoute@@ -280,6 +306,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AgentsIndexRouteImportparentRoute: typeof rootRouteImport}+ '/home/': {+ id: '/home/'+ path: '/home'+ fullPath: '/home/'+ preLoaderRoute: typeof HomeIndexRouteImport+ parentRoute: typeof rootRouteImport+ }+ '/home/$taskId': {+ id: '/home/$taskId'+ path: '/home/$taskId'+ fullPath: '/home/$taskId'+ preLoaderRoute: typeof HomeTaskIdRouteImport+ parentRoute: typeof rootRouteImport+ }'/keyvault/': {id: '/keyvault/'path: '/keyvault'@@ -417,8 +457,10 @@ const SettingsRouteRouteWithChildren = SettingsRouteRoute._addFileChildren(const rootRouteChildren: RootRouteChildren = {IndexRoute: IndexRoute,SettingsRouteRoute: SettingsRouteRouteWithChildren,+ HomeTaskIdRoute: HomeTaskIdRoute,SpacesSpaceIdRoute: SpacesSpaceIdRoute,AgentsIndexRoute: AgentsIndexRoute,+ HomeIndexRoute: HomeIndexRoute,KeyvaultIndexRoute: KeyvaultIndexRoute,MachinesIndexRoute: MachinesIndexRoute,NotificationsIndexRoute: NotificationsIndexRoute,diff --git a/apps/cua-spaces-web/src/routes/home/$taskId.tsx b/apps/cua-spaces-web/src/routes/home/$taskId.tsxnew file mode 100644index 0000000000..d3e80449a0--- /dev/null+++ b/apps/cua-spaces-web/src/routes/home/$taskId.tsx@@ -0,0 +1,20 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { createFileRoute, redirect } from "@tanstack/react-router";++import { flagOn } from "@/bridge";+import { AskFirstTask } from "@/components/ask-first/task-view";++/** One task's conversation on the "Ask first" Home (`spaces_ask_first_home`). */+export const Route = createFileRoute("/home/$taskId")({+ beforeLoad: () => {+ if (!flagOn("spaces_ask_first_home")) throw redirect({ to: "/spaces" });+ },+ component: TaskPage,+});++function TaskPage() {+ const { taskId } = Route.useParams();+ return <AskFirstTask taskId={taskId} />;+}diff --git a/apps/cua-spaces-web/src/routes/home/index.tsx b/apps/cua-spaces-web/src/routes/home/index.tsxnew file mode 100644index 0000000000..b717ecd80b--- /dev/null+++ b/apps/cua-spaces-web/src/routes/home/index.tsx@@ -0,0 +1,15 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { createFileRoute, redirect } from "@tanstack/react-router";++import { flagOn } from "@/bridge";+import { AskFirstHome } from "@/components/ask-first/home";++/** The "Ask first" Home, while its experiment flag (`spaces_ask_first_home`) is on; Spaces otherwise. */+export const Route = createFileRoute("/home/")({+ beforeLoad: () => {+ if (!flagOn("spaces_ask_first_home")) throw redirect({ to: "/spaces" });+ },+ component: AskFirstHome,+});diff --git a/apps/cua-spaces-web/src/routes/index.tsx b/apps/cua-spaces-web/src/routes/index.tsxindex 9366653fa2..93a71c6d6e 100644--- a/apps/cua-spaces-web/src/routes/index.tsx+++ b/apps/cua-spaces-web/src/routes/index.tsx@@ -3,8 +3,11 @@import { createFileRoute, redirect } from "@tanstack/react-router";+import { flagOn } from "@/bridge";+export const Route = createFileRoute("/")({beforeLoad: () => {- throw redirect({ to: "/spaces" });+ // The "Ask first" Home experiment opens on Home; otherwise Spaces, as before.+ throw redirect({ to: flagOn("spaces_ask_first_home") ? "/home" : "/spaces" });},});