Skip to content

Commit b541cfd

Browse files
committed
fix(cli): improve text rendering and user message styling
- Make user message vertical line extend full height with calculated line count - Italicize user input text for better visual distinction - Fix markdown paragraph spacing (single newlines instead of double) - Add spacing between consecutive text blocks to prevent bleeding - Update userLine colors for better visibility in both themes
1 parent df3593e commit b541cfd

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

cli/src/components/message-block.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,11 @@ export const MessageBlock = ({
448448
: rawContent
449449
const prevBlock = idx > 0 ? blocks[idx - 1] : null
450450
const marginTop =
451-
prevBlock &&
452-
(prevBlock.type === 'tool' || prevBlock.type === 'agent')
453-
? 0
454-
: 0
451+
prevBlock && prevBlock.type === 'text'
452+
? 1
453+
: prevBlock && (prevBlock.type === 'tool' || prevBlock.type === 'agent')
454+
? 0
455+
: 0
455456
const blockTextColor = block.color ?? textColor
456457
return (
457458
<text key={renderKey} style={{ fg: blockTextColor, marginTop }}>
@@ -497,6 +498,7 @@ export const MessageBlock = ({
497498
<text
498499
key={`message-content-${messageId}`}
499500
style={{ fg: textColor }}
501+
attributes={isUser ? TextAttributes.ITALIC : undefined}
500502
>
501503
{displayContent}
502504
</text>

cli/src/hooks/use-message-renderer.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ export const useMessageRenderer = (
280280
const hasAgentChildren = agentChildren.length > 0
281281
const showVerticalLine = isUser
282282

283+
// Calculate height for vertical line
284+
const contentLines = message.content ? message.content.split('\n').length : 1
285+
const verticalLineHeight = Math.max(1, contentLines + 1) // +1 for timestamp
286+
const verticalLineText = Array(verticalLineHeight).fill('│').join('\n')
287+
283288
return (
284289
<box
285290
key={message.id}
@@ -307,16 +312,14 @@ export const useMessageRenderer = (
307312
}}
308313
>
309314
<box
310-
border
311-
borderStyle="single"
312-
borderColor={lineColor}
313-
customBorderChars={verticalLineBorderChars}
314315
style={{
315316
width: 1,
316-
marginTop: 0,
317-
marginBottom: 0,
317+
flexShrink: 0,
318+
flexDirection: 'column',
318319
}}
319-
/>
320+
>
321+
<text fg={lineColor}>{verticalLineText}</text>
322+
</box>
320323
<box
321324
style={{
322325
backgroundColor: 'transparent',

cli/src/utils/markdown-renderer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function nodeToPlainText(node: Content | Root): string {
8787

8888
case 'paragraph':
8989
return (
90-
(node as Paragraph).children.map(nodeToPlainText).join('') + '\n\n'
90+
(node as Paragraph).children.map(nodeToPlainText).join('') + '\n'
9191
)
9292

9393
case 'text':
@@ -100,7 +100,7 @@ function nodeToPlainText(node: Content | Root): string {
100100
const heading = node as Heading
101101
const prefix = '#'.repeat(Math.max(1, Math.min(heading.depth, 6)))
102102
const content = heading.children.map(nodeToPlainText).join('')
103-
return `${prefix} ${content}\n\n`
103+
return `${prefix} ${content}\n`
104104
}
105105

106106
case 'list': {
@@ -115,7 +115,7 @@ function nodeToPlainText(node: Content | Root): string {
115115
.trimEnd()
116116
return marker + text
117117
})
118-
.join('\n') + '\n\n'
118+
.join('\n') + '\n'
119119
)
120120
}
121121

@@ -129,13 +129,13 @@ function nodeToPlainText(node: Content | Root): string {
129129
const content = blockquote.children
130130
.map((child) => nodeToPlainText(child).replace(/^/gm, '> '))
131131
.join('')
132-
return `${content}\n\n`
132+
return `${content}\n`
133133
}
134134

135135
case 'code': {
136136
const code = node as Code
137137
const header = code.lang ? `\`\`\`${code.lang}\n` : '```\n'
138-
return `${header}${code.value}\n\`\`\`\n\n`
138+
return `${header}${code.value}\n\`\`\`\n`
139139
}
140140

141141
default:

cli/src/utils/theme-system.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const BASE_THEMES: Record<'dark' | 'light', ChatTheme> = {
6666
accentText: '#facc15',
6767
panelBg: 'transparent',
6868
aiLine: '#34d399',
69-
userLine: '#38bdf8',
69+
userLine: '#0ea5e9',
7070
timestampAi: '#4ade80',
7171
timestampUser: '#60a5fa',
7272
messageAiText: '#9aa5ce',
@@ -124,7 +124,7 @@ const BASE_THEMES: Record<'dark' | 'light', ChatTheme> = {
124124
accentText: '#f59e0b',
125125
panelBg: 'transparent',
126126
aiLine: '#059669',
127-
userLine: '#3b82f6',
127+
userLine: '#0284c7',
128128
timestampAi: '#047857',
129129
timestampUser: '#2563eb',
130130
messageAiText: '#9aa5ce',

0 commit comments

Comments
 (0)