Skip to content

Commit dee790d

Browse files
committed
Thinking v0
1 parent 395a61d commit dee790d

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ export function AgentGroup({
100100
status={item.data.status}
101101
/>
102102
) : (
103-
<p
103+
<div
104104
key={`text-${idx}`}
105-
className='whitespace-pre-wrap pl-[24px] font-base text-[13px] text-[var(--text-secondary)]'
105+
className='ml-[24px] rounded-lg border border-[var(--divider)] bg-[var(--surface-4)] px-3 py-2 text-[13px] text-[var(--text-tertiary)] italic'
106106
>
107107
{item.content.trim()}
108-
</p>
108+
</div>
109109
)
110110
)}
111111
</div>

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface CredentialTagData {
2727

2828
export type ContentSegment =
2929
| { type: 'text'; content: string }
30+
| { type: 'thinking'; content: string }
3031
| { type: 'options'; data: OptionsTagData }
3132
| { type: 'usage_upgrade'; data: UsageUpgradeTagData }
3233
| { type: 'credential'; data: CredentialTagData }
@@ -36,7 +37,7 @@ export interface ParsedSpecialContent {
3637
hasPendingTag: boolean
3738
}
3839

39-
const SPECIAL_TAG_NAMES = ['options', 'usage_upgrade', 'credential'] as const
40+
const SPECIAL_TAG_NAMES = ['thinking', 'options', 'usage_upgrade', 'credential'] as const
4041

4142
/**
4243
* Parses inline special tags (`<options>`, `<usage_upgrade>`) from streamed
@@ -103,11 +104,17 @@ export function parseSpecialTags(content: string, isStreaming: boolean): ParsedS
103104
}
104105

105106
const body = content.slice(bodyStart, closeIdx)
106-
try {
107-
const data = JSON.parse(body)
108-
segments.push({ type: nearestTagName as 'options' | 'usage_upgrade' | 'credential', data })
109-
} catch {
110-
/* malformed JSON — drop the tag silently */
107+
if (nearestTagName === 'thinking') {
108+
if (body.trim()) {
109+
segments.push({ type: 'thinking', content: body })
110+
}
111+
} else {
112+
try {
113+
const data = JSON.parse(body)
114+
segments.push({ type: nearestTagName as 'options' | 'usage_upgrade' | 'credential', data })
115+
} catch {
116+
/* malformed JSON — drop the tag silently */
117+
}
111118
}
112119

113120
cursor = closeIdx + closeTag.length
@@ -137,6 +144,13 @@ interface SpecialTagsProps {
137144
*/
138145
export function SpecialTags({ segment, onOptionSelect }: SpecialTagsProps) {
139146
switch (segment.type) {
147+
/** TODO: FIX THINKING BLOCK RENDERING*/
148+
case 'thinking':
149+
return (
150+
<div className='rounded-lg border border-[var(--divider)] bg-[var(--surface-4)] px-3 py-2 text-[13px] text-[var(--text-tertiary)] italic'>
151+
{segment.content.trim()}
152+
</div>
153+
)
140154
case 'options':
141155
return <OptionsDisplay data={segment.data} onSelect={onOptionSelect} />
142156
case 'usage_upgrade':

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

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

495-
const ensureTextBlock = (): ContentBlock => {
495+
const ensureTextBlock = (subagent?: boolean): ContentBlock => {
496+
const wantType = subagent ? 'subagent_text' : 'text'
496497
const last = blocks[blocks.length - 1]
497-
if (last?.type === 'text') return last
498-
const b: ContentBlock = { type: 'text', content: '' }
498+
if (last?.type === wantType) return last
499+
const b: ContentBlock = { type: wantType, content: '' }
499500
blocks.push(b)
500501
return b
501502
}
@@ -578,7 +579,7 @@ export function useChat(
578579
lastContentSource !== contentSource &&
579580
runningText.length > 0 &&
580581
!runningText.endsWith('\n')
581-
const tb = ensureTextBlock()
582+
const tb = ensureTextBlock(!!activeSubagent)
582583
const normalizedChunk = needsBoundaryNewline ? `\n${chunk}` : chunk
583584
tb.content = (tb.content ?? '') + normalizedChunk
584585
runningText += normalizedChunk

0 commit comments

Comments
 (0)