Skip to content

fix: recover drifted tabs instead of abandoning them (#652)#715

Merged
jackwener merged 1 commit intomainfrom
fix/tab-drift-robustness-652
Apr 2, 2026
Merged

fix: recover drifted tabs instead of abandoning them (#652)#715
jackwener merged 1 commit intomainfrom
fix/tab-drift-robustness-652

Conversation

@jackwener
Copy link
Copy Markdown
Owner

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, use chrome.tabs.move() to bring it back — preserving page state instead of creating a new tab
  • handleNavigate(): after navigation completes, detect if the tab drifted during navigation and move it back to the session window
  • ensureAttached(): log final tab URL and windowId on attach failure for better diagnosis of extension conflicts

This is a focused first step. Further hardening (e.g., tab URL hijack recovery, broader cross-window reconciliation) can follow in separate PRs.

Test plan

  • Extension tests: cd extension && npx vitest run — 9/9 pass (2 new tests for drift recovery)
  • Main unit tests: npx vitest run --project unit — 483/483 pass
  • Extension typecheck: cd extension && npx tsc --noEmit — clean
  • Extension build: cd extension && npm run build — clean

Closes #652 (partially)

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)
@jackwener jackwener force-pushed the fix/tab-drift-robustness-652 branch from 07b069d to d1d9973 Compare April 2, 2026 19:46
@jackwener jackwener merged commit 2d005d1 into main Apr 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser Bridge 与标签管理/新标签页扩展冲突:自动化标签页会漂移或被劫持到 chrome-extension 页面

1 participant