From 958edefcac3637edb9cb08bd4eef5ecbb8436634 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 17 Nov 2026 05:59:54 +0100 Subject: [PATCH] fix: switching an optional valve to Custom in the chat controls shows an error (#34478) * fix: switching an optional valve to Custom in the chat controls shows an error Switching an optional valve, such as an optional on/off setting, from Default to Custom in the Valves section of the chat controls saved the still empty box right away, and the server refused it with "Error updating function user valves". Emptying the box later failed the same way. Switching to Custom now saves once something is entered, and an emptied optional on/off or number valve goes back to its default; optional text valves still save an empty text. Fixes #34475 * Drop a comment that restates its condition * Name schema entries the way the schema helpers do --- src/lib/components/chat/Controls/Valves.svelte | 5 +++++ src/lib/components/common/Valves.svelte | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Controls/Valves.svelte b/src/lib/components/chat/Controls/Valves.svelte index 046f2fcc70..b99c1bc5d2 100644 --- a/src/lib/components/chat/Controls/Valves.svelte +++ b/src/lib/components/chat/Controls/Valves.svelte @@ -94,6 +94,11 @@ } else if (valves[property] == null) { valves[property] = null; } + } else if (valves[property] === '') { + const types = (valvesSpec.properties[property]?.anyOf ?? []).map((inner) => inner.type); + if (types.includes('null') && !types.includes('string')) { + valves[property] = null; + } } } diff --git a/src/lib/components/common/Valves.svelte b/src/lib/components/common/Valves.svelte index 5c30a9024c..81cc70037a 100644 --- a/src/lib/components/common/Valves.svelte +++ b/src/lib/components/common/Valves.svelte @@ -55,7 +55,9 @@ valves[property] = null; } - dispatch('change'); + if (valves[property] !== '') { + dispatch('change'); + } }} > {#if (valves[property] ?? null) === null}