Skip to content

windows: one console window flashes per project open in 2.2.0 (core git rev-parse without windowsHide) #59598

Closed as duplicate

Description

@mhxy2zhaocaimao

Summary

On Windows 11 with Windows Terminal as the default terminal application, opening or creating a project in the OpenCode desktop app (v2.2.0) makes exactly one console window flash. It is caused by the core repository detector spawning git without hiding the console: git rev-parse --git-dir --git-common-dir --show-toplevel.

Environment

  • opencode version: 2.2.0 (desktop, bundled CLI 2.2.0-x64) 鈥?opencode v2.2.0
  • OS: Windows 11, Microsoft Windows NT 10.0.26300.0 (win32 x64)
  • Terminal: Windows Terminal 1.24.12741 as the default terminal application (CASCADIA_HOSTING_WINDOW_CLASS)
  • Shell: C:\WINDOWS\system32\cmd.exe
  • Install/channel: release desktop app (%LOCALAPPDATA%\Programs\ai.opencode.desktop)
  • Active plugins: local context-mode development build + cbm-augment (both already spawn with windowsHide: true; see Additional Context)

Reproduction

  1. Use Windows 11 with Windows Terminal set as "Default terminal application".
  2. Start the OpenCode desktop app (v2.2.0) and let the server start.
  3. Open an existing project or create a new one, or trigger a location reload (POST /api/location/reload).
  4. A single console/Windows Terminal window appears and disappears immediately, once per opened location.

Expected Behavior

No visible console window is created for background subprocesses such as the Git repository probe.

Actual Behavior

One visible console window per project open. Window capture (Win32 EnumWindows + IsWindowVisible, sampled every 20 ms) during a location load shows:

19:47:11.350  git   parent=13648 [opencode-cli.exe]  cmd=git -C C:\Users\DELL rev-parse --show-toplevel
19:47:28.994  hwnd=3868748  pid=4528  proc=git  class=ConsoleWindowClass  (visible)

The corresponding server log line for the same flow:

level=INFO message="spawning process" command="C:\Program Files\Git\cmd\git.EXE"
args="[\"rev-parse\",\"--git-dir\",\"--git-common-dir\",\"--show-toplevel\"]"

Root cause is the well-known one: opencode-cli.exe runs without a console, and the child console process is created without CREATE_NO_WINDOW (i.e. without windowsHide: true). Windows then allocates a new console, which the configured default terminal (Windows Terminal) hosts as a visible window for a moment.

Additional Context

Suggested fix: pass windowsHide: true (or CREATE_NO_WINDOW) to every Bun.spawn/child_process invocation of git, or attach a hidden console to the server process so inherited console children never create a new window.

Activity

  1. opencode-agent commented on Oct 27, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed capture with the exact command lines and window handle!

    I think this is a duplicate of #52266, the open issue tracking console windows flashing on Windows when the background service starts git and other console programs.

    Some things I found in the code that may help narrow it down:

    • In v2.2.0, core runs its discovery call (git rev-parse --git-dir --git-common-dir --show-toplevel) through the shared spawner in packages/util/src/cross-spawn-spawner.ts. That spawner already passes windowsHide: true on Windows, so the suggested fix is already in place for that call.
    • The process your window capture caught runs git -C C:\Users\DELL rev-parse --show-toplevel. Core doesn't run git in that form: it doesn't use -C and doesn't make a bare --show-toplevel call. Core also only runs git after it finds a .git entry, so folders that aren't repositories shouldn't trigger a core git call at all. One of your plugins (context-mode or cbm-augment) may still be running git -C … rev-parse --show-toplevel without windowsHide. Could you check whether the flash still happens with both plugins disabled?
    • The git -C capture (19:47:11) and the visible window (19:47:28) are 17 seconds apart, so they may not be the same process.

    Possible duplicates and closely related issues, ordered from most to least likely:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. If the flash still appears with plugins disabled, please add that result to #52266 (or reply here), since it would show the window really comes from core.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions