fix semantic search model_size showing dirty for genai embeddings providers

The resolved config always reports model_size (schema default), so clearing it
whenever a provider was selected falsely marked the field dirty on load and sent
a delete for a YAML key that isn't there (Error updating config: 'model_size').
Only clear a non-default value, which is the only case actually present in the
config file.
This commit is contained in:
Josh Hawkins
2026-07-19 06:47:08 -05:00
parent 6f80bcd19f
commit ce0197cc8f
2 changed files with 139 additions and 6 deletions
@@ -24,15 +24,19 @@ export function SemanticSearchModelSizeWidget(props: WidgetProps) {
model !== "jinav1" &&
model !== "jinav2";
// Clear model_size while on a provider (buildOverrides converts to ""
// which the backend treats as "remove"). Restore the schema default
// when returning to a Jina model so the field isn't left empty.
// model_size is unused on a GenAI provider. Only clear it (which the backend
// treats as "remove") for a non-default value, which can only come from the
// config file. A defaulted value is indistinguishable from unset in the
// resolved config, so clearing it would falsely dirty the field and delete a
// YAML key that isn't there. Restore the default when returning to a Jina model.
const { value, onChange, schema } = props;
const schemaDefault = schema?.default as string | undefined;
useEffect(() => {
if (isProvider && value !== undefined) {
onChange(undefined);
} else if (!isProvider && value === undefined && schemaDefault) {
if (isProvider) {
if (value !== undefined && value !== schemaDefault) {
onChange(undefined);
}
} else if (value === undefined && schemaDefault) {
onChange(schemaDefault);
}
}, [isProvider, value, onChange, schemaDefault]);