Skip to content

fix(extension): skip user windows in tab-group discovery#1762

Open
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/tab-group-user-window-residue
Open

fix(extension): skip user windows in tab-group discovery#1762
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/tab-group-user-window-residue

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

Description

discoverOwnedContainerFromTabGroup queries Chrome for any tab group titled "OpenCLI Adapter" across all windows and adopts the first match as the automation container. When Chrome moves our tab group into the user's main window (via tab drag or "Merge all windows"), the residual group survives there after the original automation window closes. The next service-worker discovery cycle then adopts the user's window, and findReusableOwnedContainerTab happily returns the user's real http(s) tab as a reusable automation target. resolveTab proceeds to overwrite that tab.

Adapter tabs created by the extension are always added to our group via ensureOwnedContainerTabGroup, so any http(s) tab in the candidate window that is outside our group must be a user tab. Use that as the residue signal in toOwnedContainerDiscoveryCandidate: when present, return null so selectOwnedContainerDiscoveryCandidate does not adopt the window and a fresh automation window is created instead.

Related issue: fixes #1760.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Screenshots / Output

Unit test skips a residual OpenCLI Adapter group when its window holds user http tabs outside the group covers the regression: a window with a user https:// tab outside the matched group and an "OpenCLI Adapter" group inside it now triggers a fresh automation window via chrome.windows.create and the user's tab url is preserved.

Live test on Chrome for Testing 149 with the patched extension loaded: a probe driven from the service-worker debug WS prepared the residue state (user window with one https://example.com/users-real-tab tab outside the group and one about:blank tab inside an "OpenCLI Adapter" group) and the patched discovery returned adopted: null while the pre-patch logic would have selected the user's window. Full extension suite: 75/75 pass.

@Benjamin-eecs Benjamin-eecs changed the title fix(extension): skip user windows in tab-group discovery (fixes #1760) fix(extension): skip user windows in tab-group discovery May 26, 2026
@Benjamin-eecs Benjamin-eecs force-pushed the fix/tab-group-user-window-residue branch from baef6ff to e9c8833 Compare May 26, 2026 23:12
@Benjamin-eecs Benjamin-eecs marked this pull request as ready for review May 27, 2026 01:49
Copilot AI review requested due to automatic review settings May 27, 2026 01:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a guard so that a tab group labelled as an owned container is skipped during discovery if its window contains user http(s) tabs outside the group, preventing the extension from hijacking a user's main window when a group has been dragged/merged into it.

Changes:

  • Skip owned-container discovery candidates whose window has user http(s) tabs outside the group.
  • Add a test verifying that such residual groups are not reused and a new window is created instead.
  • Mirror the source change in the compiled dist/background.js bundle.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
extension/src/background.ts Adds the residual-window detection in toOwnedContainerDiscoveryCandidate.
extension/src/background.test.ts Adds a test for the new skip behavior.
extension/dist/background.js Compiled output reflecting the source change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ener#1760)

Chrome can move our "OpenCLI Adapter" tab group into the user's main
window via drag or window merge. After the original automation window
closes the residual group survives in the user's window, and the next
service-worker discovery cycle adopts that window as the automation
container, letting `resolveTab` reuse the user's real http(s) tabs as
automation targets.

`toOwnedContainerDiscoveryCandidate` now skips any candidate window
whose tabs include http(s) pages outside the matched group, since
extension-created adapter tabs are always inside the group.

Fixes jackwener#1760
@Benjamin-eecs Benjamin-eecs force-pushed the fix/tab-group-user-window-residue branch from e9c8833 to cd4399b Compare May 27, 2026 13:41
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.

[Bug] Empty tab group residue causes resolveTab to reuse user's existing tabs instead of creating new automation window

2 participants