[Bug]: Windows desktop app spawns two fully independent Electron instances instead of focusing the existing one
Platform: Windows 10, AO pinned v0.11.2, agent-orchestrator.exe distributed build.
Observed: Launching the desktop app (via ao start, or directly) a second time while an instance is already running does not focus the existing window — it spawns a second, fully independent process tree. Confirmed via Get-CimInstance Win32_Process -Filter "Name='agent-orchestrator.exe'":
ProcessId ParentProcessId CommandLine
4508 4404 agent-orchestrator.exe --installed-via=npm-bootstrap
5008 4508 --type=gpu-process ...
15792 4508 --type=utility ...
8304 4508 --type=renderer ...
20476 20056 agent-orchestrator.exe --installed-via=npm-bootstrap
4400 20476 --type=gpu-process ...
20248 20476 --type=utility ...
17700 20476 --type=renderer ...
Two completely separate main processes (4508 and 20476), each with its own gpu/utility/renderer children, both pointing at the same --user-data-dir="C:\Users\<user>\.ao\electron" and presumably the same daemon port (3001).
Expected: Electron's app.requestSingleInstanceLock() should make the second launch a no-op that just focuses the first window's existing instance.
Impact: since the desktop app now owns the daemon lifecycle (ao start no longer starts a background daemon — the app itself does), closing either of the two windows appears to tear down the daemon, since both instances are contending for the same daemon/port state. This causes the daemon to unexpectedly stop (ao doctor reports daemon: stopped) even though the user only closed one of the two (seemingly identical) windows, which is surprising and hard to diagnose from the user's side.
Suggested fix: call app.requestSingleInstanceLock() early in the main process and quit immediately on failure (standard Electron pattern), forwarding second-instance to focus/restore the existing window instead.
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @illegalcall
- @somewherelostt
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.
For faster context or live questions, you can also join the AO Discord.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
@AgentWrapper PR #3692 added the single-instance lock and existing-window focus handler requested here. Should be closed
Hi @faogomes, single-instance lock is on main (the second instance now focuses the first instead of spawning an independent window). Closing as completed. Thanks for the clear report.