Skip to content

Commit 91883da

Browse files
committed
fix(gui): serialize provider saves and surface mode PATCH rejections
Block the regular settings save while an account-mode save is in flight (and vice versa) so a stale config refresh cannot overwrite the freshly applied mode, and show the localized failure message when the mode PATCH rejects.
1 parent 7a0df5d commit 91883da

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎gui/src/components/provider-workspace/ProviderSettings.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default function ProviderSettings({
139139

140140
const save = async (): Promise<boolean> => {
141141
if (!onUpdateProvider) { setMsg({ ok: false, text: t("pws.updatesUnavailable") }); return false; }
142+
if (modeSaving) return false;
142143
const nextBaseUrl = hasEndpointPicker
143144
? resolvedBaseUrlForChoice(baseUrlChoices, endpointChoice, baseUrl)
144145
: baseUrl.trim();
@@ -171,7 +172,7 @@ export default function ProviderSettings({
171172
}, [onRegisterSave]);
172173

173174
const applyAccountMode = async (next: "pool" | "direct") => {
174-
if (modeSaving || next === accountMode) return;
175+
if (modeSaving || saving || next === accountMode) return;
175176
if (!onUpdateProvider) { setModeMsg({ ok: false, text: t("pws.updatesUnavailable") }); return; }
176177
setModeSaving(true);
177178
setModeMsg(null);
@@ -184,6 +185,8 @@ export default function ProviderSettings({
184185
} else {
185186
setModeMsg({ ok: false, text: res.error || t("pws.accountModeFailed") });
186187
}
188+
} catch {
189+
setModeMsg({ ok: false, text: t("pws.accountModeFailed") });
187190
} finally {
188191
setModeSaving(false);
189192
}
@@ -325,7 +328,7 @@ export default function ProviderSettings({
325328
<span className="muted">{t("pws.settingsUnsavedBar")}</span>
326329
<div className="pwi-settings-sticky-bar-actions">
327330
<button type="button" className="btn btn-ghost btn-sm" onClick={discard} disabled={saving}>{t("pws.discardSettings")}</button>
328-
<button type="button" className="btn btn-primary btn-sm" onClick={() => void save()} disabled={saving}>{saving ? t("pws.saving") : t("pws.saveSettings")}</button>
331+
<button type="button" className="btn btn-primary btn-sm" onClick={() => void save()} disabled={saving || modeSaving}>{saving ? t("pws.saving") : t("pws.saveSettings")}</button>
329332
</div>
330333
</div>
331334
)}

0 commit comments

Comments
 (0)