You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] OpenCode steals foreground focus and disrupts user workflow when testing/running apps (Window Activation / Focus Stealing) #57578
When OpenCode executes tasks in the background that involve launching, testing, or inspecting an application, the target application window forcefully launches into the foreground active window. This steals OS-level keyboard/mouse focus from whichever window the user is currently working in (e.g., code editor, browser, notes).
Actual Behavior
Running an app or background test in OpenCode pops the application window directly on top of active work.
Focus is stolen from the active window, causing mid-sentence typing interruptions.
The user has to manually re-focus their active application every time OpenCode runs or tests a UI build.
Expected Behavior
OpenCode should execute background app checks, previews, and UI tests without taking active window focus away from the user's primary workspace.
Testing and UI inspection tasks should run:
Headless or Off-Screen: Virtual framebuffers or hidden rendering contexts so no physical window disrupts the desktop.
Without Focus Activation: If a GUI window must open, it should launch in a non-activating background layer (SHOWNOACTIVATE / non-activating window flags) so typing and work in the foreground are never interrupted.
Steps to Reproduce
Open a workspace in OpenCode.
Trigger an action or agent task that executes or tests a target application.
Switch to another app and begin typing or editing.
Observe: The application spawned by OpenCode pops into the active foreground, stealing focus and interrupting work.
Here are the additional details to help debug this issue:
OpenCode version: OpenCode Desktop Version 2.1.2 (running on macOS, Apple Silicon / M1).
Interface: OpenCode Desktop App.
What took focus & command ran:
The app taking focus is the desktop application under development in the workspace (for example, myapp.app).
The focus-stealing occurs when OpenCode runs/launches the compiled desktop app binary during background test/build cycles (e.g., executing the app directly via shell commands or open myapp.app without the -g background flag).
It is not the OpenCode built-in browser taking focus—it is the local macOS target application being tested.
Summary of behavior:
I was actively dictating text and working in another application (such as Notepad/TextEdit) while OpenCode was running background tasks on my project in the OpenCode Desktop app. While OpenCode was executing/testing the local desktop app build (myapp.app), the launched app window forcefully opened in the OS foreground. This stole system-level keyboard focus mid-dictation/mid-typing, causing text input to drop or lose target window state, and interrupting active media playback (like YouTube) by popping over the workspace.
Key issue:
When OpenCode spawns or runs target macOS application binaries to verify or test UI work, it launches them as activated foreground processes rather than executing them quietly in the background (e.g., using open -g on macOS, non-activating window flags, or headless preview wrappers).
Thanks for the report! To work out what's going on, we need a few more details:
OpenCode version: the output of opencode --version.
Interface: are you using the TUI (and in which terminal), the desktop app, or the web app?
What took focus: what was the exact command or tool call the agent ran (for example npm run dev, open MyApp.app, an Xcode/Electron build, the built-in browser), and which app's window came to the front?
In a couple of sentences, in your own words: what you did, what you expected, and what you saw.
This matters because when the agent runs a command, whether the launched app takes focus is mostly up to that app and macOS. For example, open MyApp.app brings the app to the front, but open -g MyApp.app launches it in the background. So we need to know what is being launched to tell whether OpenCode is causing this.
You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
I didn't find an exact duplicate. These are related, ordered by likelihood:
We're closing this for now because we haven't heard back. To tell whether OpenCode is causing the focus stealing, we need your OpenCode version, which interface you're using (TUI/desktop/web), and the exact command or app that came to the front. On macOS, the launched app usually decides whether it takes focus.
If it still happens, please reply here with those details or open a new issue, and we'll take another look. Thanks!
Activity
opencode-agent commentedon Oct 21, 2026
Thanks for the report! To work out what's going on, we need a few more details:
opencode --version.npm run dev,open MyApp.app, an Xcode/Electron build, the built-in browser), and which app's window came to the front?This matters because when the agent runs a command, whether the launched app takes focus is mostly up to that app and macOS. For example,
open MyApp.appbrings the app to the front, butopen -g MyApp.applaunches it in the background. So we need to know what is being launched to tell whether OpenCode is causing this.You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
I didn't find an exact duplicate. These are related, ordered by likelihood:
cmd.exe(git probes, MCP spawns) flashes a visible console window and steals focus despitewindowsHidebeing set #52281: child processes stealing focus, but on Windows (cmd.exewindows)koddek commentedon Oct 21, 2026
i updated the issue with the additional information
opencode-agent commentedon Oct 24, 2026
We're closing this for now because we haven't heard back. To tell whether OpenCode is causing the focus stealing, we need your OpenCode version, which interface you're using (TUI/desktop/web), and the exact command or app that came to the front. On macOS, the launched app usually decides whether it takes focus.
If it still happens, please reply here with those details or open a new issue, and we'll take another look. Thanks!