Skip to content

fix(tui): sanitize foreground Bash tool output - #2919

Merged
Grapedge merged 1 commit into
MoonshotAI:mainfrom
duyphan154:fix/sanitize-foreground-bash-output
Oct 8, 2026
Merged

Grapedge merged 1 commit into
MoonshotAI:mainfrom
duyphan154:fix/sanitize-foreground-bash-output

Conversation

@duyphan154

@duyphan154 duyphan154 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

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[?1049h switches 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 matching ESC[?1049l is emitted.

sanitizeShellOutput already guards ! shell mode and the background task views (#2863), but not the tool-call card.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 17b09e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@duyphan154
duyphan154 force-pushed the fix/sanitize-foreground-bash-output branch from 910d9ef to cec058a Compare August 14, 2026 08:17
@duyphan154

duyphan154 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor 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 ESC[?1049h from command output flips the host terminal to the alternate screen and takes tmux scrollback with it.

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.

@duyphan154

duyphan154 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Friendly bump. Rechecked against current main (50 commits later): still conflict-free, and shell-execution.ts / shell-output.ts are untouched, so #2915 is still open and this still applies.

Regression tests for the split-chunk and final-result paths are ready to push if you want them in this PR — just say so. Happy to redirect to someone else if the TUI area has a different owner now.

cc: @liruifengv

@duyphan154

duyphan154 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@liruifengv @7Sageer — please review at your convenience

@duyphan154
duyphan154 force-pushed the fix/sanitize-foreground-bash-output branch from cec058a to f7fa06b Compare August 24, 2026 01:24
@duyphan154

Copy link
Copy Markdown
Contributor Author

@sailist @wbxl2000 — could one of you take a look, or /approve #2915 so this is on-policy? One call site + changeset, no conflicts, all CI jobs verified locally.

@duyphan154

Copy link
Copy Markdown
Contributor Author

@RealKai42 @liruifengv — could one of you review this TUI fix? I revalidated it today against current main (317 commits ahead): Git reports no conflicts, and the effective diff remains one sanitizeShellOutput call plus the changeset. It covers both streaming and final foreground Bash output, including escape sequences split across chunks.

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.
@Grapedge
Grapedge force-pushed the fix/sanitize-foreground-bash-output branch from f7fa06b to 17b09e3 Compare October 6, 2026 10:03
@pkg-pr-new

pkg-pr-new Bot commented Oct 6, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@17b09e3
npx https://pkg.pr.new/@moonshot-ai/kimi-code@17b09e3

commit: 17b09e3

@Grapedge
Grapedge merged commit 0f052fe into MoonshotAI:main Oct 8, 2026
25 of 26 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Foreground Bash tool output renders raw terminal escape sequences (breaks tmux scrollback)

2 participants