Skip to content

[Bug]: sh.exe console window flashes on Windows during async hook execution (missing windowsHide in spawn) #494

Description

@Feoni4

Prerequisites

  • I have searched existing issues to avoid duplicates
  • I am using the latest version of CodeMie CLI
  • I have read the documentation

Bug Description

On Windows, a brief sh.exe (Git Bash) console window flashes during tool execution when running via codemie-opencode. This is visually disruptive.

Steps to Reproduce

install https://github.com/waybarrios/opencode-power-pack as on opencode plugin
start codemie: codemie-opencode
Do common work using opencode capabilities

Expected Behavior

No unexpected terminal windows opens and closes during work

Actual Behavior

Periodically you see an sh terminal window

CodeMie CLI Version

0.14.0

Which agent are you using?

Not applicable / General CLI

Which provider are you using?

Not applicable

Model

any model

Node.js Version

v24.19.0

Operating System

Windows (native)

Configuration (Redacted)

{
  "version": 2,
  "activeProfile": "default",
  "profiles": {
    "default": {
      "provider": "ai-run-sso",
      "codeMieUrl": ",
      "codeMieProject": "",
      "apiKey": "sso-provided",
      "baseUrl": "",
      "model": "deepseek-v4-pro",
      "haikuModel": "claude-haiku-4-5-20251001",
      "sonnetModel": "claude-sonnet-5",
      "opusModel": "claude-opus-5",
      "name": "default"
    }
  },
  "userEmail": ""
}

Error Logs

Additional Context

Per codemie-opencode investigation:

Root Cause

In shell-hooks-source.js:233, the execCommandAsync() function spawns sh.exe directly without windowsHide: true:

const child = spawn("sh", ["-c", command], {
    env: { ...process.env, ...env },
    stdio: ["pipe", "ignore", "ignore"],
    detached: true,
    // ❌ missing: windowsHide: true
});

The detached: true option prevents the child from being attached to the parent console, but on Windows it does not suppress the creation of a new console window for the detached process. The windowsHide: true option is required to prevent the console window from appearing.

Additional Context

  • The synchronous execCommand() at line 210 also uses execSync() without windowsHide (Node.js 16+ supports windowsHide on execSync), though execSync typically inherits the parent hidden window when the parent was spawned with windowsHide: true.
  • The utils/exec.js utility (line 48) already correctly passes windowsHide: true.
  • The main process spawn in BaseAgentAdapter.js:749 already passes windowsHide: true.

Environment

  • OS: Windows
  • Git Bash provides the sh.exe binary
  • Codemie version: 0.14.0

Fix

Add windowsHide: true to the spawn options in execCommandAsync():

const child = spawn("sh", ["-c", command], {
    env: { ...process.env, ...env },
    stdio: ["pipe", "ignore", "ignore"],
    detached: true,
    windowsHide: true,  // ✅ suppress console window
});

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions