Skip to content

fix(tui): bound completed shell output frames - #2385

Open
lurenjia534 wants to merge 1 commit into
MoonshotAI:mainfrom
lurenjia534:fix/tui-shell-final-output-2320
Open

fix(tui): bound completed shell output frames#2385
lurenjia534 wants to merge 1 commit into
MoonshotAI:mainfrom
lurenjia534:fix/tui-shell-final-output-2320

Conversation

@lurenjia534

@lurenjia534 lurenjia534 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Related Issue

Resolve #2320

Problem

Completed foreground shell commands passed their entire captured output to the terminal renderer. A command that emitted many short lines could therefore create a very large frame, causing unnecessary wrapping work and memory pressure even though only the tail is useful in the interactive view.

What changed

  • Bound each completed stdout/stderr presentation tail by both line count and character count.
  • Apply the same bounded presentation to live completion and session replay.
  • Preserve the complete formatted output in the transcript entry so session history and exports remain lossless.
  • Keep completed replay components timer-free and recalculate theme styling when the active theme changes.
  • Cover large short-line output, a single long line, stdout/stderr, theme changes, and replay retention with regression tests.

Validation

  • pnpm --filter @moonshot-ai/kimi-code exec vitest run test/tui/components/messages/shell-run.test.ts test/tui/message-replay.test.ts
  • pnpm --filter @moonshot-ai/kimi-code exec vitest run — 2,462 passed, 5 skipped
  • pnpm --filter @moonshot-ai/kimi-code typecheck
  • pnpm --filter @moonshot-ai/kimi-code build
  • pnpm exec oxlint --type-aware --quiet
  • git diff --check
  • Controlled before/after memory probe against upstream
    691ec4679ea19d6be8ac18f359088384ed3e446d and fixed
    6fb6bac22889bc0a1c2816aef437c76c3b397be5, using the real
    ShellRunComponent → pi-tui Text render path while retaining the complete
    formatBashOutputForDisplay transcript. With 50,000 high-entropy short
    lines (2,750,000 characters), five isolated node --expose-gc processes
    produced these forced-GC medians:
    • upstream: 50,000 rendered rows, 15,679,944 B retained-heap delta,
      9,850,880 B RSS delta
    • fixed: 6 rendered rows, 2,784,936 B retained-heap delta,
      2,772,992 B RSS delta
    • reduction: 82.24% retained heap and 71.85% RSS
  • The same probe at 300,000 lines retained the complete transcript and reduced
    the forced-GC median by 82.60% for heap and 68.83% for RSS.
    These are post-GC deltas for the affected render path on this run, not a
    cross-platform claim about whole-process peak CLI memory.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • 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 Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6fb6bac

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

@lurenjia534
lurenjia534 marked this pull request as ready for review July 29, 2026 21:52
@pkg-pr-new

pkg-pr-new Bot commented Jul 29, 2026

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

commit: 6fb6bac

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 6fb6bac228

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

Final rendering of many short shell-output lines amplifies frame size and memory use

1 participant