diff --git a/src/stores/nodeDefStore.ts b/src/stores/nodeDefStore.ts index b92837205..fe836110f 100644 --- a/src/stores/nodeDefStore.ts +++ b/src/stores/nodeDefStore.ts @@ -374,6 +374,21 @@ export const useNodeDefStore = defineStore('nodeDef', () => { 'Hides nodes marked as experimental unless explicitly enabled', predicate: (nodeDef) => showExperimental.value || !nodeDef.experimental }) + + // Subgraph nodes filter + // @todo Remove this filter when subgraph v2 is released + registerNodeDefFilter({ + id: 'core.subgraph', + name: 'Hide Subgraph Nodes', + description: + 'Temporarily hides subgraph nodes from node library and search', + predicate: (nodeDef) => { + // Hide subgraph nodes (identified by category='subgraph' and python_module='nodes') + return !( + nodeDef.category === 'subgraph' && nodeDef.python_module === 'nodes' + ) + } + }) } // Register core filters on store initialization diff --git a/tests-ui/tests/store/nodeDefStore.test.ts b/tests-ui/tests/store/nodeDefStore.test.ts index 068bf1c0c..071565a6c 100644 --- a/tests-ui/tests/store/nodeDefStore.test.ts +++ b/tests-ui/tests/store/nodeDefStore.test.ts @@ -236,6 +236,45 @@ describe('useNodeDefStore', () => { expect(store.visibleNodeDefs).toHaveLength(2) }) + + it('should hide subgraph nodes by default', () => { + const normalNode = createMockNodeDef({ + name: 'normal', + category: 'conditioning', + python_module: 'nodes' + }) + const subgraphNode = createMockNodeDef({ + name: 'MySubgraph', + category: 'subgraph', + python_module: 'nodes' + }) + + store.updateNodeDefs([normalNode, subgraphNode]) + + expect(store.visibleNodeDefs).toHaveLength(1) + expect(store.visibleNodeDefs[0].name).toBe('normal') + }) + + it('should show non-subgraph nodes with subgraph category', () => { + const normalNode = createMockNodeDef({ + name: 'normal', + category: 'conditioning', + python_module: 'custom_extension' + }) + const fakeSubgraphNode = createMockNodeDef({ + name: 'FakeSubgraph', + category: 'subgraph', + python_module: 'custom_extension' // Different python_module + }) + + store.updateNodeDefs([normalNode, fakeSubgraphNode]) + + expect(store.visibleNodeDefs).toHaveLength(2) + expect(store.visibleNodeDefs.map((n) => n.name)).toEqual([ + 'normal', + 'FakeSubgraph' + ]) + }) }) describe('performance', () => {