Skip to content

Commit 1e9df2f

Browse files
Sg312emir-karabeg
authored andcommitted
Change
1 parent 4750dc5 commit 1e9df2f

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
@@ -513,11 +513,10 @@ export function useChat(
513513
streamingContentRef.current = ''
514514
streamingBlocksRef.current = []
515515

516-
const ensureTextBlock = (subagent?: boolean): ContentBlock => {
517-
const wantType = subagent ? 'subagent_text' : 'text'
516+
const ensureTextBlock = (): ContentBlock => {
518517
const last = blocks[blocks.length - 1]
519-
if (last?.type === wantType) return last
520-
const b: ContentBlock = { type: wantType, content: '' }
518+
if (last?.type === 'text') return last
519+
const b: ContentBlock = { type: 'text', content: '' }
521520
blocks.push(b)
522521
return b
523522
}
@@ -608,9 +607,10 @@ export function useChat(
608607
lastContentSource !== contentSource &&
609608
runningText.length > 0 &&
610609
!runningText.endsWith('\n')
611-
const tb = ensureTextBlock(!!activeSubagent)
610+
const tb = ensureTextBlock()
612611
const normalizedChunk = needsBoundaryNewline ? `\n${chunk}` : chunk
613612
tb.content = (tb.content ?? '') + normalizedChunk
613+
if (activeSubagent) tb.subagent = activeSubagent
614614
runningText += normalizedChunk
615615
lastContentSource = contentSource
616616
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)