ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Add unified jobs API with /api/jobs endpoints

Open ric-yu opened this issue 1 month ago • 4 comments

Summary

  • Add GET /api/jobs endpoint with filtering, sorting, and pagination
    • Filter by status: pending, in_progress, completed, error
    • Sort by create_time or execution_time
    • Pagination via limit/offset
  • Add GET /api/jobs/{job_id} for single job details with full outputs
  • Track execution_time in history for completed jobs
  • Include outputs_count and preview_output in job responses
  • Preview logic matches frontend (prefers type=output, supports images/video/audio/3D)

Motivation

Currently /queue and /history are separate endpoints with different response shapes. This unified API provides:

  • Consistent job representation across all states
  • Proper pagination and filtering
  • Summary fields (outputs_count, preview_output) for list views without fetching full outputs

Test plan

  • [x] Run existing tests: pytest tests/execution/test_execution.py -v
  • [x] Verify /api/jobs returns jobs from queue and history on https://www.github.com/Comfy-Org/ComfyUI_frontend/commit/a57ea57a09a274efdc8444b949452509d7cf49de
  • [x] Verify /api/jobs/{id} returns full job with outputs
  • [x] Verify execution_time is tracked for completed jobs

ric-yu avatar Dec 02 '25 19:12 ric-yu

Rebasing

ric-yu avatar Dec 04 '25 20:12 ric-yu

Can you test this properly? The endpoint doesn't work after I run a regular workflow.

comfyanonymous avatar Dec 05 '25 04:12 comfyanonymous

Can you test this properly? The endpoint doesn't work after I run a regular workflow.

Fixed an issue with preview as text. This endpoint has been working for me otherwise, but I'm stuck with testing light workflows since I'm on a Mac

ric-yu avatar Dec 09 '25 03:12 ric-yu

rebasing

ric-yu avatar Dec 12 '25 00:12 ric-yu