Skip to content

[Windows] Every shell command spawns a visible PowerShell console window (new console, not hidden) that stays open for the command's lifetime #4549

Open

Description

@siramk2022

Summary

On Windows, Copilot CLI briefly flashes an empty PowerShell / conhost console
window every time the agent executes a shell command. During normal agent
activity (many commands per task) this produces near-constant window flashing
that momentarily steals focus and is very distracting.

This appears to be the same class of bug as the already-fixed git / hook /
path-resolution flashes (PRs #10235 and #11037) and the open MCP-startup flash
(#3171), but on the general agent shell-command execution path, which is
still affected.

Environment

  • Copilot CLI: 1.0.80 (latest at time of report)
  • OS: Windows 11 24H2, build 26100.9106
    (registry ProductName cosmetically reads "Windows 10 Enterprise" on this build)
  • Shell: PowerShell (default on Windows)
  • Terminal: Windows Terminal

Steps to reproduce

  1. Launch copilot in Windows Terminal on Windows 11.
  2. Ask the agent to run essentially any shell command (e.g. a simple
    Get-ChildItem, or any node -e "..." invocation).
  3. Watch the screen while the command executes.

Expected

Shell commands run without any visible console window appearing — as already
happens for git commands and for hook / path-resolution after #10235 / #11037.

Actual

A blank PowerShell / conhost window flashes on screen for each spawned
command, briefly stealing focus.

Real-world example that triggers it

This is an actual command a session spawned (a mermaid-diagram validation step).
Every command shaped like this flashes a window:

$node = "C:\ProgramData\global-npm\node_modules\node\bin\node.exe"
$script = @'
const fs = require("fs");
const files = process.argv.slice(2);
let idx = 0;
for (const f of files) {
  const txt = fs.readFileSync(f, "utf8").split(/\r?\n/);
  let inBlock = false, buf = [], start = 0;
  for (let i = 0; i < txt.length; i++) {
    const line = txt[i];
    if (!inBlock && /^\s*```mermaid\s*$/.test(line)) { inBlock = true; buf = []; start = i + 1; continue; }
    if (inBlock && /^\s*```\s*$/.test(line)) {
      inBlock = false; idx++;
      const base = f.replace(/^.*[\\/]/, "");
      const out = `${process.env.TEMP}\\mmvalidate\\block_${idx}_${base}_L${start+1}.mmd`;
      fs.writeFileSync(out, buf.join("\n"));
      continue;
    }
    if (inBlock) buf.push(line);
  }
}
'@
Set-Content -Path "$env:TEMP\mmvalidate\extract.js" -Value $script -Encoding utf8
& $node "$env:TEMP\mmvalidate\extract.js" "$env:TEMP\brga.md" "$env:TEMP\rad.md" "$env:TEMP\rrd.md"

Note: the window that flashes is the outer powershell.exe host the CLI
spawns
to run the command — not node.exe. node is a console app and
inherits the parent console, so it does not create a window on its own. The
content of the command is irrelevant; any shell command triggers the flash.

Likely root cause

The CLI runs shell commands on Windows via node-pty / ConPTY (conpty.node).
The pseudo-console host (conhost.exe) for the spawned command is not being
suppressed on this path, so its window briefly appears. The earlier fixes added
window suppression (windowsHide / CREATE_NO_WINDOW) only to specific paths:

  • #10235 — "Git commands no longer flash a console window on Windows"
  • #11037 — "Prevent brief console windows from flashing on Windows when the
    agent runs hook commands or resolves command paths"

The main agent command-execution path appears not to have the equivalent
suppression.

Related

Suggested fix

Apply the same window-suppression used in #10235 / #11037 to the agent's
shell-command execution path — i.e. ensure the ConPTY / child-process spawn
passes windowsHide: true (or creates the console host without a visible
window / uses a headless OpenConsole host consistently) for every command the
agent runs, not just git, hooks, and path resolution.

Activity

  1. changed the title [-][Windows] A PowerShell/conhost window flashes on screen for every shell command the agent runs[/-] [+][Windows] Every shell command spawns a visible PowerShell console window (new console, not hidden) that stays open for the command's lifetime[/+] on Aug 21, 2026
  2. siramk2022 commented on Aug 21, 2026

    @siramk2022
    Author

    Correction + hard evidence — updating the "brief flash" framing in the description above.

    After reproducing on the affected machine, the symptom is more specific (and more severe) than a brief flash: each shell command is spawned in a brand‑new, visible console window that stays open for the entire lifetime of that command's process. Short commands flash; anything longer‑running (node scripts, watchers, mermaid/validation steps, anything that waits) leaves a PowerShell window sitting on screen. Because the CLI runs many commands per task, visible windows accumulate.

    Process‑tree proof (Windows 11 24H2, build 26100.9106, CLI 1.0.80)

    Launcher chain and per‑command console:

    agency.exe ──> copilot.exe ──> pwsh.exe  (+ its OWN dedicated conhost.exe child, per command)
    

    A child process that inherits its parent's console never gets its own conhost.exe; the conhost belongs to whoever allocated the console. A dedicated conhost per pwsh therefore proves a new console is being created for every command — i.e. the shell is spawned without windowsHide: true (console‑less parent / CREATE_NEW_CONSOLE‑style behavior), not into a hidden or inherited console.

    Two consecutive commands, each allocated a fresh console:

    pwsh.exe(84020, parent copilot.exe) -> conhost.exe(6572)
    pwsh.exe(90612, parent copilot.exe) -> conhost.exe(63056)
    

    Invocation the CLI uses for each command:

    "pwsh.exe" -NoProfile -NoLogo -NonInteractive -Command "…"
    

    It is NOT a process leak

    A system‑wide scan for orphaned pwsh/powershell/conhost (parent process gone) found only 1 orphaned conhost, from an unrelated app. So the windows are not leaked zombies — each one is a live, visible console for a currently‑running command, and it stays on screen until that command's pwsh exits. The fix is to spawn the shell hidden, not to reap leaks.

    Root cause (refined)

    The shell child is created with a new console and without windowsHide: true, so Windows displays the console window and keeps it visible until the command's pwsh process exits. This is the same class of defect fixed for other paths but on the main agent command‑execution path:

    • #10235 — "Git commands no longer flash a console window on Windows"
    • #11037 — "Prevent brief console windows from flashing on Windows when the agent runs hook commands or resolves command paths"
    • [Windows] CMD windows flash on screen when MCP servers start #3171 — "[Windows] CMD windows flash on screen when MCP servers start" (related, still open)

    Suggested fix (refined)

    Pass windowsHide: true on the shell‑command spawn (and/or avoid CREATE_NEW_CONSOLE/detached for foreground commands, or attach a headless ConPTY host) so the per‑command pwsh runs without a visible console. Extend the suppression already applied in #10235 / #11037 to cover every command the agent runs.

  3. exetico commented on Sep 14, 2026

    @exetico

    On my machine, it even keeps the windows open, resulting in 20-50 PowerShell windows runnning in "Terminal", which I'd need to close manually. I've not faced this issue before.

  4. added
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    area:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior
    on Nov 15, 2026
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

    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions