From b4e48ce375e7240a886b02d3e9a14926f970dd25 Mon Sep 17 00:00:00 2001 From: koko210Serve Date: Wed, 8 Apr 2026 15:05:25 +0300 Subject: [PATCH] fix: /config/set now syncs all runtime-relevant globals Previously only 4 of 5+ settings were synced to globals when set via the generic /config/set endpoint. Added: - memory.use_cheshire_cat -> globals.USE_CHESHIRE_CAT - runtime.mood.dm_mood -> globals.DM_MOOD + DM_MOOD_DESCRIPTION - Uses same _GLOBALS_SYNC mapping pattern as restore_runtime_settings --- bot/api.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/bot/api.py b/bot/api.py index 83d9a68..5f84ef1 100644 --- a/bot/api.py +++ b/bot/api.py @@ -2978,15 +2978,27 @@ async def set_config_value(request: Request): from config_manager import config_manager config_manager.set(key_path, value, persist=persist) - # Update globals if needed - if key_path == "discord.language_mode": - globals.LANGUAGE_MODE = value - elif key_path == "autonomous.debug_mode": - globals.AUTONOMOUS_DEBUG = value - elif key_path == "voice.debug_mode": - globals.VOICE_DEBUG_MODE = value - elif key_path == "gpu.prefer_amd": - globals.PREFER_AMD_GPU = value + # ── Sync globals for every runtime-relevant key path ── + _GLOBALS_SYNC = { + "discord.language_mode": ("LANGUAGE_MODE", str), + "autonomous.debug_mode": ("AUTONOMOUS_DEBUG", bool), + "voice.debug_mode": ("VOICE_DEBUG_MODE", bool), + "memory.use_cheshire_cat": ("USE_CHESHIRE_CAT", bool), + "gpu.prefer_amd": ("PREFER_AMD_GPU", bool), + } + + if key_path in _GLOBALS_SYNC: + attr, converter = _GLOBALS_SYNC[key_path] + setattr(globals, attr, converter(value)) + elif key_path == "runtime.mood.dm_mood": + # DM mood needs description loaded alongside + if isinstance(value, str) and value in getattr(globals, "AVAILABLE_MOODS", []): + globals.DM_MOOD = value + try: + from utils.moods import load_mood_description + globals.DM_MOOD_DESCRIPTION = load_mood_description(value) + except Exception: + globals.DM_MOOD_DESCRIPTION = f"I'm feeling {value} today." return { "success": True,