From 37d3066faf9ad5329153f78e8707319655ddfd49 Mon Sep 17 00:00:00 2001 From: liruifengv Date: Mon, 6 Jul 2026 16:41:55 +0800 Subject: [PATCH] fix(tui): keep Edit preview height stable as results land --- .changeset/fix-edit-preview-height.md | 5 +++++ apps/kimi-code/src/tui/components/messages/tool-call.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-edit-preview-height.md diff --git a/.changeset/fix-edit-preview-height.md b/.changeset/fix-edit-preview-height.md new file mode 100644 index 0000000000..7324bcb88a --- /dev/null +++ b/.changeset/fix-edit-preview-height.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Fix the Edit tool card jumping in height and flickering while its result streams in. diff --git a/apps/kimi-code/src/tui/components/messages/tool-call.ts b/apps/kimi-code/src/tui/components/messages/tool-call.ts index 9b2a2d20f1..03d24c5bcc 100644 --- a/apps/kimi-code/src/tui/components/messages/tool-call.ts +++ b/apps/kimi-code/src/tui/components/messages/tool-call.ts @@ -1921,7 +1921,14 @@ export class ToolCallComponent extends Container { this.buildStreamingPreview(this.toolCall.streamingArguments); return; } - const shouldCap = this.result !== undefined && !this.expanded; + // Cap Edit's diff as soon as args finalize, not only when the result + // lands — mirroring Write's writeShouldCap below. Otherwise the render + // tick between finalized args (streamingArguments cleared by the + // `tool.call.started` payload) and the result draws the full diff, then + // snaps back to the cap: a height collapse that triggers pi-tui's full + // redraw and wipes scrollback. Streaming frames (streamingArguments set) + // still take buildStreamingPreview above and never reach here. + const shouldCap = !this.expanded; if (name === 'Write') { const content = str(this.toolCall.args['content']); if (content.length === 0) return;