From 5a9b56291f82b9269346053594d8b5dfca736976 Mon Sep 17 00:00:00 2001 From: Abdul Azeez Date: Thu, 3 Sep 2026 02:54:24 +0530 Subject: [PATCH] fix(web): warn when shared settings have no target environment (#9207) --- apps/web/src/hooks/useSettings.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/web/src/hooks/useSettings.ts b/apps/web/src/hooks/useSettings.ts index a04c514fb45894f649c1d3a41e273a588742afb9..6eb571f70aac889dc3e4ccc34686896dc5f07da8 100644 --- a/apps/web/src/hooks/useSettings.ts +++ b/apps/web/src/hooks/useSettings.ts @@ -377,24 +377,31 @@ function useUpdateSettingsTarget(environmentId: EnvironmentId | null) { if (Object.keys(serverPatch).length > 0) { const { sharedPatch, localPatch } = splitSharedServerPatch(serverPatch); - if (environmentId && Object.keys(localPatch).length > 0) { - void persistServerSettings({ - environmentId, - input: { patch: localPatch }, - }); - } else { - // Dropping the write silently leaves the control looking saved. + // Dropping the write silently leaves the control looking saved. + const warnUnsaved = () => toastManager.add({ type: "warning", title: "Setting not saved", description: PRIMARY_SETTINGS_UNAVAILABLE_MESSAGE, }); + if (Object.keys(localPatch).length > 0) { + if (environmentId) { + void persistServerSettings({ + environmentId, + input: { patch: localPatch }, + }); + } else { + warnUnsaved(); + } } if (Object.keys(sharedPatch).length > 0) { const targets = new Set(connectedEnvironmentIds); if (environmentId) { targets.add(environmentId); } + if (targets.size === 0) { + warnUnsaved(); + } for (const targetId of targets) { void persistServerSettings({ environmentId: targetId, -- 2.54.0