Improve ComfyUI Integration - Local & Cloud Support, Workflow Preview, Community Browser - #138
Conversation
…y.icu polling, add community workflow API routes
|
Thanks for pushing this forward. I took a focused pass against #5, especially the local/cloud generation path and the workflow browser/import path. A few things I would double-check before merge:
I avoided opening a duplicate implementation PR because #138 already covers the broad ComfyUI surface. If a narrow companion patch is useful, I can focus on prompt injection + apply-workflow detail fetch wiring. |
|
Maintainer-focused review-assist on #138 (trying to help converge toward closing #5 without adding yet another duplicate PR):
If maintainers want to refine the acceptance criteria for #5 (must-have vs nice-to-have), I can help produce a checklist that maps to minimal mergeable slices (local ComfyUI run for image/video first, then cloud providers, then community browser + graph preview, then audio/voice/music). |
Summary
This PR significantly improves the ComfyUI integration in Clapper, addressing issue #5. It fixes existing bugs, completes incomplete implementations, and adds new features for workflow preview and community workflow browsing.
Changes Made
1. 🔧 Fixed Local ComfyUI Provider (
packages/app/src/app/api/resolve/providers/comfyui/index.ts)getWorkflowForSegment()helper function to properly look up the correct workflow from settingsgetWorkflowCategoryForSegment()helper to map segment categories to workflow categories2. 🔧 Fixed Comfy.icu Cloud Provider (
packages/app/src/app/api/resolve/providers/comfy-comfyicu/index.ts)pollWorkflowRun()- a robust polling mechanism that checks workflow status every 2 seconds (configurable)sleep()utility for polling intervalsrun_idfield and additional payload fields3. 🆕 Community Workflow API Routes (
packages/app/src/app/api/workflows/)New API endpoints for browsing community workflows:
GET /api/workflows?q=...&source=openart&page=1GET /api/workflows/[source]/[id]4. 🆕 Workflow Graph Preview Component (
packages/app/src/components/comfy/ComfyWorkflowGraphPreview.tsx)A React component that renders a ComfyUI workflow graph as a visual SVG node graph:
5. 🆕 Community Workflow Browser Component (
packages/app/src/components/comfy/CommunityWorkflowBrowser.tsx)A UI component for browsing and importing workflows from community platforms:
6. 🆕 Component Exports (
packages/app/src/components/comfy/index.ts)Barrel exports for the new ComfyUI components.
Implementation Details
Local ComfyUI
The local provider connects to any ComfyUI instance (default:
http://localhost:8188) using the@saintno/comfyui-sdk. It supports HTTP Basic Auth for secured instances. Workflows are configured in settings and the provider automatically maps Clapper inputs (prompt, negative prompt, width, height, seed, image) to the workflow node inputs.Comfy.icu Cloud
The cloud provider uses the Comfy.icu API with a polling workflow:
/api/v1/workflows/{id}/runsto start a run/api/v1/workflows/{id}/runs/{runId}to poll for statusCommunity Workflow Sources
Testing
Future Improvements