Skip to content

Windows: first TUI launch flashes several console windows (detached service and updater probes spawn console children without a hidden window) #56704

Open

Description

@cloud-assa

Description

On Windows 11, the first opencode launch after a boot briefly flashes ~6-8 console windows (a few milliseconds each) before the TUI paints. Later launches in the same boot are clean, because the background service and MCP servers are already running.

Reproduced on 2.0.30 (npm global install) with a process trace. This is cosmetic but looks like a crash or malware, and it repeats on every cold start.

Environment

  • OpenCode 2.0.30 (@opencode/cli, npm global at %APPDATA%\npm)
  • Windows 11, Node v24.12.0 (only used by the npm shim)
  • TUI launched from a cmd.exe /c opencode window
  • Local MCP servers enabled: repomix (resolved through the npm .cmd shim), engram (native .exe), a Python MCP server
  • Plugins present, but not required to see the flashes

Steps to reproduce

  1. Reboot, or make sure no opencode / MCP process is running (opencode serve --service, engram, repomix).
  2. Open a terminal and run opencode.
  3. Watch the taskbar: several console windows pop up and vanish while the TUI starts.

Observed

Process trace during a cold launch (Get-Process poll + Win32_Process details). Every conhost.exe below is a newly allocated console, i.e. a visible window:

PID=16568 PPID=4644  opencode :: "...\@opencode\cli\bin\opencode.exe" serve --service
PID=7172  PPID=16568 engram   :: "...\engram\bin\engram.exe" serve
PID=16800 PPID=16508 opencode :: "...\@opencode\cli\bin\opencode.exe"            (the TUI)
PID=13780 PPID=16800 cmd      :: cmd.exe /d /s /c "npm ^"list^" ^"-g^" ^"--depth=0^" ^"@opencode/cli^""
PID=14084 PPID=16800 cmd      :: cmd.exe /d /s /c "pnpm ^"list^" ^"-g^" ^"--depth=0^" ^"@opencode/cli^""
PID=18184 PPID=16568 cmd      :: cmd.exe /d /s /c "repomix ^"--mcp^""
PID=9612  PPID=16568 engram   :: "...\engram.exe" mcp --tools=agent
PID=17064 PPID=16568 cmd      :: cmd.exe /d /s /c "repomix ^"--mcp^""
PID=19956 PPID=16568 engram   :: "...\engram.exe" mcp --tools=agent
PID=2436  PPID=16508 conhost  :: \??\C:\WINDOWS\system32\conhost.exe 0x4   <- TUI console
PID=10304 PPID=13780 conhost  :: ...   <- new console for the npm probe
PID=14088 PPID=18184 conhost  :: ...   <- new console for repomix --mcp
...

Analysis

  • opencode serve --service starts detached, so it has no console. Every console child it spawns (MCP servers such as repomix --mcp, engram mcp) gets a newly allocated console, and Windows shows that console window by default.
  • The TUI's install/update probes (cmd /d /s /c npm list -g ..., pnpm list -g ...) also get their own consoles instead of inheriting the TUI's.
  • The MCP servers are duplicated (two repomix, two engram mcp) on cold start, which doubles the number of windows.
  • Note the Win32 caveat: CREATE_NO_WINDOW is ignored when combined with DETACHED_PROCESS / CREATE_NEW_CONSOLE, and windowsHide in Node/Bun maps to CREATE_NO_WINDOW. So detached: true + windowsHide: true still produces a visible window; the detached children need a hidden STARTUPINFO (STARTF_USESHOWWINDOW + SW_HIDE) or a different spawn strategy.

Expected

Children spawned by the service, by MCP startup, and by the update probes run without a visible console window.

Impact

Cosmetic, but noisy on every boot and looks suspicious to the user (several terminals opening and closing by themselves).

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the process trace. I couldn't reproduce this myself because the sandbox I test in runs Linux, and these console window flashes only happen on Windows, so a maintainer with a Windows machine will need to check it.

    A look at the current code (not a test run) fits your analysis: the background service is still started with detached: true plus windowsHide: true, and Windows ignores the hide flag in that combination. #52594 tried a different approach, giving the service a console with no window, but that PR was closed and its change is not on dev.

    Related reports, most likely first:

    Your report adds two things those don't cover: the cold-start updater probes (npm/pnpm list -g) and the MCP servers being started twice.

  2. stdray commented on Oct 18, 2026

    @stdray

    Same root cause, measured

    The background service has no console. I probed it with AttachConsole(pid):

    process has a console?
    opencode.exe serve --service no — error 6 (ERROR_INVALID_HANDLE)
    opencode.exe serve --stdio --port 0 (--standalone) yes

    A console child of the service therefore gets a new console, and the default terminal application shows it. This fits the process trace in the report above.

    The main open thread for this class is #51887. I posted the full data point there. Please follow that thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions