Windows: detached background pty hosts (--bg-pty-host --bg-spare) cause visible pwsh/console window flashes at session start

Open 💬 0 comments Opened Jul 16, 2026 by tillbob

What's Wrong?

On native Windows, starting or resuming a session pops multiple visible console windows (pwsh) over the screen. With Windows 11's default terminal set to Windows Terminal (the "Let Windows decide" default), each flash is a full Windows Terminal window, which is very intrusive.

Diagnosis (Windows 11 Pro build 26200, native claude.exe, Claude Code 2.1.211):

  • Hook and MCP child processes are spawned with windowsHide (hidden console) — those are not the cause.
  • The background-shell subsystem spawns claude --bg-pty-host ... --bg-spare helper processes with DETACHED_PROCESS (detached: true). DETACHED_PROCESS gives the child no console at all and takes precedence over CREATE_NO_WINDOW.
  • When one of these console-less background hosts then spawns a console application (pwsh.exe) without CREATE_NO_WINDOW — e.g. on the ConPTY-unavailable fallback path — Windows allocates a new console, which is a visible window.
  • Observed process tree: multiple argless claude.exe background processes, several with pwsh.exe children parented directly to console-less hosts. The spare-pool prewarm at session start matches the timing of the flashes exactly.
  • The effect is multiplied when anything launches a nested headless claude -p at session start (e.g. a plugin), since the nested instance prewarms its own background hosts.

What Should Happen?

Background pty hosts and the shells they spawn should never allocate a visible console — spawn shell children with CREATE_NO_WINDOW/windowsHide (including on the ConPTY fallback path), or keep the host attached to a hidden console instead of fully detached.

Workaround

Setting the Windows default terminal to Windows Console Host (HKCU\Console\%%StartupDelegationConsole/DelegationTerminal = {B23D10C0-E52E-411E-9D5B-C09FDF709C7D}) shrinks the flashes from full Windows Terminal windows to brief conhost blips, but does not eliminate them. CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 avoids it entirely but disables background tasks, which is not a real option.

Related: #14828 covers general per-tool console flashing; this report is specifically the detached background-pty spawn path at session start/resume.

Environment

  • Claude Code 2.1.211, native Windows install (claude.exe)
  • Windows 11 Pro build 26200
  • Shell: PowerShell 7
  • Default terminal: "Let Windows decide" (= Windows Terminal) when the issue was diagnosed

🤖 Generated with Claude Code

View original on GitHub ↗