diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 506f735e..8c38409a 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed extra spacing between thinking-only assistant content and subsequent tool execution blocks when assistant messages contain no text + ## [0.52.6] - 2026-02-05 ### Breaking Changes diff --git a/packages/coding-agent/src/modes/interactive/components/assistant-message.ts b/packages/coding-agent/src/modes/interactive/components/assistant-message.ts index 5f9acb2c..ae5256c6 100644 --- a/packages/coding-agent/src/modes/interactive/components/assistant-message.ts +++ b/packages/coding-agent/src/modes/interactive/components/assistant-message.ts @@ -63,13 +63,16 @@ export class AssistantMessageComponent extends Container { // Set paddingY=0 to avoid extra spacing before tool executions this.contentContainer.addChild(new Markdown(content.text.trim(), 1, 0, this.markdownTheme)); } else if (content.type === "thinking" && content.thinking.trim()) { - // Check if there's text content after this thinking block - const hasTextAfter = message.content.slice(i + 1).some((c) => c.type === "text" && c.text.trim()); + // Add spacing only when another visible assistant content block follows. + // This avoids a superfluous blank line before separately-rendered tool execution blocks. + const hasVisibleContentAfter = message.content + .slice(i + 1) + .some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim())); if (this.hideThinkingBlock) { // Show static "Thinking..." label when hidden this.contentContainer.addChild(new Text(theme.italic(theme.fg("thinkingText", "Thinking...")), 1, 0)); - if (hasTextAfter) { + if (hasVisibleContentAfter) { this.contentContainer.addChild(new Spacer(1)); } } else { @@ -80,7 +83,9 @@ export class AssistantMessageComponent extends Container { italic: true, }), ); - this.contentContainer.addChild(new Spacer(1)); + if (hasVisibleContentAfter) { + this.contentContainer.addChild(new Spacer(1)); + } } } }