diff --git a/.changeset/disable-wsl-terminal-progress.md b/.changeset/disable-wsl-terminal-progress.md new file mode 100644 index 000000000..268a1aefb --- /dev/null +++ b/.changeset/disable-wsl-terminal-progress.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Disable terminal progress reporting under WSL in Windows Terminal. diff --git a/apps/kimi-code/src/tui/utils/terminal-notification.ts b/apps/kimi-code/src/tui/utils/terminal-notification.ts index ab6f1bff7..7861d9712 100644 --- a/apps/kimi-code/src/tui/utils/terminal-notification.ts +++ b/apps/kimi-code/src/tui/utils/terminal-notification.ts @@ -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; @@ -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)) diff --git a/apps/kimi-code/test/tui/terminal-notification.test.ts b/apps/kimi-code/test/tui/terminal-notification.test.ts index cef7b8086..0c823d59c 100644 --- a/apps/kimi-code/test/tui/terminal-notification.test.ts +++ b/apps/kimi-code/test/tui/terminal-notification.test.ts @@ -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);