fix: hide PowerShell and other child process windows on Windows - #79
Open
yaojin3616 wants to merge 1 commit into
Open
fix: hide PowerShell and other child process windows on Windows#79yaojin3616 wants to merge 1 commit into
yaojin3616 wants to merge 1 commit into
Conversation
The harness Node.js process was already started with windowsHide: true, but DSH spawns its own child processes (pwsh, etc.) without that flag, causing visible console windows that steal focus on Windows. Add a monkey-patch in harness-node-entry.mjs that defaults windowsHide to true for all child_process functions (spawn, spawnSync, exec, execSync, execFile, execFileSync, fork) when running on win32. Callers can still explicitly set windowsHide: false to override. Closes #35
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.
问题
在 Windows 上使用 DSH Desktop 时,Harness 执行 PowerShell 命令会反复打开用户可见的
pwsh窗口,并将该窗口切换为前台活动窗口,打断用户正常使用。根因
桌面层启动 Harness Node.js 进程时已经设置了
windowsHide: true,但 DSH 内部通过child_process启动的子进程(如pwsh)没有设置该标志。由于父进程使用CREATE_NO_WINDOW没有控制台,子进程(控制台应用)会创建新的可见控制台窗口。修复
在
harness-node-entry.mjs中加入 monkey-patch,在 Windows 平台上对所有child_process函数(spawn、spawnSync、exec、execSync、execFile、execFileSync、fork)默认注入windowsHide: true。调用方仍可显式设置
windowsHide: false来覆盖此默认值。变更文件
build/harness-node-entry.mjs— 在加载 DSH 前安装 windowsHide monkey-patch(仅 win32)test/harness-node-entry.test.ts— 新增 19 个单元测试覆盖所有 child_process 函数的签名和覆盖行为验证
Closes #35