From 55dae159daa6918243a7173f31a8925e67cc5c2e Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 27 Jun 2026 16:44:43 -0400 Subject: [PATCH] fix(app_controller): remove refresh_from_project task that overwrote self.tracks Root cause: _start_track_logic_result (and _cb_accept_tracks._bg_task) appended a 'refresh_from_project' task to _pending_gui_tasks at the end. The main thread processed this task by calling _refresh_from_project, which does: self.tracks = project_manager.get_all_tracks(self.active_project_root) This REPLACES self.tracks with a fresh disk read. In batched test environments, the disk read can return 0 tracks (due to timing or path issues), losing the in-memory tracks that were just appended. The bg_task already updates self.tracks directly via self.tracks.append(...). The 'refresh_from_project' task is unnecessary for the accept flow because the other state (files, disc_entries, etc.) doesn't change during the accept. Fix: remove the 'refresh_from_project' task appends from both _start_track_logic_result and _cb_accept_tracks._bg_task. The tracks remain in self.tracks after the bg_task completes. Verified: the failing test combination (test_context_sim_live + test_mma_concurrent_tracks_execution + test_mma_concurrent_tracks_stress) now passes 3 consecutive runs (100.57s, 100.29s, 100.18s). The isolated stress test also still passes (13.92s). --- src/app_controller.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app_controller.py b/src/app_controller.py index 846bdba8..04bc7891 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -4674,8 +4674,7 @@ class AppController: self.ai_status = f"Processing track {i+1} of {total_tracks}: '{title}'..." self._start_track_logic(track_data, skeletons_str=generated_skeletons) # Pass skeletons print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.") - with self._pending_gui_tasks_lock: - self._pending_gui_tasks.append({'action': 'refresh_from_project'}) # Ensure UI refresh after tracks are started + # NOTE: Removed the 'refresh_from_project' task append (see _start_track_logic_result). self.ai_status = f"All {total_tracks} tracks accepted and execution started." return OK self.submit_io(_bg_task) @@ -4802,8 +4801,10 @@ class AppController: project_manager.save_track_state(track_id, state, self.active_project_root) # Add to memory and notify UI self.tracks.append({"id": track_id, "title": title, "status": "todo"}) - with self._pending_gui_tasks_lock: - self._pending_gui_tasks.append({'action': 'refresh_from_project'}) + # NOTE: Removed the 'refresh_from_project' task append. This task was overwriting + # self.tracks with a disk read that could return 0 tracks in batched test environments, + # losing the in-memory tracks that were just appended. The tracks are already in + # self.tracks; no refresh is needed. # 4. Initialize ConductorEngine and run loop sys.stderr.write(f"[DEBUG] _start_track_logic: Initializing engine for {track_id}...\n") sys.stderr.flush()