feat: add per-folder caching for multi-folder runnables loading

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
centdix
2026-03-27 12:33:49 +01:00
parent 9a4a8d20b6
commit 23d22a97f4
@@ -223,18 +223,24 @@
}
})
async function getCachedRunnables(workspace: string, folder: string): Promise<string[]> {
const cacheKey = `${workspace}-false-${folder}`
if (runnablesCache.has(cacheKey)) {
return runnablesCache.get(cacheKey) || []
}
const [scripts, flows] = await Promise.all([
getScripts(false, workspace, folder),
getFlows(false, workspace, folder)
])
const combined = [...scripts, ...flows]
runnablesCache.set(cacheKey, combined)
return combined
}
async function loadRunnablesForFolders(workspace: string, folders: string[]) {
try {
loadingRunnables = true
const results = await Promise.all(
folders.map(async (folder) => {
const [scripts, flows] = await Promise.all([
getScripts(false, workspace, folder),
getFlows(false, workspace, folder)
])
return [...scripts, ...flows]
})
)
const results = await Promise.all(folders.map((f) => getCachedRunnables(workspace, f)))
includedRunnables = [...new Set(results.flat())]
} finally {
loadingRunnables = false