diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 5b2d25c5..dfdefed7 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- **Thinking Block Toggle**: Added `Ctrl+T` shortcut to toggle visibility of LLM thinking blocks. When toggled off, shows a static "Thinking..." label instead of full content. Useful for reducing visual clutter during long conversations. ([#113](https://github.com/badlogic/pi-mono/pull/113)) +- **Thinking Block Toggle**: Added `Ctrl+T` shortcut to toggle visibility of LLM thinking blocks. When toggled off, shows a static "Thinking..." label instead of full content. Useful for reducing visual clutter during long conversations. ([#113](https://github.com/badlogic/pi-mono/pull/113) by [@markusylisiurunen](https://github.com/markusylisiurunen)) ## [0.12.10] - 2025-12-04 diff --git a/packages/coding-agent/src/tui/assistant-message.ts b/packages/coding-agent/src/tui/assistant-message.ts index 31e0f80e..8757e76c 100644 --- a/packages/coding-agent/src/tui/assistant-message.ts +++ b/packages/coding-agent/src/tui/assistant-message.ts @@ -41,15 +41,22 @@ export class AssistantMessageComponent extends Container { } // Render content in order - for (const content of message.content) { + for (let i = 0; i < message.content.length; i++) { + const content = message.content[i]; if (content.type === "text" && content.text.trim()) { // Assistant text messages with no background - trim the text // Set paddingY=0 to avoid extra spacing before tool executions this.contentContainer.addChild(new Markdown(content.text.trim(), 1, 0, getMarkdownTheme())); } 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()); + if (this.hideThinkingBlock) { // Show static "Thinking..." label when hidden this.contentContainer.addChild(new Text(theme.fg("muted", "Thinking..."), 1, 0)); + if (hasTextAfter) { + this.contentContainer.addChild(new Spacer(1)); + } } else { // Thinking traces in muted color, italic // Use Markdown component with default text style for consistent styling