Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Thinking v0
  • Loading branch information
Sg312 authored and emir-karabeg committed Mar 17, 2026
commit 4750dc58415780e66a056ce5e9bfcc9e2a1a9962
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export function AgentGroup({
status={item.data.status}
/>
) : (
<p
<div
key={`text-${idx}`}
className='whitespace-pre-wrap pl-[24px] font-base text-[13px] text-[var(--text-secondary)]'
className='ml-[24px] rounded-lg border border-[var(--divider)] bg-[var(--surface-4)] px-3 py-2 text-[13px] text-[var(--text-tertiary)] italic'
>
{item.content.trim()}
</p>
</div>
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
)
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface CredentialTagData {

export type ContentSegment =
| { type: 'text'; content: string }
| { type: 'thinking'; content: string }
| { type: 'options'; data: OptionsTagData }
| { type: 'usage_upgrade'; data: UsageUpgradeTagData }
| { type: 'credential'; data: CredentialTagData }
Expand All @@ -36,7 +37,7 @@ export interface ParsedSpecialContent {
hasPendingTag: boolean
}

const SPECIAL_TAG_NAMES = ['options', 'usage_upgrade', 'credential'] as const
const SPECIAL_TAG_NAMES = ['thinking', 'options', 'usage_upgrade', 'credential'] as const

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

const body = content.slice(bodyStart, closeIdx)
try {
const data = JSON.parse(body)
segments.push({ type: nearestTagName as 'options' | 'usage_upgrade' | 'credential', data })
} catch {
/* malformed JSON — drop the tag silently */
if (nearestTagName === 'thinking') {
if (body.trim()) {
segments.push({ type: 'thinking', content: body })
}
} else {
try {
const data = JSON.parse(body)
segments.push({ type: nearestTagName as 'options' | 'usage_upgrade' | 'credential', data })
} catch {
/* malformed JSON — drop the tag silently */
}
}

cursor = closeIdx + closeTag.length
Expand Down Expand Up @@ -137,6 +144,13 @@ interface SpecialTagsProps {
*/
export function SpecialTags({ segment, onOptionSelect }: SpecialTagsProps) {
switch (segment.type) {
/** TODO: FIX THINKING BLOCK RENDERING*/
case 'thinking':
return (
<div className='rounded-lg border border-[var(--divider)] bg-[var(--surface-4)] px-3 py-2 text-[13px] text-[var(--text-tertiary)] italic'>
{segment.content.trim()}
</div>
)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
case 'options':
return <OptionsDisplay data={segment.data} onSelect={onOptionSelect} />
case 'usage_upgrade':
Expand Down
9 changes: 5 additions & 4 deletions apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,11 @@ export function useChat(
streamingContentRef.current = ''
streamingBlocksRef.current = []

const ensureTextBlock = (): ContentBlock => {
const ensureTextBlock = (subagent?: boolean): ContentBlock => {
const wantType = subagent ? 'subagent_text' : 'text'
const last = blocks[blocks.length - 1]
if (last?.type === 'text') return last
const b: ContentBlock = { type: 'text', content: '' }
if (last?.type === wantType) return last
const b: ContentBlock = { type: wantType, content: '' }
blocks.push(b)
return b
}
Expand Down Expand Up @@ -607,7 +608,7 @@ export function useChat(
lastContentSource !== contentSource &&
runningText.length > 0 &&
!runningText.endsWith('\n')
const tb = ensureTextBlock()
const tb = ensureTextBlock(!!activeSubagent)
const normalizedChunk = needsBoundaryNewline ? `\n${chunk}` : chunk
tb.content = (tb.content ?? '') + normalizedChunk
runningText += normalizedChunk
Expand Down