Improve model config provider controls

Reset the custom API base URL whenever the provider dropdown changes so stale endpoints do not carry across provider tests. Move the chat Supports Vision toggle out of Advanced Settings while keeping dependent vision settings, such as Max embeds, inside Advanced.

Alessandro committed May 12, 2026 at 03:52 UTC ba0d90c3801c87b3cf1b67e0fcfb96424cdd8648
2 files changed +43 -14
plugins/_model_config/webui/model-field.html
+19 -14
@@ -27,7 +27,8 @@
27 </div>
28 <div class="field-control">
29 <select x-model="model.provider"
30 - x-effect="$nextTick(() => { if (providers.length) $el.value = model.provider })">
30 + x-effect="$nextTick(() => { if (providers.length) $el.value = model.provider })"
31 + @change="model.api_base = ''">
32 <option value="">&mdash; select &mdash;</option>
33 <template x-for="p in providers" :key="p.value">
34 <option :value="p.value" x-text="p.label"></option>
@@ -124,6 +125,22 @@
125 </div>
126 </template>
127
128 + <!-- Vision support (chat only) -->
129 + <template x-if="modelType === 'chat'">
130 + <div class="field">
131 + <div class="field-label">
132 + <div class="field-title">Supports Vision</div>
133 + <div class="field-description">Models capable of Vision can for example natively see the content of image attachments.</div>
134 + </div>
135 + <div class="field-control">
136 + <label class="toggle">
137 + <input type="checkbox" x-model="model.vision" />
138 + <span class="toggler"></span>
139 + </label>
140 + </div>
141 + </div>
142 + </template>
143 +
144 <!-- Advanced Settings (collapsed by default) -->
145 <div class="advanced-section" x-data="{ advOpen: false }">
146 <div class="advanced-toggle" @click="advOpen = !advOpen">
@@ -158,7 +175,7 @@
175 </div>
176 </template>
177
161 - <!-- Chat-specific: ctx_history, vision, max_embeds -->
178 + <!-- Chat-specific: ctx_history, max_embeds -->
179 <template x-if="modelType === 'chat'">
180 <div>
181 <div class="field">
@@ -171,18 +188,6 @@
188 <span class="range-value" x-text="model.ctx_history"></span>
189 </div>
190 </div>
174 - <div class="field">
175 - <div class="field-label">
176 - <div class="field-title">Supports Vision</div>
177 - <div class="field-description">Models capable of Vision can for example natively see the content of image attachments.</div>
178 - </div>
179 - <div class="field-control">
180 - <label class="toggle">
181 - <input type="checkbox" x-model="model.vision" />
182 - <span class="toggler"></span>
183 - </label>
184 - </div>
185 - </div>
191 <template x-if="model.vision">
192 <div class="field">
193 <div class="field-label">
tests/test_model_config_api_keys.py
+24
@@ -118,6 +118,30 @@ def test_model_config_frontend_tracks_inline_api_key_edits():
118 assert "$store.modelConfig.resetApiKeyDrafts();" in modal_content
119
120
121 +def test_model_config_provider_switch_resets_custom_api_base():
122 + model_field_path = PROJECT_ROOT / "plugins" / "_model_config" / "webui" / "model-field.html"
123 + content = model_field_path.read_text(encoding="utf-8")
124 + select_start = content.index('<select x-model="model.provider"')
125 + select_end = content.index("</select>", select_start)
126 + provider_select = content[select_start:select_end]
127 +
128 + assert 'x-model="model.provider"' in provider_select
129 + assert '@change="model.api_base = \'\'"' in provider_select
130 +
131 +
132 +def test_model_config_vision_toggle_is_outside_advanced_settings():
133 + model_field_path = PROJECT_ROOT / "plugins" / "_model_config" / "webui" / "model-field.html"
134 + content = model_field_path.read_text(encoding="utf-8")
135 +
136 + vision_start = content.index('<div class="field-title">Supports Vision</div>')
137 + advanced_start = content.index("<!-- Advanced Settings (collapsed by default) -->")
138 + max_embeds_start = content.index('<div class="field-title">Max embeds</div>')
139 +
140 + assert content.count('<div class="field-title">Supports Vision</div>') == 1
141 + assert vision_start < advanced_start
142 + assert advanced_start < max_embeds_start
143 +
144 +
145 def test_ollama_cloud_provider_config_requires_key_and_base_url():
146 import yaml
147