fix: auto-assign tasks to PM agent when moved to in_progress, fix datetime serialization in WebSocket, add executor logging
This commit is contained in:
@@ -74,24 +74,44 @@ async def websocket_endpoint(websocket: WebSocket):
|
||||
|
||||
async def broadcast_task_update(task_id: int, action: str, task_data: dict):
|
||||
"""Broadcast task update to all connected clients"""
|
||||
# Serialize datetime objects to ISO format
|
||||
serialized_data = task_data.copy()
|
||||
for key in ["created_at", "updated_at", "completed_at", "due_date"]:
|
||||
if serialized_data.get(key):
|
||||
serialized_data[key] = serialized_data[key].isoformat() if hasattr(serialized_data[key], 'isoformat') else serialized_data[key]
|
||||
|
||||
timestamp = task_data.get("updated_at")
|
||||
if timestamp and hasattr(timestamp, 'isoformat'):
|
||||
timestamp = timestamp.isoformat()
|
||||
|
||||
message = {
|
||||
"type": "task_update",
|
||||
"task_id": task_id,
|
||||
"action": action, # created, updated, moved, deleted
|
||||
"data": task_data,
|
||||
"timestamp": task_data.get("updated_at")
|
||||
"data": serialized_data,
|
||||
"timestamp": timestamp
|
||||
}
|
||||
await manager.broadcast(message)
|
||||
|
||||
|
||||
async def broadcast_agent_execution(execution_id: int, status: str, execution_data: dict):
|
||||
"""Broadcast agent execution update"""
|
||||
# Serialize datetime objects to ISO format
|
||||
serialized_data = execution_data.copy()
|
||||
for key in ["started_at", "completed_at"]:
|
||||
if serialized_data.get(key):
|
||||
serialized_data[key] = serialized_data[key].isoformat() if hasattr(serialized_data[key], 'isoformat') else serialized_data[key]
|
||||
|
||||
timestamp = execution_data.get("started_at") or execution_data.get("completed_at")
|
||||
if timestamp and hasattr(timestamp, 'isoformat'):
|
||||
timestamp = timestamp.isoformat()
|
||||
|
||||
message = {
|
||||
"type": "agent_execution",
|
||||
"execution_id": execution_id,
|
||||
"status": status, # pending, running, completed, failed, pending_approval
|
||||
"data": execution_data,
|
||||
"timestamp": execution_data.get("started_at") or execution_data.get("completed_at")
|
||||
"data": serialized_data,
|
||||
"timestamp": timestamp
|
||||
}
|
||||
await manager.broadcast(message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user