From 75ca9221530edfe22c67c2bce35e27d882e4dc3b Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:52:41 +0100 Subject: [PATCH] fix: importing tools or functions says it succeeded when every item failed (#35267) Re-importing an export whose IDs already exist showed an "already registered" error for each item and then a green "imported successfully" toast. The success toast now only shows when at least one tool or function was actually imported. A partial import still shows it, next to the errors for the items that failed. Fixes #35266 --- src/lib/components/admin/Functions.svelte | 4 +++- src/lib/components/workspace/Tools.svelte | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/components/admin/Functions.svelte b/src/lib/components/admin/Functions.svelte index d5c19aad2f..8a66490b81 100644 --- a/src/lib/components/admin/Functions.svelte +++ b/src/lib/components/admin/Functions.svelte @@ -771,6 +771,7 @@ const _functions = JSON.parse(event.target.result); console.log(_functions); + let imported = false; for (let func of _functions) { if ('function' in func) { // Required for Community JSON import @@ -781,9 +782,10 @@ toast.error(`${error}`); return null; }); + if (res) imported = true; } - toast.success($i18n.t('Functions imported successfully')); + if (imported) toast.success($i18n.t('Functions imported successfully')); functions = await getFunctionList(localStorage.token); _functions.set(await getFunctions(localStorage.token)); models.set(await getModels(localStorage.token, false, true)); diff --git a/src/lib/components/workspace/Tools.svelte b/src/lib/components/workspace/Tools.svelte index 7b5d6b062e..984b92c152 100644 --- a/src/lib/components/workspace/Tools.svelte +++ b/src/lib/components/workspace/Tools.svelte @@ -777,14 +777,16 @@ const _tools = JSON.parse(event.target.result); console.log(_tools); + let imported = false; for (const tool of _tools) { const res = await createNewTool(localStorage.token, tool).catch((error) => { toast.error(`${error}`); return null; }); + if (res) imported = true; } - toast.success($i18n.t('Tool imported successfully')); + if (imported) toast.success($i18n.t('Tool imported successfully')); await init(); importFiles = null; toolsImportInputElement.value = '';