Repository navigation
Description
Summary
On Windows 11, opencode-cli (v2.0.20, serve --service, Bun-compiled) spawns short-lived child processes through cmd.exe (cmd /d /s /c "git rev-parse --git-common-dir", git rev-parse --show-toplevel, git config user.email, MCP npx ...). Each spawn creates a visible console window that takes foreground focus, then disappears. During active sessions this happens at ~1.5??/sec for 30??5 second bursts (100+ windows per burst), making the app nearly unusable ??focus is ripped away from the editor continuously.
Environment
- Windows 11, x64
- OpenCode Desktop 2.0.20 ??
opencode-cli.exe serve --service(v2.0.20, built with Bun 1.4.2) - Default terminal application: Windows Console Host (reproduced with both Console Host and Windows Terminal as default)
Reproduction
- Open OpenCode Desktop on Windows with a git repository project.
- Send messages / run sessions normally.
- Observe bursts of
cmd.execonsole windows flashing and stealing focus.
Captured command lines (parent = opencode-cli.exe serve --service):
cmd /d /s /c "git rev-parse --git-common-dir"
cmd /d /s /c "git rev-parse --show-toplevel"
cmd /d /s /c "git config user.email"
cmd /d /s /c "npx -y obsidian-mcp-server@latest"
Observed via a WinEvent hook (EVENT_OBJECT_SHOW, EVENT_SYSTEM_FOREGROUND): each spawn produces SHOW + FOREGROUND events on a ConsoleWindowClass window at a fixed rhythm (~500??00ms apart, ~100 windows per 45s burst).
Expected behavior
Child processes spawned for internal git probes/MCP must not create visible windows or steal focus.
Analysis
packages/util/src/cross-spawn-spawner.ts(at tagv2.0.20) does passwindowsHide: process.platform === "win32"tochild_process.spawn, and the stringwindowsHide:!0is present in the shippedopencode-cli.exe.- However the windows still appear. Suspected cause:
windowsHideis ineffective for this spawn path on Windows ??likely the combination with thecmd.exewrapper /shelloption / Bun'snode:child_processcompat layer. Known upstream references: child_process - windowsHide not working with detached: true nodejs/node#21825 (windowsHideignored withdetached), and the distinct observation thatdetached: command.options.detached ?? process.platform !== "win32"interacts with the hide flag. - Control experiment on the same machine: a Bun 1.4.2 compiled binary (GUI subsystem, no console) spawning
cmd.exewithwindowsHide: truedoes not create a window;windowsHide: falsedoes. So Bun honors the flag in isolation ??the effective spawn path inopencode-climust be dropping it (or spawning with a flag combination that defeats it). - Also observed:
git rev-parseprobes run at ~1.5??/sec for 30??5s at a time during active sessions. Regardless of window visibility, this polling rate for git discovery seems high; cachingRepository.discoverresults might reduce the spawn volume substantially.
Suggested fix
- Ensure
CREATE_NO_WINDOW(not justSTARTF_USESHOWWINDOW/SW_HIDE) is applied to every internal child spawn on Windows, including thecmd.exe /d /s /cwrapper path and MCP server spawns. - Alternatively avoid the
cmd.exewrapper entirely forgit(it is a native.exe; spawning it directly needs no shell). - Consider caching git repository discovery instead of re-running
rev-parseper operation.
Related
- Similar reports: Windows: subprocess spawn (git, codegraph, etc.) flashes console window #31629, Windows: Console window flash on subprocess spawn — root cause analysis and solutions (CREATE_NO_WINDOW, S4U, conhost --headless) #38715, windows: console window flashes on every subprocess spawn (v2 next build) #42440, Windows: bash tool spawns visible cmd.exe window on v1.15.12 (regression) #30315 (closed without fix), PRs fix(desktop): hide helper process windows #40137, fix(opencode2): hide background console windows on windows #45259 (closed unmerged).
- This report adds: exact spawn command lines, parent process chain, WinEvent-hook capture timestamps, and the Bun A/B control experiment.
Workaround currently used
A local WinEvent hook script hides each console window immediately on EVENT_OBJECT_SHOW and returns focus to the app. Users should not need this.
Activity
github-actions commentedon Sep 30, 2026
This issue might be a duplicate of existing issues. Please check:
a2belugin commentedon Oct 1, 2026
Confirming this on the Desktop build too — the problem is still present in
1.18.34.Environment: Windows x64, opencode desktop
1.18.34(Electron,%LOCALAPPDATA%\Programs\@opencode-aidesktop\OpenCode.exe).Repro: launch desktop, open a git working copy → burst of console windows at startup and again on changes/refresh.
Captured live (Win32_Process polling loop). Parent of every line below = the
OpenCode.exenode utility process (--type=utility --utility-sub-type=node.mojom.NodeService):Worth noting: this is the VCS status/diff discovery path, not snapshots. Setting top-level
"snapshot": falseremoved the snapshotgit init/git config/write-treespawns, but the windows above remained.Second, independent source — the codegraph MCP server.
codegraph.js serve --mcp --path <repo>(parent = its ownnode.exe) also spawns git without hiding:Why this is desktop-specific (CLI/TUI is not affected): the desktop is a GUI Electron process with no console. Every console child (
git.exe/cmd.exe) spawned withoutCREATE_NO_WINDOWallocates a new console window. The TUI runs inside a console, so its git children inherit that console and no new window appears.In
resources/app.asar,@opencode/Gitruns git via the process service with options that omitwindowsHide:and the central spawner never sets it either:
…while the MCP spawn path does set
windowsHide: process.platform === "win32". So the flag is applied inconsistently.Can confirm the problem still exists on 1.18.34 desktop.
xxmisaoxx commentedon Oct 6, 2026
Additional data point: still present on OpenCode Desktop 2.0.24 (bundled
opencode-cli2.0.24). I captured the full parent chain and exact command lines with a process monitor, which may help confirm the call site.Environment
opencode-cli2.0.24,serve --service)cmd.exe(%ComSpec%), default terminal application: Windows Console Hostlatestchannelopencode-supermemory@latestonly (no third-party plugins; snapshots disabled in config)Observation
While using the app I get bursts of visible
cmd.execonsole windows (they briefly take focus). Captured during a single burst (local time 14:18:04–14:18:21, ~17 s):cmd.exespawned with parent =opencode-cli.exe serve --service(PID observed)cmd.exe /d /s /c "git ..."git.exechildren of thosecmd.exeCommand lines seen (parent =
...\ai.opencode.desktop\cli\2.0.24\opencode-cli.exe serve --service):Additional Context
location services bootedfor each open project in the server log. With multiple projects open, the probe burst multiplies per location.windowsHide:!0(e.g.spawn(..., { detached: !0, windowsHide: !0, ... })and the process-options helper defaultswindowsHide = !detachedon win32), yet thecmd.exe /d /s /cwrapper path still produces a visible console window.Happy to provide more detail or run additional captures if useful.
xxmisaoxx commentedon Oct 8, 2026
Correction to my earlier comment on this issue.
I originally wrote "no third-party plugins", but I later isolated the real source on the same machine: the remaining
cmd.exe /d /s /c "git ..."spawns come from theopencode-supermemoryplugin (v2.0.15, which is also the currentlateston npm) — not from core.Its
dist/index.js(sourcesrc/services/tags.ts) runs git viaexecSyncwithoutwindowsHide:These match the captured lines exactly.
execSyncalways runs through a shell, so on Windows it becomescmd.exe /d /s /c "git ...". Because plugins execute inside the console-lessopencode-cli serve --serviceprocess, each call withoutwindowsHideallocates a visible console window — which is why the parent process in my capture showed asopencode-cli.exe. Disabling the plugin stopped the bursts on my machine.This is consistent with the "plugins run inside the console-less service" line of investigation (see also #53730), and supports adding the
windowsHideguidance/helper for plugin authors that is being requested — core can't fix third-party call sites.Filed against the plugin: supermemoryai/opencode-supermemory#105
hxbb00 commentedon Oct 10, 2026
Confirmed still reproducible on v2.0.26 (latest release channel, Windows 11).
Environment
@opencode/cli, installed globally via npm)Windows_NT 10.0.26300(win32 x64)WT_SESSIONset),TERM=xterm-256colorpwsh.exe)latest)superpowers@git+https://github.com/obra/superpowers.gitC:\Program Files\Git\cmd\git.exeWhat I see
Flashing
git.execonsole windows (sometimes stealing focus / popping new Windows Terminal tabs) during normal TUI use. Matches the pattern described above: the managed background service (serve --service, detached, no console) spawns console-subsystem children, so the kernel allocates a fresh visible console per spawn.Log evidence
%USERPROFILE%\.local\share\opencode\log\opencode.log, allrole=server, 21 git spawns within a short session — e.g.:Shell tool calls also spawn visible
pwsh.EXEconsoles from the same detached service.Workaround status
opencode --standaloneavoids the flashes (service inherits the TUI console), as previously reported by @ramagdev — confirms the detached-service root cause.Happy to test a fix build (
nextchannel) if one lands.Forrest-Gump0927 commentedon Oct 13, 2026
Still reproducible on OpenCode Desktop 2.0.27 (Windows 11) — data from a 12-hour process-creation monitor
Environment
opencode-cli.exe serve --service(%APPDATA%\ai.opencode.desktop\cli\2.0.27\opencode-cli.exe)gitprobes seen here are not repo-drivenoh-my-opencodefolder exists under%LOCALAPPDATA%)Method
Continuous WMI subscription to
__InstanceCreationEventonWin32_Process(0.3 s polling), logging every new process with its parent PID/name and full command line, ~12 h.Parent -> child counts (my own interactive shell excluded)
WindowsTerminal.exe289 +OpenConsole.exe291, all reported with parentsvchost.exe(console handoff) — i.e. one visible console per spawn.Notes
git.exespawns are most likely the plugin-update / MCP-related probes discussed in server: unpinned plugin update check flashes visible git console window on Windows #50868. Exactcmd.execommand lines were not captured in this run — happy to add them if useful.Forrest-Gump0927 commentedon Oct 13, 2026
Follow-up — exact command lines captured (Desktop 2.0.27, Windows 11)
I extracted the command line of every
opencode-cli.exe -> cmd.exespawn from the same ~12 h monitor log (379 total, parent =opencode-cli.exe serve --service):Additional data points:
npx/ MCP spawns in the entire log: 0 — no MCP server is started through a shell on this machine, so MCP is not a factor here.token-usage-toast.jsthat contains nospawn/exec/child_processusage, and the config file has nopluginsentries. So these git probes come from the core.git rev-parse --git-common-diris spawned roughly 24×/hour, in tight bursts during active sessions — consistent with the per-session/per-message git probe path.~/.config/opencode), whereas a clean V2 install on another machine shows no flashing at all — which suggests the trigger frequency may depend on session/state carried over, but the spawn itself is core behavior.neriousy commentedon Oct 20, 2026
Thanks for the report and the process captures. We're tracking this same Windows child-process console flashing in #52266, so I'm closing this as a duplicate. Please follow that issue for updates.