Skip to content
Closed
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/disable-wsl-terminal-progress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Disable terminal progress reporting under WSL in Windows Terminal.
10 changes: 9 additions & 1 deletion apps/kimi-code/src/tui/utils/terminal-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function supportsOsc9Notification(env: NodeJS.ProcessEnv = process.env):
* always safe.
*/
export function supportsTerminalProgress(env: NodeJS.ProcessEnv = process.env): boolean {
if ((env['WT_SESSION'] ?? '').length > 0) return true;
if ((env['WT_SESSION'] ?? '').length > 0) return !isInsideWsl(env);
if (env['ConEmuANSI'] === 'ON') return true;
const termProgram = env['TERM_PROGRAM'] ?? '';
if (termProgram === 'ghostty' || termProgram === 'WezTerm') return true;
Expand All @@ -134,6 +134,14 @@ export function isInsideTmux(env: NodeJS.ProcessEnv = process.env): boolean {
return tmux.length > 0;
}

function isInsideWsl(env: NodeJS.ProcessEnv): boolean {
return (
(env['WSL_DISTRO_NAME'] ?? '').length > 0 ||
(env['WSLENV'] ?? '').length > 0 ||
(env['WSL_INTEROP'] ?? '').length > 0
);
}

function sanitizeNotificationText(value: string): string {
return Array.from(value)
.map((ch) => (isControlCharacter(ch) ? ' ' : ch))
Expand Down
12 changes: 12 additions & 0 deletions apps/kimi-code/test/tui/terminal-notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ describe('supportsTerminalProgress', () => {
expect(supportsTerminalProgress({ ConEmuANSI: 'ON' })).toBe(true);
});

it('rejects Windows Terminal under WSL', () => {
expect(supportsTerminalProgress({ WT_SESSION: 'abc-123', WSL_DISTRO_NAME: 'example' })).toBe(
false,
);
expect(supportsTerminalProgress({ WT_SESSION: 'abc-123', WSLENV: 'WT_SESSION/u' })).toBe(
false,
);
expect(
supportsTerminalProgress({ WT_SESSION: 'abc-123', WSL_INTEROP: '/run/WSL/example.sock' }),
).toBe(false);
});

it('detects Ghostty / WezTerm via TERM_PROGRAM and TERM', () => {
expect(supportsTerminalProgress({ TERM_PROGRAM: 'ghostty' })).toBe(true);
expect(supportsTerminalProgress({ TERM: 'xterm-ghostty' })).toBe(true);
Expand Down