feat: add task cancellation feature (task-management)
- Backend: Add API endpoint to cancel tasks and mark status as cancelled - Frontend: Add cancel button to task management UI (visible only for cancellable tasks) - Process: Implement cancellation check during generation to abort in-progress tasks - UI: Update status display styles with a visual indicator for the cancelled state
This commit is contained in:
@@ -21,3 +21,19 @@ def get_project_tasks(project_id: str, session: Session = Depends(get_session)):
|
||||
# Filter only recent or active tasks if list is too long?
|
||||
# For now return all, maybe limit 20
|
||||
return tasks[:20]
|
||||
|
||||
@router.post("/{task_id}/cancel", response_model=TaskRead)
|
||||
def cancel_task(task_id: str, session: Session = Depends(get_session)):
|
||||
task = session.get(Task, task_id)
|
||||
if not task:
|
||||
raise HTTPException(status_code=404, detail="Task not found")
|
||||
|
||||
if task.status in ["completed", "failed", "cancelled"]:
|
||||
return task
|
||||
|
||||
task.status = "cancelled"
|
||||
task.message = "Task cancelled by user"
|
||||
session.add(task)
|
||||
session.commit()
|
||||
session.refresh(task)
|
||||
return task
|
||||
Reference in New Issue
Block a user