Skip to content

fix(cli): hide Windows console windows from kimi web and file opens#1913

Open
liujunGH wants to merge 2 commits into
MoonshotAI:mainfrom
liujunGH:fix/windows-console-windows
Open

fix(cli): hide Windows console windows from kimi web and file opens#1913
liujunGH wants to merge 2 commits into
MoonshotAI:mainfrom
liujunGH:fix/windows-console-windows

Conversation

@liujunGH

Copy link
Copy Markdown

Problem

On Windows, kimi web makes Windows allocate a visible console window when it opens the browser: openUrl shells out to cmd /c start via execFile with no options, and Node's windowsHide defaults to false. From a console-less parent the transient cmd.exe gets its own console window; users see a shell window flash every time the Web UI opens.

Two more sites in the same flow have the same issue:

  • kap-server's launchDetached (web UI "open file / reveal / open in editor" actions) spawns with detached: true and no windowsHide — a detached child gets its own console window on Windows (see the identical comment in cli/update/preflight.ts).
  • commandExists's win32 where probe (spawnSync('cmd', ...)) flashes a console when the open-in-app menu is built.

Fix

Pass windowsHide: true at all three sites, unconditional (ignored off Windows — same convention as kaos). Same class of bug and same one-option fix as the already-merged #957 (spawned commands), #1336 (background updater), and #1466 (hooks).

Tests

  • New apps/kimi-code/test/utils/open-url.test.ts: asserts execFile receives windowsHide: true and the per-platform opener command.
  • New packages/kap-server/test/fileLaunch.test.ts: asserts launchDetached and the win32 where probe pass windowsHide: true.
  • Existing related suites still green: kap-server/test/files.test.ts (7), test/tui/commands/web.test.ts (14); tsc --noEmit clean in both packages.

Note: verified on macOS only (no Windows machine at hand); the option is a no-op elsewhere, and the behavior matches the three merged precedent fixes.

`openUrl` (used by `kimi web`, `kimi vis`, the login flow) and
kap-server's `launchDetached` / win32 `where` probe spawned processes
without `windowsHide`, so Windows allocated a visible console window —
flashing a cmd.exe window when opening the browser and pinning one for
detached children. Same class as MoonshotAI#957 / MoonshotAI#1336 / MoonshotAI#1466; same one-option fix,
kept unconditional (ignored off Windows, matching kaos).
@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2220852

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebdbc92eda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// On Windows a detached child gets its own console window; hide it so
// "open file" from the web UI does not flash a console (see also the
// background updater's identical guard in cli/update/preflight.ts).
windowsHide: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Explorer reveal windows visible

For Windows users invoking the web UI's Reveal action, handleReveal routes through revealFileCommandFor, which launches explorer.exe /select,... directly rather than through cmd; applying this option to every detached launch can hide the Explorer window itself. I checked Node v24/libuv's Windows spawn path (source), where UV_PROCESS_WINDOWS_HIDE uses SW_HIDE to avoid any process window, so please restrict windowsHide to console/shell commands instead of GUI openers.

Useful? React with 👍 / 👎.

Codex review: `windowsHide` maps to SW_HIDE, which would also hide the
FIRST window of GUI children — e.g. explorer.exe launched by the web UI's
reveal action. Apply it only when the direct child is console-subsystem
(a shell shim or cmd.exe itself); GUI targets stay visible.
@liujunGH

Copy link
Copy Markdown
Author

Codex P2 addressed in 2220852: windowsHide now only applies when the direct child is console-subsystem (shell shim or cmd.exe itself, via launchesConsole()). GUI targets like explorer.exe (the reveal action) and editors keep their windows visible. Added test coverage for all three cases (shell shim → hidden, direct cmd → hidden, explorer.exe → visible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant