Repository navigation
Guard node outputs by workflowId #22271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3636,6 +3636,42 @@ describe('ComfyApp', () => { | |
| ).toEqual(['blob:1']) | ||
| }) | ||
|
|
||
| it.for([ | ||
| { label: 'shows', workflowId: workflowAId, expected: { text: ['out'] } }, | ||
| { label: 'hides', workflowId: workflowBId, expected: undefined } | ||
| ])( | ||
| '$label an unowned output by whether its workflow_id matches the visible workflow', | ||
| ({ workflowId, expected }) => { | ||
| useNodeOutputStore().resetAllOutputsAndPreviews() | ||
| const graph = new LGraph() | ||
| graph.configure(serialisedGraph(workflowAId)) | ||
| Reflect.set(app, 'rootGraphInternal', graph) | ||
| const addEventListener = vi.spyOn(api, 'addEventListener') | ||
| Reflect.apply(Reflect.get(app, 'addApiUpdateHandlers'), app, []) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stub socket initialization in this test.
As per coding guidelines: “Unit tests make no real network calls.”
|
||
| const executedHandler = addEventListener.mock.calls.find( | ||
| ([name]) => name === 'executed' | ||
| )?.[1] as EventListener | undefined | ||
|
|
||
| executedHandler?.( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: |
||
| new CustomEvent('executed', { | ||
| detail: { | ||
| node: '1', | ||
| display_node: '1', | ||
| prompt_id: 'unowned-job', | ||
| workflow_id: workflowId, | ||
| output: { text: ['out'] } | ||
| } | ||
| }) | ||
| ) | ||
|
|
||
| expect( | ||
| useNodeOutputStore().getNodeOutputByExecutionId( | ||
| createNodeExecutionId([1]) | ||
| ) | ||
| ).toEqual(expected) | ||
| } | ||
| ) | ||
|
|
||
| it('restores the failed run state when returning to a workflow tab', async () => { | ||
| const workflowService = await useRealWorkflowService() | ||
| const graph = new LGraph() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -786,6 +786,7 @@ export class ComfyApp implements IComfyApp { | |
|
|
||
| api.addEventListener('executed', ({ detail }) => { | ||
| if (!useExecutionStore().belongsToActiveWorkflow(detail.prompt_id)) return | ||
| if (detail.workflow_id && detail.workflow_id !== this.rootGraph.id) return | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: The guard compares |
||
| const nodeOutputStore = useNodeOutputStore() | ||
| const executionId = tryNormalizeNodeExecutionId( | ||
| detail.display_node || detail.node | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Which server contract adds
workflow_idtoexecuted? If it is a new Cloud field, could it come from the generated types, or could you link the backend PR so this hand-written WS shape follows the server contract and doesn't lead it?