From 23d22a97f4a80ca57785f4a60863b9dd901aebe8 Mon Sep 17 00:00:00 2001 From: centdix Date: Fri, 27 Mar 2026 12:33:49 +0100 Subject: [PATCH] feat: add per-folder caching for multi-folder runnables loading Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/mcp/McpScopeSelector.svelte | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/components/mcp/McpScopeSelector.svelte b/frontend/src/lib/components/mcp/McpScopeSelector.svelte index 44bc85cf3b..f91091ea4c 100644 --- a/frontend/src/lib/components/mcp/McpScopeSelector.svelte +++ b/frontend/src/lib/components/mcp/McpScopeSelector.svelte @@ -223,18 +223,24 @@ } }) + async function getCachedRunnables(workspace: string, folder: string): Promise { + 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