Open-source SEO, GEO, and marketing skills for AI agents.
fix
Yuting Zhonge6e73e08c315
diff --git a/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx b/src/app/(app)/[project]/agents/[agent]/tasks/page.tsxindex 278eaa0b..82398e57 100644--- a/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx+++ b/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx@@ -10,8 +10,7 @@ import {type TranscriptEvent,} from "@/server/openclaw/transcript-tail";import { generateTaskThreadId } from "@/server/orchestration/process-blocks";-import { claimTaskIfProposed } from "@/server/orchestration/run-task";-import { buildTaskKickoffMessage } from "@/server/orchestration/task-kickoff";+import { startTaskIfProposed } from "@/server/orchestration/run-task";import type { Task } from "@/types";type Props = {@@ -25,13 +24,6 @@ type SelectedBundle = {sessionKey: string;initialEvents: TranscriptEvent[];initialByteOffset: number;- /**- * When set, the client should auto-send this message via /api/chat to- * kick the task off — that path streams agent tokens as SSE in real- * time. Only populated when this page-load is the one that flipped the- * task from proposed to running.- */- kickoffMessage: string | null;};export default async function AgentTasksPage({ params, searchParams }: Props) {@@ -88,14 +80,9 @@ async function loadSelectedBundle(if (!task.thread_id) return null;const threadId = task.thread_id;- // Claim proposed → running but DON'T fire the server-side kickoff. The- // client will send the kickoff message through /api/chat so the agent's- // tokens stream live as SSE deltas. No-op when the task isn't proposed,- // so reloading the page doesn't restart it. The justClaimed flag tells us- // whether this page-load is the one that should drive the kickoff.- const { task: nextTask, justClaimed } = claimTaskIfProposed(task);- task = nextTask;- const kickoffMessage = justClaimed ? buildTaskKickoffMessage(task) : null;+ // Atomically transition proposed → running and fire the kickoff. No-op+ // when the task isn't proposed, so reloading the page doesn't restart.+ task = startTaskIfProposed(task);// Resolve canonical sessionKey for /api/chat composer sends (when task// is done and user wants to keep chatting). The pending key is a safe@@ -112,6 +99,5 @@ async function loadSelectedBundle(sessionKey,initialEvents: events,initialByteOffset: byteOffset,- kickoffMessage,};}diff --git a/src/components/agent-task-workspace.tsx b/src/components/agent-task-workspace.tsxindex 51b44b7d..63593ed9 100644--- a/src/components/agent-task-workspace.tsx+++ b/src/components/agent-task-workspace.tsx@@ -53,13 +53,6 @@ type SelectedTaskBundle = {sessionKey: string;initialEvents: TranscriptEvent[];initialByteOffset: number;- /**- * Server-built kickoff prompt. Non-null only when this page-load was the- * one that flipped the task from proposed → running; the client fires it- * via /api/chat so the agent's response streams as SSE deltas in real- * time instead of arriving as a single JSONL-flushed wall of text.- */- kickoffMessage: string | null;};type Props = {@@ -314,8 +307,6 @@ function SelectedTaskPanel({initialByteOffset={selected.initialByteOffset}composerDisabled={isInFlight}onPolled={onPolled}- autoKickoff={!!selected.kickoffMessage}- kickoffMessage={selected.kickoffMessage ?? undefined}/>);}diff --git a/src/server/orchestration/run-task.ts b/src/server/orchestration/run-task.tsindex 27a830b3..78864467 100644--- a/src/server/orchestration/run-task.ts+++ b/src/server/orchestration/run-task.ts@@ -11,16 +11,14 @@ import { buildTaskKickoffMessage } from "./task-kickoff";/*** Idempotent "claim and kickoff" — flips a proposed task to running and* fires the server-side kickoff. No-op when the task isn't proposed (already- * started, already done, etc.). Used by sub-task delegation paths (CMO- * creates a task for a specialist, no client is watching) and the "Start- * all" batch button.+ * started, already done, etc.). Used by the agent workspace so opening a+ * proposed task auto-starts it the same way "Start all" does for batches,+ * without bouncing through the chat client.*- * The kickoff itself runs fire-and-forget — callers shouldn't await it.- * Since the gateway stream is consumed server-side, the page only sees- * tokens once OpenClaw flushes the complete assistant message to JSONL- * (typically when the turn ends). For tasks the user is actively watching- * in the workspace, prefer `claimTaskIfProposed` and let the client run the- * kickoff via `/api/chat` so SSE deltas stream live.+ * Returns the post-transition task (still proposed if no claim happened, or+ * running on success). The kickoff itself runs fire-and-forget — callers+ * shouldn't await it; the workspace's live transcript polling will reveal+ * progress.*/export function startTaskIfProposed(task: Task): Task {if (task.status !== "proposed") return task;@@ -32,26 +30,6 @@ export function startTaskIfProposed(task: Task): Task {return claimed;}-/**- * Flip a proposed task to running without firing the gateway. Used by the- * task workspace so opening a proposed task immediately reflects "running"- * in the UI while the client drives the kickoff itself via `/api/chat` —- * that path streams the agent's tokens as SSE so the user sees the response- * forming in real time instead of a wall of text dumping in at the end.- *- * Returns the (possibly-claimed) task plus a `justClaimed` flag the page- * uses to decide whether the client should auto-send the kickoff message.- */-export function claimTaskIfProposed(task: Task): {- task: Task;- justClaimed: boolean;-} {- if (task.status !== "proposed") return { task, justClaimed: false };- const claimed = updateTask(task.id, { status: "running" });- if (!claimed) return { task, justClaimed: false };- return { task: claimed, justClaimed: true };-}-/*** Server-side kickoff for a task. Consumes the full gateway stream (no SSE* pipe to a client) and applies orchestration blocks the assignee emits.