feat(agent): add task cancellation with stop button
Users can now interrupt running agents via a "Stop" button on the live
card. The daemon polls task status every 5 seconds and kills the agent
process when cancellation is detected.
Changes:
- New CancelAgentTask SQL query and CancelTask service method
- POST /api/issues/{id}/tasks/{taskId}/cancel endpoint
- Daemon polls GetTaskStatus during execution, cancels context on match
- Frontend: Stop button on AgentLiveCard, task:cancelled WS event
This commit is contained in:
parent
3b6f64ba8e
commit
365b5b5f0e
10 changed files with 173 additions and 4 deletions
|
|
@ -107,6 +107,12 @@ WHERE (status = 'dispatched' AND dispatched_at < now() - make_interval(secs => @
|
|||
OR (status = 'running' AND started_at < now() - make_interval(secs => @running_timeout_secs::double precision))
|
||||
RETURNING id, agent_id, issue_id;
|
||||
|
||||
-- name: CancelAgentTask :one
|
||||
UPDATE agent_task_queue
|
||||
SET status = 'cancelled', completed_at = now()
|
||||
WHERE id = $1 AND status IN ('queued', 'dispatched', 'running')
|
||||
RETURNING *;
|
||||
|
||||
-- name: CountRunningTasks :one
|
||||
SELECT count(*) FROM agent_task_queue
|
||||
WHERE agent_id = $1 AND status IN ('dispatched', 'running');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue