From c34cdb690dfe2532a64134cf5b6a2f94f82d0b62 Mon Sep 17 00:00:00 2001 From: bymyself Date: Wed, 28 Oct 2026 01:11:09 +0000 Subject: [PATCH 1/6] test: job detail returns each node's execution meta --- tests/execution/test_jobs.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/execution/test_jobs.py b/tests/execution/test_jobs.py index 5086f18b7fd..47079791a7d 100644 --- a/tests/execution/test_jobs.py +++ b/tests/execution/test_jobs.py @@ -683,6 +683,37 @@ def test_include_outputs(self): 'extra_data': {'create_time': 1234567890, 'client_id': 'abc'}, } + def test_include_outputs_returns_execution_meta(self): + """Detail view should expose each node's display node as execution_meta.""" + meta = { + '15.0.0.3': {'node_id': '3', 'display_node': '15', 'parent_node': '15', 'real_node_id': '3'}, + '9': {'node_id': '9', 'display_node': '9', 'parent_node': None, 'real_node_id': '9'}, + } + history_item = { + 'prompt': (5, 'prompt-meta', {}, {'create_time': 1234567890}, ['9']), + 'status': {'status_str': 'success', 'completed': True, 'messages': []}, + 'outputs': {'9': {'images': [{'filename': 'a.png'}]}}, + 'meta': meta, + } + + detail = normalize_history_item('prompt-meta', history_item, include_outputs=True) + summary = normalize_history_item('prompt-meta', history_item) + + assert detail['execution_meta'] == meta + assert 'execution_meta' not in summary + + def test_include_outputs_without_meta(self): + """History written before meta existed should still give an object.""" + history_item = { + 'prompt': (5, 'prompt-old', {}, {'create_time': 1234567890}, []), + 'status': {'status_str': 'success', 'completed': True, 'messages': []}, + 'outputs': {}, + } + + job = normalize_history_item('prompt-old', history_item, include_outputs=True) + + assert job['execution_meta'] == {} + def test_include_outputs_normalizes_3d_strings(self): """Detail view should transform string 3D filenames into file output dicts.""" history_item = { From 7d20cb9734cb72be12fe8ca05770a6aa6f8eeff9 Mon Sep 17 00:00:00 2001 From: bymyself Date: Wed, 28 Oct 2026 01:11:11 +0000 Subject: [PATCH 2/6] Return execution_meta in the job detail GET /api/jobs/{job_id} documents execution_meta but never filled it. The history record already stores each node's meta, including the display_node an expanded node is shown on. Return it so a client that reloads a finished job's outputs (for example after a websocket reconnect) can send each output to the node the live executed message would have used. --- comfy_execution/jobs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/comfy_execution/jobs.py b/comfy_execution/jobs.py index 0476d31ad43..1a8dcf2e1a7 100644 --- a/comfy_execution/jobs.py +++ b/comfy_execution/jobs.py @@ -261,6 +261,7 @@ def normalize_history_item(prompt_id: str, history_item: dict, include_outputs: if include_outputs: job['outputs'] = normalize_outputs(outputs) job['execution_status'] = status_info + job['execution_meta'] = history_item.get('meta', {}) job['workflow'] = { 'prompt': prompt, 'extra_data': extra_data, From 9f90853219b98e782c51e7464ddc4e61be07137e Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 12:11:18 +0000 Subject: [PATCH 3/6] test: a cached output keeps its own node's execution meta Two identical previews share an output cache entry. The second one replays the entry with the first node's meta, so the job detail points its output at the wrong node. --- .../execution_test/test_enrich_output.py | 20 +++++++++++++++++++ tests/execution/test_execution.py | 15 ++++++++++++++ tests/execution/test_jobs.py | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests-unit/execution_test/test_enrich_output.py b/tests-unit/execution_test/test_enrich_output.py index d12e2edd6da..3f0f146ec8b 100644 --- a/tests-unit/execution_test/test_enrich_output.py +++ b/tests-unit/execution_test/test_enrich_output.py @@ -384,3 +384,23 @@ def test_emit_cached_sends_enriched_output_to_client(output_path_environment) -> assert event == "executed" assert client_id == "client-1" assert payload["output"]["images"][0]["id"] is not None + + +def test_cached_output_records_the_current_nodes_meta(output_path_environment) -> None: + """A cache entry shared by two nodes must not carry the first node's meta into the second's history.""" + manager = InMemoryAssets() + server = _Server(client_id="client-1") + ui_outputs: dict = {} + cached = _CacheEntry(ui=_wrapper("shared.png", node_id="4"), outputs=[]) + current_meta = { + "node_id": "7", + "display_node": "7", + "parent_node": None, + "real_node_id": "7", + } + + register_executed_outputs(_output("shared.png"), "seed-job", manager) + emit_cached_output(server, "7", "7", cached, "prompt-1", ui_outputs, manager, meta=current_meta) + + assert ui_outputs["7"]["meta"] == current_meta + assert cached.ui["meta"]["node_id"] == "4" diff --git a/tests/execution/test_execution.py b/tests/execution/test_execution.py index beaf905649e..951060789f2 100644 --- a/tests/execution/test_execution.py +++ b/tests/execution/test_execution.py @@ -1211,6 +1211,21 @@ def test_cached_outputs_in_job_without_client_id(self, client: ComfyClient, buil assert job['status'] == 'completed' assert output.id in job['outputs'], "Cached outputs must appear in job outputs without a client_id" + def test_cached_output_meta_names_its_own_node(self, client: ComfyClient, builder: GraphBuilder): + """Two identical previews share a cache entry; each must keep its own meta in the job detail.""" + g = builder + image = g.node("StubImage", content="BLACK", height=32, width=32, batch_size=1) + first = g.node("PreviewImage", images=image.out(0)) + second = g.node("PreviewImage", images=image.out(0)) + + result = client.run(g) + job = client.get_job(result.get_prompt_id()) + + meta = job['execution_meta'] + for node in (first, second): + assert meta[node.id]['node_id'] == node.id + assert meta[node.id]['display_node'] == node.id + def _create_history_item(self, client, builder): g = GraphBuilder(prefix="offset_test") input_node = g.node( diff --git a/tests/execution/test_jobs.py b/tests/execution/test_jobs.py index 47079791a7d..48e95e0eefa 100644 --- a/tests/execution/test_jobs.py +++ b/tests/execution/test_jobs.py @@ -686,7 +686,7 @@ def test_include_outputs(self): def test_include_outputs_returns_execution_meta(self): """Detail view should expose each node's display node as execution_meta.""" meta = { - '15.0.0.3': {'node_id': '3', 'display_node': '15', 'parent_node': '15', 'real_node_id': '3'}, + '15.0.0.3': {'node_id': '15.0.0.3', 'display_node': '15', 'parent_node': '15', 'real_node_id': '3'}, '9': {'node_id': '9', 'display_node': '9', 'parent_node': None, 'real_node_id': '9'}, } history_item = { From 39b4b7fd84d64de5b3d87dba99adc3f923a31bfe Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 12:11:18 +0000 Subject: [PATCH 4/6] Record the current node's meta for a cached output emit_cached_output stored the meta of whichever node wrote the cache entry. Pass the current node's meta from both callers instead. --- comfy_execution/asset_enrichment.py | 6 +++++- execution.py | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/comfy_execution/asset_enrichment.py b/comfy_execution/asset_enrichment.py index cd1eb0f6b84..a425067a867 100644 --- a/comfy_execution/asset_enrichment.py +++ b/comfy_execution/asset_enrichment.py @@ -126,11 +126,15 @@ def register_cached_outputs(ui_wrapper: dict | None, job_id: str, asset_manager: return enriched -def emit_cached_output(server: "ExecutionServer", node_id: str, display_node_id: str, cached: "CacheEntry", prompt_id: str, ui_outputs: dict, asset_manager: "AssetManager") -> None: +def emit_cached_output(server: "ExecutionServer", node_id: str, display_node_id: str, cached: "CacheEntry", prompt_id: str, ui_outputs: dict, asset_manager: "AssetManager", meta: dict | None = None) -> None: if node_id in ui_outputs: return enriched = register_cached_outputs(cached.ui, prompt_id, asset_manager) if enriched is not None: + # The cache entry may have been written by another node with the same + # inputs, so record this node's meta rather than the writer's. + if meta is not None: + enriched["meta"] = meta ui_outputs[node_id] = enriched if server.client_id is None: return diff --git a/execution.py b/execution.py index 3d67a46277d..3ac4aab01dc 100644 --- a/execution.py +++ b/execution.py @@ -436,17 +436,25 @@ def _is_intermediate_output(dynprompt, node_id): return getattr(class_def, 'HAS_INTERMEDIATE_OUTPUT', False) +def _node_meta(dynprompt, unique_id) -> dict: + return { + "node_id": unique_id, + "display_node": dynprompt.get_display_node_id(unique_id), + "parent_node": dynprompt.get_parent_node_id(unique_id), + "real_node_id": dynprompt.get_real_node_id(unique_id), + } + + async def execute(server: "ExecutionServer", dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list, pending_subgraph_results, pending_async_nodes, ui_outputs, asset_manager: AssetManager): unique_id = current_item real_node_id = dynprompt.get_real_node_id(unique_id) display_node_id = dynprompt.get_display_node_id(unique_id) - parent_node_id = dynprompt.get_parent_node_id(unique_id) inputs = dynprompt.get_node(unique_id)['inputs'] class_type = dynprompt.get_node(unique_id)['class_type'] class_def = nodes.NODE_CLASS_MAPPINGS[class_type] cached = await caches.outputs.get(unique_id) if cached is not None: - emit_cached_output(server, unique_id, display_node_id, cached, prompt_id, ui_outputs, asset_manager) + emit_cached_output(server, unique_id, display_node_id, cached, prompt_id, ui_outputs, asset_manager, meta=_node_meta(dynprompt, unique_id)) get_progress_state().finish_progress(unique_id) execution_list.cache_update(unique_id, cached) return (ExecutionResult.SUCCESS, None, None) @@ -567,12 +575,7 @@ async def await_completion(): if len(output_ui) > 0: asset_previews = take_asset_previews(output_ui) output_ui = enrich_output_with_media_metadata(output_ui) - meta = { - "node_id": unique_id, - "display_node": display_node_id, - "parent_node": parent_node_id, - "real_node_id": real_node_id, - } + meta = _node_meta(dynprompt, unique_id) enriched_output_ui = register_executed_outputs(output_ui, prompt_id, asset_manager, asset_previews) ui_outputs[unique_id] = {"meta": meta, "output": enriched_output_ui} cache_ui_value = {"meta": meta, "output": output_ui} @@ -824,7 +827,7 @@ async def execute_async(self, prompt, prompt_id, extra_data={}, execute_outputs= cached = await self.caches.outputs.get(node_id) if cached is not None: display_node_id = dynamic_prompt.get_display_node_id(node_id) - emit_cached_output(self.server, node_id, display_node_id, cached, prompt_id, ui_node_outputs, self.asset_manager) + emit_cached_output(self.server, node_id, display_node_id, cached, prompt_id, ui_node_outputs, self.asset_manager, meta=_node_meta(dynamic_prompt, node_id)) self.add_message("execution_success", { "prompt_id": prompt_id }, broadcast=False) ui_outputs = {} From 0163b8d875a7b78b19f572ea3049ac06fbeb6d34 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 12:35:55 +0000 Subject: [PATCH 5/6] Pass the node meta to emit_cached_output instead of the display id Both callers now always pass the current node's meta, so the optional parameter and the separate display id go away; the executed message reads display_node from the meta. The test fixture's real_node_id now matches get_real_node_id (the top-level node). --- comfy_execution/asset_enrichment.py | 7 +++--- execution.py | 5 ++-- .../execution_test/test_enrich_output.py | 23 +++++++++---------- tests/execution/test_jobs.py | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/comfy_execution/asset_enrichment.py b/comfy_execution/asset_enrichment.py index a425067a867..a12e95eb038 100644 --- a/comfy_execution/asset_enrichment.py +++ b/comfy_execution/asset_enrichment.py @@ -126,21 +126,20 @@ def register_cached_outputs(ui_wrapper: dict | None, job_id: str, asset_manager: return enriched -def emit_cached_output(server: "ExecutionServer", node_id: str, display_node_id: str, cached: "CacheEntry", prompt_id: str, ui_outputs: dict, asset_manager: "AssetManager", meta: dict | None = None) -> None: +def emit_cached_output(server: "ExecutionServer", node_id: str, meta: dict, cached: "CacheEntry", prompt_id: str, ui_outputs: dict, asset_manager: "AssetManager") -> None: if node_id in ui_outputs: return enriched = register_cached_outputs(cached.ui, prompt_id, asset_manager) if enriched is not None: # The cache entry may have been written by another node with the same # inputs, so record this node's meta rather than the writer's. - if meta is not None: - enriched["meta"] = meta + enriched["meta"] = meta ui_outputs[node_id] = enriched if server.client_id is None: return output = enriched.get("output") if enriched is not None else None server.send_sync( "executed", - {"node": node_id, "display_node": display_node_id, "output": output, "prompt_id": prompt_id}, + {"node": node_id, "display_node": meta["display_node"], "output": output, "prompt_id": prompt_id}, server.client_id, ) diff --git a/execution.py b/execution.py index 3ac4aab01dc..a8918ada17a 100644 --- a/execution.py +++ b/execution.py @@ -454,7 +454,7 @@ async def execute(server: "ExecutionServer", dynprompt, caches, current_item, ex class_def = nodes.NODE_CLASS_MAPPINGS[class_type] cached = await caches.outputs.get(unique_id) if cached is not None: - emit_cached_output(server, unique_id, display_node_id, cached, prompt_id, ui_outputs, asset_manager, meta=_node_meta(dynprompt, unique_id)) + emit_cached_output(server, unique_id, _node_meta(dynprompt, unique_id), cached, prompt_id, ui_outputs, asset_manager) get_progress_state().finish_progress(unique_id) execution_list.cache_update(unique_id, cached) return (ExecutionResult.SUCCESS, None, None) @@ -826,8 +826,7 @@ async def execute_async(self, prompt, prompt_id, extra_data={}, execute_outputs= continue cached = await self.caches.outputs.get(node_id) if cached is not None: - display_node_id = dynamic_prompt.get_display_node_id(node_id) - emit_cached_output(self.server, node_id, display_node_id, cached, prompt_id, ui_node_outputs, self.asset_manager, meta=_node_meta(dynamic_prompt, node_id)) + emit_cached_output(self.server, node_id, _node_meta(dynamic_prompt, node_id), cached, prompt_id, ui_node_outputs, self.asset_manager) self.add_message("execution_success", { "prompt_id": prompt_id }, broadcast=False) ui_outputs = {} diff --git a/tests-unit/execution_test/test_enrich_output.py b/tests-unit/execution_test/test_enrich_output.py index 3f0f146ec8b..c8162a20415 100644 --- a/tests-unit/execution_test/test_enrich_output.py +++ b/tests-unit/execution_test/test_enrich_output.py @@ -50,6 +50,10 @@ def _output(filename: str, *, subfolder: str = "", type_: str = "output") -> dic return {"images": [{"filename": filename, "subfolder": subfolder, "type": type_}]} +def _meta(node_id: str) -> dict: + return {"node_id": node_id, "display_node": node_id, "parent_node": None, "real_node_id": node_id} + + def _wrapper(filename: str, node_id: str = "1") -> dict: return { "meta": { @@ -220,7 +224,7 @@ def test_cached_registration_happens_without_client(output_path_environment) -> emit_cached_output( server, "node-1", - "node-1", + _meta("node-1"), _CacheEntry(ui=_wrapper("noclient.png"), outputs=[]), "job-x", ui_outputs, @@ -254,7 +258,7 @@ def test_cached_ui_object_unmodified_after_emission(output_path_environment) -> snapshot = copy.deepcopy(cached.ui) register_executed_outputs(_output("immut.png"), "seed-job", manager) - emit_cached_output(server, "1", "1", cached, "prompt-1", {}, manager) + emit_cached_output(server, "1", _meta("1"), cached, "prompt-1", {}, manager) assert cached.ui == snapshot @@ -266,8 +270,8 @@ def test_double_emission_yields_single_delivery(output_path_environment) -> None cached = _CacheEntry(ui=_wrapper("dbl.png"), outputs=[]) register_executed_outputs(_output("dbl.png"), "seed-job", manager) - emit_cached_output(server, "1", "1", cached, "prompt-1", ui_outputs, manager) - emit_cached_output(server, "1", "1", cached, "prompt-1", ui_outputs, manager) + emit_cached_output(server, "1", _meta("1"), cached, "prompt-1", ui_outputs, manager) + emit_cached_output(server, "1", _meta("1"), cached, "prompt-1", ui_outputs, manager) deliveries = manager.deliveries_by_path[os.path.join(_BASE, "dbl.png")] assert len([delivery for delivery in deliveries if delivery.asset.job_id == "prompt-1"]) == 1 @@ -372,7 +376,7 @@ def test_emit_cached_sends_enriched_output_to_client(output_path_environment) -> emit_cached_output( server, "1", - "1", + _meta("1"), _CacheEntry(ui=_wrapper("send.png"), outputs=[]), "prompt-1", ui_outputs, @@ -392,15 +396,10 @@ def test_cached_output_records_the_current_nodes_meta(output_path_environment) - server = _Server(client_id="client-1") ui_outputs: dict = {} cached = _CacheEntry(ui=_wrapper("shared.png", node_id="4"), outputs=[]) - current_meta = { - "node_id": "7", - "display_node": "7", - "parent_node": None, - "real_node_id": "7", - } + current_meta = _meta("7") register_executed_outputs(_output("shared.png"), "seed-job", manager) - emit_cached_output(server, "7", "7", cached, "prompt-1", ui_outputs, manager, meta=current_meta) + emit_cached_output(server, "7", current_meta, cached, "prompt-1", ui_outputs, manager) assert ui_outputs["7"]["meta"] == current_meta assert cached.ui["meta"]["node_id"] == "4" diff --git a/tests/execution/test_jobs.py b/tests/execution/test_jobs.py index 48e95e0eefa..355be097eb4 100644 --- a/tests/execution/test_jobs.py +++ b/tests/execution/test_jobs.py @@ -686,7 +686,7 @@ def test_include_outputs(self): def test_include_outputs_returns_execution_meta(self): """Detail view should expose each node's display node as execution_meta.""" meta = { - '15.0.0.3': {'node_id': '15.0.0.3', 'display_node': '15', 'parent_node': '15', 'real_node_id': '3'}, + '15.0.0.3': {'node_id': '15.0.0.3', 'display_node': '15', 'parent_node': '15', 'real_node_id': '15'}, '9': {'node_id': '9', 'display_node': '9', 'parent_node': None, 'real_node_id': '9'}, } history_item = { From a6d0f1ada8299a2066c0310643bb2e053002fb36 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 13:03:55 +0000 Subject: [PATCH 6/6] test: an expanded node's execution meta names the node that expanded it --- tests/execution/test_execution.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/execution/test_execution.py b/tests/execution/test_execution.py index 951060789f2..9f554f6f01f 100644 --- a/tests/execution/test_execution.py +++ b/tests/execution/test_execution.py @@ -1226,6 +1226,23 @@ def test_cached_output_meta_names_its_own_node(self, client: ComfyClient, builde assert meta[node.id]['node_id'] == node.id assert meta[node.id]['display_node'] == node.id + def test_expanded_output_meta_names_its_display_node(self, client: ComfyClient, builder: GraphBuilder): + """An output from an expanded node is shown on the node that expanded it.""" + g = builder + expander = g.node("TestExecutedNodeIdsExpander", value="expanded-child") + + result = client.run(g) + job = client.get_job(result.get_prompt_id()) + + expanded = {k: v for k, v in job['execution_meta'].items() if k != expander.id} + assert len(expanded) == 1 + node_id, meta = next(iter(expanded.items())) + assert meta['node_id'] == node_id + assert meta['display_node'] == expander.id + assert meta['parent_node'] == expander.id + assert meta['real_node_id'] == expander.id + assert node_id in job['outputs'] + def _create_history_item(self, client, builder): g = GraphBuilder(prefix="offset_test") input_node = g.node(