fix: recover drifted tabs instead of abandoning them (#652)#715
Merged
fix: recover drifted tabs instead of abandoning them (#652)#715
Conversation
When other Chrome extensions (tab managers, new-tab overrides) move automation tabs to a different window, the Browser Bridge now attempts to move the tab back to the automation window rather than creating a new one. This preserves the existing page state and avoids redundant navigation. Changes: - resolveTab(): when a provided tabId has drifted to another window but content is still debuggable, use chrome.tabs.move() to bring it back - handleNavigate(): after navigation completes, detect if the tab drifted during navigation and move it back to the session window - cdp.ts ensureAttached(): log final tab URL and windowId on attach failure for better diagnosis of extension conflicts Closes #652 (partially — addresses tab drift recovery and diagnostics)
07b069d to
d1d9973
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the core issue from #652: when other Chrome extensions (tab managers, new-tab overrides) move automation tabs to a different window, the Browser Bridge now recovers instead of treating it as fatal.
resolveTab(): when a provided tabId has drifted to another window but content is still debuggable, usechrome.tabs.move()to bring it back — preserving page state instead of creating a new tabhandleNavigate(): after navigation completes, detect if the tab drifted during navigation and move it back to the session windowensureAttached(): log final tab URL and windowId on attach failure for better diagnosis of extension conflictsThis is a focused first step. Further hardening (e.g., tab URL hijack recovery, broader cross-window reconciliation) can follow in separate PRs.
Test plan
cd extension && npx vitest run— 9/9 pass (2 new tests for drift recovery)npx vitest run --project unit— 483/483 passcd extension && npx tsc --noEmit— cleancd extension && npm run build— cleanCloses #652 (partially)