Skip to content

Windows: codegraph daemon spawns visible console windows on file edits #530

@yc-2503

Description

@yc-2503

Environment

  • OS: Windows
  • codegraph version: 0.9.6 (installed via npm install -g @colbymchenry/codegraph)
  • Trigger scenario: Running codegraph as MCP server (codegraph serve --mcp) alongside AI coding assistant (OpenCode)

Description

When codegraph MCP server is running, every file save triggers a black console window to flash briefly. This is particularly disruptive during typing — the flashing window steals keyboard focus and interrupts input.

Steps to Reproduce

  1. Configure codegraph MCP server in project (codegraph serve --mcp)
  2. Start the AI coding assistant (e.g. OpenCode)
  3. Edit and save any file
  4. Observe a black console window flashing momentarily

Investigation

1. Running processes

After codegraph serve --mcp, multiple related processes are visible:

ProcessId CommandLine
71136    "node" codegraph\npm-shim.js "serve" "--mcp"
31024    codegraph\node.exe  (daemon)
83384    codegraph\node.exe  (daemon)
38888    codegraph\node.exe  (daemon)

2. --no-watch does not help

Added --no-watch to disable the file watcher:

"command": ["codegraph", "serve", "--mcp", "--no-watch"]

The black console windows still appear. This confirms the issue is not caused by the file watcher, but by the daemon process itself spawning child processes without windowsHide.

3. Uninstalling eliminates the issue

After uninstalling codegraph, removing MCP config, and killing related processes, the flashing stops completely — confirming the issue originates from codegraph.

Root Cause

The shared daemon mode introduced in v0.9.5 creates background daemon processes (codegraph\node.exe) for file watching and indexing. On Windows, Node.js child_process.spawn() defaults to creating a new console window for child processes (CREATE_NEW_CONSOLE) unless windowsHide: true is explicitly set.

The daemon spawns child processes for:

  • Incremental indexing on file changes
  • Tree-sitter parser invocations
  • Other background maintenance tasks

These child processes exist briefly, causing the console window to flash.

Suggested Fix

Add windowsHide: true to all child_process.spawn() calls on Windows:

// Before
spawn(process, args, { /* missing windowsHide */ });

// After
spawn(process, args, {
  windowsHide: true,
  // ...other options
});

If using execa or another wrapper library, ensure windowsHide is enabled on Windows.

References

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