You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Agent mode phase 0: clean up background tasks when switching workspaces
killAllBackgroundCommands() was only ever called from app.on("window-all-closed")/"before-quit" — neither the session-load effect nor changeAgentWorkspace() in Chat.tsx cleaned up the *previous* workspace's tasks when switching to a different one, so they kept running indefinitely and kept counting against MAX_BACKGROUND_TASKS.
- New app/src/process-tree.ts: killProcessTree(pid), since spawn(cmd, {shell:true}).kill() only kills the shell, not whatever it spawned (e.g. npm run dev -> node). POSIX kills the process group (requires detached:true at spawn time, now set); Windows shells out to taskkill /t /f.
- BackgroundTask now carries its workspaceRoot. New killBackgroundCommandsForWorkspace(root) kills and forgets only that workspace's tasks, leaving others running.
- New agent:closeWorkspace IPC call, invoked from Chat.tsx via a small ref-tracking helper right before every place agentWorkspace changes (initial pick, folder change, session load) so the previously-active workspace's tasks get torn down on the actual transition, not just at quit.
This is prep work for a real sandbox/permission system and persistent terminals, both of which need the same workspace-scoped process lifecycle rather than duplicating it.
0 commit comments