mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 22:32:06 +00:00
fix: prevent cross-project UI contamination (#71)
When running multiple projects simultaneously, UI would show mixed data because the manager registry used only project_name as key. Projects with the same name but different paths shared the same manager instance. Changed manager registries to use composite key (project_name, resolved_path): - server/services/process_manager.py: AgentProcessManager registry - server/services/dev_server_manager.py: DevServerProcessManager registry This ensures that: - /old/my-app and /new/my-app get separate managers - Multiple browser tabs viewing different projects stay isolated - Project renames don't cause callback contamination Fixes: leonvanzyl/autocoder#71 Also fixes: leonvanzyl/autocoder#62 (progress bar sync) Also fixes: leonvanzyl/autocoder#61 (features missing in kanban) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -510,7 +510,9 @@ class AgentProcessManager:
|
||||
|
||||
|
||||
# Global registry of process managers per project with thread safety
|
||||
_managers: dict[str, AgentProcessManager] = {}
|
||||
# Key is (project_name, resolved_project_dir) to prevent cross-project contamination
|
||||
# when different projects share the same name but have different paths
|
||||
_managers: dict[tuple[str, str], AgentProcessManager] = {}
|
||||
_managers_lock = threading.Lock()
|
||||
|
||||
|
||||
@@ -523,9 +525,11 @@ def get_manager(project_name: str, project_dir: Path, root_dir: Path) -> AgentPr
|
||||
root_dir: Root directory of the autonomous-coding-ui project
|
||||
"""
|
||||
with _managers_lock:
|
||||
if project_name not in _managers:
|
||||
_managers[project_name] = AgentProcessManager(project_name, project_dir, root_dir)
|
||||
return _managers[project_name]
|
||||
# Use composite key to prevent cross-project UI contamination (#71)
|
||||
key = (project_name, str(project_dir.resolve()))
|
||||
if key not in _managers:
|
||||
_managers[key] = AgentProcessManager(project_name, project_dir, root_dir)
|
||||
return _managers[key]
|
||||
|
||||
|
||||
async def cleanup_all_managers() -> None:
|
||||
|
||||
Reference in New Issue
Block a user