fix(src): update load_context_preset to handle Result from load_all

After migrating ContextPresetManager.load_all to return Result[Dict],
the caller in app_controller.load_context_preset needs to extract
.data from the Result before checking 'name not in presets'.

Updates:
- src/app_controller.py:load_context_preset - check result.ok and
  extract result.data before iterating; raise RuntimeError if
  result.ok is False (consistent with the convention).
- tests/test_context_presets_manager.py:test_manager_load_all -
  extract result.data before assertions.

Tests verified:
- tests/test_context_presets_manager.py (4 tests) PASS
- tests/test_project_switch_persona_preset.py::
  test_load_context_preset_missing_raises_keyerror PASS (KeyError
  raised correctly when preset not found)
- tests/test_phase6_engine.py (3 tests) PASS
This commit is contained in:
ed
2026-06-17 23:15:57 -04:00
parent 294f92386d
commit 052881ec20
3 changed files with 16 additions and 2 deletions
+4 -1
View File
@@ -2977,7 +2977,10 @@ class AppController:
self._save_active_project()
def load_context_preset(self, name: str) -> models.ContextPreset:
presets = self.context_preset_manager.load_all(self.project)
presets_result = self.context_preset_manager.load_all(self.project)
if not presets_result.ok:
raise RuntimeError(f"Failed to load context presets: {presets_result.errors}")
presets = presets_result.data
if name not in presets:
raise KeyError(f"Context preset '{name}' not found.")
preset = presets[name]