Skip to content

Commit 950b0ca

Browse files
committed
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.
1 parent 9952953 commit 950b0ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cli/src/components/thinking.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const Thinking = memo(
3939
}
4040

4141
const width = Math.max(10, availableWidth ?? contentMaxWidth)
42-
// Normalize content to single line for consistent preview
42+
// Normalize content to single line for consistent preview (but preserve in expanded mode)
4343
const normalizedContent = content.replace(/\n+/g, ' ').trim()
4444
// Account for "..." prefix (3 chars) when calculating line widths
4545
const effectiveWidth = width - 3
@@ -48,6 +48,8 @@ export const Thinking = memo(
4848
effectiveWidth,
4949
PREVIEW_LINE_COUNT,
5050
)
51+
// In expanded mode, preserve original line breaks for proper markdown rendering
52+
const expandedContent = content.replace(/\n\n+/g, '\n\n').trim()
5153

5254
const showFull = thinkingCollapseState === 'expanded'
5355
const showPreview = thinkingCollapseState === 'preview' && lines.length > 0
@@ -94,7 +96,7 @@ export const Thinking = memo(
9496
}}
9597
attributes={TextAttributes.ITALIC}
9698
>
97-
{content}
99+
{expandedContent}
98100
</text>
99101
</box>
100102
)}

0 commit comments

Comments
 (0)