Skip to content

Commit c084872

Browse files
CadiacAlex O
authored andcommitted
feat(editor): Show the simple vector store first in the nodes panel (no-changelog) (n8n-io#15931)
1 parent 1252906 commit c084872

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,17 @@ export class VectorStoreInMemory extends createVectorStoreNode<MemoryVectorStore
5656
meta: {
5757
displayName: 'Simple Vector Store',
5858
name: 'vectorStoreInMemory',
59-
description:
60-
"Work with your data in a Simple Vector Store. Don't use this for production usage.",
59+
description: 'The easiest way to experiment with vector stores, without external setup.',
6160
icon: 'fa:database',
6261
iconColor: 'black',
6362
docsUrl:
6463
'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',
64+
categories: ['AI'],
65+
subcategories: {
66+
AI: ['Vector Stores', 'Tools', 'Root Nodes'],
67+
'Vector Stores': ['For Beginners'],
68+
Tools: ['Other Tools'],
69+
},
6570
},
6671
sharedFields: [
6772
{

packages/@n8n/nodes-langchain/nodes/vector_store/shared/createVectorStoreNode/__snapshots__/createVectorStoreNode.test.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ exports[`createVectorStoreNode retrieve mode supplies vector store as data 1`] =
2222
"Tools": [
2323
"Other Tools",
2424
],
25+
"Vector Stores": [
26+
"Other Vector Stores",
27+
],
2528
},
2629
},
2730
"credentials": undefined,

packages/@n8n/nodes-langchain/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ export const createVectorStoreNode = <T extends VectorStore = VectorStore>(
5050
name: args.meta.displayName,
5151
},
5252
codex: {
53-
categories: ['AI'],
54-
subcategories: {
53+
categories: args.meta.categories ?? ['AI'],
54+
subcategories: args.meta.subcategories ?? {
5555
AI: ['Vector Stores', 'Tools', 'Root Nodes'],
56+
'Vector Stores': ['Other Vector Stores'],
5657
Tools: ['Other Tools'],
5758
},
5859
resources: {

packages/@n8n/nodes-langchain/nodes/vector_store/shared/createVectorStoreNode/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export interface NodeMeta {
2525
iconColor?: ThemeIconColor;
2626
credentials?: INodeCredentialDescription[];
2727
operationModes?: NodeOperationMode[];
28+
categories?: string[];
29+
subcategories?: Record<string, string[]>;
2830
}
2931

3032
export interface VectorStoreNodeConstructorArgs<T extends VectorStore = VectorStore> {

packages/frontend/editor-ui/src/components/Node/NodeCreator/composables/useViewStacks.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
AI_CATEGORY_MCP_NODES,
1010
AI_CATEGORY_ROOT_NODES,
1111
AI_CATEGORY_TOOLS,
12+
AI_CATEGORY_VECTOR_STORES,
1213
AI_CODE_NODE_TYPE,
1314
AI_NODE_CREATOR_VIEW,
1415
AI_OTHERS_NODE_CREATOR_VIEW,
@@ -122,14 +123,14 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {
122123

123124
const searchResults = extendItemsWithUUID(searchNodes(stack.search || '', searchBase));
124125

125-
const groupedNodes = groupIfAiNodes(searchResults, false) ?? searchResults;
126+
const groupedNodes = groupIfAiNodes(searchResults, stack.title, false) ?? searchResults;
126127
// Set the active index to the second item if there's a section
127128
// as the first item is collapsable
128129
stack.activeIndex = groupedNodes.some((node) => node.type === 'section') ? 1 : 0;
129130

130131
return groupedNodes;
131132
}
132-
return extendItemsWithUUID(groupIfAiNodes(stack.baselineItems, true));
133+
return extendItemsWithUUID(groupIfAiNodes(stack.baselineItems, stack.title, true));
133134
});
134135

135136
const activeViewStack = computed<ViewStack>(() => {
@@ -146,7 +147,7 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {
146147
});
147148

148149
const activeViewStackMode = computed(
149-
() => activeViewStack.value.mode || TRIGGER_NODE_CREATOR_VIEW,
150+
() => activeViewStack.value.mode ?? TRIGGER_NODE_CREATOR_VIEW,
150151
);
151152

152153
const searchBaseItems = computed<INodeCreateElement[]>(() => {
@@ -183,7 +184,7 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {
183184
searchNodes(stack.search || '', filteredNodes),
184185
);
185186
if (isAiRootView(stack)) {
186-
globalSearchResult = groupIfAiNodes(globalSearchResult);
187+
globalSearchResult = groupIfAiNodes(globalSearchResult, stack.title, false);
187188
}
188189

189190
const filteredItems = globalSearchResult.filter((item) => {
@@ -233,7 +234,11 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {
233234
});
234235
}
235236

236-
function groupIfAiNodes(items: INodeCreateElement[], sortAlphabetically = true) {
237+
function groupIfAiNodes(
238+
items: INodeCreateElement[],
239+
stackCategory: string | undefined,
240+
sortAlphabetically: boolean,
241+
) {
237242
const aiNodes = items.filter((node): node is NodeCreateElement => isAINode(node));
238243
const canvasHasAINodes = useCanvasStore().aiNodes.length > 0;
239244

@@ -247,7 +252,12 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {
247252
const section = subcategories[AI_SUBCATEGORY]?.[0];
248253

249254
if (section) {
250-
const subSection = subcategories[section]?.[0];
255+
// Don't show sub sections for Vector Stores if we're currently viewing a 'Tools' stack
256+
const subSection =
257+
section === AI_CATEGORY_VECTOR_STORES && stackCategory === AI_CATEGORY_TOOLS
258+
? undefined
259+
: subcategories[section]?.[0];
260+
251261
const sectionKey = subSection ?? section;
252262
const currentItems = sectionsMap.get(sectionKey)?.items ?? [];
253263
const isSubnodesSection = !(

0 commit comments

Comments
 (0)