Skip to content

Commit c2cbc7e

Browse files
committed
improvement(mothership-chat): hoist EMPTY_BLOCKS constant to keep MessageContent memoized for block-free messages
1 parent 06564fc commit c2cbc7e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
ChatMessage,
2020
ChatMessageAttachment,
2121
ChatMessageContext,
22+
ContentBlock,
2223
FileAttachmentForApi,
2324
MothershipResource,
2425
QueuedMessage,
@@ -80,6 +81,8 @@ const LAYOUT_STYLES = {
8081
},
8182
} as const
8283

84+
const EMPTY_BLOCKS: ContentBlock[] = []
85+
8386
interface UserMessageRowProps {
8487
content: string
8588
contexts?: ChatMessageContext[]
@@ -133,7 +136,7 @@ const AssistantMessageRow = memo(function AssistantMessageRow({
133136
onOptionSelect,
134137
onWorkspaceResourceSelect,
135138
}: AssistantMessageRowProps) {
136-
const blocks = message.contentBlocks ?? []
139+
const blocks = message.contentBlocks ?? EMPTY_BLOCKS
137140
const hasAnyBlocks = blocks.length > 0
138141
const trimmedContent = message.content?.trim() ?? ''
139142

0 commit comments

Comments
 (0)