[Bug]: Background window steals focus on initial creation on macOS
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
- Use macOS with no existing OpenCLI-owned browser window.
- Set
OPENCLI_WINDOW=background. - Keep another application focused.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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