Add workflow_id to all websocket messages#13643
Draft
luke-mino-altherr wants to merge 1 commit intomasterfrom
Draft
Add workflow_id to all websocket messages#13643luke-mino-altherr wants to merge 1 commit intomasterfrom
luke-mino-altherr wants to merge 1 commit intomasterfrom
Conversation
This commit addresses BE-672 by ensuring all execution-related websocket messages include the workflow_id field when available. Changes: - Added extract_workflow_id() helper function in comfy_execution/jobs.py to extract workflow_id from extra_data - Updated execution.py to include workflow_id in all websocket messages: - execution_start - execution_cached - execution_success - execution_error - execution_interrupted - executing - executed (including cached UI) - Updated main.py to include workflow_id in: - progress messages (via hijack_progress hook) - final executing message (node=None) - Updated comfy_execution/progress.py to include workflow_id in: - progress_state messages - preview image metadata The workflow_id is extracted from extra_data['extra_pnginfo']['workflow']['id'] and is conditionally included in messages only when present, maintaining backward compatibility with workflows that don't have this field. Fixes: BE-672 Co-authored-by: Luke Mino-Altherr <luke-mino-altherr@users.noreply.github.com>
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 adds
workflow_idto all execution-related websocket messages in the ComfyUI core repository, addressing issues with node progress state getting stuck, cross-workflow progress leakage, and node outputs being applied to the wrong workflow when switching tabs.Changes
1. New Helper Function
extract_workflow_id()function incomfy_execution/jobs.pyto extract workflow_id fromextra_data['extra_pnginfo']['workflow']['id']2. Updated WebSocket Messages in
execution.pyAdded
workflow_idfield to the following messages when available:execution_start- Sent when prompt execution beginsexecution_cached- Sent for cached nodesexecution_success- Sent on successful completionexecution_error- Sent when execution errors occurexecution_interrupted- Sent when execution is interruptedexecuting- Sent when a node starts/stops executingexecuted- Sent when a node completes with output3. Updated Progress Messages in
main.pyhijack_progress()to includeworkflow_idin progress messagesnode=None) to includeworkflow_id4. Updated Progress State in
comfy_execution/progress.pyProgressRegistryto store and passworkflow_idprogress_statemessages to includeworkflow_idworkflow_idto preview image metadataBackward Compatibility
The
workflow_idfield is only included when present in the extra_data. Workflows that don't provide a workflow_id will continue to work as before, with messages sent without this field. This ensures backward compatibility with existing workflows and integrations.Testing
extract_workflow_id()function passes all test casesRelated Issues
Fixes: BE-672
Impact
This change enables the frontend to:
The workflow_id field complements the existing
prompt_idfield, providing an additional layer of scoping for multi-workflow scenarios.Linear Issue: BE-672