Improve ComfyUI Integration - Local & Cloud Support, Workflow Preview, Community Browser#138
Open
yihangwu539-png wants to merge 2 commits into
Open
Conversation
…y.icu polling, add community workflow API routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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