Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-windows-status-line-quotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Fix status line commands with quoted arguments on Windows.
21 changes: 14 additions & 7 deletions apps/kimi-code/src/tui/utils/status-line-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@ export function runStatusLineCommand(
const isWin = process.platform === 'win32';
let child;
try {
child = spawn(isWin ? (process.env['ComSpec'] ?? 'cmd.exe') : 'sh', isWin ? ['/d', '/s', '/c', command] : ['-c', command], {
stdio: ['pipe', 'pipe', 'ignore'],
env: { ...process.env, KIMI_CODE_STATUS_LINE: '1' },
// Own process group on POSIX so a timeout can drop the whole tree,
// not just the shell wrapper.
detached: !isWin,
});
child = spawn(
isWin ? (process.env['ComSpec'] ?? 'cmd.exe') : 'sh',
isWin ? ['/d', '/s', '/c', `"${command}"`] : ['-c', command],
{
stdio: ['pipe', 'pipe', 'ignore'],
env: { ...process.env, KIMI_CODE_STATUS_LINE: '1' },
// Own process group on POSIX so a timeout can drop the whole tree,
// not just the shell wrapper.
detached: !isWin,
// Preserve the nested quotes in cmd /s /c "<command>" instead of
// letting libuv escape them as literal backslashes.
windowsVerbatimArguments: isWin,
},
);
} catch {
finish(null);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ describe('FooterComponent status_line items', () => {
});

describe('runStatusLineCommand', () => {
it.runIf(process.platform === 'win32')(
'preserves double quotes in Windows commands',
async () => {
const command = `"${process.execPath}" -e "process.stdout.write('quoted-ok')"`;

expect(await runStatusLineCommand(command, payload, 5_000)).toBe('quoted-ok');
},
);

it('passes the payload as JSON on stdin and returns the first stdout line', async () => {
const line = await runStatusLineCommand('cat', payload);

Expand Down