From b90d1026d8af9f36164887ef8becbebab0ee09a7 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 25 May 2026 08:34:15 +0000 Subject: [PATCH] Studio: also reset vision_image_size when YAML lacks a training section Round 9's parseYamlConfig normalization only fired when the YAML had a training mapping that omitted vision_image_size. A lora-only or logging-only YAML (or one with `training: null`) still left trainingObj unset, the mapper saw no vision_image_size key, and the previously selected store value persisted into the next training run. Now an absent or null training section is synthesised as { vision_image_size: null } so model-defaults.ts always patches visionImageSize back to Default on file import. Same-model defaults reloads still preserve manual choices via the existing Object.hasOwn gate in mapBackendModelConfigToTrainingPatch. --- .../frontend/src/features/training/lib/yaml-config.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/studio/frontend/src/features/training/lib/yaml-config.ts b/studio/frontend/src/features/training/lib/yaml-config.ts index 8455908177..cf40e938ec 100644 --- a/studio/frontend/src/features/training/lib/yaml-config.ts +++ b/studio/frontend/src/features/training/lib/yaml-config.ts @@ -32,14 +32,18 @@ export function parseYamlConfig(text: string): BackendModelConfig { // preserve a stale one. Same-model defaults reloads (which also flow // through the model-config mapper) skip the reset via Object.hasOwn // in model-defaults.ts; here we forge the key so import always wins. - const trainingObj = + // This also covers configs with no training section at all (lora-only + // exports), which otherwise would not trigger the mapper's vision + // patch and would leak the previously selected image size. + let trainingObj: unknown = raw.training != null && typeof raw.training === "object" && !Array.isArray(raw.training) ? { ...(raw.training as Record) } : raw.training; - if ( - trainingObj != null && + if (trainingObj == null) { + trainingObj = { vision_image_size: null }; + } else if ( typeof trainingObj === "object" && !Array.isArray(trainingObj) && !Object.hasOwn(trainingObj, "vision_image_size")