jackwener / jackwener/OpenCLI

[Bug]: Background window steals focus on initial creation on macOS

Open Beginner friendly
#2,167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29.5k
Forks
2.9k
Avg merge
15h 36m
Merged PRs (30d)
70

Description

Description

The first Browser Bridge window created for a background session can activate Chrome on macOS, even though OpenCLI passes focused: false to chrome.windows.create.

This is the residual initial-creation case from #739. The current grouped-window architecture avoids repeated windows, but a newly created owned container still interrupts the foreground application once.

Steps to reproduce

  1. Use macOS with no existing OpenCLI-owned browser window.
  2. Set OPENCLI_WINDOW=background.
  3. Keep another application focused.
  4. Run:
opencli browser focus-probe open https://example.com/ --window background

Actual behavior

Chrome creates a normal window and becomes the foreground application.

Expected behavior

The owned window is created without activating Chrome or stealing keyboard focus.

Environment

  • OpenCLI: 1.8.6
  • Extension: 1.0.22
  • macOS: 26.5.2 (25F84)
  • Chrome: 150.0.7871.181
  • Node.js: 22.22.0

Proposed fix

Create background owned windows with state: minimized and omit focused and window bounds. Chrome does not allow minimized creation to be combined with left, top, width, or height. Keep the existing focused, sized create data for foreground mode.

Unlike the post-create minimize attempted in #1232, minimizing in the initial windows.create call prevents the visible focus flash.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the browser window creation path used by opencli browser focus-probe open ... --window background and inspect the chrome.windows.create data for background versus foreground mode. Verify that background creation uses minimized state without bounds or focus settings, then reproduce on macOS with another application focused and confirm Chrome does not activate or flash visibly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.