Open-source SEO, GEO, and marketing skills for AI agents.
refactor(tasks): unify TaskStatus vocab on agent verbs (running→working, succeeded→done)
Yuting Zhong5660dc806e09
diff --git a/src/app/(app)/[project]/page.tsx b/src/app/(app)/[project]/page.tsxindex e6520761..1900ff8f 100644--- a/src/app/(app)/[project]/page.tsx+++ b/src/app/(app)/[project]/page.tsx@@ -51,7 +51,7 @@ export default async function ProjectHomePage({// Intentionally NOT calling openclaw here. The cron tab is the source of// truth for scheduled jobs; calling `openclaw cron list` from the home page// would block render for 5-15s on some machines. Show a link instead.- const running = tasks.filter((t) => t.status === "running").length;+ const running = tasks.filter((t) => t.status === "working").length;return (<div className="mx-auto max-w-6xl space-y-6">diff --git a/src/app/(app)/[project]/tasks/page.tsx b/src/app/(app)/[project]/tasks/page.tsxindex 4ef48d52..ef975fb5 100644--- a/src/app/(app)/[project]/tasks/page.tsx+++ b/src/app/(app)/[project]/tasks/page.tsx@@ -12,9 +12,9 @@ import type { TaskStatus } from "@/types";const STATUS_GROUPS: Array<{ status: TaskStatus; label: string }> = [{ status: "proposed", label: "Proposed" },{ status: "approved", label: "Approved" },- { status: "running", label: "Running" },+ { status: "working", label: "Working" },{ status: "blocked", label: "Blocked on approval" },- { status: "succeeded", label: "Succeeded" },+ { status: "done", label: "Done" },{ status: "failed", label: "Failed" },{ status: "cancelled", label: "Cancelled" },];@@ -22,9 +22,9 @@ const STATUS_GROUPS: Array<{ status: TaskStatus; label: string }> = [const STATUS_VARIANT: Record<TaskStatus, "default" | "secondary" | "outline" | "destructive"> = {proposed: "outline",approved: "secondary",- running: "default",+ working: "default",blocked: "secondary",- succeeded: "secondary",+ done: "secondary",failed: "destructive",cancelled: "outline",};diff --git a/src/components/agent-task-workspace.test.tsx b/src/components/agent-task-workspace.test.tsxindex 17a11289..5f9a5873 100644--- a/src/components/agent-task-workspace.test.tsx+++ b/src/components/agent-task-workspace.test.tsx@@ -123,7 +123,7 @@ describe("AgentTaskWorkspace empty state", () => {render(<AgentTaskWorkspace{...baseProps({- tasks: [makeTask({ status: "succeeded" })],+ tasks: [makeTask({ status: "done" })],})}/>,);@@ -138,9 +138,9 @@ describe("AgentTaskWorkspace in-flight summary + StartAllTasksButton", () => {<AgentTaskWorkspace{...baseProps({tasks: [- makeTask({ id: "a", display_id: "demo-1", status: "running" }),+ makeTask({ id: "a", display_id: "demo-1", status: "working" }),makeTask({ id: "b", display_id: "demo-2", status: "approved" }),- makeTask({ id: "c", display_id: "demo-3", status: "succeeded" }),+ makeTask({ id: "c", display_id: "demo-3", status: "done" }),],proposedCount: 0,})}@@ -169,7 +169,7 @@ describe("AgentTaskWorkspace in-flight summary + StartAllTasksButton", () => {render(<AgentTaskWorkspace{...baseProps({- tasks: [makeTask({ status: "succeeded" })],+ tasks: [makeTask({ status: "done" })],})}/>,);@@ -183,15 +183,15 @@ describe("AgentTaskWorkspace task list grouping", () => {<AgentTaskWorkspace{...baseProps({tasks: [- makeTask({ id: "1", display_id: "demo-1", status: "running" }),+ makeTask({ id: "1", display_id: "demo-1", status: "working" }),makeTask({ id: "2", display_id: "demo-2", status: "proposed" }),- makeTask({ id: "3", display_id: "demo-3", status: "succeeded" }),+ makeTask({ id: "3", display_id: "demo-3", status: "done" }),makeTask({ id: "4", display_id: "demo-4", status: "failed", error_message: "boom" }),],})}/>,);- expect(screen.getByText("Running")).toBeInTheDocument();+ expect(screen.getByText("Working")).toBeInTheDocument();expect(screen.getByText("Proposed")).toBeInTheDocument();expect(screen.getByText("Done")).toBeInTheDocument();expect(screen.getByText("Failed")).toBeInTheDocument();@@ -251,7 +251,7 @@ describe("AgentTaskWorkspace selected-task panel", () => {const task = makeTask({display_id: "demo-42",title: "Audit yesterday's spend",- status: "running",+ status: "working",});render(<AgentTaskWorkspace@@ -269,7 +269,7 @@ describe("AgentTaskWorkspace selected-task panel", () => {);expect(screen.getAllByText("demo-42").length).toBeGreaterThan(0);expect(screen.getAllByText("Audit yesterday's spend").length).toBeGreaterThan(0);- expect(screen.getAllByText("running").length).toBeGreaterThan(0);+ expect(screen.getAllByText("working").length).toBeGreaterThan(0);const stub = screen.getByTestId("live-transcript");expect(stub.getAttribute("data-thread")).toBe("thr-1");expect(stub.getAttribute("data-disabled")).toBe("true");@@ -298,7 +298,7 @@ describe("AgentTaskWorkspace selected-task panel", () => {const task = makeTask({brief: "Brief body text",success_criteria: "Success criteria text",- status: "succeeded",+ status: "done",});render(<AgentTaskWorkspace@@ -320,7 +320,7 @@ describe("AgentTaskWorkspace selected-task panel", () => {});it("does not render the Cancel button on terminal-status tasks", () => {- const task = makeTask({ status: "succeeded" });+ const task = makeTask({ status: "done" });render(<AgentTaskWorkspace{...baseProps({@@ -341,7 +341,7 @@ describe("AgentTaskWorkspace selected-task panel", () => {describe("AgentTaskWorkspace CancelTaskButton", () => {function renderWithRunningSelected() {- const task = makeTask({ display_id: "demo-77", status: "running" });+ const task = makeTask({ display_id: "demo-77", status: "working" });return render(<AgentTaskWorkspace{...baseProps({diff --git a/src/components/agent-task-workspace.tsx b/src/components/agent-task-workspace.tsxindex 05f2c435..ee8e9d71 100644--- a/src/components/agent-task-workspace.tsx+++ b/src/components/agent-task-workspace.tsx@@ -25,14 +25,14 @@ import { projectHref } from "@/lib/project-href";import type { TranscriptEvent } from "@/server/openclaw/transcript-tail";import type { Approval, Task, TaskStatus } from "@/types";-const TASK_IN_FLIGHT: TaskStatus[] = ["proposed", "approved", "running", "blocked"];+const TASK_IN_FLIGHT: TaskStatus[] = ["proposed", "approved", "working", "blocked"];const STATUS_GROUPS: Array<{ status: TaskStatus; label: string }> = [- { status: "running", label: "Running" },+ { status: "working", label: "Working" },{ status: "blocked", label: "Waiting on approval" },{ status: "proposed", label: "Proposed" },{ status: "approved", label: "Approved" },- { status: "succeeded", label: "Done" },+ { status: "done", label: "Done" },{ status: "failed", label: "Failed" },{ status: "cancelled", label: "Cancelled" },];@@ -43,9 +43,9 @@ const STATUS_VARIANT: Record<> = {proposed: "outline",approved: "secondary",- running: "default",+ working: "default",blocked: "secondary",- succeeded: "secondary",+ done: "secondary",failed: "destructive",cancelled: "outline",};@@ -96,7 +96,7 @@ export function AgentTaskWorkspace({const totalCount = tasks.length;const inFlightCount =- (grouped.get("running")?.length ?? 0) ++ (grouped.get("working")?.length ?? 0) +(grouped.get("proposed")?.length ?? 0) +(grouped.get("approved")?.length ?? 0);@@ -207,7 +207,7 @@ export function AgentTaskWorkspace({</h1></div><div className="flex shrink-0 items-center gap-2">- {(selected.task.status === "running" ||+ {(selected.task.status === "working" ||selected.task.status === "proposed" ||selected.task.status === "approved") && (<>@@ -402,9 +402,9 @@ function TaskRow({selected: boolean;onSelect: () => void;}) {- const isRunning = task.status === "running";+ const isRunning = task.status === "working";const isInFlight =- task.status === "running" ||+ task.status === "working" ||task.status === "proposed" ||task.status === "approved";return (@@ -433,7 +433,7 @@ function TaskRow({<spanclassName={cn(selected ? "font-medium text-foreground" : "text-foreground/90",- !isInFlight && task.status !== "running" && "text-muted-foreground",+ !isInFlight && task.status !== "working" && "text-muted-foreground",)}>{task.title ?? task.brief.slice(0, 80)}@@ -454,7 +454,7 @@ function TaskRow({function StatusGlyph({ status }: { status: TaskStatus }) {switch (status) {- case "succeeded":+ case "done":return <CheckCircle2 className="size-3.5 text-emerald-600" />;case "failed":return <XCircle className="size-3.5 text-destructive" />;@@ -462,7 +462,7 @@ function StatusGlyph({ status }: { status: TaskStatus }) {return <Circle className="size-3.5 text-muted-foreground" />;case "approved":return <CircleDot className="size-3.5 text-sky-600" />;- case "running":+ case "working":return <Loader2 className="size-3.5 animate-spin text-sky-600" />;case "blocked":return <CircleDot className="size-3.5 text-amber-600" />;diff --git a/src/components/live-transcript.tsx b/src/components/live-transcript.tsxindex 2c7d5aef..3cc73b6f 100644--- a/src/components/live-transcript.tsx+++ b/src/components/live-transcript.tsx@@ -863,7 +863,7 @@ function ToolGroup({ tools }: { tools: ToolEntry[] }) {<span className="inline-flex items-center gap-1.5"><RunningDot size="sm" aria-label="" />{tools.length === 1- ? "running"+ ? "working": `${tools.length} steps · ${inFlightCount} live`}</span>) : (diff --git a/src/server/actions/tasks.test.ts b/src/server/actions/tasks.test.tsindex 5293b548..0d1cd381 100644--- a/src/server/actions/tasks.test.ts+++ b/src/server/actions/tasks.test.ts@@ -109,8 +109,8 @@ describe("startAllProposedTasksAction", () => {const t2 = makeTask({ id: "t2" });listTasksByAgentMock.mockReturnValue([t1, t2]);claimProposedTaskMock.mockImplementation((id: string) => {- if (id === "t1") return { ...t1, status: "running" };- if (id === "t2") return { ...t2, status: "running" };+ if (id === "t1") return { ...t1, status: "working" };+ if (id === "t2") return { ...t2, status: "working" };return null;});@@ -134,7 +134,7 @@ describe("startAllProposedTasksAction", () => {const t2 = makeTask({ id: "t2" });listTasksByAgentMock.mockReturnValue([t1, t2]);claimProposedTaskMock.mockImplementation((id: string) => {- if (id === "t1") return { ...t1, status: "running" };+ if (id === "t1") return { ...t1, status: "working" };return null;});@@ -153,7 +153,7 @@ describe("startAllProposedTasksAction", () => {const tMine = makeTask({ id: "t-mine", project_slug: "demo" });const tOther = makeTask({ id: "t-other", project_slug: "other" });listTasksByAgentMock.mockReturnValue([tMine, tOther]);- claimProposedTaskMock.mockReturnValue({ ...tMine, status: "running" });+ claimProposedTaskMock.mockReturnValue({ ...tMine, status: "working" });const out = await startAllProposedTasksAction("demo-google-ads");expect(out.ok).toBe(true);@@ -166,7 +166,7 @@ describe("startAllProposedTasksAction", () => {getActiveProjectMock.mockResolvedValue(makeProject());const t = makeTask({ id: "t1" });listTasksByAgentMock.mockReturnValue([t]);- claimProposedTaskMock.mockReturnValue({ ...t, status: "running" });+ claimProposedTaskMock.mockReturnValue({ ...t, status: "working" });runTaskKickoffServerSideMock.mockRejectedValue(new Error("kickoff boom"));const out = await startAllProposedTasksAction("demo-google-ads");@@ -218,7 +218,7 @@ describe("cancelTaskAction", () => {expect(updateTaskMock).not.toHaveBeenCalled();});- it.each(["succeeded", "failed", "cancelled"] as const)(+ it.each(["done", "failed", "cancelled"] as const)("returns ok:false when the task is already %s",async (status) => {getActiveProjectMock.mockResolvedValue(makeProject());@@ -229,7 +229,7 @@ describe("cancelTaskAction", () => {},);- it.each(["proposed", "approved", "running"] as const)(+ it.each(["proposed", "approved", "working"] as const)("cancels the task when it is in non-terminal state %s",async (status) => {getActiveProjectMock.mockResolvedValue(makeProject());@@ -249,7 +249,7 @@ describe("cancelTaskAction", () => {it("accepts a display_id and forwards it to getTask", async () => {getActiveProjectMock.mockResolvedValue(makeProject());- getTaskMock.mockReturnValue(makeTask({ id: "uuid-xyz", status: "running" }));+ getTaskMock.mockReturnValue(makeTask({ id: "uuid-xyz", status: "working" }));await cancelTaskAction("demo-7");expect(getTaskMock).toHaveBeenCalledWith("demo-7");// updateTask is keyed by the row PK, not the display_id input.diff --git a/src/server/actions/tasks.ts b/src/server/actions/tasks.tsindex 1a79842f..be33eeff 100644--- a/src/server/actions/tasks.ts+++ b/src/server/actions/tasks.ts@@ -91,7 +91,7 @@ export async function cancelTaskAction(return { ok: false, error: "Task isn't in the active project." };}if (- task.status === "succeeded" ||+ task.status === "done" ||task.status === "failed" ||task.status === "cancelled") {diff --git a/src/server/db/migrations.ts b/src/server/db/migrations.tsindex 7db3c4c1..57123225 100644--- a/src/server/db/migrations.ts+++ b/src/server/db/migrations.ts@@ -274,6 +274,55 @@ CREATE TABLE IF NOT EXISTS approval_policies (created_by_id TEXT);CREATE INDEX IF NOT EXISTS idx_approval_policies_project ON approval_policies(project_slug, action_type);+`,+ },+ {+ name: "007_unify_task_status_vocab.sql",+ sql: `+-- Unify TaskStatus on the agent-facing verb form: running→working,+-- succeeded→done. SQLite can't ALTER CHECK in place — recreate the table+-- and transform existing rows via CASE. See 007_unify_task_status_vocab.sql+-- for the rationale.++CREATE TABLE tasks_new (+ id TEXT PRIMARY KEY,+ project_slug TEXT NOT NULL REFERENCES projects(slug),+ agent_id TEXT NOT NULL,+ brief TEXT NOT NULL,+ success_criteria TEXT,+ deadline_iso TEXT,+ status TEXT NOT NULL CHECK (status IN ('proposed','approved','working','blocked','done','failed','cancelled')),+ result_json TEXT,+ error_message TEXT,+ created_at TEXT NOT NULL,+ updated_at TEXT NOT NULL,+ title TEXT,+ thread_id TEXT,+ assigner_agent_id TEXT,+ display_id TEXT+);++INSERT INTO tasks_new (+ id, project_slug, agent_id, brief, success_criteria, deadline_iso,+ status, result_json, error_message, created_at, updated_at, title,+ thread_id, assigner_agent_id, display_id+)+SELECT+ id, project_slug, agent_id, brief, success_criteria, deadline_iso,+ CASE status+ WHEN 'running' THEN 'working'+ WHEN 'succeeded' THEN 'done'+ ELSE status+ END AS status,+ result_json, error_message, created_at, updated_at, title,+ thread_id, assigner_agent_id, display_id+FROM tasks;++DROP TABLE tasks;+ALTER TABLE tasks_new RENAME TO tasks;+CREATE INDEX IF NOT EXISTS idx_tasks_project ON tasks(project_slug);+CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(project_slug, status);+CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_display_id ON tasks(display_id);`,},];diff --git a/src/server/db/migrations/007_unify_task_status_vocab.sql b/src/server/db/migrations/007_unify_task_status_vocab.sqlnew file mode 100644index 00000000..68ce08a2--- /dev/null+++ b/src/server/db/migrations/007_unify_task_status_vocab.sql@@ -0,0 +1,55 @@+-- Unify TaskStatus vocabulary on the agent-facing verb form.+--+-- Before: tasks.status ∈ proposed | approved | running | blocked | succeeded | failed | cancelled+-- After: tasks.status ∈ proposed | approved | working | blocked | done | failed | cancelled+--+-- Rationale: the `submit_task_status` MCP tool always accepted the verb+-- enum (working/done/blocked/failed), then the handler mapped it to the+-- DB's noun enum (running/succeeded). The mapping created a visible+-- inconsistency between what the agent calls + what the UI shows on+-- /tasks ("Succeeded" / "Running"), and what the `list_task_statuses`+-- discovery tool returned. One vocabulary everywhere = no mapping layer,+-- no drift surface.+--+-- SQLite can't ALTER CHECK constraints in place — recreate the table.+-- Existing rows are transformed via CASE during the INSERT...SELECT.++CREATE TABLE tasks_new (+ id TEXT PRIMARY KEY,+ project_slug TEXT NOT NULL REFERENCES projects(slug),+ agent_id TEXT NOT NULL,+ brief TEXT NOT NULL,+ success_criteria TEXT,+ deadline_iso TEXT,+ status TEXT NOT NULL CHECK (status IN ('proposed','approved','working','blocked','done','failed','cancelled')),+ result_json TEXT,+ error_message TEXT,+ created_at TEXT NOT NULL,+ updated_at TEXT NOT NULL,+ title TEXT,+ thread_id TEXT,+ assigner_agent_id TEXT,+ display_id TEXT+);++INSERT INTO tasks_new (+ id, project_slug, agent_id, brief, success_criteria, deadline_iso,+ status, result_json, error_message, created_at, updated_at, title,+ thread_id, assigner_agent_id, display_id+)+SELECT+ id, project_slug, agent_id, brief, success_criteria, deadline_iso,+ CASE status+ WHEN 'running' THEN 'working'+ WHEN 'succeeded' THEN 'done'+ ELSE status+ END AS status,+ result_json, error_message, created_at, updated_at, title,+ thread_id, assigner_agent_id, display_id+FROM tasks;++DROP TABLE tasks;+ALTER TABLE tasks_new RENAME TO tasks;+CREATE INDEX IF NOT EXISTS idx_tasks_project ON tasks(project_slug);+CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(project_slug, status);+CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_display_id ON tasks(display_id);diff --git a/src/server/db/tasks.test.ts b/src/server/db/tasks.test.tsindex 9b9d6e30..a47f305f 100644--- a/src/server/db/tasks.test.ts+++ b/src/server/db/tasks.test.ts@@ -191,7 +191,7 @@ describe("listTasks", () => {`INSERT INTO tasks (id, display_id, project_slug, agent_id, brief, status, created_at, updated_at)VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,)- .run("t2", "acme-2", "acme", "x", "second", "running", "2026-01-02T00:00:00.000Z", "2026-01-02T00:00:00.000Z");+ .run("t2", "acme-2", "acme", "x", "second", "working", "2026-01-02T00:00:00.000Z", "2026-01-02T00:00:00.000Z");const rows = listTasks("acme");expect(rows.map((r) => r.brief)).toEqual(["second", "first"]);@@ -200,10 +200,10 @@ describe("listTasks", () => {it("filters by status when provided", () => {seedProject();createTask({ project_slug: "acme", agent_id: "x", brief: "p" });- createTask({ project_slug: "acme", agent_id: "x", brief: "r", status: "running" });+ createTask({ project_slug: "acme", agent_id: "x", brief: "r", status: "working" });expect(listTasks("acme", "proposed")).toHaveLength(1);- expect(listTasks("acme", "running")).toHaveLength(1);- expect(listTasks("acme", "succeeded")).toHaveLength(0);+ expect(listTasks("acme", "working")).toHaveLength(1);+ expect(listTasks("acme", "done")).toHaveLength(0);});it("isolates by project", () => {@@ -234,9 +234,9 @@ describe("listTasksByAgent", () => {project_slug: "acme",agent_id: "a1",brief: "r",- status: "running",+ status: "working",});- expect(listTasksByAgent("a1", "running")).toHaveLength(1);+ expect(listTasksByAgent("a1", "working")).toHaveLength(1);expect(listTasksByAgent("a1", "proposed")).toHaveLength(1);});@@ -259,19 +259,19 @@ describe("inFlightCountsByAgent", () => {project_slug: "acme",agent_id: "ads",brief: "3",- status: "running",+ status: "working",});createTask({project_slug: "acme",agent_id: "ads",brief: "4",- status: "succeeded",+ status: "done",});createTask({project_slug: "acme",agent_id: "seo",brief: "1",- status: "running",+ status: "working",});createTask({project_slug: "acme",@@ -293,7 +293,7 @@ describe("inFlightCountsByAgent", () => {it("returns an empty map when no in-flight tasks exist", () => {seedProject();- createTask({ project_slug: "acme", agent_id: "x", brief: "1", status: "succeeded" });+ createTask({ project_slug: "acme", agent_id: "x", brief: "1", status: "done" });const map = inFlightCountsByAgent("acme");expect(map.size).toBe(0);});@@ -357,12 +357,12 @@ describe("updateTask", () => {const t = createTask({ project_slug: "acme", agent_id: "x", brief: "b" });await new Promise((r) => setTimeout(r, 5));const out = updateTask(t.id, {- status: "succeeded",+ status: "done",result: { hello: "world" },error_message: null,});expect(out).not.toBeNull();- expect(out!.status).toBe("succeeded");+ expect(out!.status).toBe("done");expect(out!.result_json).toBe(JSON.stringify({ hello: "world" }));expect(out!.error_message).toBeNull();expect(Date.parse(out!.updated_at)).toBeGreaterThanOrEqual(@@ -389,7 +389,7 @@ describe("updateTask", () => {});it("returns null when task doesn't exist", () => {- expect(updateTask("missing", { status: "running" })).toBeNull();+ expect(updateTask("missing", { status: "working" })).toBeNull();});it("rejects invalid status via CHECK constraint", () => {@@ -408,7 +408,7 @@ describe("claimProposedTask", () => {const t = createTask({ project_slug: "acme", agent_id: "x", brief: "b" });const out = claimProposedTask(t.id);expect(out).not.toBeNull();- expect(out!.status).toBe("running");+ expect(out!.status).toBe("working");});it("returns null when the task is already past proposed", () => {@@ -417,7 +417,7 @@ describe("claimProposedTask", () => {project_slug: "acme",agent_id: "x",brief: "b",- status: "running",+ status: "working",});expect(claimProposedTask(t.id)).toBeNull();});@@ -425,9 +425,9 @@ describe("claimProposedTask", () => {it("returns null when the task is terminal (succeeded)", () => {seedProject();const t = createTask({ project_slug: "acme", agent_id: "x", brief: "b" });- updateTask(t.id, { status: "succeeded" });+ updateTask(t.id, { status: "done" });expect(claimProposedTask(t.id)).toBeNull();- expect(getTask(t.id)!.status).toBe("succeeded"); // not regressed+ expect(getTask(t.id)!.status).toBe("done"); // not regressed});it("returns null when the task doesn't exist", () => {@@ -437,7 +437,7 @@ describe("claimProposedTask", () => {it("is single-shot: a second call after a successful claim returns null", () => {seedProject();const t = createTask({ project_slug: "acme", agent_id: "x", brief: "b" });- expect(claimProposedTask(t.id)!.status).toBe("running");+ expect(claimProposedTask(t.id)!.status).toBe("working");expect(claimProposedTask(t.id)).toBeNull();});});@@ -450,7 +450,7 @@ describe("markTaskBlocked + unblockTask", () => {const blocked = markTaskBlocked(t.id);expect(blocked?.status).toBe("blocked");const unblocked = unblockTask(t.id);- expect(unblocked?.status).toBe("running");+ expect(unblocked?.status).toBe("working");});it("markTaskBlocked accepts proposed + approved as source states", () => {@@ -474,10 +474,10 @@ describe("markTaskBlocked + unblockTask", () => {project_slug: "acme",agent_id: "x",brief: "b",- status: "succeeded",+ status: "done",});const after = markTaskBlocked(t.id);- expect(after?.status).toBe("succeeded");+ expect(after?.status).toBe("done");});it("unblockTask is a no-op when the task isn't blocked", () => {@@ -485,7 +485,7 @@ describe("markTaskBlocked + unblockTask", () => {const t = createTask({ project_slug: "acme", agent_id: "x", brief: "b" });claimProposedTask(t.id);const after = unblockTask(t.id);- expect(after?.status).toBe("running"); // unchanged+ expect(after?.status).toBe("working"); // unchanged});it("inFlightCountsByAgent counts blocked tasks too", () => {diff --git a/src/server/db/tasks.ts b/src/server/db/tasks.tsindex 425a3291..a58947d2 100644--- a/src/server/db/tasks.ts+++ b/src/server/db/tasks.ts@@ -145,7 +145,7 @@ export function listTasksByAgent(agent_id: string, status?: TaskStatus): Task[]/*** Map of `agent_id → in-flight task count` for a single project. Drives the* sidebar's per-agent live-task badge. "In flight" means proposed (kickoff- * pending), approved, or running. Terminal states (succeeded/failed/cancelled)+ * pending), approved, working, or blocked. Terminal states (done/failed/cancelled)* never count.*/export function inFlightCountsByAgent(@@ -156,7 +156,7 @@ export function inFlightCountsByAgent(.prepare(`SELECT agent_id, COUNT(*) as countFROM tasks- WHERE project_slug = ? AND status IN ('proposed', 'approved', 'running', 'blocked')+ WHERE project_slug = ? AND status IN ('proposed', 'approved', 'working', 'blocked')GROUP BY agent_id`,).all(project_slug) as Array<{ agent_id: string; count: number }>;@@ -189,11 +189,11 @@ export function updateTask(id: string, update: UpdateTaskInput): Task | null {}/**- * Atomically flip a task from `proposed` to `running` and return the post-flip+ * Atomically flip a task from `proposed` to `working` and return the post-flip* row, or null when no claim happened (already started, already terminal, row* missing). The conditional WHERE clause is the whole point — callers* (kickoff entry points, "Start all" batch) can never accidentally regress a- * `succeeded`/`failed`/`cancelled` row back to `running` by passing in a+ * `done`/`failed`/`cancelled` row back to `working` by passing in a* stale in-memory task snapshot. better-sqlite3 is synchronous, so the* read-back here cannot race with a concurrent writer in this process.*/@@ -202,7 +202,7 @@ export function claimProposedTask(id: string): Task | null {const now = new Date().toISOString();const info = db.prepare(- "UPDATE tasks SET status = 'running', updated_at = ? WHERE id = ? AND status = 'proposed'",+ "UPDATE tasks SET status = 'working', updated_at = ? WHERE id = ? AND status = 'proposed'",).run(now, id);if (info.changes === 0) return null;@@ -210,28 +210,28 @@ export function claimProposedTask(id: string): Task | null {}/**- * Flip a running task to `blocked` (waiting on an approval). Only transitions- * from `running` or `proposed` so we don't undo a terminal state. Returns+ * Flip a working task to `blocked` (waiting on an approval). Only transitions+ * from `working` or `proposed` so we don't undo a terminal state. Returns* the post-flip row, or the current row when the transition didn't apply.*/export function markTaskBlocked(id: string): Task | null {const db = getDb();const now = new Date().toISOString();db.prepare(- "UPDATE tasks SET status = 'blocked', updated_at = ? WHERE id = ? AND status IN ('running','proposed','approved')",+ "UPDATE tasks SET status = 'blocked', updated_at = ? WHERE id = ? AND status IN ('working','proposed','approved')",).run(now, id);return getTask(id);}/**- * Flip a blocked task back to running once its approval resolves. No-op when+ * Flip a blocked task back to working once its approval resolves. No-op when* the task isn't blocked (e.g., already terminal because the user cancelled).*/export function unblockTask(id: string): Task | null {const db = getDb();const now = new Date().toISOString();db.prepare(- "UPDATE tasks SET status = 'running', updated_at = ? WHERE id = ? AND status = 'blocked'",+ "UPDATE tasks SET status = 'working', updated_at = ? WHERE id = ? AND status = 'blocked'",).run(now, id);return getTask(id);}diff --git a/src/server/mcp-server/jsonrpc.test.ts b/src/server/mcp-server/jsonrpc.test.tsindex 181324cc..e1dc5263 100644--- a/src/server/mcp-server/jsonrpc.test.ts+++ b/src/server/mcp-server/jsonrpc.test.ts@@ -110,7 +110,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {display_id: "demo-1",project_slug: "demo",agent_id: "demo-google-ads",- status: "running",+ status: "working",});const r = await call({jsonrpc: "2.0",@@ -133,7 +133,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {expect(updateTaskMock).toHaveBeenCalledWith("t-uuid",expect.objectContaining({- status: "succeeded",+ status: "done",result: { summary: "shipped the change" },}),);@@ -151,7 +151,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {display_id: "x-1",project_slug: "x",agent_id: "x-agent",- status: "running",+ status: "working",});await call({jsonrpc: "2.0",@@ -179,7 +179,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {display_id: "x-1",project_slug: "x",agent_id: "x-agent",- status: "running",+ status: "working",});await call({jsonrpc: "2.0",@@ -235,7 +235,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {display_id: "x-1",project_slug: "demo",agent_id: "demo-google-ads",- status: "running",+ status: "working",});const r = await call({jsonrpc: "2.0",@@ -265,7 +265,7 @@ describe("handleJsonRpc — tools/call submit_task_status", () => {display_id: "x-1",project_slug: "x",agent_id: "x-agent",- status: "succeeded",+ status: "done",});const r = await call({jsonrpc: "2.0",diff --git a/src/server/mcp-server/tools.ts b/src/server/mcp-server/tools.tsindex 42629c5e..e502aac7 100644--- a/src/server/mcp-server/tools.ts+++ b/src/server/mcp-server/tools.ts@@ -289,9 +289,9 @@ async function handleGetTaskTool(input: unknown): Promise<ToolResult> {const TASK_STATUS_FILTER_VALUES = ["proposed","approved",- "running",+ "working","blocked",- "succeeded",+ "done","failed","cancelled","in_flight",@@ -334,9 +334,9 @@ const listTasksInput = z.object({.enum(["proposed","approved",- "running",+ "working","blocked",- "succeeded",+ "done","failed","cancelled",])diff --git a/src/server/onboarding/accounts.test.ts b/src/server/onboarding/accounts.test.tsindex e86e12d7..7095d70c 100644--- a/src/server/onboarding/accounts.test.ts+++ b/src/server/onboarding/accounts.test.ts@@ -223,7 +223,7 @@ describe("setOnboardingAccountAction", () => {project_slug: "acme",agent_id: "acme-cmo",title: "Audit the account and propose a starter playbook",- status: "running",+ status: "working",},]);const r = await setOnboardingAccountAction("acme", "3251706605");diff --git a/src/server/orchestration/approval-wakeup.test.ts b/src/server/orchestration/approval-wakeup.test.tsindex 2ca5add6..7f113e43 100644--- a/src/server/orchestration/approval-wakeup.test.ts+++ b/src/server/orchestration/approval-wakeup.test.ts@@ -106,7 +106,7 @@ describe("wakeTaskOnApprovalResolution", () => {});it("is a no-op when the task is terminal (succeeded/failed/cancelled)", async () => {- getTaskMock.mockReturnValue(makeTask({ status: "succeeded" }));+ getTaskMock.mockReturnValue(makeTask({ status: "done" }));await wakeTaskOnApprovalResolution(makeApproval());expect(streamMock).not.toHaveBeenCalled();expect(unblockTaskMock).not.toHaveBeenCalled();diff --git a/src/server/orchestration/approval-wakeup.ts b/src/server/orchestration/approval-wakeup.tsindex 2c885f91..f3637355 100644--- a/src/server/orchestration/approval-wakeup.ts+++ b/src/server/orchestration/approval-wakeup.ts@@ -32,7 +32,7 @@ export async function wakeTaskOnApprovalResolution(approval: Approval): Promise<// Don't restart agents on terminal tasks — the user may have cancelled// while the approval was outstanding.if (- task.status === "succeeded" ||+ task.status === "done" ||task.status === "failed" ||task.status === "cancelled") {diff --git a/src/server/orchestration/handlers.test.ts b/src/server/orchestration/handlers.test.tsindex 56813ba7..07bafe46 100644--- a/src/server/orchestration/handlers.test.ts+++ b/src/server/orchestration/handlers.test.ts@@ -36,7 +36,7 @@ vi.mock("@/server/agent-meta", () => ({vi.mock("./run-task", () => ({startTaskIfProposed: (task: { id: string; status: string }) => ({...task,- status: "running",+ status: "working",}),}));@@ -213,7 +213,7 @@ describe("handleTaskStatus — cannot-close-with-pending-approval invariant", (){ task_id: t.id, status: "done", summary: "shipped" },{ project_slug: "demo", agent_id: "demo-google-ads" },);- expect(r.ok && r.data.status).toBe("succeeded");+ expect(r.ok && r.data.status).toBe("done");});});@@ -221,7 +221,7 @@ describe("handleListMyTasks", () => {it("returns only in-flight tasks by default, filtered to this project + agent", () => {createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "a", title: "A" });const t2 = createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "b", title: "B" });- testDb.prepare("UPDATE tasks SET status='succeeded' WHERE id = ?").run(t2.id);+ testDb.prepare("UPDATE tasks SET status='done' WHERE id = ?").run(t2.id);createTask({ project_slug: "demo", agent_id: "demo-seo", brief: "not mine" });createTask({ project_slug: "other", agent_id: "other-google-ads", brief: "other proj" });@@ -237,7 +237,7 @@ describe("handleListMyTasks", () => {it("status='all' returns terminal + in-flight", () => {createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "a", title: "A" });const t2 = createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "b", title: "B" });- testDb.prepare("UPDATE tasks SET status='succeeded' WHERE id = ?").run(t2.id);+ testDb.prepare("UPDATE tasks SET status='done' WHERE id = ?").run(t2.id);const r = handleListMyTasks({ status: "all" },@@ -246,13 +246,13 @@ describe("handleListMyTasks", () => {expect(r.ok && r.data.length).toBe(2);});- it("status='succeeded' narrows", () => {+ it("status='done' narrows", () => {const t1 = createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "a" });- testDb.prepare("UPDATE tasks SET status='succeeded' WHERE id = ?").run(t1.id);+ testDb.prepare("UPDATE tasks SET status='done' WHERE id = ?").run(t1.id);createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "b" });const r = handleListMyTasks(- { status: "succeeded" },+ { status: "done" },{ project_slug: "demo", agent_id: "demo-google-ads" },);expect(r.ok && r.data.length).toBe(1);@@ -311,7 +311,7 @@ describe("handleUpdateTask", () => {describe("handleCancelTask", () => {it("flips a running task to cancelled with reason", () => {const t = createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "x" });- testDb.prepare("UPDATE tasks SET status='running' WHERE id = ?").run(t.id);+ testDb.prepare("UPDATE tasks SET status='working' WHERE id = ?").run(t.id);const r = handleCancelTask({ task_id: t.id, reason: "no longer needed" },{ project_slug: "demo", agent_id: "demo-cmo" },@@ -322,12 +322,12 @@ describe("handleCancelTask", () => {it("is a no-op on already-terminal tasks", () => {const t = createTask({ project_slug: "demo", agent_id: "demo-google-ads", brief: "x" });- testDb.prepare("UPDATE tasks SET status='succeeded' WHERE id = ?").run(t.id);+ testDb.prepare("UPDATE tasks SET status='done' WHERE id = ?").run(t.id);const r = handleCancelTask({ task_id: t.id },{ project_slug: "demo", agent_id: "demo-cmo" },);- expect(r.ok && r.data.status).toBe("succeeded");+ expect(r.ok && r.data.status).toBe("done");});});@@ -430,15 +430,15 @@ describe("enum discovery handlers", () => {expect(r.ok).toBe(true);if (!r.ok) return;expect(r.data.map((s) => s.value).sort()).toEqual(- ["approved", "blocked", "cancelled", "failed", "proposed", "running", "succeeded"].sort(),+ ["approved", "blocked", "cancelled", "failed", "proposed", "working", "done"].sort(),);- const succeeded = r.data.find((s) => s.value === "succeeded")!;+ const succeeded = r.data.find((s) => s.value === "done")!;expect(succeeded.terminal).toBe(true);expect(succeeded.next).toEqual([]);- const running = r.data.find((s) => s.value === "running")!;+ const running = r.data.find((s) => s.value === "working")!;expect(running.terminal).toBe(false);expect(running.next).toContain("blocked");- expect(running.next).toContain("succeeded");+ expect(running.next).toContain("done");});it("list_approval_action_types marks cost-required types", () => {diff --git a/src/server/orchestration/handlers.ts b/src/server/orchestration/handlers.tsindex 87b53f11..70f82f4b 100644--- a/src/server/orchestration/handlers.ts+++ b/src/server/orchestration/handlers.ts@@ -175,14 +175,14 @@ export function handleTaskStatus(if (task.status === "cancelled" ||task.status === "failed" ||- task.status === "succeeded"+ task.status === "done") {return { ok: true, data: { task_id: task.id, status: task.status } };}// Closing a task that's gated on an unresolved approval is almost always// a mistake — the agent thinks "I queued the approval, my work is done"- // and prematurely marks the task succeeded, orphaning the approval in the+ // and prematurely marks the task done, orphaning the approval in the// inbox. Refuse the transition and tell the agent what's blocking it.// The exception is `failed`, which we DO allow even with pending// approvals (an agent should be able to bail out of a stuck flow).@@ -199,14 +199,9 @@ export function handleTaskStatus(}}- const newStatus: TaskStatus =- input.status === "working"- ? "running"- : input.status === "done"- ? "succeeded"- : input.status === "blocked"- ? "blocked"- : "failed";+ // No mapping layer anymore: the agent-facing enum (working/done/blocked/+ // failed) IS the DB enum. Migration 007 unified the vocabularies.+ const newStatus: TaskStatus = input.status;updateTask(task.id, {status: newStatus,@@ -418,7 +413,7 @@ export function handleListMyTasks(const inFlight = new Set<TaskStatus>(["proposed","approved",- "running",+ "working","blocked",]);all = all.filter((t) => inFlight.has(t.status));@@ -518,7 +513,7 @@ export function handleCancelTask(};}if (- task.status === "succeeded" ||+ task.status === "done" ||task.status === "failed" ||task.status === "cancelled") {@@ -667,11 +662,11 @@ export type TaskStatusInfo = {};const TASK_STATUS_INFO: TaskStatusInfo[] = [- { value: "proposed", description: "Task created, awaiting kickoff or user approval.", terminal: false, next: ["approved", "running", "cancelled"] },- { value: "approved", description: "User approved a guarded task; ready for the assignee to pick up.", terminal: false, next: ["running", "cancelled"] },- { value: "running", description: "Assignee is actively working.", terminal: false, next: ["blocked", "succeeded", "failed", "cancelled"] },- { value: "blocked", description: "Waiting on a user decision, an approval, or a missing input.", terminal: false, next: ["running", "succeeded", "failed", "cancelled"] },- { value: "succeeded", description: "Task complete (terminal).", terminal: true, next: [] },+ { value: "proposed", description: "Task created, awaiting kickoff or user approval.", terminal: false, next: ["approved", "working", "cancelled"] },+ { value: "approved", description: "User approved a guarded task; ready for the assignee to pick up.", terminal: false, next: ["working", "cancelled"] },+ { value: "working", description: "Assignee is actively working.", terminal: false, next: ["blocked", "done", "failed", "cancelled"] },+ { value: "blocked", description: "Waiting on a user decision, an approval, or a missing input.", terminal: false, next: ["working", "done", "failed", "cancelled"] },+ { value: "done", description: "Task complete (terminal).", terminal: true, next: [] },{ value: "failed", description: "Task could not complete (terminal). error_message has the reason.", terminal: true, next: [] },{ value: "cancelled", description: "User or CMO cancelled before completion (terminal).", terminal: true, next: [] },];diff --git a/src/server/orchestration/run-task.test.ts b/src/server/orchestration/run-task.test.tsindex 146f85cb..42a01815 100644--- a/src/server/orchestration/run-task.test.ts+++ b/src/server/orchestration/run-task.test.ts@@ -76,7 +76,7 @@ describe("startTaskIfProposed", () => {it("returns the input task untouched when the claim fails (already running)", () => {claimProposedTaskMock.mockReturnValue(null);- const task = makeTask({ status: "running" });+ const task = makeTask({ status: "working" });const result = startTaskIfProposed(task);expect(result).toBe(task);// Kickoff must not be triggered when the claim doesn't succeed.@@ -84,7 +84,7 @@ describe("startTaskIfProposed", () => {});it("returns the claimed task and fires kickoff in the background when claim succeeds", async () => {- const claimed = makeTask({ status: "running" });+ const claimed = makeTask({ status: "working" });claimProposedTaskMock.mockReturnValue(claimed);const result = startTaskIfProposed(makeTask({ status: "proposed" }));@@ -98,7 +98,7 @@ describe("startTaskIfProposed", () => {it("swallows kickoff errors so the caller (synchronous) never throws", async () => {const errSpy = vi.spyOn(console, "error").mockImplementation(() => {});- const claimed = makeTask({ status: "running", thread_id: null });+ const claimed = makeTask({ status: "working", thread_id: null });claimProposedTaskMock.mockReturnValue(claimed);// Force the kickoff to throw — thread assignment will fail because both// claim + setTaskThreadIfMissing return null.diff --git a/src/server/orchestration/task-kickoff.test.ts b/src/server/orchestration/task-kickoff.test.tsindex e60b851a..189236d6 100644--- a/src/server/orchestration/task-kickoff.test.ts+++ b/src/server/orchestration/task-kickoff.test.ts@@ -14,7 +14,7 @@ function makeTask(overrides: Partial<Task> = {}): Task {brief: "Add the Google Ads conversion tag to /thanks.",success_criteria: "Tag fires on /thanks and a test conv lands in Google Ads.",deadline_iso: null,- status: "running",+ status: "working",result_json: null,error_message: null,thread_id: "thread-1",diff --git a/src/types/index.ts b/src/types/index.tsindex 0fb7a93e..f6fcb620 100644--- a/src/types/index.ts+++ b/src/types/index.ts@@ -19,9 +19,9 @@ export type Project = {export type TaskStatus =| "proposed"| "approved"- | "running"+ | "working"| "blocked"- | "succeeded"+ | "done"| "failed"| "cancelled";