Skip to content

Commit c8c32fd

Browse files
committed
fix config issues
1 parent 7ace114 commit c8c32fd

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

config.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ def generate_default_config_name(self):
2727
# Use the selected model name from the listbox if available,
2828
# otherwise fall back to the path stem.
2929
selected_name = ""
30-
sel = self.launcher.model_listbox.curselection()
31-
if sel:
32-
selected_name = self.launcher.model_listbox.get(sel[0])
30+
try:
31+
if hasattr(self.launcher, 'model_listbox'):
32+
sel = self.launcher.model_listbox.curselection()
33+
if sel:
34+
selected_name = self.launcher.model_listbox.get(sel[0])
35+
except Exception:
36+
pass # UI might not be fully initialized
3337

3438
if selected_name:
3539
raw_name = selected_name
@@ -211,6 +215,8 @@ def generate_default_config_name(self):
211215
print("DEBUG: Preserved custom config name.", file=sys.stderr)
212216
else:
213217
print("DEBUG: Generated name same as current, no update needed.", file=sys.stderr)
218+
219+
return generated_name
214220

215221

216222
def update_default_config_name_if_needed(self, *args):
@@ -484,7 +490,8 @@ def update_config_listbox(self):
484490
if current_selection:
485491
selected_name = self.launcher.config_listbox.get(current_selection[0])
486492
self.launcher.config_listbox.delete(0, "end")
487-
sorted_names = sorted(self.launcher.saved_configs.keys())
493+
# Filter out None keys and convert to strings before sorting
494+
sorted_names = sorted([str(name) for name in self.launcher.saved_configs.keys() if name is not None])
488495
for cfg_name in sorted_names:
489496
self.launcher.config_listbox.insert("end", cfg_name)
490497
if selected_name in sorted_names:
@@ -726,7 +733,9 @@ def load_saved_configs(self):
726733
print(f"DEBUG: Loading config from FULL PATH: {self.launcher.config_path.resolve()}", file=sys.stderr)
727734
try:
728735
data = json.loads(self.launcher.config_path.read_text(encoding="utf-8"))
729-
self.launcher.saved_configs = data.get("configs", {})
736+
# Load configs and filter out any None keys
737+
raw_configs = data.get("configs", {})
738+
self.launcher.saved_configs = {k: v for k, v in raw_configs.items() if k is not None}
730739
loaded_app_settings = data.get("app_settings", {})
731740
print(f"DEBUG: Found {len(self.launcher.saved_configs)} saved configurations in config file", file=sys.stderr)
732741
print(f"DEBUG: Loaded saved config names: {list(self.launcher.saved_configs.keys())}", file=sys.stderr)
@@ -885,6 +894,11 @@ def save_configuration(self):
885894
suggested_name = self.generate_default_config_name()
886895
self.launcher.config_name.set(suggested_name)
887896
name = suggested_name
897+
898+
# Ensure name is not None
899+
if name is None:
900+
name = "default_config"
901+
self.launcher.config_name.set(name)
888902

889903
current_cfg = self.current_cfg()
890904
self.launcher.saved_configs[name] = current_cfg

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-07-12-1
1+
2025-07-12-2

0 commit comments

Comments
 (0)