fix(windows): hide the console window forked by the console-list agent - #966
Open
Aikio (Aikiooo) wants to merge 1 commit into
Open
Aikio (Aikiooo) wants to merge 1 commit into
Aikio (Aikiooo) wants to merge 1 commit into
Conversation
WindowsPtyAgent.kill() calls _getConsoleProcessList(), which forks conpty_console_list_agent. fork() inherits stdio, so on Windows that child is given a console of its own, and a console window appears every time a pty is killed. In an embedding application it can also take focus from the host's window. windowsHide still leaves the helper a console - it needs one, because getConsoleProcessList() calls FreeConsole() then AttachConsole(shellPid) - it just gives it no window. @types/node's ForkOptions does not declare windowsHide (still true on DefinitelyTyped master), so the options object is typed to keep strict building.
Aikio (Aikiooo)
force-pushed
the
fix/hide-console-list-agent-window
branch
from
September 10, 2026 16:24
05644ea to
a9483f0
Compare
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.
What
WindowsPtyAgent.kill()calls_getConsoleProcessList(), which forksconpty_console_list_agent:fork()inherits stdio, so on Windows that child is given a console of its own. The result is a console window appearing on screen every time a pty is killed. In an embedding application it can also take focus away from the host's window, which is how it surfaced for us.Change
Pass
windowsHide: trueto that fork. The helper still gets a console — it needs one, becausegetConsoleProcessList()callsFreeConsole()and thenAttachConsole(shellPid)— it just has no window.fork()spreads its options through tospawn()(options = { __proto__: null, ...options, shell: false }), which honourswindowsHide, so nothing else about how the helper is started changes.Why the local is typed
windowsHideis honoured at runtime but is missing from@types/node'sForkOptions— still true on DefinitelyTyped master — so passing it inline does not compile againststrict:The options object is typed with a cast to keep the build green. Happy to send the DefinitelyTyped change instead and drop the cast if you'd prefer that first.
Verification
npm run build(tsc,strict) andnpm run lintpass.kill › should kill the process treeon the path this touches (useConptyDll = false). It polls the real process tree and still sees it removed, so the console-list sweep is unaffected by hiding the console.Not covered here
windowsHidefor spawned processes. This does not implement that. It only stops the window for the internal helper on kill, which no caller can currently suppress.fork()defaults tosilent: false. This change doesn't address either; it only removes the window.