The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Only show last 200 elements in the UI history tab.
comfyanonymous2dd5b4dd78fc
diff --git a/execution.py b/execution.pyindex 9a2ca5b9d..bca48a785 100644--- a/execution.py+++ b/execution.py@@ -750,10 +750,20 @@ class PromptQueue:return Truereturn False- def get_history(self, prompt_id=None):+ def get_history(self, prompt_id=None, max_items=None, offset=-1):with self.mutex:if prompt_id is None:- return copy.deepcopy(self.history)+ out = {}+ i = 0+ if offset < 0 and max_items is not None:+ offset = len(self.history) - max_items+ for k in self.history:+ if i >= offset:+ out[k] = self.history[k]+ if max_items is not None and len(out) >= max_items:+ break+ i += 1+ return outelif prompt_id in self.history:return {prompt_id: copy.deepcopy(self.history[prompt_id])}else:diff --git a/server.py b/server.pyindex 11bd2a0fb..1a8e92b8f 100644--- a/server.py+++ b/server.py@@ -431,7 +431,10 @@ class PromptServer():@routes.get("/history")async def get_history(request):- return web.json_response(self.prompt_queue.get_history())+ max_items = request.rel_url.query.get("max_items", None)+ if max_items is not None:+ max_items = int(max_items)+ return web.json_response(self.prompt_queue.get_history(max_items=max_items))@routes.get("/history/{prompt_id}")async def get_history(request):diff --git a/web/scripts/api.js b/web/scripts/api.jsindex b1d245d73..de56b2310 100644--- a/web/scripts/api.js+++ b/web/scripts/api.js@@ -256,7 +256,7 @@ class ComfyApi extends EventTarget {*/async getHistory() {try {- const res = await this.fetchApi("/history");+ const res = await this.fetchApi("/history?max_items=200");return { History: Object.values(await res.json()) };} catch (error) {console.error(error);