[Bug] [Windows] Agent 执行 shell 命令时每次闪现控制台黑窗(子进程缺少 windowsHide/CREATE_NO_WINDOW)
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 已搜索现有 issue 和 Discussions,确认无重复报告
- 已阅读 CONTRIBUTING.md
问题类别 · Category
工具调用 / MCP · Tool use / MCP
涉及的 Agent 框架 · Agent framework
不涉及框架 · Not framework-specific(ZCode 客户端自身的子进程创建行为)
严重程度 · Severity
影响体验 · Major
复现频率 · Reproducibility
必现 · Always(Windows 平台)
问题描述 · Description
Windows 上,Agent 每次通过 Bash 工具执行 shell 命令(bash / cmd / powershell 等)时,桌面都会闪现一个黑色控制台窗口,命令执行结束窗口随即消失。一次会话中命令调用非常频繁,黑窗反复闪现:
- 严重影响使用体验,且极易被误认为恶意软件弹窗(我最初就是把它当成可疑弹窗去逐个排查系统计划任务和启动项的);
- 全屏游戏、演示、投屏场景下会反复打断。
技术原因分析:Agent 执行命令时创建子进程未带 CREATE_NO_WINDOW 标志(Node.js 的 windowsHide: true)。检查 app.asar 可见 ZCode 内部其他 spawn 调用(约 50 处,如 docker、环境检测类命令)大多已带 windowsHide: true,仅 Agent shell 执行路径遗漏。进程监控可抓到每次命令执行都伴随新建 conhost.exe。
复现步骤 · Steps to reproduce
- 在 Windows 10/11 打开 ZCode 桌面版
- 让 Agent 执行任意 shell 命令(例如
powershell -NoProfile -Command "Get-Process"或最简单的ls) - 观察桌面:每次命令执行时都会闪现黑色控制台窗口,随即消失
期望表现 · Expected behavior
子进程在后台静默执行,不显示任何窗口(创建进程时加 CREATE_NO_WINDOW / windowsHide: true)。
实际表现 · Actual behavior
每次 Bash 工具调用都会新建可见控制台窗口,命令结束即关闭。进程监控日志摘录(ZCode CLI 执行命令时,每次都伴随新建 conhost.exe):
2026-08-25 17:26:49.996 conhost.exe pid=34700 parent_pid=42048
FROM bash.exe [C:\developEnv\Git\bin\bash.exe -c ". /c/Users/niuniu/.zcode/cli/exec/shell-startup/..."]
2026-08-25 17:26:51.887 conhost.exe pid=4592 parent_pid=33752
FROM bash.exe [C:\developEnv\Git\bin\bash.exe -c ". /c/Users/niuniu/.zcode/cli/exec/shell-startup/..."]
(如需完整监控日志或复现录屏,可以补充。)
ZCode 版本 · ZCode version
v3.7.7.4926
设备 / 系统 · Device / OS
Windows 11 25H2(10.0.26200)x64,桌面版
English summary: On Windows, every shell command executed via the agent's Bash tool flashes a visible console window (conhost) on screen, which closes when the command finishes. The spawn calls in the agent shell-execution path appear to be missing windowsHide: true / CREATE_NO_WINDOW, while most other internal spawns in app.asar already set it. Adding the flag to the agent command-execution path should fully fix this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start at the Agent Bash tool's shell-command spawn path described in the report, and compare it with the other app.asar spawn calls that already use windowsHide. Done means shell commands on Windows run without a visible console window; verify with the listed PowerShell or ls reproductions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, node.js, powershell
- Domain
- desktop, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100