Skip to content

Conversation

ric-yu
Copy link

@ric-yu ric-yu commented Jul 12, 2025

Context

This PR refactors the /history_v2 API endpoints to improve scalability and usability by compacting responses, preparing for pagination support, and enhancing data clarity.

This PR

  • Introduces a /history_v2 endpoint that:
    • provides historys in an array, so the order of histories is explicit
    • removes unused fields to reduce the size of the response
    • clarifies the prompt response by returning it as a JSON object
    • is returned as a JSON object to allow room for more properties (e.g. pagination support)
  • Introduces a /history_v2/:prompt_id that:
    • clarifies the prompt response by returning it as a JSON object
    • allows us to fetch individual workflows for prompts (they are no longer included in the /history_v2 response)

Screen recording

Copy link
Collaborator

@christian-byrne christian-byrne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

guill
guill previously approved these changes Jul 19, 2025
Copy link
Collaborator

@guill guill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@guill
Copy link
Collaborator

guill commented Jul 19, 2025

(Other than the failingruff check due to whitespace issues.)

@ric-yu ric-yu force-pushed the update-history-api-to-array branch from 2e13882 to 94684db Compare July 20, 2025 21:11
@ric-yu
Copy link
Author

ric-yu commented Jul 20, 2025

Rebasing off latest master

Copy link
Collaborator

@guill guill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

In the future though, once you've received some reviews, please merge master in rather than rebasing. Rebasing (and the required force push associated with it) make it difficult to see what's changed or to reference old comments on code.

prompt_id = request.match_info.get("prompt_id", None)
return web.json_response(self.prompt_queue.get_history(prompt_id=prompt_id))

@routes.get("/history_v2")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a better name like ordered_history

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the decision was to use this name because we're moving from the old endpoint later on cc: @webfiltered @guill to confirm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the intention was to deprecate the /history endpoint eventually in favor of this one (so we don't have to maintain both).

I don't have a particularly strong opinion on the name though. Any of:

  • history_v2
  • history_info
  • workflow_history
  • user_history
  • prompt_history
  • ordered_history
    seem reasonable to me.


return web.json_response(self.prompt_queue.get_ordered_history(max_items=max_items, offset=offset))

@routes.get("/history_v2/{prompt_id}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we agreed we'd update this endpoint as well cc: @guill @webfiltered

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was specifically my recommendation to avoid a case where people need to remember to use one endpoint for the list and one for individual items (which goes against normal REST principles). It's much easier if we're just able to say "move to this new endpoint as we'll be deprecating /history eventually".

I don't have a strong opinion on the specific name we use, but do strongly feel we should keep this route to preserve consistency.

@comfyanonymous
Copy link
Owner

b850d9a

Use this and remove everything from execution.py

@ric-yu
Copy link
Author

ric-yu commented Aug 3, 2025

b850d9a

Use this and remove everything from execution.py

Sounds good, I'll make this change

@ric-yu ric-yu marked this pull request as draft August 3, 2025 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants