Repository navigation
fix(windows): hide child console windows via a hidden Harness console - #289
Merged
yaojin3616 merged 1 commit intoSep 4, 2026
Merged
Conversation
The desktop spawns the Harness with detached + windowsHide (DETACHED_PROCESS | CREATE_NO_WINDOW), so the Harness itself has no console. On Windows, a console child (pwsh, git, ripgrep, ...) spawned from a console-less parent with only windowsHide (CREATE_NO_WINDOW) still allocates a fresh, briefly-visible console — the flash reported on every tool call in issue dataelement#233. Attach a hidden console to the Harness at startup (AllocConsole + ShowWindow(SW_HIDE)) so its children inherit a console that is already hidden and CREATE_NO_WINDOW suppresses their windows the same way it does for a console-attached parent. `detached` is left in place, so the dataelement#208 Ctrl+C process-group isolation is preserved. Fixes dataelement#233.
bobowsh
added a commit
to bobowsh/dsh-desktop
that referenced
this pull request
Sep 13, 2026
冲突决策: - package.json: 依赖取上游 rc.1 tarball(244 deps);保留本地 chardet + dsh-llm-opencode fork; 移除上游已删的 alpha.1 demo 包(spine-demo/tool-subagent-report);version 保持本地 0.3.2; build 脚本采纳上游 build:market,dev 保留本地 sync-harness-pkgs 前缀 - package-lock.json: 取上游 rc.1 lock 并对齐 version=0.3.2 - extraResources: 补打包 windows-hidden-console.mjs(上游 dataelement#289 entry 动态 import 但漏配打包) - .gitignore: 合并(保留本地 data/ 注释块 + 上游 __pycache__) - vitest.config.ts: 采纳上游 include 模式(test/**/test,spec.ts,js,mjs),兼容本地 .mjs 测试 - release.yml: 保留上游 prerelease/sign-windows job;两个 ModelScope step 均 if:false(本地 fork 无 token) - 黑窗问题:采纳上游根因修复 createHiddenConsole(dataelement#289 AllocConsole+SW_HIDE),与本地 enforceWindowsChildProcessHide(spawn 层 windowsHide) 在 harness-node-entry.mjs 共存双保险 - 保留本地特有:imc-region-capture 全屏截图桥、mobileBridge/ENABLE_MOBILE_BRIDGE、 便携打包(bundle-user-data/installer.nsh extraFiles)、@earendil-works/pi-ai 补丁
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.
Summary
On Windows, every
pwsh(and other console tool) call briefly flashes a console window. The root cause: the desktop spawns the Harness withdetached: true+windowsHide: true(DETACHED_PROCESS | CREATE_NO_WINDOW), so the Harness has no console. A console child spawned from a console-less parent with onlywindowsHide(CREATE_NO_WINDOW) still allocates a fresh, briefly-visible console — the flash (issue #233).Fix
Give the Harness its own console and hide it at startup (
AllocConsole+ShowWindow(..., SW_HIDE)). Its children then inherit a console that is already hidden, soCREATE_NO_WINDOWsuppresses their windows the same way it does for a console-attached parent.detachedis left in place, so the #208 Ctrl+C process-group isolation is preserved —AllocConsoleon a detached process is the documented escape hatch for exactly this situation.Changes
build/windows-hidden-console.mjs(new):createHiddenConsole()wraps theAllocConsole/GetConsoleWindow/ShowWindow(SW_HIDE)koffi calls, best-effort (never blocks Harness startup), with an injectable loader for tests.build/harness-node-entry.mjs: callcreateHiddenConsole()on Windows before the existingwindowsHidechild-process patch.test/windows-hidden-console.test.ts(new): unit tests for the call sequence (alloc → hide withSW_HIDE),AllocConsolefailure, null window, and loader-error fallbacks.Validation
node --checkpasses on both changedbuild/*.mjsfiles.createHiddenConsolelogic exercised with a fake loader (alloc → hide withSW_HIDE=0; returnsfalseonAllocConsolefailure and on loader errors).node_modulesin this checkout). Please treat the console-flash behaviour as needing on-Windows confirmation.Fixes #233