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.

Spaces: Agents page shows what agents did (CUA-2314) (#5980)

cua-agents[bot]eed9f0279e90
diff --git a/apps/cua-spaces-web/src/__tests__/agents-page.test.tsx b/apps/cua-spaces-web/src/__tests__/agents-page.test.tsx
new file mode 100644
index 0000000000..f170047dc4
--- /dev/null
+++ b/apps/cua-spaces-web/src/__tests__/agents-page.test.tsx
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+// The Agents page: always-on agents under Running, recent runs with Watch or
+// Replay, a run that needs the person, and the empty page by what is true
+// on this computer.
+
+import { cleanup, fireEvent, waitFor, within } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+import { wasmBuilt } from "@/bridge/__tests__/testCore";
+import { mountApp, stubBrowserApis } from "./app-harness";
+
+afterEach(cleanup);
+stubBrowserApis();
+
+const section = (id: string) => document.querySelector<HTMLElement>(`[data-agents-section="${id}"]`);
+const noRuns = (op: string) => (op === "agents.list" || op === "agents.runs" ? [] : undefined);
+const host = { failsCreates: false, listsGhost: false } as const;
+
+describe.skipIf(!wasmBuilt)("Agents page", () => {
+ it("shows always-on agents under Running and the runs below, without a Connect button", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", host);
+ await waitFor(() => expect(section("running")).not.toBeNull(), { timeout: 8000 });
+ expect(within(section("running")!).getByText("ada")).toBeTruthy();
+ expect(document.querySelector("[data-agent-view]")).toBeNull();
+ expect(section("running")!.compareDocumentPosition(section("runs")!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(document.body.textContent).not.toContain("Connect an agent");
+ expect(document.querySelector("[data-connected-apps-link]")).not.toBeNull();
+ const buttons = [...section("runs")!.querySelectorAll("[data-run-open]")].map((b) => b.textContent);
+ expect(buttons).toContain("Watch");
+ expect(buttons).toContain("Replay");
+ });
+
+ it("offers Open Space for a run that needs you, in its own section", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", host);
+ await waitFor(() => expect(section("waiting")).not.toBeNull(), { timeout: 8000 });
+ expect(within(section("waiting")!).getByText("OpenClaw needs you to sign in to GitHub")).toBeTruthy();
+ expect(within(section("waiting")!).getByRole("button", { name: "Open Space" })).toBeTruthy();
+ // No reply to a waiting agent from the app yet: nothing else to press.
+ expect(within(section("waiting")!).getAllByRole("button")).toHaveLength(1);
+ });
+
+ it("opens a run and goes back to the overview", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", host);
+ await waitFor(() => expect(section("runs")).not.toBeNull(), { timeout: 8000 });
+ fireEvent.click(section("runs")!.querySelector("[data-run-open]")!);
+ await waitFor(() => expect(document.querySelector("[data-agent-view]")).not.toBeNull());
+ fireEvent.click(document.querySelector("[data-agents-back]")!);
+ await waitFor(() => expect(section("runs")).not.toBeNull());
+ });
+
+ it("asks to set up once in place when coding apps are found but Cua is not in them", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", { ...host, intercept: noRuns, demo: { agents: "unset" } });
+ await waitFor(() => expect(document.querySelector("[data-agents-empty]")).not.toBeNull(), { timeout: 8000 });
+ await waitFor(() => expect(document.querySelector("[data-agents-empty]")?.getAttribute("data-agents-empty")).toBe("setup"), { timeout: 8000 });
+ const setup = await waitFor(() => {
+ const b = document.querySelector("[data-agents-setup]");
+ expect(b).not.toBeNull();
+ return b!;
+ }, { timeout: 8000 });
+ fireEvent.click(setup);
+ await waitFor(() => expect(document.querySelector("[data-agents-empty]")?.getAttribute("data-agents-empty")).toBe("ready"), { timeout: 8000 });
+ });
+
+ it("teaches the first prompts when Cua is already in the apps", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", { ...host, intercept: noRuns });
+ await waitFor(() => expect(document.querySelector('[data-agents-empty="ready"]')).not.toBeNull(), { timeout: 8000 });
+ expect(document.querySelectorAll("[data-agent-prompt]")).toHaveLength(3);
+ });
+
+ it("says no coding app was found", { timeout: 20_000 }, async () => {
+ await mountApp("/agents", { ...host, intercept: noRuns, demo: { agents: "none" } });
+ await waitFor(() => expect(document.querySelector('[data-agents-empty="none"]')).not.toBeNull(), { timeout: 8000 });
+ expect(document.querySelectorAll("[data-agent-prompt]")).toHaveLength(0);
+ });
+});
diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo-agents.ts b/apps/cua-spaces-web/src/bridge/adapters/demo-agents.ts
index e41cd9e907..8e3b1ec9ea 100644
--- a/apps/cua-spaces-web/src/bridge/adapters/demo-agents.ts
+++ b/apps/cua-spaces-web/src/bridge/adapters/demo-agents.ts
@@ -290,7 +290,7 @@ export function demoRunRecords(t0: number): DemoRunRecord[] {
),
finished(
"relay:mac-mini/qa-windows",
- { runId: "run-claw-4", agent: "openclaw", status: "idle", reason: "waiting for a follow-up", summary: "Install the 0.6.1 Windows build and note what breaks", createdAt: Math.floor((t0 - 3 * 60 * MIN) / 1000) },
+ { runId: "run-claw-4", agent: "openclaw", status: "idle", reason: "waiting for a follow-up", summary: "Install the 0.6.1 Windows build and note what breaks", needsYou: { title: "OpenClaw needs you to sign in to GitHub", detail: "It is checking the installer in qa-windows and can't go on until you sign in." }, createdAt: Math.floor((t0 - 3 * 60 * MIN) / 1000) },
installer,
),
];
diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo.ts b/apps/cua-spaces-web/src/bridge/adapters/demo.ts
index c7d900db0b..4ea2c49eb7 100644
--- a/apps/cua-spaces-web/src/bridge/adapters/demo.ts
+++ b/apps/cua-spaces-web/src/bridge/adapters/demo.ts
@@ -85,8 +85,8 @@ export interface DemoOptions {
/** The relay allowance: `idle` (free, no live session, so prompts can show),
* `warn` (80% of the hours), `limit` (used up), `pro` or `teams`. */
usage?: "idle" | "warn" | "limit" | "pro" | "teams";
- /** Which agents are on this computer (`?demo=agents-none`, `?demo=agents-codex`); all of them by default. */
- agents?: "none" | "codex";
+ /** Which agents are on this computer (`?demo=agents-none`, `?demo=agents-codex`); all of them by default. `unset`: all found, none set up for Cua yet, without the first-run onboarding. */
+ agents?: "none" | "codex" | "unset";
/** This Mac's free disk: `low` (`?demo=low-disk`) or `full` (`?demo=disk-full`). */
disk?: "low" | "full";
/** The machine the demo runs on: a Mac on Apple silicon unless set (the
@@ -193,7 +193,7 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { re
agents: demoPersistentAgents(now()),
// A named allowance is for showing the prompts, which wait for no agent run.
runs: options.usage ? [] : demoRunRecords(now()),
- agentSetup: demoAgentSetup(options.onboarded === false, options.agents === "none" ? [] : options.agents === "codex" ? ["codex"] : null),
+ agentSetup: demoAgentSetup(options.onboarded === false || options.agents === "unset", options.agents === "none" ? [] : options.agents === "codex" ? ["codex"] : null),
platform: options.platform ?? MAC_DEMO_PLATFORM,
paired: [],
renamed: {},
diff --git a/apps/cua-spaces-web/src/bridge/contracts/agents.ts b/apps/cua-spaces-web/src/bridge/contracts/agents.ts
index 95305d4640..7c023c06cb 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/agents.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/agents.ts
@@ -49,6 +49,8 @@ export interface SpaceAgentRun {
/** Finer phase (`thinking`, `tool`, `waiting`, ...). */
phase: string;
turn: number;
+ /** The run is blocked until the person acts (a sign-in, an approval). A host that cannot tell leaves it out. */
+ needsYou?: { title: string; detail: string } | null;
}
/** How a conversation view shows an event (`cua_agents::events::CATEGORIES`). */
diff --git a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
index 360e051d1b..2230f6dfaa 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
+++ b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
@@ -5305,6 +5305,24 @@
},
"turn": {
"type": "number"
+ },
+ "needsYou": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "properties": {
+ "title": {
+ "type": "string"
+ },
+ "detail": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "title",
+ "detail"
+ ]
}
},
"required": [
@@ -7057,6 +7075,24 @@
},
"turn": {
"type": "number"
+ },
+ "needsYou": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "properties": {
+ "title": {
+ "type": "string"
+ },
+ "detail": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "title",
+ "detail"
+ ]
}
},
"required": [
diff --git a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
index 64bd58ff32..ab9a17ef56 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
@@ -909,6 +909,7 @@ export const OP_SHAPES: Record<OpName, Schema> = {
createdAt: nullable(num),
phase: str,
turn: num,
+ needsYou: optNull(obj<{ title: string; detail: string }>()({ title: str, detail: str })),
}),
),
"agents.events": obj<AgentEventsPage>()({
diff --git a/apps/cua-spaces-web/src/components/agents/agents-empty.tsx b/apps/cua-spaces-web/src/components/agents/agents-empty.tsx
new file mode 100644
index 0000000000..305562ff77
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/agents/agents-empty.tsx
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { useNavigate } from "@tanstack/react-router";
+import { CheckIcon, CopyIcon } from "lucide-react";
+import { useEffect, useState } from "react";
+
+import { useAgents, type AgentSetupRow } from "@/bridge";
+import { Button } from "@/components/ui/button";
+import { toastError } from "@/components/ui/toast";
+
+const MAIN_PROMPT = "Reproduce the crash from issue #4821 on a fresh Windows 11 Space and show me a recording.";
+const MORE_PROMPTS = ["Run our tests on Ubuntu and macOS at the same time and tell me which ones fail.", "Check that the installer works on a clean Windows machine."];
+
+/** "Claude Code, Codex and Cursor". */
+export function nameList(names: string[]): string {
+ if (names.length <= 1) return names[0] ?? "";
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
+}
+
+/**
+ * The Agents page before any run. It says what to do next, by what is true
+ * on this computer: coding apps found but Cua not in them yet (one Set up
+ * button, asked once, in place); Cua already in them (the first prompts to
+ * try); or no coding app found.
+ */
+export function AgentsEmpty() {
+ const { agentSetup, configureAgents } = useAgents();
+ const navigate = useNavigate();
+ const [rows, setRows] = useState<AgentSetupRow[] | null>(null);
+ const [busy, setBusy] = useState(false);
+
+ useEffect(() => {
+ let live = true;
+ agentSetup().then(
+ (r) => live && setRows(r),
+ () => live && setRows([]),
+ );
+ return () => {
+ live = false;
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- once per showing
+ }, []);
+
+ if (rows === null) return <div className="min-h-64" />;
+ const installed = rows.filter((r) => r.installed);
+ const ready = installed.filter((r) => r.configured);
+ const todo = installed.filter((r) => !r.configured);
+ const state = installed.length === 0 ? "none" : ready.length === 0 ? "setup" : "ready";
+
+ const setUp = () => {
+ setBusy(true);
+ configureAgents(todo.map((r) => r.agent))
+ .then(setRows)
+ .catch(toastError("Couldn't set up your apps"))
+ .finally(() => setBusy(false));
+ };
+
+ return (
+ <div className="mx-auto flex w-full max-w-xl flex-col items-center pt-8 text-center" data-agents-empty={state}>
+ <img src="/cua-key-128.png" alt="" className="size-24" />
+ <h2 className="mt-6 text-[22px] font-semibold tracking-[-0.01em]">
+ {state === "ready" ? "Ask an agent to work in a Space" : state === "setup" ? "Your agents can't use Cua yet" : "No coding app found yet"}
+ </h2>
+ <p className="mt-3 text-[15px] leading-relaxed text-muted-foreground">
+ {state === "ready"
+ ? "Open Claude Code, Codex or Cursor and ask it for something that needs a clean computer. It makes the Space, works in it and shows you the result here."
+ : state === "setup"
+ ? `${nameList(todo.map((r) => r.name))} ${todo.length === 1 ? "is" : "are"} on this Mac. Let ${todo.length === 1 ? "it" : "them"} use Cua, then ask one to work in a Space.`
+ : "Install Claude Code, Codex or Cursor and Cua will notice. Spaces work without one."}
+ </p>
+ {state === "setup" ? (
+ <Button size="lg" className="mt-6" disabled={busy} onClick={setUp} data-agents-setup>
+ {busy ? "Setting up…" : "Set up"}
+ </Button>
+ ) : null}
+ {state !== "none" ? (
+ <>
+ <div className="mt-8 w-full">
+ {state === "setup" ? <p className="mb-3 text-[13px] text-muted-foreground">Then try</p> : null}
+ <CopyPrompt text={MAIN_PROMPT} large={state === "ready"} />
+ </div>
+ {state === "ready" ? (
+ <div className="mt-6 flex w-full flex-col gap-3">
+ <p className="text-[13px] text-muted-foreground">Or try</p>
+ {MORE_PROMPTS.map((p) => (
+ <CopyPrompt key={p} text={p} />
+ ))}
+ </div>
+ ) : null}
+ <p className="mt-8 max-w-sm text-[13px] text-muted-foreground">
+ {state === "ready" ? (
+ <>
+ {nameList(ready.map((r) => r.name))} can use Cua.{" "}
+ <button type="button" className="text-brand-strong hover:underline" onClick={() => void navigate({ to: "/settings/connected-apps" as "/settings" })}>
+ Manage
+ </button>
+ </>
+ ) : (
+ "Cua adds itself to each app's settings and leaves the rest alone. You can turn it off in Settings."
+ )}
+ </p>
+ </>
+ ) : null}
+ </div>
+ );
+}
+
+function CopyPrompt({ text, large }: { text: string; large?: boolean }) {
+ const [copied, setCopied] = useState(false);
+ return (
+ <div data-agent-prompt="" className="flex min-h-12 items-center gap-3 rounded-xl border bg-card px-4 py-3 text-left shadow-xs">
+ <p className={large ? "min-w-0 flex-1 text-[15px] leading-relaxed" : "min-w-0 flex-1 text-[13px] text-muted-foreground"}>{text}</p>
+ <Button
+ size="icon"
+ variant="ghost"
+ aria-label={copied ? "Copied" : "Copy this prompt"}
+ onClick={() => {
+ void navigator.clipboard?.writeText(text).then(() => {
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ });
+ }}
+ >
+ {copied ? <CheckIcon /> : <CopyIcon />}
+ </Button>
+ </div>
+ );
+}
diff --git a/apps/cua-spaces-web/src/components/agents/harness-mark.tsx b/apps/cua-spaces-web/src/components/agents/harness-mark.tsx
new file mode 100644
index 0000000000..4a3537dc21
--- /dev/null
+++ b/apps/cua-spaces-web/src/components/agents/harness-mark.tsx
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { cn } from "@/lib/utils";
+
+/** The marks the app already ships for the apps it has them for. Others get their first letter. */
+const MARKS: Record<string, string> = {
+ "claude-code": "/onboarding/marks/mark-claude.svg",
+ codex: "/onboarding/marks/mark-openai.svg",
+ "openai-codex": "/onboarding/marks/mark-openai.svg",
+ hermes: "/onboarding/marks/mark-hermes.svg",
+ openclaw: "/onboarding/marks/mark-openclaw.svg",
+};
+
+/** A coding app's logo in a small tile; a neutral initial tile when there is no logo. */
+export function HarnessMark({ agent, name, large }: { agent: string; name: string; large?: boolean }) {
+ const src = MARKS[agent];
+ return (
+ <span
+ className={cn(
+ "flex shrink-0 items-center justify-center rounded-lg border bg-background font-semibold text-muted-foreground",
+ large ? "size-10 text-[14px]" : "size-8 text-xs",
+ )}
+ data-harness-mark={agent}
+ aria-hidden
+ >
+ {src ? <img src={src} alt="" className={large ? "size-6" : "size-5"} /> : name.trim().charAt(0).toUpperCase() || "?"}
+ </span>
+ );
+}
diff --git a/apps/cua-spaces-web/src/lib/agents.ts b/apps/cua-spaces-web/src/lib/agents.ts
index f97fc395fb..959323bb45 100644
--- a/apps/cua-spaces-web/src/lib/agents.ts
+++ b/apps/cua-spaces-web/src/lib/agents.ts
@@ -36,6 +36,9 @@ export function spaceLabel(name: string): string {
return tail || name;
}
+/** A run that is blocked on the person (the host says so with `needsYou`). */
+export const isWaiting = (r: AgentRunSummary): boolean => Boolean(r.needsYou) && r.status !== "failed" && r.status !== "crashed";
+
export const monogram = (harnessName: string) => harnessName.trim().charAt(0).toUpperCase() || "?";
/** What the URL selects: a persistent agent by name, or a run by Space and id. */
diff --git a/apps/cua-spaces-web/src/routes/agents/index.tsx b/apps/cua-spaces-web/src/routes/agents/index.tsx
index a81d146125..1b75450f70 100644
--- a/apps/cua-spaces-web/src/routes/agents/index.tsx
+++ b/apps/cua-spaces-web/src/routes/agents/index.tsx
@@ -2,7 +2,7 @@
// Copyright (c) 2026 Cua AI, Inc.
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
-import { BotIcon, KeyRoundIcon, PlugIcon } from "lucide-react";
+import { ArrowLeftIcon, BotIcon, KeyRoundIcon, SettingsIcon } from "lucide-react";
import { useEffect, useState } from "react";
import {
@@ -19,7 +19,8 @@ import {
type AgentTimeline,
} from "@/bridge";
import { AgentPanel } from "@/components/agents/agent-panels";
-import { ConnectAgentDialog } from "@/components/agents/connect-dialog";
+import { AgentsEmpty } from "@/components/agents/agents-empty";
+import { HarnessMark } from "@/components/agents/harness-mark";
import { Timeline } from "@/components/agents/timeline";
import { EmptyState, PageHeader } from "@/components/page";
import { Button } from "@/components/ui/button";
@@ -28,10 +29,9 @@ import {
AGENT_STATE_LABEL,
RUN_STATUS_LABEL,
agentTone,
- monogram,
+ isWaiting,
resolveSelection,
runTone,
- shortAge,
spaceLabel,
type AgentsSelection,
type Tone,
@@ -67,160 +67,211 @@ function useNow(ms = 30_000): number {
return now;
}
+/** Settings, Connected apps: where Cua is switched on for each coding app. */
+function ConnectedAppsLink() {
+ const navigate = useNavigate();
+ return (
+ <Button variant="outline" onClick={() => void navigate({ to: "/settings/connected-apps" as "/settings" })} data-connected-apps-link>
+ <SettingsIcon /> Connected apps
+ </Button>
+ );
+}
+
function AgentsPage() {
const search = Route.useSearch();
const navigate = useNavigate({ from: "/agents/" });
const { data, isLoading, error } = useAgents();
useFeatureRecorded("agents_page_open");
- const [connectOpen, setConnectOpen] = useState(false);
+ // The page opens on the overview; a run or an agent opens its own view.
+ const opened = Boolean(search.agent || (search.run && search.space));
const selected = resolveSelection(data, search);
- const select = (next: AgentsSelection) => void navigate({ search: next, replace: true });
+ const select = (next: AgentsSelection) => void navigate({ search: next, replace: false });
const empty = data !== undefined && data.agents.length === 0 && data.runs.length === 0;
+ const detail = opened && (selected.ref || selected.agent);
return (
- <div className="flex h-full flex-col">
- <div className="px-8 pt-6">
- <PageHeader
- title="Agents"
- description="Persistent agents and the runs in your Spaces."
- actions={
- <Button variant="outline" onClick={() => setConnectOpen(true)}>
- <PlugIcon /> Connect an agent
+ <div className="h-full overflow-y-auto [scrollbar-gutter:stable]">
+ <div className="mx-auto flex min-h-full w-full max-w-5xl flex-col px-8 pt-8 pb-16">
+ {detail ? (
+ <div className="flex min-h-0 flex-1 flex-col" data-agent-view>
+ <Button variant="ghost" size="sm" className="mb-4 -ml-2 self-start" onClick={() => select({})} data-agents-back>
+ <ArrowLeftIcon /> Agents
</Button>
- }
- />
- </div>
- <div className="min-h-0 flex-1 px-8 pb-6">
- {error ? (
- <EmptyState
- icon={<BotIcon />}
- title={isUnsupported(error) ? "Agents aren't available here yet" : "Couldn't load agents"}
- action={
- <div className="flex gap-2">
- <Button variant="outline" onClick={() => setConnectOpen(true)}>
- Connect an agent
- </Button>
- <AgentKeysLink />
- </div>
- }
- >
- {isUnsupported(error) ? "This version of the app can't list agents. The Cua Spaces app on macOS shows them in its own window." : error.message}
- </EmptyState>
- ) : isLoading && !data ? null : empty ? (
- <EmptyState
- icon={<BotIcon />}
- title="No agents yet"
- action={
- <div className="flex gap-2">
- <Button variant="outline" onClick={() => setConnectOpen(true)}>
- <PlugIcon /> Connect an agent
- </Button>
- <AgentKeysLink />
- </div>
- }
- >
- Connect a coding agent to Cua, then ask it to work in a Space. Its runs and persistent agents show up here. Agents need a provider key to run: add one in Settings → Agents.
- </EmptyState>
- ) : data ? (
- <div className="flex h-full overflow-hidden rounded-xl border bg-card shadow-xs">
- <AgentList data={data} selected={selected} onSelect={select} />
- <div className="flex min-w-0 flex-1 flex-col border-l bg-background">
- {selected.ref || selected.agent ? (
- <AgentDetail
- key={selected.ref ? `${selected.ref.spaceId}/${selected.ref.runId}` : selected.agent?.name}
- agent={selected.agent}
- run={selected.run}
- runRef={selected.ref}
- />
- ) : null}
+ <div className="flex min-h-[28rem] flex-1 flex-col overflow-hidden rounded-xl border bg-card shadow-xs">
+ <AgentDetail
+ key={selected.ref ? `${selected.ref.spaceId}/${selected.ref.runId}` : selected.agent?.name}
+ agent={selected.agent}
+ run={selected.run}
+ runRef={selected.ref}
+ />
</div>
</div>
- ) : null}
+ ) : (
+ <>
+ <PageHeader title="Agents" description="What your agents have done in your Spaces." actions={<ConnectedAppsLink />} />
+ {error ? (
+ <EmptyState
+ icon={<BotIcon />}
+ title={isUnsupported(error) ? "Agents aren't available here yet" : "Couldn't load agents"}
+ action={<AgentKeysLink />}
+ >
+ {isUnsupported(error) ? "This version of the app can't list agents. The Cua Spaces app on macOS shows them in its own window." : error.message}
+ </EmptyState>
+ ) : isLoading && !data ? null : empty ? (
+ <AgentsEmpty />
+ ) : data ? (
+ <Overview data={data} onSelect={select} />
+ ) : null}
+ </>
+ )}
</div>
- <ConnectAgentDialog open={connectOpen} onOpenChange={setConnectOpen} />
</div>
);
}
-/* ---- The list -------------------------------------------------------------- */
+/* ---- The overview ---------------------------------------------------------- */
-function AgentList({
- data,
- selected,
- onSelect,
-}: {
- data: AgentsData;
- selected: ReturnType<typeof resolveSelection>;
- onSelect: (s: AgentsSelection) => void;
-}) {
+function Overview({ data, onSelect }: { data: AgentsData; onSelect: (s: AgentsSelection) => void }) {
const now = useNow();
- const isRunSelected = (r: AgentRunSummary) => !selected.agent && selected.ref?.spaceId === r.spaceId && selected.ref.runId === r.runId;
+ const navigate = useNavigate();
+ const waiting = data.runs.filter(isWaiting);
+ const openSpace = (spaceId: string) => void navigate({ to: "/spaces/$spaceId", params: { spaceId } });
return (
- <nav aria-label="Agents and runs" className="flex w-[320px] shrink-0 flex-col overflow-y-auto py-2">
- {data.canList ? (
- <Section title="Persistent agents" count={data.agents.length}>
- {data.agents.length === 0 ? (
- <p className="px-4 py-2 text-xs text-muted-foreground">None yet. Ask an agent to create one, or run cua agent create.</p>
- ) : (
- data.agents.map((a) => (
- <ListRow
- key={a.name}
- selected={selected.agent?.name === a.name}
- onClick={() => onSelect({ agent: a.name })}
- agent={a.name}
- mark={monogram(a.harnessName)}
- title={a.name}
- subtitle={a.detail}
- tone={agentTone(a.state)}
- state={AGENT_STATE_LABEL[a.state]}
- age={a.state === "running" ? "now" : shortAge(a.lastActivityMs, now)}
- ageTitle={a.lastActivityMs ? `Last saved ${relativeTime(a.lastActivityMs, now)}` : undefined}
- />
- ))
- )}
- </Section>
- ) : null}
- <Section title="Recent runs" count={data.runs.length}>
- {data.runs.length === 0 ? (
- <p className="px-4 py-2 text-xs text-muted-foreground">No runs in your running Spaces.</p>
- ) : (
- data.runs.map((r) => (
- <ListRow
+ <div className="flex flex-col gap-8">
+ {waiting.length > 0 ? (
+ <Block title="Waiting for you" count={waiting.length} id="waiting">
+ {waiting.map((r) => (
+ <div
key={`${r.spaceId}/${r.runId}`}
- selected={isRunSelected(r)}
- onClick={() => onSelect({ space: r.spaceId, run: r.runId })}
- mark={monogram(r.harnessName)}
- title={r.summary || r.harnessName}
- subtitle={`${r.agentName ? `${r.agentName}, ` : ""}${r.harnessName} in ${spaceLabel(r.spaceName)}`}
- tone={runTone(r.status)}
- state={RUN_STATUS_LABEL[r.status]}
- age={shortAge(r.startedMs, now)}
- ageTitle={r.startedMs ? `Started ${relativeTime(r.startedMs, now)}` : undefined}
- />
- ))
- )}
- </Section>
+ data-waiting-run={r.runId}
+ className="flex min-h-12 items-center gap-3 border-l-2 border-l-warning px-4 py-3"
+ >
+ <HarnessMark agent={r.agent} name={r.harnessName} />
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-[14px] font-medium">{r.needsYou!.title}</div>
+ <div className="truncate text-[13px] text-muted-foreground">{r.needsYou!.detail}</div>
+ </div>
+ <Button onClick={() => openSpace(r.spaceId)} data-waiting-open>
+ Open Space
+ </Button>
+ </div>
+ ))}
+ </Block>
+ ) : null}
+
+ {data.canList && data.agents.length > 0 ? (
+ <Block title="Running" count={data.agents.length} id="running">
+ {data.agents.map((a) => (
+ <button
+ key={a.name}
+ type="button"
+ data-agent-row={a.name}
+ onClick={() => onSelect({ agent: a.name })}
+ className="flex min-h-12 w-full cursor-default items-center gap-3 px-4 py-3 text-left outline-none transition-colors hover:bg-foreground/[0.04] focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset"
+ >
+ <HarnessMark agent={a.harness} name={a.harnessName} />
+ <span className="min-w-0 flex-1">
+ <span data-row-title className="block truncate text-[14px] font-medium">
+ {a.name}
+ </span>
+ <span data-row-detail className="block truncate text-[13px] text-muted-foreground">
+ {a.detail}
+ </span>
+ </span>
+ <span data-row-state className="inline-flex shrink-0 items-center gap-1.5 text-[13px] text-muted-foreground">
+ <StatusDot tone={agentTone(a.state)} />
+ {AGENT_STATE_LABEL[a.state]}
+ </span>
+ <span className="w-24 shrink-0 text-right text-[13px] text-muted-foreground" title={a.lastActivityMs ? `Last saved ${relativeTime(a.lastActivityMs, now)}` : undefined}>
+ {a.state === "running" ? "Now" : a.lastActivityMs ? relativeTime(a.lastActivityMs, now) : ""}
+ </span>
+ </button>
+ ))}
+ </Block>
+ ) : null}
+
+ <Block title="Recent runs" count={data.runs.length} id="runs" empty={data.runs.length === 0 ? "No runs yet in your running Spaces." : null}>
+ {data.runs.length > 0 ? (
+ <div role="table" aria-label="Recent runs">
+ <div role="row" className="grid min-h-12 grid-cols-[minmax(0,3fr)_minmax(0,2fr)_8rem_7rem_6rem] items-center gap-4 px-4 text-[13px] text-muted-foreground">
+ <span role="columnheader">What it did</span>
+ <span role="columnheader">Space</span>
+ <span role="columnheader">Status</span>
+ <span role="columnheader">Started</span>
+ <span role="columnheader" />
+ </div>
+ {data.runs.map((r) => {
+ const live = r.status === "running";
+ const needs = isWaiting(r);
+ return (
+ <div
+ key={`${r.spaceId}/${r.runId}`}
+ role="row"
+ data-run-row={r.runId}
+ className="grid min-h-12 grid-cols-[minmax(0,3fr)_minmax(0,2fr)_8rem_7rem_6rem] items-center gap-4 border-t px-4 py-2"
+ >
+ <div role="cell" className="flex min-w-0 items-center gap-3">
+ <HarnessMark agent={r.agent} name={r.harnessName} />
+ <span className="min-w-0">
+ <span data-row-title className="block truncate text-[14px] font-medium">
+ {r.summary || r.harnessName}
+ </span>
+ <span data-row-detail className="block truncate text-[13px] text-muted-foreground">
+ {r.agentName ? `${r.agentName}, ${r.harnessName}` : r.harnessName}
+ </span>
+ </span>
+ </div>
+ <div role="cell" className="min-w-0 truncate text-[13px]">
+ {spaceLabel(r.spaceName)}
+ </div>
+ <div role="cell" data-row-state className="inline-flex items-center gap-1.5 text-[13px]">
+ <StatusDot tone={needs ? "paused" : runTone(r.status)} />
+ {needs ? "Needs you" : RUN_STATUS_LABEL[r.status]}
+ </div>
+ <div role="cell" className="text-[13px] text-muted-foreground" title={r.startedMs ? relativeTime(r.startedMs, now) : undefined}>
+ {live ? "Now" : r.startedMs ? relativeTime(r.startedMs, now) : ""}
+ </div>
+ <div role="cell" className="flex justify-end">
+ {needs ? (
+ <Button size="sm" onClick={() => openSpace(r.spaceId)}>
+ Open Space
+ </Button>
+ ) : (
+ <Button size="sm" variant="outline" data-run-open onClick={() => onSelect({ space: r.spaceId, run: r.runId })}>
+ {live ? "Watch" : "Replay"}
+ </Button>
+ )}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ ) : null}
+ </Block>
{data.unread.length ? (
- <div className="mt-auto space-y-1 border-t px-4 pt-3 pb-1">
+ <div className="space-y-1">
{data.unread.map((u) => (
- <p key={u.spaceId} className="text-2xs text-muted-foreground">
+ <p key={u.spaceId} className="text-xs text-muted-foreground">
Couldn't read runs in {spaceLabel(u.spaceName)}: {u.message}
</p>
))}
</div>
) : null}
- </nav>
+ </div>
);
}
-function Section({ title, count, children }: { title: string; count: number; children: React.ReactNode }) {
+/** A titled card: 32px between blocks, rows of at least 48px inside. */
+function Block({ title, count, id, children, empty }: { title: string; count: number; id: string; children?: React.ReactNode; empty?: string | null }) {
return (
- <section className="mb-2">
- <h2 className="flex h-8 items-center gap-2 px-4 text-xs font-semibold text-muted-foreground">
+ <section data-agents-section={id}>
+ <h2 className="mb-3 flex items-center gap-2 text-[15px] font-semibold">
{title}
- <span className="font-normal tabular-nums text-muted-foreground/70">{count}</span>
+ <span className="text-[13px] font-normal tabular-nums text-muted-foreground">{count}</span>
</h2>
- <ul className="space-y-px px-2">{children}</ul>
+ <div className="divide-y overflow-hidden rounded-xl border bg-card shadow-xs">
+ {empty ? <p className="px-4 py-3 text-[13px] text-muted-foreground">{empty}</p> : children}
+ </div>
</section>
);
}
@@ -240,70 +291,6 @@ function StatusDot({ tone, className }: { tone: Tone; className?: string }) {
);
}
-function ListRow(props: {
- /** A persistent agent's row (the parity harness reads it). */
- agent?: string;
- selected: boolean;
- onClick: () => void;
- mark: string;
- title: string;
- subtitle: string;
- tone: Tone;
- state: string;
- age: string;
- ageTitle?: string;
-}) {
- return (
- <li>
- <button
- type="button"
- aria-current={props.selected ? "true" : undefined}
- data-agent-row={props.agent}
- onClick={props.onClick}
- className={cn(
- "flex w-full cursor-default items-start gap-2.5 rounded-lg px-2 py-2 text-left outline-none transition-colors hover:bg-foreground/[0.04] focus-visible:ring-2 focus-visible:ring-ring/60",
- props.selected && "bg-foreground/[0.06] hover:bg-foreground/[0.06] dark:bg-white/[0.07]",
- )}
- >
- <HarnessMark mark={props.mark} />
- <span className="min-w-0 flex-1">
- <span className="flex items-baseline gap-2">
- <span data-row-title className="min-w-0 flex-1 truncate text-[13px] font-medium">
- {props.title}
- </span>
- <span className="shrink-0 text-2xs tabular-nums text-muted-foreground" title={props.ageTitle}>
- {props.age}
- </span>
- </span>
- <span className="mt-0.5 flex items-center gap-2">
- <span data-row-detail className="min-w-0 flex-1 truncate text-xs text-muted-foreground">
- {props.subtitle}
- </span>
- <span data-row-state className="inline-flex shrink-0 items-center gap-1.5 text-2xs text-muted-foreground">
- <StatusDot tone={props.tone} />
- {props.state}
- </span>
- </span>
- </span>
- </button>
- </li>
- );
-}
-
-function HarnessMark({ mark, large }: { mark: string; large?: boolean }) {
- return (
- <span
- className={cn(
- "flex shrink-0 items-center justify-center rounded-md border bg-background font-semibold text-muted-foreground",
- large ? "size-8 text-[13px]" : "mt-px size-6 text-2xs",
- )}
- aria-hidden
- >
- {mark}
- </span>
- );
-}
-
/* ---- The detail ------------------------------------------------------------- */
function AgentDetail({ agent, run, runRef }: { agent: AgentSummary | null; run: AgentRunSummary | null; runRef: { spaceId: string; runId: string } | null }) {
@@ -341,7 +328,7 @@ function AgentDetail({ agent, run, runRef }: { agent: AgentSummary | null; run:
return (
<>
<header className="flex items-center gap-3 border-b bg-card px-5 py-3">
- <HarnessMark mark={monogram(harness)} large />
+ <HarnessMark agent={agent?.harness ?? run?.agent ?? ""} name={harness} large />
<div className="min-w-0 flex-1">
<h2 className="truncate text-[14px] font-semibold">{title}</h2>
<p className="truncate text-xs text-muted-foreground" title={subtitle}>