Skip to content

Bug: Windows 11: hook's process-snapshot PowerShell flashes a visible terminal window despite windowsHide:true (Windows Terminal default-terminal delegation) #627

Description

@Schlaflied

Symptom

A blank PowerShell/terminal window flashes on screen intermittently while working in Claude Code with Clawd on Desk installed. Unlike #586/#605 (taskbar-icon-only, fixed by #587), this is an actual visible console window. #596 may be the same root cause showing as a milder symptom.

Environment

  • Windows 11 Home 10.0.26200, default terminal application = "Let Windows decide" (i.e. Windows Terminal on current Win11 builds — HKCU\Console\%%Startup absent)
  • Clawd on Desk build installed 2026-07-01, Claude Code CLI, hooks registered per the standard install
  • Node.js v25.5.0 (C:\nodejs → nvm junction)

Forensics (Windows 4688 process-creation audit, command line included)

Every Claude Code hook event fires clawd-hook.js, which calls getWindowsProcessSnapshot() in hooks/shared-process.js — one PowerShell spawn per resolve:

22:05:11  powershell.exe  PARENT: claude.exe        CMD: ...node clawd-hook.js PreToolUse     ← hidden, fine
22:05:12  powershell.exe  PARENT: node.exe (hook)   CMD: powershell -NoProfile -NonInteractive -Command "...ClawdWin32 typedef + Get-CimInstance Win32_Process..."   ← THIS one flashes

Over 48h of normal use this snapshot spawn fired 600+ times.

Root cause

shared-process.js correctly passes { windowsHide: true } (→ CREATE_NO_WINDOW) to execFileSync. But on Windows 11, when the OS-level default terminal application delegates console hosting to Windows Terminal, WT's takeover path does not always honor CREATE_NO_WINDOW — the spawned conhost/WT window becomes briefly visible (timing/cold-start dependent, which is why it's intermittent rather than every event). This is a known WT-side behavior (microsoft/terminal delegation issues), so Clawd's code is technically correct and still flashes.

Confirmed on this machine: the flash correlates 1:1 with the snapshot spawn timestamps in the 4688 log, not with the Electron hit-window path fixed in #587.

Suggested fixes (any of these would do)

  1. Reuse a long-lived helper instead of a cold PowerShell per hook event — the comment in shared-process.js already notes the ~270 ms PS cold-start dominates; a persistent resolver (or short-TTL snapshot cache shared across consecutive hook events) would fix both the flash exposure and the perf issue tracked in follow-up #331: state hook reliability, startup sync deferral, Windows PID resolution perf #350.
  2. Move the snapshot into the compiled sidecar (cc-connect-clawd already ships as a native exe) — a GUI-subsystem or truly windowless native binary can't flash regardless of WT delegation.
  3. At minimum, document the workaround: setting Windows' default terminal application back to "Windows Console Host" makes CREATE_NO_WINDOW honored again and the flashes disappear.

Happy to test a patched build on this machine — the 4688 audit setup here makes before/after verification easy.

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