Private
Public Access
0
0

fix(app_controller): regression in test_context_sim_live from clearing active_project_path

Task 2 (_handle_reset_session reset) introduced a regression: setting self.active_project_path to empty caused an infinite re-switch loop in _do_project_switch because _flush_to_project writes to active_project_path (raises OSError on empty path), and the finally block re-submitted the failed switch on every iteration. Result: test_context_sim_live saw switching-to status for 5+ seconds and MD-only generation was blocked.

Fix: keep self.active_project_path as-is in _handle_reset_session. Only reset self.project (to a fresh default_project dict) and self.project_paths (to empty list). The stale project state issue is solved by replacing the project dict; the active_project_path stays valid for _flush_to_project.

- src/app_controller.py: refined _handle_reset_session project reset
- tests/test_handle_reset_session_clears_project.py: updated contract test to assert active_project_path is preserved
This commit is contained in:
2026-06-08 12:24:10 -04:00
parent 40d61bf3d8
commit e0a3eb8c05
2 changed files with 30 additions and 17 deletions
+8 -7
View File
@@ -3267,14 +3267,15 @@ class AppController:
for d_name in discussions:
discussions[d_name]["history"] = []
# Reset project state so stale data from prior live_gui tests does not
# leak into the next session. Mirrors the default-project branch in
# __init__ (see lines 1743-1745).
reset_name = Path(self.active_project_path).stem if self.active_project_path else "unnamed"
self.project = project_manager.default_project(reset_name)
self.active_project_path = ""
# leak into the next session. We do NOT clear self.active_project_path
# because _do_project_switch calls _flush_to_project() which writes to
# self.active_project_path; an empty path would raise OSError and
# create an infinite re-switch loop. (See test_context_sim_live
# regression on 2026-06-08.)
self.project = project_manager.default_project(
Path(self.active_project_path).stem if self.active_project_path else "unnamed"
)
self.project_paths = []
self.workspace_manager = workspace_manager.WorkspaceManager(project_root=None)
self.workspace_profiles = self.workspace_manager.load_all_profiles()
self.ai_status = "session reset"
self.ai_response = ""
self.ui_ai_input = ""