fix(mcp): configure mcp_client allowlist on project switch

Previously mcp_client.configure() was only called during ai_client.send()
which meant GUI buttons (Slices/Inspect) couldn't access files when
project was switched to an external project like gencpp. Now _switch_project
reconfigures mcp_client with the new project's root and file_items.
This commit is contained in:
2026-05-10 20:57:11 -04:00
parent c8d2dda763
commit 6861ce0dca
4 changed files with 29 additions and 23 deletions
+3
View File
@@ -2347,6 +2347,9 @@ class AppController:
self.ai_status = f"failed to load project: {e}"
return
self._refresh_from_project()
import mcp_client
file_items_as_dicts = [{"path": f.path if hasattr(f, "path") else str(f)} for f in self.files]
mcp_client.configure(file_items_as_dicts, [str(new_root)])
self.ai_status = f"switched to: {Path(path).stem}"
def _refresh_from_project(self) -> None:
+4 -1
View File
@@ -2909,7 +2909,10 @@ class App:
self.ui_editing_slices_file = f_item
f_path = f_item.path if hasattr(f_item, "path") else str(f_item)
self.text_viewer_title = f"Slices: {f_path}"
self.text_viewer_content = f_item.content or ""
try:
self.text_viewer_content = mcp_client.read_file(f_path)
except Exception as e:
self.text_viewer_content = f"Error reading file: {e}"
self.text_viewer_type = 'cpp' if f_path.endswith(('.cpp', '.hpp', '.h')) else 'python' if f_path.endswith('.py') else 'text'
self.show_text_viewer = True