Skip to content

Browser Bridge: new windows steal focus on macOS (should use tabs instead) #739

@rickexpgame

Description

@rickexpgame

Problem

The Browser Bridge extension creates new Chrome windows (chrome.windows.create) for each automation workspace. On macOS, every new window steals focus from the user's active application, making the computer unusable during automated scans.

Current behavior

  1. Each opencli command triggers getAutomationWindow() in the extension's background.js
  2. If no existing session for the workspace, it calls chrome.windows.create({ focused: false, ... })
  3. macOS ignores focused: false — the new window always activates and comes to front
  4. Different OPENCLI_CDP_TARGET values create separate workspaces, each spawning its own window
  5. Windows idle-timeout after 30s (WINDOW_IDLE_TIMEOUT), so repeated scans keep creating/destroying windows

Impact

When running batch scans (e.g., 146 restaurants across tabelog/omakase/tablecheck), the user experiences:

  • Constant window pop-ups stealing keyboard/mouse focus
  • Inability to use other applications during the ~60 min scan
  • Chrome windows flashing on screen every few seconds

Attempted workarounds (all insufficient)

Approach Result
focused: false macOS ignores this for new windows
state: "minimized" in create() Conflicts with focused/width/height params
chrome.windows.update(id, {state:"minimized"}) after create Works but window still flashes briefly on main screen
left: -9999 (off-screen) Chrome rejects: "Bounds must be at least 50% within visible screen space"
Move to secondary monitor after create Works but still flashes on primary screen first
--window-position Chrome flag Ignored by Google Chrome (only works in Chromium)

Suggested fix

Follow the pattern used by the Claude in Chrome extension:

  • Use tabs within an existing window (chrome.tabs.create) instead of new windows (chrome.windows.create)
  • Optionally use a tab group to isolate automation tabs
  • This avoids the macOS focus-stealing issue entirely, since new tabs don't activate the window

Minimal code change suggestion

In the extension's background.js, getAutomationWindow():

// Instead of:
const win = await chrome.windows.create({ url: BLANK_PAGE, ... });

// Consider:
// Reuse the existing Chrome window, create a tab in it
const [existingWindow] = await chrome.windows.getAll({ windowTypes: ['normal'] });
const tab = await chrome.tabs.create({ 
  windowId: existingWindow.id, 
  url: BLANK_PAGE, 
  active: false  // this actually works for tabs, unlike focused:false for windows
});

Environment

  • macOS 15 (Darwin 25.3.0)
  • Google Chrome 146.0.7680.178
  • opencli v1.6.1, extension v1.5.5
  • Dual monitor setup (Studio Display + DELL S2722QC)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions