fix(tui): sanitize foreground Bash tool output - #2919
Open
nhatduy227 wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: cec058a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Captured Bash stdout/stderr reached pi-tui unsanitized in the tool-call card, so sequences such as ESC[?1049h switched the host terminal to the alternate screen and left tmux scrollback unavailable after exit. Sanitize the accumulated buffer in ShellExecutionComponent, which covers both streaming live output and the final result.
nhatduy227
force-pushed
the
fix/sanitize-foreground-bash-output
branch
from
August 14, 2026 08:17
910d9ef to
cec058a
Compare
Author
|
@liruifengv — tagging you since this continues #2863 (which you merged). The foreground Bash tool card still passes captured output straight to pi-tui, so Diff is one call site plus a changeset. Happy to add regression tests for the split-chunk and final-result paths if you'd like them in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Fixes #2915
Problem
Foreground Bash tool stdout/stderr reaches pi-tui unsanitized, both while streaming and in the final result. A captured
ESC[?1049hswitches the host terminal to the alternate screen; inside tmux this makes native scrollback unavailable, and the pane stays in that state after Kimi Code exits because no matchingESC[?1049lis emitted.sanitizeShellOutputalready guards!shell mode and the background task views (#2863), but not the tool-call card.What changed
Sanitize
result.outputinShellExecutionComponentbefore styling. This single site covers both the accumulated live stdout/stderr and the final Bash result, sincebuildLiveOutputBlockrenders live output through the same component.Scoped to
ShellExecutionComponentrather thanTruncatedOutputComponent, which is thedefaultresult renderer and would change generic and MCP tool rendering too.Includes a patch changeset for
@moonshot-ai/kimi-code.Verification
vitest run apps/kimi-code/test/tui/(139 files, 1956 passed, 3 skipped)pnpm --filter @moonshot-ai/kimi-code run typecheckoxlint apps/kimi-code/src/tui/components/messages/shell-execution.ts(0 warnings, 0 errors)MAX_LIVE_OUTPUT_CHARScap measured at ~0.075 ms on escape-heavy input.