Problem
Opening or running WebBrain can leave Chrome showing that the extension is debugging the browser after the run has ended. The Chrome implementation stores debugger sessions by tabId, so CDP control is tab-scoped, but the session is not consistently detached when a run finishes, aborts, or a tab is closed.
This makes the scope unclear to users who want to use WebBrain in one tab while leaving other tabs unchanged. It also leaves the debugger attachment alive longer than the documented active-run lifecycle.
Expected behavior
- Attach the debugger only to the target WebBrain tab that needs CDP.
- Keep other tabs free of WebBrain debugger attachments.
- Detach the target tab after the run or temporary CDP operation finishes, unless an explicitly active feature still owns the session.
- Clean up sessions when a run aborts, errors, or the tab is removed.
- Preserve existing per-tab Dev diagnostics, WebMCP, screenshot, and tool behavior.
Scope
The first fix should centralize debugger-session ownership and cleanup by tabId, add regression coverage for normal and exceptional cleanup, and keep the broader question of reducing static <all_urls> content-script injection separate if needed.
Problem
Opening or running WebBrain can leave Chrome showing that the extension is debugging the browser after the run has ended. The Chrome implementation stores debugger sessions by
tabId, so CDP control is tab-scoped, but the session is not consistently detached when a run finishes, aborts, or a tab is closed.This makes the scope unclear to users who want to use WebBrain in one tab while leaving other tabs unchanged. It also leaves the debugger attachment alive longer than the documented active-run lifecycle.
Expected behavior
Scope
The first fix should centralize debugger-session ownership and cleanup by
tabId, add regression coverage for normal and exceptional cleanup, and keep the broader question of reducing static<all_urls>content-script injection separate if needed.