/* Runs — the inbox: a flat list of every agent across every project on the left, the * selected agent's checkmark + log + answer/resume flow on the right. Maps the design's * "Runs" pane to Handler's agent / checkmark / log model. */ "use client"; import { useMemo, useState } from "react"; import { useDashboard } from "@/components/store"; import { Badge, Button, Callout, Stat, StatusBadge, Tabs, Textarea } from "@/components/ui"; import { fmtFull, shortSha, statusTone, timeAgo } from "@/lib/format"; import type { Agent } from "@/lib/api"; const FILTERS = [ { value: "all", label: "All" }, { value: "needs", label: "Needs Input" }, { value: "working", label: "Working" }, { value: "done", label: "Done" }, ]; function matches(filter: string, status: string): boolean { if (filter === "all") return true; if (filter === "needs") return status === "paused_for_input"; if (filter === "working") return status === "working" || status === "running"; if (filter === "done") return status === "done" || status === "completed"; return true; } export function RunsSection() { const s = useDashboard(); const [filter, setFilter] = useState("all"); const runs = useMemo(() => { const list = s.agents.filter((a) => matches(filter, a.status)); return [...list].sort((a, b) => (a.created_at < b.created_at ? 1 : -1)); }, [s.agents, filter]); const selected = s.selectedRun; const needs = s.agents.filter((a) => a.status === "paused_for_input").length; const working = s.agents.filter((a) => a.status === "working" || a.status === "running").length; return (
Runs
{runs.length === 0 && No runs match this filter.} {runs.map((a) => ( s.selectRun(a.project_id, a.name)} /> ))}
{selected ? : }
); } function RunRow({ agent, selected, onSelect, }: { agent: Agent; selected: boolean; onSelect: () => void; }) { return ( ); } function RunEmpty() { return (
Select a run to see its checkmark, log, and any open question.
); } function RunDetail() { const s = useDashboard(); const run = s.selectedRun!; const agent = s.agents.find((a) => a.project_id === run.projectId && a.name === run.name); const cm = s.checkmark; const [answer, setAnswer] = useState(""); const [busy, setBusy] = useState(false); const isPaused = agent?.status === "paused_for_input"; const doAnswer = async (resume: boolean) => { if (!answer.trim()) return; setBusy(true); const ok = await s.submitAnswer(answer.trim(), resume); setBusy(false); if (ok) setAnswer(""); }; return ( <>
{run.projectId} / {run.name} {agent?.role && {agent.role}}
{agent?.working_dir ?? "—"} · created {fmtFull(agent?.created_at)}
{/* Checkmark */}
Checkmark
{s.checkmarkMissing && No checkpoint recorded yet.} {cm && !s.checkmarkMissing && (
Status
Where it stopped
{cm.where_it_stopped || "—"}
Open question
{cm.open_question || "—"}
Next steps
{cm.next_steps && cm.next_steps.length > 0 ? (
    {cm.next_steps.map((step, i) => (
  • {step}
  • ))}
) : ( "—" )}
Tests
{cm.tests_status} {cm.tested_at ? fmtFull(cm.tested_at) : ""}
Build
{cm.build_status} {cm.built_at ? fmtFull(cm.built_at) : ""}
Checkpoint at
{fmtFull(cm.checkpoint_at)}
)}
{/* Answer / resume */} {isPaused && (
Answer this question
{cm?.open_question || "(no question text on the checkmark)"}