mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
5.2 KiB
5.2 KiB
Parallel Execution Implementation Plan
Goals
- Support multiple simultaneous workflow executions across:
- Separate browser tabs (multiple clients).
- In-app workflow tabs (multiple workflows).
- Show correct progress, outputs, and errors per workflow/job.
- Avoid regressions for single-run behavior and existing UI.
Non-goals (initial scope)
- Redesign the queue UI beyond enabling per-job progress indicators.
- New backend features beyond prompt context for WS events (see dependencies).
Dependencies / coordination (verified vs ../cloud-3 + ../backend-3)
- Prompt-scoped data is already available for core execution events:
execution_start,execution_success,execution_error,execution_interrupted,executed,progress,progress_state, andexecutingincludeprompt_idin../backend-3and are forwarded unchanged through../cloud-3.- Frontend currently drops
prompt_idforexecuting; this can be fixed without backend changes.
progress_textis a binary message containing onlynodeId+ text in../backend-3(send_progress_text);../cloud-3forwards it as raw binary.- Per-prompt progress text is not possible without backend changes.
- If we want it, we need to extend ComfyUI/backend to include
prompt_idin the binary payload or add a parallel JSON event.
b_preview_with_metadataincludesprompt_idand is forwarded as binary; usable as-is for prompt/workflow scoping.- Decide whether UI should filter by
client_id(current tab only) or show all user jobs; document and apply consistently.
Phase 1: Data model and execution state
-
Refactor execution store to be prompt-centric:
- Replace
activePromptIdsingle value with:promptStates: Record<promptId, PromptExecutionState>.runningPromptIdsderived from prompt states.promptIdToWorkflowIdremains the primary routing map.
- Provide selectors:
getPromptProgress(promptId)getPromptNodeProgressStates(promptId)getWorkflowRunningPromptIds(workflowId)getActivePromptForWorkflow(workflowId)(if needed)
- Redefine
isIdleasrunningPromptIds.length === 0. - Keep backward-compat getters but scope to:
- active workflow tab, or
- "most recently started prompt".
- Replace
-
Update event handlers to write prompt-scoped state:
execution_startcreates prompt state.progress_statemerges intopromptStates[promptId].nodeProgressStates.execution_success/error/interruptedremove prompt state only for that id.- Preserve initialization tracking per prompt.
Phase 2: Prompt-aware node progress and canvas updates
- Update graph/node progress to be scoped to the active workflow tab:
- Derive
nodeLocationProgressStatesfrom the prompt(s) mapped to the active workflow only. - Ensure
GraphCanvas.vueapplies progress for active workflow only.
- Derive
- Update vue-node execution composables to use workflow-scoped progress.
- Update
groupNodeprogress rendering to use prompt-scoped state.
Phase 3: Outputs and previews isolation
- Introduce per-workflow output maps in
imagePreviewStore:outputsByWorkflowId[workflowId][nodeLocatorId].previewsByWorkflowId[workflowId][nodeLocatorId].
- When switching active workflow tab:
- Swap
app.nodeOutputsandapp.nodePreviewImagesto the selected map.
- Swap
- Update
executedandb_preview_with_metadatahandlers to:- Use
prompt_id -> workflowIdmapping to store outputs/previews in the correct workflow bucket.
- Use
- Update
ChangeTrackerand history loading paths to restore per-workflow outputs without overwriting other workflows.
Phase 4: UI updates for multi-run visibility
- Queue overlay:
useQueueProgressto compute per-job progress for all running tasks.useJobListto attach progress to each running item, not just one.QueueOverlayActiveto show aggregated or multi-job state.
- Actionbar interrupt:
- Route interrupt to prompt(s) for the active workflow tab.
- Optionally add a "stop all running" action.
- Browser tab title + favicon:
- Use aggregate progress (e.g., max or average of running jobs) or show count of running jobs with a generic progress indicator.
Phase 5: Browser-tab concurrency policy
- Decide and implement filtering:
- Option A: show only jobs for the current
client_idin the UI. - Option B: show all jobs for the user, but mark which client started them.
- Option A: show only jobs for the current
- Apply consistent filtering in:
- queue overlay,
- completion summary,
- progress favicon/title.
Phase 6: Tests and validation
- Unit tests:
executionStoreselectors and lifecycle per prompt.useQueueProgressanduseJobListshowing per-job progress.
- Update existing stories/tests that assume single
activePromptId. - Manual validation checklist:
- Two workflows running in two in-app tabs: progress and outputs isolated.
- Two browser tabs running distinct workflows: no cross-talk in UI.
- Interrupt from actionbar affects intended prompt(s).
Phase 7: Rollout and cleanup
- Remove deprecated single-prompt fields after migration is stable.
- Update documentation/comments where prompt-scoped behavior is required.
- Coordinate backend/WS schema changes with
../backend-3and../cloud-3.