MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / buildNotesFolderSuggestions

Function buildNotesFolderSuggestions

packages/app-core/src/lib/move-note.ts:85–101  ·  view source on GitHub ↗

* Folder suggestions for creating a new note, mirroring the sidebar NOTES tree: * the vault root plus its real subfolders. Excludes `archive` (a separate * lifecycle area) and the redundant bare `inbox` (which is the root itself).

(folders: FolderEntry[])

Source from the content-addressed store, hash-verified

83 * lifecycle area) and the redundant bare `inbox` (which is the root itself).
84 */
85function buildNotesFolderSuggestions(folders: FolderEntry[]): PromptSuggestion[] {
86 const out: PromptSuggestion[] = [{ value: '', label: 'Vault root' }]
87 const seen = new Set<string>([''])
88 for (const folder of folders) {
89 if (folder.folder !== 'inbox') continue // notes area only
90 const sub = normalizeMoveTarget(folder.subpath)
91 if (!sub || seen.has(sub)) continue
92 seen.add(sub)
93 const parts = sub.split('/')
94 out.push({ value: sub, detail: parts.slice(0, -1).join('/') || 'Vault root' })
95 }
96 return out.sort((a, b) => {
97 const aDepth = a.value === '' ? -1 : a.value.split('/').length
98 const bDepth = b.value === '' ? -1 : b.value.split('/').length
99 return aDepth - bDepth || a.value.localeCompare(b.value)
100 })
101}
102
103/**
104 * Prompt for where a new note should be created. Defaults to `initialPath`

Callers 2

Calls 1

normalizeMoveTargetFunction · 0.85

Tested by

no test coverage detected