From cd1832b9fe944347c9d1c8a1ebe0ba7431e4d290 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Fri, 7 Aug 2026 12:15:25 +0200 Subject: [PATCH] feat: Clamp and style numeric settings inputs from registry bounds --- .../app/settings/SettingsChat/SettingsChat.svelte | 7 ++++++- .../settings/SettingsChat/SettingsChatFields.svelte | 10 ++++++++-- tools/ui/src/lib/constants/settings-registry.ts | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte index 5d772359a6..8dfb04530c 100644 --- a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte +++ b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte @@ -98,7 +98,12 @@ const numValue = Number(processedConfig[field]); if (!isNaN(numValue)) { if ((POSITIVE_INTEGER_FIELDS as readonly string[]).includes(field)) { - processedConfig[field] = Math.max(1, Math.round(numValue)); + const entryByMinMax = SETTINGS_CHAT_SECTIONS.flatMap( + (section) => section.fields ?? [] + ).find((entry) => entry.key === field); + const lo = entryByMinMax?.min ?? 1; + const hi = entryByMinMax?.max ?? Number.POSITIVE_INFINITY; + processedConfig[field] = Math.max(lo, Math.min(hi, Math.round(numValue))); } else { processedConfig[field] = numValue; } diff --git a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte index fa871cc983..a54c61556c 100644 --- a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte +++ b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte @@ -83,12 +83,18 @@ onConfigChange(field.key, e.currentTarget.value)} placeholder={currentModelParams[field.key] != null ? `Default: ${normalizeFloatingPoint(currentModelParams[field.key])}` - : ''} + : (field.placeholder ?? '')} class="w-full {isCustomRealTime ? 'pr-8' : ''}" /> {#if isCustomRealTime} diff --git a/tools/ui/src/lib/constants/settings-registry.ts b/tools/ui/src/lib/constants/settings-registry.ts index 2112b9c3a1..adb2dfb787 100644 --- a/tools/ui/src/lib/constants/settings-registry.ts +++ b/tools/ui/src/lib/constants/settings-registry.ts @@ -716,6 +716,9 @@ export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = [ type: s.type, isExperimental: s.isExperimental, isPositiveInteger: s.isPositiveInteger, + placeholder: s.placeholder, + min: s.min, + max: s.max, dependsOn: s.dependsOn, help: s.help, options: s.options,