Skip to content

Windows: spawn() in client.ts missing windowsHide:true -- every CLI invocation creates visible console window #2

@jagilber

Description

@jagilber

Bug: Missing windowsHide:true on spawn() in client.ts

File: nodejs/src/client.ts lines 871-877

Verified: 100% confirmed via kernel trace. This is definitively in the SDK code, not the consuming application.

Current code

this.cliProcess = spawn(command, spawnArgs, {
    stdio: this.options.useStdio
        ? ["pipe", "pipe", "pipe"]
        : ["ignore", "pipe", "pipe"],
    cwd: this.options.cwd,
    env: envWithoutNodeDebug,
    // windowsHide: true is MISSING
});

Impact

On Windows, every spawn() call without windowsHide: true causes the OS to allocate a new console (conhost.exe) that is visible on the desktop. Each window:

  • Steals keyboard focus
  • Disrupts z-order
  • Flashes on screen

In a 20-second kernel trace of a copilot-ui session startup, 71 conhost.exe windows were created. The desktop becomes unusable -- the user cannot type because focus is constantly stolen.

Evidence

Kernel trace (ETW Process provider, 20-second capture):

  • conhost.exe: 71 spawns
  • cmd.exe: 10 spawns (from the related cmd /c issue)
  • All in Windows session 1 (interactive desktop)

Proposed fix

Add windowsHide: true to the spawn options:

this.cliProcess = spawn(command, spawnArgs, {
    stdio: this.options.useStdio
        ? ["pipe", "pipe", "pipe"]
        : ["ignore", "pipe", "pipe"],
    cwd: this.options.cwd,
    env: envWithoutNodeDebug,
    windowsHide: true,
});

This is a one-line fix with zero behavioral change on non-Windows platforms (the flag is ignored on Linux/macOS).

Note

This fork issue tracks a fix for jagilber/copilot-sdk. The consuming app (copilot-ui) is new code and many of the overall visibility problems may be self-inflicted, but this specific spawn site is 100% verified to be missing the flag in the SDK itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions