Skip to content

Commit 028cff9

Browse files
committed
Sync skeleton controls and improve JSON save
Call _sync_skeleton_controls_from_model() to centralize enabling/disabling of skeleton UI controls (ensures controls are disabled when self._skeleton is None) instead of manually toggling the checkbox. Change save_skeleton to use model.model_dump_json() for .json output so Pydantic's JSON serialization is used (ensures Enums and other non-primitive types are serialized correctly); keep YAML branch using model_dump and safe_dump. Raises same error for unsupported suffixes.
1 parent 4bcacb7 commit 028cff9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

dlclivegui/gui/main_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,8 @@ def _configure_skeleton_for_model(self, model_path: str) -> None:
18341834

18351835
# Default: disable until we find a compatible skeleton
18361836
if hasattr(self, "show_skeleton_checkbox"):
1837-
self.show_skeleton_checkbox.setEnabled(False)
1838-
# keep checked state but it won't be used unless enabled
1837+
# This will disable all skeleton controls when self._skeleton is None
1838+
self._sync_skeleton_controls_from_model()
18391839

18401840
p = Path(model_path).expanduser()
18411841

dlclivegui/utils/skeleton.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,13 @@ def load_skeleton(path: Path) -> Skeleton:
165165

166166

167167
def save_skeleton(path: Path, model: SkeletonModel) -> None:
168-
data = model.model_dump()
169-
170168
if path.suffix in {".yaml", ".yml"}:
169+
data = model.model_dump()
171170
path.write_text(yaml.safe_dump(data, sort_keys=False))
172171
elif path.suffix == ".json":
173-
path.write_text(json.dumps(data, indent=2))
172+
# Use Pydantic's JSON serialization to ensure Enums and other types
173+
# are converted to JSON-friendly values.
174+
path.write_text(model.model_dump_json(indent=2))
174175
else:
175176
raise SkeletonLoadError(f"Unsupported skeleton file type: {path.suffix}")
176177

0 commit comments

Comments
 (0)