This commit is contained in:
2026-01-31 15:37:17 -08:00
parent ae7acd48ac
commit c854f8c6a8
5 changed files with 151 additions and 7 deletions

View File

@@ -173,6 +173,8 @@ class ConfigModal(ModalScreen):
yield ScrollableContainer(id="fields-container")
with Horizontal(id="config-actions"):
yield Button("Save", variant="success", id="save-btn")
# Durable synchronous save: waits and verifies DB persisted critical keys
yield Button("Save (durable)", variant="primary", id="save-durable-btn")
yield Button("Add Store", variant="primary", id="add-store-btn")
yield Button("Add Provider", variant="primary", id="add-provider-btn")
yield Button("Add Tool", variant="primary", id="add-tool-btn")
@@ -790,6 +792,43 @@ class ConfigModal(ModalScreen):
self.refresh_view()
except Exception as exc:
self.notify(f"Save failed: {exc}", severity="error", timeout=10)
elif bid == "save-durable-btn":
# Perform a synchronous, verified save and notify status to the user.
self._synchronize_inputs_to_config()
if not self.validate_current_editor():
return
if self.editing_item_name and not self._editor_has_changes():
self.notify("No changes to save", severity="warning", timeout=3)
return
try:
from SYS.config import save_config_and_verify
saved = save_config_and_verify(self.config_data, retries=3, delay=0.1)
try:
self.config_data = reload_config()
except Exception:
pass
if saved == 0:
msg = f"Configuration saved (no rows changed) to {db.db_path.name}"
else:
msg = f"Configuration saved ({saved} change(s)) to {db.db_path.name} (verified)"
try:
self.notify(msg, timeout=6)
except Exception:
pass
# Return to the main list view within the current category
self.editing_item_name = None
self.editing_item_type = None
self.refresh_view()
self._editor_snapshot = None
except Exception as exc:
self.notify(f"Durable save failed: {exc}", severity="error", timeout=10)
try:
log(f"Durable save failed: {exc}")
except Exception:
pass
elif bid in self._button_id_map:
action, itype, name = self._button_id_map[bid]
if action == "edit":