-
Notifications
You must be signed in to change notification settings - Fork 390
Fix type on LoadClip being marked as asset #6207
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
Changes from 2 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 |
|---|---|---|
|
|
@@ -115,9 +115,16 @@ function createAssetService() { | |
| * @param nodeType - The ComfyUI node comfyClass (e.g., 'CheckpointLoaderSimple', 'LoraLoader') | ||
| * @returns true if this input should use asset browser | ||
| */ | ||
| function isAssetBrowserEligible(nodeType: string = ''): boolean { | ||
| function isAssetBrowserEligible( | ||
| nodeType: string = '', | ||
| widgetName: string | ||
|
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. [quality] medium Priority Issue: Function signature inconsistency - required parameter appears optional |
||
| ): boolean { | ||
| return ( | ||
AustinMroz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| !!nodeType && useModelToNodeStore().getRegisteredNodeTypes().has(nodeType) | ||
| (nodeType && | ||
| widgetName && | ||
| useModelToNodeStore().getRegisteredNodeTypes()[nodeType] === | ||
|
||
| widgetName) || | ||
| false | ||
AustinMroz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,12 +25,12 @@ export const useModelToNodeStore = defineStore('modelToNode', () => { | |
| const haveDefaultsLoaded = ref(false) | ||
|
|
||
| /** Internal computed for reactive caching of registered node types */ | ||
| const registeredNodeTypes = computed(() => { | ||
| return new Set( | ||
| const registeredNodeTypes = computed<Record<string, string>>(() => { | ||
|
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. [quality] low Priority Issue: Inconsistent variable naming between computed property and function |
||
| return Object.fromEntries( | ||
| Object.values(modelToNodeMap.value) | ||
| .flat() | ||
| .filter((provider) => !!provider.nodeDef) | ||
| .map((provider) => provider.nodeDef.name) | ||
| .map((provider) => [provider.nodeDef.name, provider.key]) | ||
| ) | ||
| }) | ||
|
|
||
|
|
@@ -51,7 +51,7 @@ export const useModelToNodeStore = defineStore('modelToNode', () => { | |
| }) | ||
|
|
||
| /** Get set of all registered node types for efficient lookup */ | ||
| function getRegisteredNodeTypes(): Set<string> { | ||
| function getRegisteredNodeTypes(): Record<string, string> { | ||
AustinMroz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| registerDefaults() | ||
| return registeredNodeTypes.value | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,15 +16,12 @@ const mockGetCategoryForNodeType = vi.fn() | |
|
|
||
| vi.mock('@/stores/modelToNodeStore', () => ({ | ||
| useModelToNodeStore: vi.fn(() => ({ | ||
| getRegisteredNodeTypes: vi.fn( | ||
| () => | ||
| new Set([ | ||
| 'CheckpointLoaderSimple', | ||
| 'LoraLoader', | ||
| 'VAELoader', | ||
| 'TestNode' | ||
| ]) | ||
| ), | ||
| getRegisteredNodeTypes: vi.fn(() => ({ | ||
| CheckpointLoaderSimple: 'ckpt_name', | ||
| LoraLoader: 'lora_name', | ||
| VAELoader: 'vae_name', | ||
| TestNode: '' | ||
| })), | ||
| getCategoryForNodeType: mockGetCategoryForNodeType, | ||
| modelToNodeMap: { | ||
| checkpoints: [{ nodeDef: { name: 'CheckpointLoaderSimple' } }], | ||
|
|
@@ -193,16 +190,32 @@ describe('assetService', () => { | |
| describe('isAssetBrowserEligible', () => { | ||
| it('should return true for registered node types', () => { | ||
| expect( | ||
| assetService.isAssetBrowserEligible('CheckpointLoaderSimple') | ||
| assetService.isAssetBrowserEligible( | ||
| 'CheckpointLoaderSimple', | ||
| 'ckpt_name' | ||
| ) | ||
| ).toBe(true) | ||
AustinMroz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| expect(assetService.isAssetBrowserEligible('LoraLoader')).toBe(true) | ||
| expect(assetService.isAssetBrowserEligible('VAELoader')).toBe(true) | ||
| expect( | ||
| assetService.isAssetBrowserEligible('LoraLoader', 'lora_name') | ||
| ).toBe(true) | ||
| expect(assetService.isAssetBrowserEligible('VAELoader', 'vae_name')).toBe( | ||
| true | ||
| ) | ||
| }) | ||
|
|
||
| it('should return false for unregistered node types', () => { | ||
| expect(assetService.isAssetBrowserEligible('UnknownNode')).toBe(false) | ||
| expect(assetService.isAssetBrowserEligible('NotRegistered')).toBe(false) | ||
| expect(assetService.isAssetBrowserEligible('')).toBe(false) | ||
| expect(assetService.isAssetBrowserEligible('UnknownNode', 'widget')).toBe( | ||
| false | ||
| ) | ||
| expect( | ||
| assetService.isAssetBrowserEligible('NotRegistered', 'widget') | ||
| ).toBe(false) | ||
| expect(assetService.isAssetBrowserEligible('', '')).toBe(false) | ||
| }) | ||
| it('should return false for other combo widgets on the registered node', () => { | ||
| expect(assetService.isAssetBrowserEligible('ClipLoader', 'type')).toBe( | ||
|
||
| false | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.