On Windows, a black console (conhost) window flashed briefly when CodeGraph ran as a background MCP server. Several child spawns were missing `windowsHide: true`, so Windows created a visible console for the child: - scripts/npm-shim.js — launching the bundled runtime (every server start / daemon-idle reconnect) and the self-heal `tar` extraction of a missing platform bundle. - src/reasoning/login.ts — the detached `cmd /c start` browser open. - src/upgrade/index.ts — package-manager spawn (console-attached, so no flash in practice, but set for uniformity: every child spawn now hides). The daemon spawn (#411) and all git execFileSync sites already set it; this closes the remaining gaps. Adds an all-platforms source guard to __tests__/npm-shim.test.ts asserting every spawn in the shim sets windowsHide. Closes #1092 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
00765200d8
commit
6dd5512d8d
@@ -71,6 +71,23 @@ function runShim(pkgDir: string, args: string[], env: Record<string, string>) {
|
||||
});
|
||||
}
|
||||
|
||||
// Static source guard (all platforms): every child spawn in the shim must set
|
||||
// windowsHide, or a console (conhost) window flashes when the shim runs as a
|
||||
// background MCP server on Windows (issue #1092). windowsHide is a Windows-only
|
||||
// spawn behavior that can't be observed from these POSIX-only subprocess tests,
|
||||
// so we assert it at the source level instead — and this also catches any new
|
||||
// spawn site added to the shim later.
|
||||
describe('npm-shim windowsHide (#1092)', () => {
|
||||
it('sets windowsHide: true on every spawn in the shim', () => {
|
||||
const src = fs.readFileSync(SHIM_SRC, 'utf8');
|
||||
const spawnLines = src.split('\n').filter((l) => /\.spawn(Sync)?\(/.test(l));
|
||||
expect(spawnLines.length).toBeGreaterThan(0); // guard against a false pass if the calls move
|
||||
for (const line of spawnLines) {
|
||||
expect(line, `spawn without windowsHide: ${line.trim()}`).toContain('windowsHide: true');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(isWindows)('npm-shim launcher', () => {
|
||||
it('runs the installed optional-dependency bundle without any download', async () => {
|
||||
const pkg = makePkg();
|
||||
|
||||
Reference in New Issue
Block a user