MoonshotAI / MoonshotAI/kimi-code

Windows: status_line.command containing double quotes is mangled by the cmd spawn

Open
#2,332 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Summary

On Windows, a status_line.command containing double quotes (e.g. the Claude-Code-style py -3 "C:\path\to\statusline.py") is mangled before it reaches the shell: the command exits immediately and the footer silently falls back to the built-in layout. Any Windows user whose statusline command needs quoting — most commonly because the path contains spaces — cannot use the feature.

Root cause

apps/kimi-code/src/tui/utils/status-line-command.ts spawns the command as a single argv element:

spawn(isWin ? (process.env['ComSpec'] ?? 'cmd.exe') : 'sh', isWin ? ['/d', '/s', '/c', command] : ['-c', command], ...)

When libuv serializes that argv for CreateProcess, it wraps the command element in quotes and backslash-escapes any embedded ". cmd /s then strips only the outermost quote pair, leaving literal \" sequences in the executed line. The invoked program (MSVCRT-style argv parsing) reads those as escaped quote characters and glues tokens together. The interpreter ends up with a garbage path.

Reproduction (verbatim through the feature's own spawn path)

const { spawn } = require("node:child_process");
// Fails: quoted path (Claude Code's recommended form)
const cmd1 = 'py -3 "C:/Users/me/statusline.py"';
// Works: same command, unquoted
const cmd2 = 'py -3 C:/Users/me/statusline.py';

function tryIt(command) {
  const child = spawn(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", command],
    { stdio: ["pipe", "pipe", "inherit"] });
  child.on("close", (code) => console.log(JSON.stringify(command), "-> exit", code));
  child.stdin.end(JSON.stringify({ model: "K3", cwd: "C:/x", gitBranch: null,
    permissionMode: "manual", planMode: false, contextUsage: 0,
    contextTokens: 0, maxContextTokens: 0, sessionId: "s", version: "0" }));
}
tryIt(cmd1); // exit 2 — python.exe: can't open file '...\\"C:\\...\\statusline.py"'
tryIt(cmd2); // exit 0

Observed on Windows 11, Node v22.19.0, kimi-code built from source at commit 67dd03149. Verified against the real spawn semantics above, and end-to-end in the built TUI (unquoted command renders the custom line correctly; quoted command exits 2 before producing any output).

Test gap

apps/kimi-code/test/tui/components/chrome/footer-status-line.test.ts only exercises POSIX commands (cat, true, printf, sleep) — no win32 case, and nothing with embedded quotes.

Suggested directions

  • Spawn with shell: true (lets Node build the cmd /d /s /c "..." line itself), or
  • Pre-wrap the command in an extra pair of quotes on Windows so the /s strip lands correctly, or
  • If the constraint is intentional, document "no double quotes in status_line.command on Windows" — though that makes space-containing paths unusable, which quoted paths exist to solve.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/kimi-code/src/tui/utils/status-line-command.ts and inspect the Windows spawn path, then review apps/kimi-code/test/tui/components/chrome/footer-status-line.test.ts for the existing command tests. Add coverage for a quoted Windows status-line command and verify that quoted paths work without breaking the existing POSIX cases; run the footer status-line test file to confirm the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.