diff --git a/changelog.d/fixes/10247-provider-icon-data-url-save.md b/changelog.d/fixes/10247-provider-icon-data-url-save.md new file mode 100644 index 0000000000..6ad4538b86 --- /dev/null +++ b/changelog.d/fixes/10247-provider-icon-data-url-save.md @@ -0,0 +1 @@ +- **fix(providers):** compatible/custom providers now save valid Data URL icons and show Add/Edit save failures instead of silently doing nothing ([#10247](https://github.com/diegosouzapw/OmniRoute/pull/10247)) — thanks @xz-dev diff --git a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditCompatibleNodeModal.tsx b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditCompatibleNodeModal.tsx index 1ba581bf4a..b2c263605c 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditCompatibleNodeModal.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditCompatibleNodeModal.tsx @@ -60,9 +60,10 @@ export default function EditCompatibleNodeModal({ }>(null); const [showAdvanced, setShowAdvanced] = useState(false); const [iconUrlError, setIconUrlError] = useState(null); + const [saveError, setSaveError] = useState(null); useEffect(() => { - if (node) { + if (isOpen && node) { const psd = (node.providerSpecificData || {}) as Record; setFormData({ name: node.name || "", @@ -83,6 +84,8 @@ export default function EditCompatibleNodeModal({ newApiUserId: typeof psd.newApiUserId === "string" ? psd.newApiUserId : "", quotaPerUnit: typeof psd.quotaPerUnit === "number" ? String(psd.quotaPerUnit) : "", }); + setSaveError(null); + setIconUrlError(null); setShowAdvanced( !!( node.chatPath || @@ -91,7 +94,7 @@ export default function EditCompatibleNodeModal({ ) ); } - }, [node, isAnthropic, isCcCompatible]); + }, [isOpen, node, isAnthropic, isCcCompatible]); const apiTypeOptions = [ { value: "chat", label: t("chatCompletions") }, @@ -110,6 +113,7 @@ export default function EditCompatibleNodeModal({ return; } setIconUrlError(null); + setSaveError(null); setSaving(true); try { const payload: any = { @@ -140,6 +144,12 @@ export default function EditCompatibleNodeModal({ } } await onSave(payload); + } catch (error) { + setSaveError( + error instanceof Error && error.message.trim() + ? error.message + : providerText(t, "failedSave", "Failed to save") + ); } finally { setSaving(false); } @@ -359,6 +369,15 @@ export default function EditCompatibleNodeModal({ )} )} + {saveError && ( +
+ {saveError} +
+ )}
)} + {saveError && ( +
+ {saveError} +
+ )}