@@ -13,6 +13,8 @@ interface ThinkingBlockProps {
1313 onToggleCollapsed : ( id : string ) => void
1414 availableWidth : number
1515 isNested : boolean
16+ /** Whether the parent message is complete (used to hide native reasoning blocks) */
17+ isMessageComplete : boolean
1618}
1719
1820export const ThinkingBlock = memo (
@@ -21,6 +23,7 @@ export const ThinkingBlock = memo(
2123 onToggleCollapsed,
2224 availableWidth,
2325 isNested,
26+ isMessageComplete,
2427 } : ThinkingBlockProps ) => {
2528 const firstBlock = blocks [ 0 ]
2629 const thinkingId = firstBlock ?. thinkingId
@@ -39,6 +42,14 @@ export const ThinkingBlock = memo(
3942 }
4043 } , [ onToggleCollapsed , thinkingId ] )
4144
45+ // thinkingOpen === true means still streaming
46+ // thinkingOpen === false means explicitly closed with </think> tag
47+ // thinkingOpen === undefined means native reasoning block - complete when message is complete
48+ const isThinkingComplete =
49+ firstBlock ?. thinkingOpen === false ||
50+ ( firstBlock ?. thinkingOpen === undefined && isMessageComplete )
51+
52+ // Hide if no content or no thinkingId (but NOT when thinking is complete)
4253 if ( ! combinedContent || ! thinkingId ) {
4354 return null
4455 }
@@ -48,6 +59,7 @@ export const ThinkingBlock = memo(
4859 < Thinking
4960 content = { combinedContent }
5061 isCollapsed = { isCollapsed }
62+ isThinkingComplete = { isThinkingComplete }
5163 onToggle = { handleToggle }
5264 availableWidth = { availWidth }
5365 />
0 commit comments