Skip to content

Commit 0114921

Browse files
committed
Change
1 parent dee790d commit 0114921

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ function parseBlocks(blocks: ContentBlock[]): MessageSegment[] {
7878

7979
if (block.type === 'text') {
8080
if (!block.content?.trim()) continue
81+
if (block.subagent && group) {
82+
const lastItem = group.items[group.items.length - 1]
83+
if (lastItem?.type === 'text') {
84+
lastItem.content += block.content
85+
} else {
86+
group.items.push({ type: 'text', content: block.content })
87+
}
88+
continue
89+
}
8190
if (group) {
8291
segments.push(group)
8392
group = null

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,10 @@ export function useChat(
492492
streamingContentRef.current = ''
493493
streamingBlocksRef.current = []
494494

495-
const ensureTextBlock = (subagent?: boolean): ContentBlock => {
496-
const wantType = subagent ? 'subagent_text' : 'text'
495+
const ensureTextBlock = (): ContentBlock => {
497496
const last = blocks[blocks.length - 1]
498-
if (last?.type === wantType) return last
499-
const b: ContentBlock = { type: wantType, content: '' }
497+
if (last?.type === 'text') return last
498+
const b: ContentBlock = { type: 'text', content: '' }
500499
blocks.push(b)
501500
return b
502501
}
@@ -579,9 +578,10 @@ export function useChat(
579578
lastContentSource !== contentSource &&
580579
runningText.length > 0 &&
581580
!runningText.endsWith('\n')
582-
const tb = ensureTextBlock(!!activeSubagent)
581+
const tb = ensureTextBlock()
583582
const normalizedChunk = needsBoundaryNewline ? `\n${chunk}` : chunk
584583
tb.content = (tb.content ?? '') + normalizedChunk
584+
if (activeSubagent) tb.subagent = activeSubagent
585585
runningText += normalizedChunk
586586
lastContentSource = contentSource
587587
streamingContentRef.current = runningText

apps/sim/app/workspace/[workspaceId]/home/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export type ContentBlockType =
162162
export interface ContentBlock {
163163
type: ContentBlockType
164164
content?: string
165+
subagent?: string
165166
toolCall?: ToolCallInfo
166167
options?: OptionItem[]
167168
}

0 commit comments

Comments
 (0)