Private
Public Access
0
0

feat(presets): Implement ContextPresetManager and integrate with AppController

This commit is contained in:
2026-05-16 11:04:38 -04:00
parent e8fb9d1b23
commit e3d84bc4da
4 changed files with 146 additions and 33 deletions
+28
View File
@@ -0,0 +1,28 @@
from typing import Dict, Any
from src.models import ContextPreset
class ContextPresetManager:
"""Manages context presets within the project dictionary (manual_slop.toml)."""
def load_all(self, project_dict: Dict[str, Any]) -> Dict[str, ContextPreset]:
"""Loads all context presets from the project dictionary."""
presets: Dict[str, ContextPreset] = {}
presets_data = project_dict.get("context_presets", {})
for name, data in presets_data.items():
try:
presets[name] = ContextPreset.from_dict(name, data)
except Exception:
# Silent failure or logging could be added here
pass
return presets
def save_preset(self, project_dict: Dict[str, Any], preset: ContextPreset) -> None:
"""Saves a context preset into the project dictionary."""
if "context_presets" not in project_dict:
project_dict["context_presets"] = {}
project_dict["context_presets"][preset.name] = preset.to_dict()
def delete_preset(self, project_dict: Dict[str, Any], name: str) -> None:
"""Deletes a context preset from the project dictionary."""
if "context_presets" in project_dict and name in project_dict["context_presets"]:
del project_dict["context_presets"][name]