Private
Public Access
0
0

progress on context composition

This commit is contained in:
2026-05-17 07:27:55 -04:00
parent c1487d32bb
commit a5c0569417
4 changed files with 194 additions and 119 deletions
+25 -26
View File
@@ -2929,29 +2929,20 @@ class AppController:
if name not in presets:
raise KeyError(f"Context preset '{name}' not found.")
preset = presets[name]
# Apply it to the current state
self.ui_file_paths = [f.path for f in preset.files]
self.screenshots = list(preset.screenshots)
self._save_active_project()
# We need to tell gui_2 to populate the full FileItem state from the preset,
# which it does in _handle_refresh_from_project. But we also need to pass the detailed properties.
# We will let the project_manager handle merging in the preset files via configuration next turn.
# Wait, project manager doesn't load preset files into self.files automatically here.
# Let's write the preset files into self.project["files"] directly.
import copy
self.project.setdefault("files", {})["paths"] = [
{
"path": f.path,
"view_mode": f.view_mode,
"custom_slices": copy.deepcopy(f.custom_slices),
"ast_mask": copy.deepcopy(f.ast_mask),
"ast_signatures": getattr(f, "ast_signatures", False),
"ast_definitions": getattr(f, "ast_definitions", False)
} for f in preset.files
]
self._save_active_project()
return preset
# Update only temporary context state, not project files
import copy
self.context_files = []
for f in preset.files:
fi = models.FileItem(path=f.path, view_mode=f.view_mode)
fi.custom_slices = copy.deepcopy(f.custom_slices) if hasattr(f, 'custom_slices') else []
fi.ast_mask = copy.deepcopy(f.ast_mask) if hasattr(f, 'ast_mask') else {}
fi.ast_signatures = getattr(f, 'ast_signatures', False)
fi.ast_definitions = getattr(f, 'ast_definitions', False)
self.context_files.append(fi)
self.screenshots = list(preset.screenshots)
return preset
def _cb_load_track(self, track_id: str) -> None:
"""
[C: src/gui_2.py:App._render_mma_track_browser]
@@ -3459,11 +3450,19 @@ class AppController:
models.save_config(self.config)
track_id = self.active_track.id if self.active_track else None
flat = project_manager.flat_config(self.project, self.active_discussion, track_id=track_id)
flat.setdefault("files", {})["paths"] = self.context_files
import copy
flat["files"] = copy.copy(flat.get("files", {}))
flat["files"]["paths"] = self.context_files
# Configure MCP so that aggregate.py can fetch skeletons for external files (e.g. gencpp)
file_dicts = [f.to_dict() if hasattr(f, 'to_dict') else {"path": str(f)} for f in self.context_files]
mcp_client.configure(file_dicts, [self.active_project_root] if self.active_project_root else None)
import os
file_dicts = []
for f in self.context_files:
p = f.path if hasattr(f, 'path') else str(f)
if not os.path.isabs(p):
p = os.path.join(self.ui_files_base_dir, p)
file_dicts.append({"path": p})
mcp_client.configure(file_dicts, [self.ui_files_base_dir])
persona = self.personas.get(self.ui_active_persona)
strategy = persona.aggregation_strategy if persona else "auto"