/* Agents โ€” spawn a new agent into a repository and manage the ones already running. * Spawning enqueues a control command that the worker turns into a tmux + claude process. */ "use client"; import { Fragment, useMemo, useState } from "react"; import { useDashboard } from "@/components/store"; import { Badge, Button, Card, Input, Select, StatusBadge, Textarea } from "@/components/ui"; import { fmtFull, timeAgo } from "@/lib/format"; const ROLE_OPTS = [ { value: "", label: "Role โ€” none" }, { value: "junior", label: "junior" }, { value: "senior", label: "senior" }, { value: "deploy", label: "deploy" }, ]; const PLACEMENT_OPTS = [ { value: "worktree", label: "git worktree on branch" }, { value: "subdir", label: "subdir under root" }, ]; const emptySpawn = { name: "", role: "", placement: "worktree" as "worktree" | "subdir", worktree: "", subdir: "", task: "", }; export function AgentsSection() { const s = useDashboard(); const [form, setForm] = useState(emptySpawn); const projectOpts = useMemo( () => s.projects.map((p) => ({ value: p.id, label: p.id })), [s.projects], ); const agents = useMemo( () => s.agents.filter((a) => a.project_id === s.selectedProjectId), [s.agents, s.selectedProjectId], ); const spawn = async () => { const ok = await s.spawnAgent(form); if (ok) setForm(emptySpawn); }; return ( <>
Agents
Spawn agents into a repository and manage running sessions.
{s.projects.length === 0 ? (
Register a repository first.
) : ( <>
setForm({ ...form, name: v })} placeholder="junior" /> setForm({ ...form, placement: v as "worktree" | "subdir" })} options={PLACEMENT_OPTS} /> {form.placement === "worktree" ? ( setForm({ ...form, worktree: v })} placeholder="feat/auth" /> ) : ( setForm({ ...form, subdir: v })} placeholder="api" /> )}