feat(recipe): send embedded recipe workflow to ComfyUI canvas

This commit is contained in:
Will Miao
2026-08-20 22:18:13 +08:00
parent 0905e2be6e
commit 3ebf256c5d
24 changed files with 1145 additions and 27 deletions
@@ -117,6 +117,7 @@ class RecipePersistenceService:
"loras": loras_data,
"gen_params": gen_params,
"fingerprint": fingerprint,
"has_workflow": self._detect_has_workflow(normalized_image_path),
}
if checkpoint_entry:
recipe_data["checkpoint"] = checkpoint_entry
@@ -615,6 +616,9 @@ class RecipePersistenceService:
if key not in ["checkpoint", "loras"]
},
"loras_stack": lora_stack,
# Widget saves re-encode an in-memory tensor to PNG/WebP with no
# embedded metadata chunks, so a workflow can never be present.
"has_workflow": False,
}
if checkpoint_entry:
recipe_data["checkpoint"] = checkpoint_entry
@@ -639,6 +643,20 @@ class RecipePersistenceService:
# Helper methods ---------------------------------------------------
def _detect_has_workflow(self, image_path: str) -> bool:
"""Detect whether the saved recipe image embeds a ComfyUI workflow.
Extraction failures (missing file, corrupt image, unsupported format)
map to ``False`` and never propagate, mirroring the scanner's behavior.
"""
if not image_path or not os.path.exists(image_path):
return False
try:
metadata = self._exif_utils._load_structured_metadata(image_path)
return bool(metadata.get("workflow"))
except Exception:
return False
async def _build_widget_checkpoint_entry(
self,
recipe_scanner,