MoonshotAI / MoonshotAI/kimi-code
[Bug] TUI: folded assistant messages ("… N messages") are disposed and cannot be re-expanded — previous replies become invisible
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What version of Kimi Code is running?
0.36.0
Which open platform/subscription were you using?
Kimi Code (OAuth)
Which model were you using?
K3-256k (thinking: high)
What platform is your computer?
Linux 6.19.8-arch1-3-surface x86_64
What issue are you seeing?
When a turn ends, the TUI folds all but the last 2 assistant messages of that turn into a muted summary line, e.g.:
✨ <assistant reply>
… 1 messages
Once the next turn starts, the folded assistant reply is no longer visible anywhere in the transcript. Pressing Ctrl+O (expand tool output) only reveals thinking blocks and tool calls — it does not bring back the folded assistant message.
Source investigation (why Ctrl+O can't recover it)
Reading apps/kimi-code/src/tui/utils/transcript-window.ts and apps/kimi-code/src/tui/kimi-tui.ts, this appears to be by-design behavior with an unfortunate UX consequence: foldCurrentTurnContent() merges older assistant messages into a StepSummaryComponent (KIMI_CODE_TUI_KEEP_RECENT_ASSISTANT_COMPLETED, default 2) and then calls dispose() on the merged components — they are destroyed, not collapsed. toggleToolOutputExpansion() (Ctrl+O) only calls setExpanded() on still-mounted isExpandable components, so the folded reply text is unrecoverable in the live TUI. Resuming the session replays with the same folding (mergeAllTurnSteps()), so the message stays hidden there too.
The only ways to read the hidden reply are /export-md or the raw wire.jsonl, and the only way to prevent the folding is restarting with KIMI_CODE_TUI_KEEP_RECENT_ASSISTANT_COMPLETED=0.
What steps can reproduce the bug?
- Start a session and have a conversation where a single turn produces 3+ assistant messages (e.g. several Q&A evaluations in one turn).
- Send another prompt so that turn completes.
- Scroll up: earlier assistant messages of the completed turn are replaced by
… N messages. - Press
Ctrl+O— thinking/tool output expands, the folded assistant messages do not.
What is the expected behavior?
Folded assistant messages should be viewable without leaving the TUI — e.g. the … N messages summary line should be expandable via Ctrl+O (like thinking/tool output), or assistant message text should be excluded from the completed-turn folding so only thinking/tool steps fold.
Additional information
The folding itself (bounding the mounted component tree) is a reasonable memory optimization — the problem is that the folded reply text has no in-TUI escape hatch, unlike thinking traces and tool output. Related: #2296 (scroll position issues when reading earlier messages).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with foldCurrentTurnContent() in apps/kimi-code/src/tui/utils/transcript-window.ts and toggleToolOutputExpansion() in apps/kimi-code/src/tui/kimi-tui.ts. Reproduce the issue with a turn producing 3+ assistant messages, then trace how StepSummaryComponent and disposed components are handled. Done means folded assistant replies can be viewed again in the live TUI without relying on /export-md or wire.jsonl.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100