An open-source, faster Devin alternative
TypeScript
feat(web): Agents + Sessions screens, grouped sidebar (/v3 first cut)
Igor Zalutskicdacb00ea70c
diff --git a/web/src/App.tsx b/web/src/App.tsxindex 05369638..866cd8a2 100644--- a/web/src/App.tsx+++ b/web/src/App.tsx@@ -1,5 +1,5 @@import { lazy } from 'react'-import { Routes, Route, Navigate, useParams } from 'react-router-dom'+import { Routes, Route, Navigate } from 'react-router-dom'import { AuthProvider } from './hooks/auth-provider'import ProtectedRoute from './components/ProtectedRoute'import AppShell from './components/app-shell'@@ -7,6 +7,8 @@ import AppShell from './components/app-shell'// Route pages are code-split so the initial bundle stays small; the heaviest// deps (xterm, in Terminal/LogsPanel) only load on SandboxDetail when opened.const Dashboard = lazy(() => import('./pages/Dashboard'))+const Agents = lazy(() => import('./pages/Agents'))+const Sessions = lazy(() => import('./pages/Sessions'))const Sandboxes = lazy(() => import('./pages/Sandboxes'))const APIKeys = lazy(() => import('./pages/APIKeys'))const Checkpoints = lazy(() => import('./pages/Checkpoints'))@@ -22,18 +24,12 @@ export default function App() {<Route element={<ProtectedRoute />}><Route element={<AppShell />}><Route index element={<Dashboard />} />+ {/* Agent plane */}+ <Route path="agents" element={<Agents />} />+ <Route path="sessions" element={<Sessions />} />+ {/* Sandbox plane */}<Route path="sandboxes" element={<Sandboxes />} /><Route path="sandboxes/:sandboxId" element={<SandboxDetail />} />- {/* Back-compat: the tab was renamed Sandboxes → Sandboxes. Keep the- old deep links working, including /sessions/:sandboxId. */}- <Route- path="sessions"- element={<Navigate to="/sandboxes" replace />}- />- <Route- path="sessions/:sandboxId"- element={<LegacySandboxRedirect />}- /><Route path="checkpoints" element={<Checkpoints />} /><Route path="templates" element={<Templates />} /><Route path="api-keys" element={<APIKeys />} />@@ -46,9 +42,3 @@ export default function App() {</AuthProvider>)}--// Preserves the :sandboxId when redirecting the old /sessions/:id deep link.-function LegacySandboxRedirect() {- const { sandboxId } = useParams()- return <Navigate to={`/sandboxes/${sandboxId ?? ''}`} replace />-}diff --git a/web/src/api/client.ts b/web/src/api/client.tsindex 22e25e44..75c32f0e 100644--- a/web/src/api/client.ts+++ b/web/src/api/client.ts@@ -25,6 +25,12 @@ export type {StripeInvoice,SandboxUsageRow,SandboxUsage,+ Agent,+ Session,+ SessionEvent,+ Turn,+ Destination,+ Delivery,} from './schemas'const API_BASE = '/api/dashboard'@@ -341,3 +347,116 @@ export const setAutumnAutoTopup = (cfg: {// Per-sandbox usage breakdown (compute cost over a recent window)export const getSandboxUsage = (days = 30) =>apiFetch(`/usage/sandboxes?days=${days}`, {}, S.SandboxUsageSchema)++// ── Durable Agent Sessions (/v3) ─────────────────────────────────────────────+// A separate service (sessions-api). Reached through the OC edge under+// `/api/dashboard/v3/*`, so these reuse apiFetch (cookie auth, validation, mock).+// Org-key management lives server-side at the edge; live event/steer can move to+// a browser-direct client-token path later without changing these signatures.++// Agents — the reusable definition (prompt, model, runtime, credential).+export const getAgents = () => apiFetch('/v3/agents', {}, S.AgentListSchema)++export const getAgent = (id: string) =>+ apiFetch(`/v3/agents/${id}`, {}, S.AgentSchema)++export const createAgent = (body: {+ name: string+ prompt: string+ model: string+ runtime: string+ credential_id?: string+}) =>+ apiFetch(+ '/v3/agents',+ { method: 'POST', body: JSON.stringify(body) },+ S.AgentSchema,+ )++export const updateAgent = (+ id: string,+ body: Partial<{ name: string; prompt: string; model: string }>,+) =>+ apiFetch(+ `/v3/agents/${id}`,+ { method: 'PATCH', body: JSON.stringify(body) },+ S.AgentSchema,+ )++// Sessions — the durable runs.+export const getSessions = (status?: string) =>+ apiFetch(+ `/v3/sessions${status ? `?status=${status}` : ''}`,+ {},+ S.SessionListSchema,+ )++export const getSession = (id: string) =>+ apiFetch(`/v3/sessions/${id}`, {}, S.SessionSchema)++export const createSession = (body: { agent_id: string; message?: string }) =>+ apiFetch(+ '/v3/sessions',+ { method: 'POST', body: JSON.stringify(body) },+ S.SessionSchema,+ )++export const cancelSession = (id: string) =>+ apiFetch<void>(`/v3/sessions/${id}/cancel`, { method: 'POST' })++export const archiveSession = (id: string) =>+ apiFetch<void>(`/v3/sessions/${id}/archive`, { method: 'POST' })++// Events — append-only session log. Plain GET today; an SSE (`?stream=sse`)+// browser-direct path replaces the fetch in the live view later.+export const getSessionEvents = (id: string, level?: string) =>+ apiFetch(+ `/v3/sessions/${id}/events${level ? `?level=${level}` : ''}`,+ {},+ S.SessionEventListSchema,+ )++// Steer — post a user message into a session.+export const sendMessage = (+ id: string,+ text: string,+ idempotencyKey?: string,+) =>+ apiFetch<{ event: { id: string; seq: number } }>(+ `/v3/sessions/${id}/messages`,+ {+ method: 'POST',+ body: JSON.stringify({ text, idempotency_key: idempotencyKey }),+ },+ )++// Webhooks — destinations are session-scoped.+export const getDestinations = (id: string) =>+ apiFetch(`/v3/sessions/${id}/destinations`, {}, z.array(S.DestinationSchema))++export const createDestination = (+ id: string,+ body: {+ url: string+ secret?: string+ level?: string+ types?: string[]+ },+) =>+ apiFetch(+ `/v3/sessions/${id}/destinations`,+ { method: 'POST', body: JSON.stringify(body) },+ S.DestinationSchema,+ )++export const deleteDestination = (id: string, did: string) =>+ apiFetch<void>(`/v3/sessions/${id}/destinations/${did}`, { method: 'DELETE' })++// Deliveries — the send ledger for a session's destinations.+export const getDeliveries = (id: string) =>+ apiFetch(`/v3/sessions/${id}/deliveries`, {}, z.array(S.DeliverySchema))++export const redeliver = (id: string, deliveryId: string) =>+ apiFetch<void>(`/v3/sessions/${id}/deliveries/${deliveryId}/redeliver`, {+ method: 'POST',+ })diff --git a/web/src/api/mock.ts b/web/src/api/mock.tsindex a4d5aa19..8d2eb105 100644--- a/web/src/api/mock.ts+++ b/web/src/api/mock.ts@@ -370,6 +370,163 @@ const orgInvitations = [},]+// ── Durable Agent Sessions (/v3) ─────────────────────────────────────────────+const v3agents = [+ {+ id: 'agt_3kf9xz',+ name: 'PR Reviewer',+ prompt_hash: 'sha256:9c1a4f',+ model: 'claude-opus-4-8',+ runtime: 'claude',+ credential_id: 'cred_anth_1',+ revision: 3,+ created_at: at(20),+ },+ {+ id: 'agt_7mq2aa',+ name: 'Docs Writer',+ prompt_hash: 'sha256:42bd07',+ model: 'claude-sonnet-4-6',+ runtime: 'claude',+ credential_id: null,+ revision: 1,+ created_at: at(6),+ },+]++const v3sessions = [+ {+ id: 'ses_a1b2c3',+ status: 'running',+ agent_id: 'agt_3kf9xz',+ event_seq: 24,+ created_at: at(0, 1),+ last_turn: { state: 'running' },+ },+ {+ id: 'ses_d4e5f6',+ status: 'awaiting_input',+ agent_id: 'agt_3kf9xz',+ event_seq: 12,+ created_at: at(0, 3),+ last_turn: { state: 'ok', yield_reason: 'needs_input' },+ },+ {+ id: 'ses_g7h8i9',+ status: 'idle',+ agent_id: 'agt_7mq2aa',+ event_seq: 41,+ created_at: at(1, 2),+ last_turn: { state: 'ok', yield_reason: 'completed' },+ },+ {+ id: 'ses_j1k2l3',+ status: 'failed',+ agent_id: 'agt_3kf9xz',+ event_seq: 8,+ created_at: at(2, 5),+ last_turn: { state: 'error', yield_reason: 'error' },+ },+ {+ id: 'ses_m4n5o6',+ status: 'archived',+ agent_id: 'agt_7mq2aa',+ event_seq: 60,+ created_at: at(4, 1),+ last_turn: { state: 'ok', yield_reason: 'completed' },+ },+]++const v3events = [+ {+ id: 'evt_1',+ seq: 1,+ type: 'user.message',+ level: 'user',+ actor: { type: 'user', display: 'You' },+ body: {+ text: 'Review PR #412 and open a follow-up if anything needs fixing.',+ },+ ts: at(0, 1),+ },+ {+ id: 'evt_2',+ seq: 2,+ type: 'turn.started',+ level: 'progress',+ actor: { type: 'runtime' },+ ts: at(0, 1),+ },+ {+ id: 'evt_3',+ seq: 3,+ type: 'tool.call',+ level: 'progress',+ actor: { type: 'runtime' },+ body: { tool: 'bash', input: 'git fetch origin pull/412/head' },+ ts: at(0, 1),+ },+ {+ id: 'evt_4',+ seq: 4,+ type: 'agent.message',+ level: 'user',+ actor: { type: 'agent', display: 'PR Reviewer' },+ body: {+ text: 'The diff touches the auth middleware. The token-refresh path looks correct, but the retry has no ceiling — I will flag it.',+ },+ ts: at(0, 1),+ },+ {+ id: 'evt_5',+ seq: 5,+ type: 'turn.completed',+ level: 'user',+ actor: { type: 'runtime' },+ body: { yield_reason: 'needs_input' },+ ts: at(0, 1),+ },+]++const v3destinations = [+ {+ id: 'dst_1',+ url: 'https://acme.dev/hooks/oc',+ level: 'user',+ types: ['turn.completed', 'error.*'],+ enabled: true,+ has_secret: true,+ created_at: at(0, 2),+ updated_at: at(0, 2),+ },+]++const v3deliveries = [+ {+ id: 'dlv_1',+ destination_id: 'dst_1',+ event_id: 'evt_5',+ event_seq: 5,+ status: 'delivered',+ attempts: 1,+ last_attempt_at: at(0, 1),+ response_code: 200,+ created_at: at(0, 1),+ },+ {+ id: 'dlv_2',+ destination_id: 'dst_1',+ event_id: 'evt_4',+ event_seq: 4,+ status: 'failed',+ attempts: 3,+ last_attempt_at: at(0, 1),+ response_code: 502,+ error: 'upstream returned 502',+ created_at: at(0, 1),+ },+]+type Handler = () => unknown// Ordered most-specific first. Matched against the path (without /api/dashboard).@@ -393,6 +550,17 @@ const ROUTES: Array<[RegExp, Handler]> = [[/^\/org\/custom-domain$/, () => ({})],[/^\/org$/, () => org],[/^\/agents$/, () => []],+ // Durable Agent Sessions (/v3)+ [/^\/v3\/agents\/[^/]+$/, () => v3agents[0]],+ [/^\/v3\/agents$/, () => v3agents],+ [+ /^\/v3\/sessions\/[^/]+\/events/,+ () => ({ events: v3events, cursor: null }),+ ],+ [/^\/v3\/sessions\/[^/]+\/destinations$/, () => v3destinations],+ [/^\/v3\/sessions\/[^/]+\/deliveries$/, () => v3deliveries],+ [/^\/v3\/sessions\/[^/]+$/, () => v3sessions[0]],+ [/^\/v3\/sessions(\?.*)?$/, () => ({ sessions: v3sessions, cursor: null })],]export function mockFetch<T>(path: string, options: RequestInit = {}): T {diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.tsindex f75717e2..3b1c6fab 100644--- a/web/src/api/schemas.ts+++ b/web/src/api/schemas.ts@@ -239,6 +239,110 @@ export const SandboxUsageSchema = z.object({sandboxes: z.array(SandboxUsageRowSchema),})+// ── Durable Agent Sessions (/v3) ─────────────────────────────────────────────+// Mirrors the sessions-api /v3 contract verbatim (snake_case as the API returns+// it) — no transform layer to keep in sync. Reached via the edge proxy; lenient+// string fields so a new server enum never fails validation.++export const AgentSchema = z.object({+ id: z.string(),+ name: z.string(),+ prompt_hash: z.string().optional(),+ model: z.string(),+ runtime: z.string(),+ credential_id: z.string().nullable().optional(),+ revision: z.number().optional(),+ limits: record.optional(),+ created_at: z.string(),+})+export const AgentListSchema = z.array(AgentSchema)++export const SessionSchema = z.object({+ id: z.string(),+ status: z.string(),+ agent_id: z.string().nullable().optional(),+ credential_id: z.string().nullable().optional(),+ event_seq: z.number().optional(),+ last_turn: record.nullable().optional(),+ usage: record.optional(),+ limits: record.optional(),+ metadata: record.optional(),+ created_at: z.string(),+})+export const SessionListSchema = z.object({+ sessions: z.array(SessionSchema),+ cursor: z.string().nullable().optional(),+})++export const ActorSchema = z.object({+ id: z.string().optional(),+ display: z.string().optional(),+ type: z.string().optional(),+})++export const SessionEventSchema = z.object({+ id: z.string(),+ seq: z.number(),+ type: z.string(),+ level: z.string(),+ actor: ActorSchema.optional(),+ body: z.unknown().optional(),+ body_ref: z.string().nullable().optional(),+ refs: record.optional(),+ source: z.string().optional(),+ turn_id: z.string().nullable().optional(),+ ts: z.string().optional(),+ created_at: z.string().optional(),+})+export const SessionEventListSchema = z.object({+ events: z.array(SessionEventSchema),+ cursor: z.string().nullable().optional(),+})++export const TurnSchema = z.object({+ id: z.string(),+ state: z.string(),+ yield_reason: z.string().nullable().optional(),+ attempt: z.number().optional(),+ started_at: z.string().nullable().optional(),+ completed_at: z.string().nullable().optional(),+ usage: record.optional(),+ error: z.string().nullable().optional(),+})++export const DestinationSchema = z.object({+ id: z.string(),+ url: z.string(),+ level: z.string().optional(),+ types: z.array(z.string()).optional(),+ include_raw: z.boolean().optional(),+ enabled: z.boolean(),+ has_secret: z.boolean().optional(),+ created_after_seq: z.number().nullable().optional(),+ created_at: z.string(),+ updated_at: z.string().optional(),+})++export const DeliverySchema = z.object({+ id: z.string(),+ destination_id: z.string(),+ event_id: z.string().optional(),+ event_seq: z.number().optional(),+ status: z.string(),+ attempts: z.number().optional(),+ last_attempt_at: z.string().nullable().optional(),+ response_code: z.number().nullable().optional(),+ error: z.string().nullable().optional(),+ created_at: z.string(),+})++export type Agent = z.infer<typeof AgentSchema>+export type Session = z.infer<typeof SessionSchema>+export type SessionEvent = z.infer<typeof SessionEventSchema>+export type Turn = z.infer<typeof TurnSchema>+export type Destination = z.infer<typeof DestinationSchema>+export type Delivery = z.infer<typeof DeliverySchema>+export type OrgInfo = z.infer<typeof OrgInfoSchema>export type MeResponse = z.infer<typeof MeResponseSchema>export type Sandbox = z.infer<typeof SandboxSchema>diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsxindex 762ffd5b..be02c951 100644--- a/web/src/components/app-shell.tsx+++ b/web/src/components/app-shell.tsx@@ -3,6 +3,8 @@ import { Link, NavLink, Outlet, useLocation } from 'react-router-dom'import { useQuery } from '@tanstack/react-query'import {LayoutGrid,+ Bot,+ MessagesSquare,Boxes,Layers,Package,@@ -37,15 +39,36 @@ import { ErrorBoundary } from '@/components/error-boundary'import { cn } from '@/lib/utils'type NavItem = { to: string; label: string; icon: LucideIcon; end?: boolean }+type NavGroup = { label?: string; items: NavItem[] }-const NAV: NavItem[] = [- { to: '/', label: 'Dashboard', icon: LayoutGrid, end: true },- { to: '/sandboxes', label: 'Sandboxes', icon: Boxes },- { to: '/checkpoints', label: 'Checkpoints', icon: Layers },- { to: '/templates', label: 'Templates', icon: Package },- { to: '/api-keys', label: 'API Keys', icon: KeyRound },- { to: '/billing', label: 'Billing', icon: CreditCard },- { to: '/settings', label: 'Settings', icon: Settings },+// Two planes, subtly separated: the durable-agent plane and the raw-compute+// (sandbox) plane, plus account/org. Groups render with spacing + a small muted+// label rather than hard dividers.+const NAV: NavGroup[] = [+ { items: [{ to: '/', label: 'Dashboard', icon: LayoutGrid, end: true }] },+ {+ label: 'Agents',+ items: [+ { to: '/agents', label: 'Agents', icon: Bot },+ { to: '/sessions', label: 'Sessions', icon: MessagesSquare },+ ],+ },+ {+ label: 'Sandboxes',+ items: [+ { to: '/sandboxes', label: 'Sandboxes', icon: Boxes },+ { to: '/checkpoints', label: 'Checkpoints', icon: Layers },+ { to: '/templates', label: 'Templates', icon: Package },+ ],+ },+ {+ label: 'Account',+ items: [+ { to: '/api-keys', label: 'API Keys', icon: KeyRound },+ { to: '/billing', label: 'Billing', icon: CreditCard },+ { to: '/settings', label: 'Settings', icon: Settings },+ ],+ },]function Brand() {@@ -123,29 +146,38 @@ function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {</div>) : null}- <nav className="flex-1 space-y-0.5 overflow-y-auto p-3">- {NAV.map((item) => (- <NavLink- key={item.to}- to={item.to}- end={item.end}- onClick={onNavigate}- className={({ isActive }) =>- cn(- 'flex min-h-9 items-center gap-2.5 rounded-md px-3 font-mono text-sm tracking-tight transition-colors',- isActive- ? 'bg-sidebar-accent text-foreground font-medium'- : 'text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground',- )- }- >- <item.icon- className="size-4 shrink-0 opacity-50"- strokeWidth={1.25}- aria-hidden- />- {item.label}- </NavLink>+ <nav className="flex-1 space-y-5 overflow-y-auto p-3">+ {NAV.map((group, gi) => (+ <div key={group.label ?? gi} className="space-y-0.5">+ {group.label ? (+ <div className="text-muted-foreground/55 px-3 pb-1 text-[10px] font-medium tracking-wider uppercase">+ {group.label}+ </div>+ ) : null}+ {group.items.map((item) => (+ <NavLink+ key={item.to}+ to={item.to}+ end={item.end}+ onClick={onNavigate}+ className={({ isActive }) =>+ cn(+ 'flex min-h-9 items-center gap-2.5 rounded-md px-3 font-mono text-sm tracking-tight transition-colors',+ isActive+ ? 'bg-sidebar-accent text-foreground font-medium'+ : 'text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground',+ )+ }+ >+ <item.icon+ className="size-4 shrink-0 opacity-50"+ strokeWidth={1.25}+ aria-hidden+ />+ {item.label}+ </NavLink>+ ))}+ </div>))}</nav>diff --git a/web/src/components/form.tsx b/web/src/components/form.tsxindex dfc419a1..839a3f77 100644--- a/web/src/components/form.tsx+++ b/web/src/components/form.tsx@@ -6,6 +6,20 @@ import { cn } from '@/lib/utils'// Re-exported so screens import all form primitives from one place.export { Input, Label }+// Multiline input, styled to match Input (same border / focus tokens).+export function Textarea({ className, ...props }: ComponentProps<'textarea'>) {+ return (+ <textarea+ data-slot="textarea"+ className={cn(+ 'border-input placeholder:text-muted-foreground focus-visible:border-ring disabled:bg-input/50 aria-invalid:border-destructive flex min-h-20 w-full rounded-md border bg-transparent px-2.5 py-1.5 text-base transition-colors outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',+ className,+ )}+ {...props}+ />+ )+}+/*** Plain-props, RHF-agnostic field wrapper: label + control + description/error.* A later "form correctness" pass wires react-hook-form + zod into thesediff --git a/web/src/components/status-badge.tsx b/web/src/components/status-badge.tsxindex 65972b3f..ebc317b5 100644--- a/web/src/components/status-badge.tsx+++ b/web/src/components/status-badge.tsx@@ -33,6 +33,9 @@ const STATUS: Record<string, Meta> = {unknown: { tone: 'stopped', label: 'Unknown', icon: CircleSlash },hibernated: { tone: 'hibernated', label: 'Hibernated', icon: Moon },paused: { tone: 'hibernated', label: 'Paused', icon: Moon },+ idle: { tone: 'hibernated', label: 'Idle', icon: Moon },+ archived: { tone: 'stopped', label: 'Archived', icon: CircleSlash },+ awaiting_input: { tone: 'pending', label: 'Awaiting input', icon: Clock },pending: { tone: 'pending', label: 'Pending', icon: Clock },queued: { tone: 'pending', label: 'Queued', icon: Clock },building: { tone: 'pending', label: 'Building', icon: Loader2, spin: true },diff --git a/web/src/pages/Agents.tsx b/web/src/pages/Agents.tsxnew file mode 100644index 00000000..b8662ad4--- /dev/null+++ b/web/src/pages/Agents.tsx@@ -0,0 +1,217 @@+import { useState } from 'react'+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'+import { Bot, Plus } from 'lucide-react'+import { notifyError } from '@/lib/errors'+import { getAgents, createAgent, type Agent } from '@/api/client'+import { PageHeader } from '@/components/page-header'+import { Panel } from '@/components/panel'+import { Button } from '@/components/ui/button'+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog'+import { Field, Input, Textarea } from '@/components/form'+import { EmptyState } from '@/components/empty-state'+import { ResourceTable, type Column } from '@/components/resource-table'++const DEFAULT_MODEL = 'claude-opus-4-8'++export default function Agents() {+ const queryClient = useQueryClient()+ const { data: agents, isLoading } = useQuery({+ queryKey: ['agents'],+ queryFn: getAgents,+ })++ const [showCreate, setShowCreate] = useState(false)+ const [name, setName] = useState('')+ const [prompt, setPrompt] = useState('')+ const [model, setModel] = useState(DEFAULT_MODEL)++ const resetForm = () => {+ setName('')+ setPrompt('')+ setModel(DEFAULT_MODEL)+ }++ const createMutation = useMutation({+ mutationFn: () =>+ createAgent({+ name: name.trim(),+ prompt: prompt.trim(),+ model,+ runtime: 'claude',+ }),+ onSuccess: () => {+ void queryClient.invalidateQueries({ queryKey: ['agents'] })+ setShowCreate(false)+ resetForm()+ },+ onError: (e) => notifyError("Couldn't create the agent.", e),+ })++ const columns: Column<Agent>[] = [+ {+ key: 'name',+ header: 'Name',+ cell: (a) => (+ <span className="text-foreground font-medium">{a.name}</span>+ ),+ },+ {+ key: 'model',+ header: 'Model',+ cell: (a) => (+ <code className="text-muted-foreground font-mono text-xs">+ {a.model}+ </code>+ ),+ },+ {+ key: 'runtime',+ header: 'Runtime',+ cell: (a) => (+ <span className="text-muted-foreground text-xs capitalize">+ {a.runtime}+ </span>+ ),+ },+ {+ key: 'revision',+ header: 'Revision',+ align: 'right',+ cell: (a) => (+ <span className="text-muted-foreground font-mono text-xs">+ {a.revision ?? 1}+ </span>+ ),+ },+ {+ key: 'created',+ header: 'Created',+ cell: (a) => (+ <span className="text-muted-foreground font-mono text-xs">+ {new Date(a.created_at).toLocaleDateString()}+ </span>+ ),+ },+ ]++ const canCreate = name.trim().length > 0 && prompt.trim().length > 0++ return (+ <div>+ <PageHeader+ title="Agents"+ description="Reusable definitions — a prompt, model, and runtime a session runs."+ actions={+ <Button onClick={() => setShowCreate(true)}>+ <Plus className="size-4" />+ Create agent+ </Button>+ }+ />++ <Panel className="overflow-hidden">+ <ResourceTable+ columns={columns}+ rows={agents ?? []}+ rowKey={(a) => a.id}+ loading={isLoading}+ empty={+ <EmptyState+ icon={Bot}+ title="No agents yet"+ description="An agent is the reusable “what” — define it once, then start sessions from it."+ action={+ <Button size="sm" onClick={() => setShowCreate(true)}>+ <Plus className="size-4" />+ Create agent+ </Button>+ }+ />+ }+ />+ </Panel>++ <Dialog open={showCreate} onOpenChange={setShowCreate}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Create agent</DialogTitle>+ <DialogDescription>+ A reusable definition. Sessions pin a snapshot of it at create+ time.+ </DialogDescription>+ </DialogHeader>+ <form+ className="space-y-4"+ onSubmit={(e) => {+ e.preventDefault()+ if (canCreate) createMutation.mutate()+ }}+ >+ <Field label="Name" htmlFor="agent-name">+ <Input+ id="agent-name"+ value={name}+ onChange={(e) => setName(e.target.value)}+ placeholder="e.g. PR Reviewer"+ />+ </Field>+ <Field+ label="Prompt"+ htmlFor="agent-prompt"+ description="The system prompt that defines how the agent behaves."+ >+ <Textarea+ id="agent-prompt"+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ placeholder="You are a meticulous code reviewer…"+ className="min-h-28"+ />+ </Field>+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <Field label="Model" htmlFor="agent-model">+ <Input+ id="agent-model"+ value={model}+ onChange={(e) => setModel(e.target.value)}+ />+ </Field>+ <Field+ label="Runtime"+ htmlFor="agent-runtime"+ description="Codex and custom runtimes coming soon."+ >+ <Input id="agent-runtime" value="Claude" disabled />+ </Field>+ </div>+ <DialogFooter className="mt-2">+ <Button+ type="button"+ variant="ghost"+ onClick={() => {+ setShowCreate(false)+ resetForm()+ }}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ disabled={createMutation.isPending || !canCreate}+ >+ {createMutation.isPending ? 'Creating…' : 'Create agent'}+ </Button>+ </DialogFooter>+ </form>+ </DialogContent>+ </Dialog>+ </div>+ )+}diff --git a/web/src/pages/Sessions.tsx b/web/src/pages/Sessions.tsxnew file mode 100644index 00000000..bba74674--- /dev/null+++ b/web/src/pages/Sessions.tsx@@ -0,0 +1,93 @@+import { useQuery } from '@tanstack/react-query'+import { MessagesSquare } from 'lucide-react'+import { getSessions, getAgents } from '@/api/client'+import type { Session } from '@/api/client'+import { PageHeader } from '@/components/page-header'+import { Panel } from '@/components/panel'+import { StatusBadge } from '@/components/status-badge'+import { EmptyState } from '@/components/empty-state'+import { ResourceTable, type Column } from '@/components/resource-table'++export default function Sessions() {+ const { data, isLoading } = useQuery({+ queryKey: ['sessions'],+ queryFn: () => getSessions(),+ })+ // Resolve agent_id → name for display (cheap, cached alongside the Agents page).+ const { data: agents } = useQuery({+ queryKey: ['agents'],+ queryFn: getAgents,+ })+ const agentName = (id?: string | null) =>+ agents?.find((a) => a.id === id)?.name ?? id ?? '—'++ const sessions = data?.sessions ?? []++ const columns: Column<Session>[] = [+ {+ key: 'id',+ header: 'Session',+ cell: (s) => (+ <span className="text-foreground font-mono text-[13px]">{s.id}</span>+ ),+ },+ {+ key: 'status',+ header: 'Status',+ cell: (s) => <StatusBadge status={s.status} />,+ },+ {+ key: 'agent',+ header: 'Agent',+ cell: (s) => (+ <span className="text-muted-foreground text-sm">+ {agentName(s.agent_id)}+ </span>+ ),+ },+ {+ key: 'events',+ header: 'Events',+ align: 'right',+ cell: (s) => (+ <span className="text-muted-foreground font-mono text-xs">+ {s.event_seq ?? 0}+ </span>+ ),+ },+ {+ key: 'created',+ header: 'Created',+ cell: (s) => (+ <span className="text-muted-foreground font-mono text-xs">+ {new Date(s.created_at).toLocaleString()}+ </span>+ ),+ },+ ]++ return (+ <div>+ <PageHeader+ title="Sessions"+ description="Durable agent runs — an append-only event log you can steer."+ />++ <Panel className="overflow-hidden">+ <ResourceTable+ columns={columns}+ rows={sessions}+ rowKey={(s) => s.id}+ loading={isLoading}+ empty={+ <EmptyState+ icon={MessagesSquare}+ title="No sessions yet"+ description="Start a session from an agent to give it a task; it runs durably and streams events here."+ />+ }+ />+ </Panel>+ </div>+ )+}