fix(api): persist the mode selected through set_mode

The mode selector applied its choice to the shared config dict — which
the engine reads live, so the switch felt effective — but nothing ever
wrote it to disk: a restart silently reverted the node to its previous
mode. The web UI is blameless; it calls /api/set_mode expecting it to
persist (SetCommand.ts even documents that expectation), and the RF
admin path already persists the same change through
_apply_config_update.

set_mode now saves through config_manager.update_and_save, the same
path the settings endpoints use, and reports persisted: true. If the
save fails the live switch stands — matching the old behaviour — but
the response is a loud error instead of a silent future loss.

Signed-off-by: Thibault VINCENT <root@devcat.org>
This commit is contained in:
Thibault VINCENT committed 2026-08-21 22:16:22 +02:00
1 parent 653733a8b5
commit a725dfbe85
2 files changed
+31 -2

No files matched your search

+11 -1
View File
@@ -1983,8 +1983,18 @@ class APIEndpoints:
if "repeater" not in self.config:
self.config["repeater"] = {}
self.config["repeater"]["mode"] = new_mode
# The engine reads the mode live from the shared config dict;
# update_and_save writes it to disk so the choice survives a
# restart.
result = self.config_manager.update_and_save(
updates={}, live_update=True, live_update_sections=["repeater"]
)
if not result.get("saved", False):
return self._error(result.get("error", "Failed to save configuration to file"))
logger.info(f"Mode changed to: {new_mode}")
return {"success": True, "mode": new_mode}
return {"success": True, "mode": new_mode, "persisted": True}
except cherrypy.HTTPError:
# Re-raise HTTP errors (like 405 Method Not Allowed) without logging
raise