Skip to content

Commit d4d29fa

Browse files
committed
Fix empty message spacing for attachment-only user messages
1 parent d690da5 commit d4d29fa

File tree

3 files changed

+48
-45
lines changed

3 files changed

+48
-45
lines changed

cli/src/components/blocks/user-content-copy.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export const UserContentWithCopyButton = memo(
3737

3838
const hasContent = normalizedContent.length > 0
3939

40-
if (!showCopyButton || !hasContent) {
40+
if (!hasContent) {
41+
return null
42+
}
43+
44+
if (!showCopyButton) {
4145
return (
4246
<text
4347
key={`message-content-${messageId}`}

cli/src/components/message-block.tsx

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ const MessageAttachments = memo(({
7676
flexDirection: 'row',
7777
gap: 1,
7878
flexWrap: 'wrap',
79-
marginTop: 1,
8079
}}
8180
>
8281
{imageAttachments.map((attachment) => (
@@ -255,53 +254,55 @@ export const MessageBlock = memo(({
255254
</box>
256255
)}
257256

258-
{blocks ? (
259-
<box
260-
style={{
261-
flexDirection: 'column',
262-
gap: 0,
263-
width: '100%',
264-
paddingTop: 0,
265-
}}
266-
>
267-
<BlocksRenderer
268-
sourceBlocks={blocks}
257+
<box style={{ flexDirection: 'column', gap: 1, width: '100%' }}>
258+
{blocks ? (
259+
<box
260+
style={{
261+
flexDirection: 'column',
262+
gap: 0,
263+
width: '100%',
264+
paddingTop: 0,
265+
}}
266+
>
267+
<BlocksRenderer
268+
sourceBlocks={blocks}
269+
messageId={messageId}
270+
isLoading={isLoading}
271+
isComplete={isComplete}
272+
isUser={isUser}
273+
textColor={resolvedTextColor}
274+
availableWidth={availableWidth}
275+
markdownPalette={markdownPalette}
276+
onToggleCollapsed={onToggleCollapsed}
277+
onBuildFast={onBuildFast}
278+
onBuildMax={onBuildMax}
279+
isLastMessage={isLastMessage}
280+
contentToCopy={isUser ? content : undefined}
281+
/>
282+
</box>
283+
) : (
284+
<UserContentWithCopyButton
285+
content={content}
269286
messageId={messageId}
270287
isLoading={isLoading}
271288
isComplete={isComplete}
272289
isUser={isUser}
273290
textColor={resolvedTextColor}
274-
availableWidth={availableWidth}
275-
markdownPalette={markdownPalette}
276-
onToggleCollapsed={onToggleCollapsed}
277-
onBuildFast={onBuildFast}
278-
onBuildMax={onBuildMax}
279-
isLastMessage={isLastMessage}
280-
contentToCopy={isUser ? content : undefined}
281-
/>
282-
</box>
283-
) : (
284-
<UserContentWithCopyButton
285-
content={content}
286-
messageId={messageId}
287-
isLoading={isLoading}
288-
isComplete={isComplete}
289-
isUser={isUser}
290-
textColor={resolvedTextColor}
291-
codeBlockWidth={markdownOptions.codeBlockWidth}
292-
palette={markdownOptions.palette}
293-
showCopyButton={isUser}
294-
/>
295-
)}
296-
{/* Show attachments for user messages */}
297-
{isUser &&
298-
((attachments && attachments.length > 0) ||
299-
(textAttachments && textAttachments.length > 0)) && (
300-
<MessageAttachments
301-
imageAttachments={attachments ?? []}
302-
textAttachments={textAttachments ?? []}
291+
codeBlockWidth={markdownOptions.codeBlockWidth}
292+
palette={markdownOptions.palette}
293+
showCopyButton={isUser}
303294
/>
304295
)}
296+
{/* Show attachments for user messages */}
297+
{isUser &&
298+
((attachments && attachments.length > 0) ||
299+
(textAttachments && textAttachments.length > 0)) && (
300+
<MessageAttachments
301+
imageAttachments={attachments ?? []}
302+
textAttachments={textAttachments ?? []}
303+
/>
304+
)}
305+
</box>
305306

306307
{/* Display runtime error banner for AI messages */}
307308
{isAi && userError && <UserErrorBanner error={userError} />}

cli/src/utils/pending-attachments.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { existsSync } from 'node:fs'
22
import path from 'node:path'
33

4-
import { showClipboardMessage } from './clipboard'
54
import { processImageFile, resolveFilePath, isImageFile } from './image-handler'
65
import {
76
useChatStore,
@@ -82,10 +81,9 @@ export async function addPendingImageFromFile(
8281
}),
8382
}))
8483

85-
// Exit image mode and show status message after successfully adding an image
84+
// Exit image mode after successfully processing an image
8685
if (result.success) {
8786
exitImageModeIfActive()
88-
showClipboardMessage(`🖼️ Attached ${filename}`, { durationMs: 5000 })
8987
}
9088
}
9189

0 commit comments

Comments
 (0)