fix(windows): hide console window for git child processes#505
Open
yushengruohui wants to merge 2 commits into
Open
fix(windows): hide console window for git child processes#505yushengruohui wants to merge 2 commits into
yushengruohui wants to merge 2 commits into
Conversation
The codegraph daemon shells out to git via execFileSync without
windowsHide:true. Because the daemon is launched with detached:true
(no parent console), Windows allocates a fresh console window for
every git child. Each short-lived git invocation makes that window
flash on screen — very visible during auto-sync, where many file
writes can trigger several git calls per second.
This sets windowsHide:true on all 7 git call sites:
- src/extraction/index.ts: shared gitOpts (covers ls-files
--cached and -o), plus 3 inline opts for rev-parse,
check-ignore, and status --porcelain
- src/sync/worktree.ts: rev-parse --show-toplevel
- src/sync/git-hooks.ts: rev-parse --is-inside-work-tree,
rev-parse --git-path hooks
mcp/index.ts already passes windowsHide:true when spawning the
detached daemon — these git call sites were missed.
windowsHide:true is a no-op on macOS and Linux.
Fixes colbymchenry#485
Add windowsHide:true to the 4 execFileSync call sites in src/extraction/index.ts (1 shared gitOpts plus 3 inline option objects for rev-parse --show-toplevel, check-ignore -q, and status --porcelain --no-renames). Companion to the previous commit on this branch which covered the sync/ module. See colbymchenry#485 for context.
ZyphrZero
added a commit
to ZyphrZero/codegraph
that referenced
this pull request
May 28, 2026
…de-git-spawn fix(windows): hide console window for git child processes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #485.
Summary
On Windows, the daemon flashes a black
git.execonsole window on every auto-sync. The cause isexecFileSync('git', …)call sites in the daemon's code paths missingwindowsHide: true. This PR adds the option to all 7 sites; the change is a one-liner per call site and a no-op on macOS/Linux.Root cause
The daemon is launched with
detached: true(mcp/index.ts, the existingspawn(process.execPath, …)call), which deliberately leaves it without a parent console. On Windows, when a Console-subsystem child (git.exe) is started from a console-less parent, Windows allocates a fresh console window for it unlessCREATE_NO_WINDOWis set. Node mapswindowsHide: truetoCREATE_NO_WINDOW. Without it, every short-livedgitinvocation flashes its own window. The daemon launcher itself already passeswindowsHide: true— it's the git call sites that were missed.Call sites changed (7 total)
src/extraction/index.tscollectGitFilessharedgitOptsls-files -c --recurse-submodules,ls-files -o --exclude-standardsrc/extraction/index.tsgetGitVisibleFilesrev-parse --show-toplevelsrc/extraction/index.tsgetGitVisibleFilescheck-ignore -qsrc/extraction/index.tsgetGitChangedFilesstatus --porcelain --no-renamessrc/sync/worktree.tsgitWorktreeRootrev-parse --show-toplevelsrc/sync/git-hooks.tsisGitReporev-parse --is-inside-work-treesrc/sync/git-hooks.tsgitHooksDirrev-parse --git-path hooksThe fix is the same one-line addition (
windowsHide: true) on each options object.Verification
npm run build)..codegraph/daemon.pid, then trigger any CodeGraph CLI/MCP call so it respawns.git.execonsole window should no longer flash..codegraph/daemon.logstill shows the[CodeGraph MCP] Auto-synced N file(s) in <ms>mslines — i.e. the sync still runs, just hidden.windowsHideis ignored, behavior unchanged.Notes for reviewers
extraction/wasm-runtime-flags.tsusesspawnSync(process.execPath, …, { stdio: 'inherit' })— the relaunch shim spawns Node from a Node parent that already owns a console, so no new window is allocated and no change is needed.runGit(args, opts)helper that injectswindowsHide: trueso this can't regress.