From bd71938b717829a0f387021721da4a3ffed6c034 Mon Sep 17 00:00:00 2001 From: Extra Small Date: Wed, 8 Apr 2026 09:08:51 -0700 Subject: [PATCH] fix: reset loading state when prompt save fails When onSubmit throws an error (e.g. network failure), the loading flag was left as true, permanently disabling the Save button and showing an infinite spinner with no user feedback. Wrap the onSubmit call in try/catch so loading is always reset to false and an error toast is shown to the user on failure. --- .../workspace/Prompts/PromptEditor.svelte | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/lib/components/workspace/Prompts/PromptEditor.svelte b/src/lib/components/workspace/Prompts/PromptEditor.svelte index 66db6df208..01c4786222 100644 --- a/src/lib/components/workspace/Prompts/PromptEditor.svelte +++ b/src/lib/components/workspace/Prompts/PromptEditor.svelte @@ -82,23 +82,28 @@ loading = true; if (validateCommandString(command)) { - await onSubmit({ - id: prompt?.id, - name, - command, - content, - tags: tags.map((tag) => tag.name), - access_grants: accessGrants, - commit_message: commitMessage || undefined, - is_production: isProduction - }); - showEditModal = false; - commitMessage = ''; - isProduction = true; - await loadHistory(true); // Reset and reload - // Select the newest version after saving - if (history.length > 0) { - selectedHistoryEntry = history[0]; + try { + await onSubmit({ + id: prompt?.id, + name, + command, + content, + tags: tags.map((tag) => tag.name), + access_grants: accessGrants, + commit_message: commitMessage || undefined, + is_production: isProduction + }); + showEditModal = false; + commitMessage = ''; + isProduction = true; + await loadHistory(true); // Reset and reload + // Select the newest version after saving + if (history.length > 0) { + selectedHistoryEntry = history[0]; + } + } catch (e) { + console.error('Failed to save prompt:', e); + toast.error($i18n.t('Failed to save prompt. Please try again.')); } } else { toast.error(