auto-sync: 2026-05-17 13:06:14
This commit is contained in:
@@ -90,9 +90,24 @@ async def claim_task(project_id: str, task_id: str, body: Dict[str, Any]):
|
||||
@router.post("/tasks/{task_id}/status")
|
||||
async def update_status(project_id: str, task_id: str, body: Dict[str, Any]):
|
||||
bb = _bb(project_id)
|
||||
old_task = bb.get_task(task_id)
|
||||
if not bb.update_task_status(task_id, body["status"],
|
||||
agent=body.get("agent")):
|
||||
raise HTTPException(409, f"Invalid transition to {body['status']}")
|
||||
# SSE 推送
|
||||
try:
|
||||
from src.api.sse_routes import get_broker
|
||||
broker = get_broker()
|
||||
broker.publish({
|
||||
"type": "task_updated",
|
||||
"project_id": project_id,
|
||||
"task_id": task_id,
|
||||
"old_status": old_task.status if old_task else None,
|
||||
"new_status": body["status"],
|
||||
"agent": body.get("agent"),
|
||||
}, event_type="task_updated")
|
||||
except Exception:
|
||||
pass # SSE 是可选的,不影响主流程
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user