-
Notifications
You must be signed in to change notification settings - Fork 673
fix: make ComfyApp root-graph readiness reactive #14976
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
Open
mattmillerai
wants to merge
8
commits into
main
Choose a base branch
from
matt/fe-6860-root-graph-shallow-ref
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ef0059
fix: make ComfyApp root-graph readiness reactive
mattmillerai 37abbf4
test: cover rootGraph listener rebinding on graph replacement
mattmillerai d94c094
test: drop unused Pinia setup from rootGraphReadiness test
mattmillerai 9d36354
style: merge duplicate vue import in app.ts
mattmillerai 6c93b30
Merge remote-tracking branch 'origin/main' into matt/fe-6860-root-gra…
mattmillerai cf43654
Merge remote-tracking branch 'origin/main' into matt/fe-6860-root-gra…
mattmillerai 8cd9e62
Merge remote-tracking branch 'origin/main' into matt/fe-6860-root-gra…
mattmillerai 909788e
test: drop the type assertions from the root-graph test seam
mattmillerai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { LGraph } from '@/lib/litegraph/src/litegraph' | ||
| import type { ComfyApp } from '@/scripts/app' | ||
|
|
||
| /** | ||
| * `ComfyApp.setup` is the only production writer of the root graph, and it needs | ||
| * a real canvas. Tests that just need a graph in place reach the same storage | ||
| * through this seam instead. | ||
| */ | ||
| export function setRootGraph(app: ComfyApp, graph: LGraph | undefined) { | ||
| app['rootGraphRef'].value = graph | ||
| } | ||
|
|
||
| export function getRootGraph(app: ComfyApp) { | ||
| return app['rootGraphRef'].value | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { useEventListener } from '@vueuse/core' | ||
| import { effectScope, nextTick, watchEffect } from 'vue' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { LGraph } from '@/lib/litegraph/src/litegraph' | ||
| import { getRootGraph, setRootGraph } from '@/scripts/__tests__/appTestUtils' | ||
| import { app } from '@/scripts/app' | ||
|
|
||
| describe('ComfyApp root graph readiness', () => { | ||
| let scope: ReturnType<typeof effectScope> | ||
| let previousRootGraph: LGraph | undefined | ||
|
|
||
| beforeEach(() => { | ||
| vi.spyOn(console, 'error').mockImplementation(() => {}) | ||
| previousRootGraph = getRootGraph(app) | ||
| setRootGraph(app, undefined) | ||
| scope = effectScope() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| scope.stop() | ||
| setRootGraph(app, previousRootGraph) | ||
| vi.restoreAllMocks() | ||
| }) | ||
|
|
||
| it('re-runs an effect reading isGraphReady when the graph is assigned', async () => { | ||
| const readiness: boolean[] = [] | ||
| scope.run(() => { | ||
| watchEffect(() => readiness.push(app.isGraphReady)) | ||
| }) | ||
|
|
||
| expect(readiness).toEqual([false]) | ||
|
|
||
| setRootGraph(app, new LGraph()) | ||
| await nextTick() | ||
|
|
||
| expect(readiness).toEqual([false, true]) | ||
| }) | ||
|
|
||
| it('binds a rootGraph.events listener registered before the graph exists', async () => { | ||
| const onConfigured = vi.fn() | ||
| scope.run(() => { | ||
| useEventListener(() => app.rootGraph?.events, 'configured', onConfigured) | ||
| }) | ||
|
|
||
| const graph = new LGraph() | ||
| setRootGraph(app, graph) | ||
| await nextTick() | ||
| graph.events.dispatch('configured') | ||
|
|
||
| expect(onConfigured).toHaveBeenCalledOnce() | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }) | ||
|
|
||
| it('rebinds a rootGraph.events listener when the graph is replaced', async () => { | ||
| const onConfigured = vi.fn() | ||
| const firstGraph = new LGraph() | ||
| setRootGraph(app, firstGraph) | ||
| scope.run(() => { | ||
| useEventListener(() => app.rootGraph?.events, 'configured', onConfigured) | ||
| }) | ||
|
|
||
| const secondGraph = new LGraph() | ||
| setRootGraph(app, secondGraph) | ||
| await nextTick() | ||
|
|
||
| firstGraph.events.dispatch('configured') | ||
| expect(onConfigured).not.toHaveBeenCalled() | ||
|
|
||
| secondGraph.events.dispatch('configured') | ||
| expect(onConfigured).toHaveBeenCalledOnce() | ||
| }) | ||
| }) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.