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/sanitize-foreground-bash-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Sanitize foreground Bash tool output so captured terminal escape sequences no longer change the host terminal state.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container, Text } from '@moonshot-ai/pi-tui';

import { currentTheme } from '#/tui/theme';
import type { ToolCallBlockData, ToolResultBlockData } from '#/tui/types';
import { sanitizeShellOutput } from '#/tui/utils/shell-output';

import type { ResultRenderer } from './tool-renderers/types';
import { PREVIEW_LINES } from './tool-renderers/types';
Expand Down Expand Up @@ -68,8 +69,10 @@ export class ShellExecutionComponent extends Container {
expandHint: boolean,
): void {
if (!result.output) return;
// Untrusted bytes: sanitize the whole buffer, not each chunk, so escape
// sequences split across live-output chunks cannot reach the terminal.
this.addChild(
new TruncatedOutputComponent(result.output, {
new TruncatedOutputComponent(sanitizeShellOutput(result.output), {
expanded,
isError: result.is_error ?? false,
maxLines: previewLines,
Expand Down