From 0451545220f94e2e5f00c4dd3bae9549793c19aa Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 14 Nov 2026 03:48:04 +1100 Subject: [PATCH] fix(ui): clearing an agent profile field no longer leaves an unsaved change (#1874) --- ui/src/settings/AgentProfilesPage.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/src/settings/AgentProfilesPage.vue b/ui/src/settings/AgentProfilesPage.vue index bf6f9b563..98d125f87 100644 --- a/ui/src/settings/AgentProfilesPage.vue +++ b/ui/src/settings/AgentProfilesPage.vue @@ -43,8 +43,17 @@ function removeProfile(index: number) { if (!key) return; store.setDraftEntry(KIND, key, undefined); } +// A field cleared back to empty is dropped unless the stored profile has it, +// so emptying a field the profile never had is not a change. function patch(key: string, changes: Partial) { - store.setDraftEntry(KIND, key, { ...profiles.value?.[key], ...changes }); + const stored = (store.stateFor(KIND).resource?.value as Record | null)?.[key]; + const next: Record = { ...profiles.value?.[key], ...changes }; + for (const field of Object.keys(changes)) { + const value = next[field]; + const empty = Array.isArray(value) ? value.length === 0 : value === ""; + if (empty && !(stored && field in stored)) delete next[field]; + } + store.setDraftEntry(KIND, key, next); } onMounted(() => {