Windows: every CLI subprocess spawn flashes a visible cmd window (missing windowsHide)
Bug
On Windows, every CLI subprocess spawned during a run (claude / codex / gemini / kimi .cmd shims) briefly opens a visible console window. During multi-round runs this happens repeatedly and steals focus from fullscreen apps/games, which makes it impossible to use the machine while a run executes.
Environment
- Chorus v0.8.63 (npm
chorus-codes), Windows 11 Pro - CLIs installed as npm global
.cmdshims
Cause
dist/daemon/headless.js → spawnHeadless() spawns with shell: isWindows but without windowsHide: true, so each cmd.exe child gets its own visible console. Same pattern in the spawnSync('where', …) binary resolver in the same file, and in the git spawn in dist/daemon/ship.js.
Fix
Add windowsHide: true to the spawn options at those call sites (stdio is already fully piped, so no console is ever needed):
const child = spawn(resolvedCommand, [...opts.args], {
cwd: opts.cwd,
env: spawnEnv(opts.env),
stdio: ['pipe', 'pipe', 'pipe'],
shell: isWindows,
windowsHide: true, // <-- suppresses the flashing cmd windows
...
});
Verified
Patched exactly this locally (headless.js spawn + where-resolver, ship.js) on v0.8.63 — the window flashing is gone and runs behave identically otherwise.
(Report drafted with the help of Claude after debugging the flashing locally.)
Update after more testing — the fix works, but the scope is wider than spawnHeadless.
Patching only spawnHeadless() was not enough: at run start we still got a burst of ~20 flashing windows. Those come from the preflight/CLI-detection layer — spawnSync calls scattered across dist/lib/cli-detect.js, dist/lib/cli-precheck.js, dist/lib/runtime-path.js, the tmux probe in dist/daemon/tmux.js, dist/daemon/ship.js (git), dist/daemon/orchestrators/shared.js, dist/mcp/client.js, etc.
What fixed it completely for us: a tiny module loaded first in dist/daemon/index.js that wraps all child_process functions (spawn/spawnSync/exec/execSync/execFile/execFileSync) and injects windowsHide: true when the caller didn't set it (handling the optional-options/callback signatures). Zero flashing windows since, runs behave identically.
Suggestion for a proper upstream fix: either add windowsHide: true at every call site, or centralize all child_process usage behind one helper and set it there.
Two smaller Windows findings from the same session, happy to file separately if useful:
cli-precheck.jsmoonshot credential check only looks at~/.kimi/auth.json— the current kimi CLI stores credentials at~/.kimi/credentials/kimi-code.json, so a freshly logged-in CLI still yields AUTH_MISSING.- The moonshot lineage passes the template model string (e.g.
moonshotai/kimi-k3) straight to the kimi CLI, which only knows its own names (kimi-code/k3) and exits with "LLM not set" — a mapping table (or docs note) would help.
Fixed and shipped in v0.8.64 (npm i -g chorus-codes@latest). Thank you — this was an unusually good report, and all three findings were real.
1. The flashing windows (#108) — windowsHide: true at every call site that can actually surface a console: the reviewer spawn, the where/which/npm prefix detection probes, the eight mcp add/mcp remove calls during chorus init, the model probes, git/gh, the ss/lsof port probes, and the detached daemon/cockpit spawns.
I went with per-call-site rather than the child_process wrapper you suggested, for one reason worth recording: three of our sites go through promisify(execFile), and a wrapper silently loses Node's util.promisify.custom binding unless it's manually re-attached — at which point { stdout } destructuring starts returning the wrong thing. Your instinct to centralise was right in principle; it's just that this particular module fights back.
Four groups are deliberately untouched, in case you spot a flash we missed: tmux, the macOS keychain probe, sudo/ps, and the $SHELL -lic PATH capture are all POSIX-only paths that can never spawn on Windows (no shell → CreateProcess fails → no console allocated). And chorus update's npm calls use stdio: 'inherit' in your own terminal, where hiding the window would suppress the progress output you're meant to see.
2. The Kimi credentials path (#109) — correct, and not Windows-specific: it reproduces on Linux too. We only probed ~/.kimi/auth.json; the native Kimi Code build writes ~/.kimi/credentials/kimi-code.json and nothing else. Side benefit: that path also feeds the auto-heal check, so re-logging-in now clears a stuck auth_invalid badge for Kimi as well.
3. The model names (#110) — this one turned out deeper than "add a mapping table". Reading kimi_cli/app.py:
if model_name and model_name in config.models:
model = config.models[model_name]
...
if not model:
model = LLMModel(provider="", model="", ...) # → LLMNotSet
-m is an exact key match against the [models] table in your config, and those keys are minted by /login as <platform>/<model-id> from a server-issued, per-account list — so there's no static table that stays correct. Worse, because model_name was supplied, the default_model fallback is skipped entirely: a wrong -m is strictly worse than no -m, which is exactly the LLM not set + exit 0 you hit.
So Chorus now reads your actual [models] keys and resolves onto them (moonshotai/kimi-k3 → kimi-code/k3, kimi-k2.6 → kimi-code/k2.6), and when nothing matches it omits the flag so the CLI uses the model you picked at login. LLM not set is also no longer silent — it surfaces as an auth error telling you to run /login, instead of looking like a reviewer who had nothing to say.
Chasing that turned up two things beyond your report:
- gemini-cli 0.52.0 (current latest) now rejects the free individual tier outright:
IneligibleTierError … migrate to the Antigravity suite. That's an access change on Google's side, not something we can fix — free-tier users needagyinstead, which Chorus already supports. agy1.1.7 has grown--modeland anagy modelssubcommand with 11 models. Our shim still assumes it's locked to one. Follow-up, and it needs a lineage rethink first, sinceagycan runclaude-sonnet-4-6— meaning an Antigravity voice isn't necessarily a Google-family reviewer for quorum purposes.
One thing I couldn't verify: the resolver is tested against real config shapes, but not end-to-end against a logged-in Kimi Code account — this box's kimi is the Python build with an empty [models] table, which is the "omit -m" path. If you're on the native build, chorus a Kimi voice and check the run card shows your model rather than kimi (CLI default). If it doesn't, the normalisation needs another case and I'd like to see your [models] keys.
Updated to 0.8.64 on Windows 11. Our local patch went from four pieces down to
one — the windowsHide wrapper and the Kimi credential path are both yours now.
Thanks for the detail in that reply; the promisify reasoning in particular.
Your promisify point — confirmed in the field, and it was our bug.
The wrapper we suggested had exactly the flaw you describe. Four lines against the patch we had actually been running for two days:
const util = require('util'), cp = require('child_process');
const before = util.promisify(cp.execFile);
require('./win-hide-patch.cjs'); // our wrapper
const after = util.promisify(cp.execFile);
before : typeof=object stdout="hallo"
after : typeof=string stdout=undefined
cp.execFile[util.promisify.custom] after patch: false
So every const { stdout } = await execFileAsync(...) behind it was silently
getting undefined. We never noticed because we don't call it ourselves — but
Chorus does. Per-call-site was the right call, and we've dropped the wrapper.
The Kimi resolver — verified against a real logged-in native account.
lib/kimi-config.js from 0.8.64 against this box's real ~/.kimi/config.toml
(native Kimi Code build, logged in):
readKimiModelKeys() ->
["kimi-code/k3","kimi-code/k3-256k","kimi-code/kimi-for-coding",
"kimi-code/kimi-for-coding-highspeed","moonshotai/kimi-k3"]
default_model = "kimi-code/kimi-for-coding"
resolveKimiModel() ->
moonshotai/kimi-k3 -> "moonshotai/kimi-k3"
kimi-code/k3 -> "kimi-code/k3"
kimi-k3 -> "kimi-code/k3"
k3 -> "kimi-code/k3"
kimi-k2.6 -> null (omit -m -> default_model)
moonshotai/kimi-k2 -> null
Then invoked the CLI exactly as runHeadless does — kimi --print --output-format stream-json -m moonshotai/kimi-k3 — and it was accepted:
exit 0, real answer, no LLM not set. So the resolution holds end-to-end on a
real account, not just against config shapes.
One case worth a regression test, because it makes your ordering load-bearing
rather than incidental: this box has a hand-added [models."moonshotai/kimi-k3"]
backed by OpenRouter, sitting alongside the managed kimi-code/k3. Your
documented example maps the former onto the latter — here it must not, and
doesn't, because the exact-match branch runs before normalisation. If that order
ever flips, this config silently changes provider mid-run.
Two things we hit but never filed — both still present in 0.8.64, and both reproduced in that same CLI run. Happy to open them separately.
1. parseKimi is parseClaude. kimi-cli 1.49 emits --output-format stream-json in OpenAI shape. Verbatim single line from the run above:
{"role":"assistant","content":"Erledigt ✅"}
No type field, so parseClaude keys on nothing. Feeding that same stdout
through both parsers:
events, dist/daemon/agents/parsers/kimi.js (0.8.64) : 0
events, same file with an OpenAI-shape fallback : 1
Zero events is a no_output verdict on a run that returned exit 0 and a real
answer. What we run locally is additive: try parseClaude first, and only if it
yields nothing, map the OpenAI shape onto the same events (text_delta, and
tool_calls[].function onto tool_call_start). Ran the stock and patched parser
side by side over the same lines — identical output on everything parseClaude
already handled.
2. Windows + the Python kimi-cli dies on non-ASCII output. Same prompt, same
CLI, only PYTHONIOENCODING removed:
exit=1
Unknown error: 'charmap' codec can't encode character '✅' in position 42
Default cp1252, so the process dies the moment a review contains an emoji or an
umlaut — and it writes nothing usable to stdout, which surfaces as the same
no_output. Any review that ends in a ✅ or a German umlaut hits this.
That one may be cheaper for you than it looks: spawnEnv() in
dist/daemon/headless.js already builds every child environment as
{ ...process.env, ...extra }, so two lines at daemon start cover every spawned
CLI without touching a single call site —
process.env.PYTHONIOENCODING ??= 'utf-8';
process.env.PYTHONUTF8 ??= '1';
??= so an explicit setting from outside still wins. That is exactly what our
remaining local patch is now — no wrapper, nothing to lose a promisify binding
to. A user-level environment variable is not a substitute: it only works if the
daemon happened to inherit it at start, which is why this went unexplained for a
while here.