kimi-code/packages/pi-tui/test
liruifengv e45832398d
fix(tui): keep long sessions responsive and bound resumed history (#1976)
* fix(pi-tui): reuse processed lines across frames in the renderer

Each frame previously re-truncated, re-normalized, and re-compared every
transcript line, so steady-state frames (spinner ticks, streaming flushes)
cost O(total lines x chars) and pegged one core in long sessions. Keep the
previous frame's raw lines, processed output, and per-line kitty image ids;
a line whose raw string reference is unchanged reuses its processed output
verbatim, and image-id consumers read the cache instead of re-scanning text.

* fix(tui): stop tree-wide transcript invalidation on structural updates

Grouping a second Read/Agent call, removing swarm progress, finalizing an
MCP status row, replay tool-call removal, and /undo each invalidated the
entire transcript tree, forcing every mounted message to re-render (markdown
lexing + code highlighting) on the next frame. The container's render cache
already validates per child by reference, so structural child-list changes
are picked up without a tree-wide invalidate; reserve it for global style
changes such as theme switches.

* fix(tui): fold older assistant messages into the turn step summary

Step merging only collapsed thinking/tool steps, so assistant text blocks
accumulated without bound inside a turn (hundreds of markdown components in
a single long turn, all re-processed every frame). A running turn now keeps
its last 20 assistant messages (KIMI_CODE_TUI_KEEP_RECENT_ASSISTANT), and a
finished turn folds down to its conclusion tail of 2
(KIMI_CODE_TUI_KEEP_RECENT_ASSISTANT_COMPLETED); older ones collapse into
the step summary line with a message count. Entries are kept, so expand
behavior is unchanged.

* fix(session): bound resumed history to the most recent user turns

Resume used to return every agent's full replay over the RPC boundary (a
long session can reach ~100MB, serialized and parsed several times on an
in-process call), while the TUI only renders the last 10 user turns. The
resume payload now accepts an optional replayTurnLimit, the turn-boundary
predicate moves into agent-core as the single source of truth
(limitAgentReplayByTurns, re-exported through the SDK), and the CLI passes
its existing 10-turn limit so resume transfers just the tail.

* fix(session): count goal continuation rounds as replay turns

Replay turn boundaries only matched real user input, so a 100-round goal
(a handful of user prompts plus 100 system-trigger continuations) fell
entirely inside the 10-turn replay window and resumed by rendering the whole
run from the start. The goal driver already fires one synthetic prompt per
goal turn and counts those as turns itself, so replay trimming now treats
goal_continuation prompts as turn boundaries and keeps the most recent 10
rounds. The continuation prompt is model-facing and hidden live; replay no
longer renders it as a user bubble either, while still advancing the replay
turn so each round groups separately.

* fix(tui): keep replay turn folding when goal continuations are hidden

Suppressing goal continuation bubbles removed every turn-boundary
component from goal-session replays, so mergeAllTurnSteps found no turn
edges and skipped step/assistant folding entirely — a single oversized
goal round still mounted all of its tool cards and assistant messages.
Mount an invisible ReplayTurnBoundaryComponent for each hidden
continuation: it renders zero lines but keeps the turn edges discoverable
to folding and window trimming, matching replay trimming's per-round turn
semantics.

* chore: consolidate and simplify changesets
2026-07-21 15:20:12 +08:00
..
autocomplete.test.ts fix(tui): complete @ file mentions across additional workspace roots with fd (#1408) 2026-07-06 15:02:02 +08:00
bug-regression-isimageline-startswith-bug.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
chat-simple.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
editor.test.ts fix(tui): complete @ file mentions across additional workspace roots with fd (#1408) 2026-07-06 15:02:02 +08:00
fuzzy.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
image-test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
input.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
key-tester.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
keybindings.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
keys.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
markdown.test.ts fix(pi-tui): prevent crashes on very narrow terminals (#1303) 2026-07-02 17:14:11 +08:00
overlay-non-capturing.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
overlay-options.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
overlay-short-content.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
regression-overlay-cjk-boundary.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
regression-regional-indicator-width.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
select-list.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
stdin-buffer.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
tab-width.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
terminal-colors.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
terminal-image.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
terminal.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
test-themes.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
truncate-to-width.test.ts fix(pi-tui): prevent crashes on very narrow terminals (#1303) 2026-07-02 17:14:11 +08:00
truncated-text.test.ts fix(pi-tui): prevent crashes on very narrow terminals (#1303) 2026-07-02 17:14:11 +08:00
tui-cell-size-input.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
tui-overlay-style-leak.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
tui-render.test.ts fix(tui): keep long sessions responsive and bound resumed history (#1976) 2026-07-21 15:20:12 +08:00
viewport-overwrite-repro.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
virtual-terminal.ts revert(pi-tui): restore upstream differential rendering behavior (#1367) 2026-07-04 17:57:43 +08:00
word-navigation.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00
wrap-ansi.test.ts feat(kimi-code): vendor @moonshot-ai/pi-tui (#1254) 2026-07-01 20:23:35 +08:00