diff --git a/comfyui_manager/data_models/generated_models.py b/comfyui_manager/data_models/generated_models.py index c5d7f293..33450409 100644 --- a/comfyui_manager/data_models/generated_models.py +++ b/comfyui_manager/data_models/generated_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2025-06-21T23:28:48+00:00 +# timestamp: 2025-06-21T23:40:24+00:00 from __future__ import annotations @@ -476,6 +476,12 @@ class TaskHistoryItem(BaseModel): timestamp: datetime = Field(..., description="ISO timestamp when task completed") result: str = Field(..., description="Task result message or details") status: Optional[TaskExecutionStatus] = None + batch_id: Optional[str] = Field( + None, description="ID of the batch this task belongs to" + ) + end_time: Optional[datetime] = Field( + None, description="ISO timestamp when task execution ended" + ) class TaskStateMessage(BaseModel): diff --git a/comfyui_manager/glob/manager_server.py b/comfyui_manager/glob/manager_server.py index e904efd0..1814e076 100644 --- a/comfyui_manager/glob/manager_server.py +++ b/comfyui_manager/glob/manager_server.py @@ -313,7 +313,8 @@ class TaskQueue: """Mark task as completed and add to history""" with self.mutex: - timestamp = datetime.now().isoformat() + now = datetime.now() + timestamp = now.isoformat() # Remove task from running_tasks using the task_index self.running_tasks.pop(task_index, None) @@ -334,10 +335,12 @@ class TaskQueue: self.history_tasks[item.ui_id] = TaskHistoryItem( ui_id=item.ui_id, client_id=item.client_id, - timestamp=datetime.fromisoformat(timestamp), + timestamp=now, result=result_msg, kind=item.kind, status=status, + batch_id=self.batch_id, + end_time=now, ) # Force cache refresh for successful pack-modifying operations @@ -735,6 +738,10 @@ class TaskQueue: try: for ui_id, task in self.history_tasks.items(): + # Only include operations from the current batch + if task.batch_id != self.batch_id: + continue + result_status = OperationResult.success if task.status: status_str = ( @@ -755,6 +762,7 @@ class TaskQueue: target=f"task_{ui_id}", result=result_status.value, start_time=task.timestamp, + end_time=task.end_time, client_id=task.client_id, ) operations.append(operation) diff --git a/openapi.yaml b/openapi.yaml index cb362c9b..fb88960a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -71,6 +71,13 @@ components: description: Task result message or details status: $ref: '#/components/schemas/TaskExecutionStatus' + batch_id: + type: [string, 'null'] + description: ID of the batch this task belongs to + end_time: + type: [string, 'null'] + format: date-time + description: ISO timestamp when task execution ended required: [ui_id, client_id, kind, timestamp, result] TaskExecutionStatus: type: object