From 950b0caaa17a440caf31fa74f198fbc571c53102 Mon Sep 17 00:00:00 2001 From: hobostay <110hqc@gmail.com> Date: Thu, 5 Mar 2026 21:07:14 +0800 Subject: [PATCH] fix: preserve line breaks in expanded thinking content Fixes #419 The thinking component was normalizing content to a single line even in expanded mode, causing multi-line markdown content (headers, lists, flow diagrams) to be collapsed into a single unreadable line. Changes: - Added variable that preserves line breaks - Use in expanded mode instead of raw - Clean up excessive consecutive newlines while preserving paragraph breaks This ensures proper markdown rendering in the thinking section when expanded, while maintaining the compact single-line preview. --- cli/src/components/thinking.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/src/components/thinking.tsx b/cli/src/components/thinking.tsx index 87731d48d..bc1ab10e0 100644 --- a/cli/src/components/thinking.tsx +++ b/cli/src/components/thinking.tsx @@ -39,7 +39,7 @@ export const Thinking = memo( } const width = Math.max(10, availableWidth ?? contentMaxWidth) - // Normalize content to single line for consistent preview + // Normalize content to single line for consistent preview (but preserve in expanded mode) const normalizedContent = content.replace(/\n+/g, ' ').trim() // Account for "..." prefix (3 chars) when calculating line widths const effectiveWidth = width - 3 @@ -48,6 +48,8 @@ export const Thinking = memo( effectiveWidth, PREVIEW_LINE_COUNT, ) + // In expanded mode, preserve original line breaks for proper markdown rendering + const expandedContent = content.replace(/\n\n+/g, '\n\n').trim() const showFull = thinkingCollapseState === 'expanded' const showPreview = thinkingCollapseState === 'preview' && lines.length > 0 @@ -94,7 +96,7 @@ export const Thinking = memo( }} attributes={TextAttributes.ITALIC} > - {content} + {expandedContent} )}