Repository navigation
OpenCode Desktop starts multiple windows when launched once from a script #7085
Description
Summary
OpenCode Desktop can start multiple Desktop windows and multiple backend instances
when it is launched once from a script.
This happens without:
- double-clicking
- running the script multiple times
- hotkeys
- parallel execution
The script starts OpenCode.exe exactly once, yet multiple Desktop windows appear.
Environment
- OS: Windows 10 / Windows 11
- OpenCode Desktop: latest Windows build
- Installation paths:
%LOCALAPPDATA%\OpenCode\OpenCode.exe %LOCALAPPDATA%\OpenCode\opencode-cli.exe - Launch method:
- PowerShell script
- Script execution count:
- once
Steps to Reproduce (single run)
-
Create a PowerShell script with a single launch command:
& "$env:LOCALAPPDATA\OpenCode\OpenCode.exe" "C:\project"
-
Run the script once from PowerShell.
-
Observe that multiple OpenCode Desktop windows may open.
Observed Behavior
-
More than one Desktop window is shown.
-
Process list contains multiple instances:
OpenCode.exe OpenCode.exe -
Multiple backend instances are spawned:
opencode-cli.exe serve --port=64840 opencode-cli.exe serve --port=64854 opencode-cli.exe serve --port=64870 -
The script itself launches
OpenCode.exeonly once.
Expected Behavior
- A single script execution should result in:
- exactly one Desktop window
- exactly one backend instance
Analysis / Findings
Investigation shows that OpenCode Desktop appears to re-launch or self-spawn
during startup.
Indicators:
- Multiple
OpenCode.exeprocesses exist even though the parent script started it once. - At least one
OpenCode.exeinstance has anotherOpenCode.exeas its parent. - Desktop seems to perform an internal restart / re-exec (possibly for setup,
update, or backend initialization), but the original instance does not exit.
This results in multiple UI windows instead of a clean handoff.
Why This Is a Bug
Even if Desktop needs to restart itself internally:
- the original instance should exit, or
- the new instance should take over,
but multiple visible Desktop windows must not remain active.
Single-instance behavior should be enforced inside the application, not in user scripts.
Workaround
Users must implement a global OS-level mutex in their launcher scripts, for example:
$mutex = New-Object System.Threading.Mutex($false, "Global\OpenCodeDesktopSingleton")
if (-not $mutex.WaitOne(0)) { exit }This workaround prevents the issue, confirming that the problem is related to missing
single-instance protection in Desktop.
Proposed Fix
Implement a single-instance guard inside OpenCode Desktop:
- Use a global named mutex on Windows (e.g.
Global\OpenCodeDesktop) - On detecting an existing instance:
- bring the existing window to foreground
- exit immediately
This is standard behavior for IDEs and desktop developer tools.
Impact
- Confusing user experience (multiple windows from one launch)
- Difficult automation and scripting
- Backend and MCP duplication
- Unnecessary resource usage
Additional Notes
- The issue reproduces without any bootstrap backend.
- The issue reproduces without proxy configuration.
- The issue is not caused by user double-clicking or concurrent launches.
Activity
github-actions commentedon Jan 6, 2026
This issue might be a duplicate of existing issues. Please check:
Both issues report the same core problem: OpenCode Desktop opening multiple windows on Windows when launched once, due to a missing single-instance guard. The root cause and proposed fix are identical (lacking single-instance protection).
Feel free to ignore if this doesn't match your specific case.
andrey-golovko commentedon Jan 6, 2026
Solution. Remove proxies if you don't need them.
umirza-geo commentedon Feb 18, 2026
Hi @andrey-golovko ,
Your solution didn't work on my Windows machine. FYI
github-actions commentedon Apr 20, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.