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.
This commit is contained in:
Daniel Han 2026-05-25 08:34:15 +00:00
commit b90d1026d8

View file

@ -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<string, unknown>) }
: 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")