@@ -7,6 +7,7 @@ import type { Message } from 'ai'
77import { useLocalStorage } from '../hooks/useLocalStorage'
88import { type Servers } from '../lib/schemas'
99import { ToolCallMessage } from './ToolCallMessage'
10+ import { ReasoningMessage } from './ReasoningMessage'
1011import { useModel } from '../contexts/ModelContext'
1112
1213// Streamed event type
@@ -22,6 +23,15 @@ type StreamEvent =
2223 arguments ?: unknown
2324 }
2425 | { type : 'user' ; id : string ; content : string }
26+ | {
27+ type : 'reasoning'
28+ effort : string
29+ summary : string | null
30+ model ?: string
31+ serviceTier ?: string
32+ temperature ?: number
33+ topP ?: number
34+ }
2535
2636export function Chat ( ) {
2737 const messagesEndRef = useRef < HTMLDivElement > ( null )
@@ -61,6 +71,22 @@ export function Chat() {
6171 try {
6272 const toolState = JSON . parse ( line . slice ( 2 ) )
6373
74+ if ( toolState . type === 'reasoning' ) {
75+ setStreamBuffer ( ( prev ) => [
76+ ...prev ,
77+ {
78+ type : 'reasoning' ,
79+ effort : toolState . effort ,
80+ summary : toolState . summary ,
81+ model : toolState . model ,
82+ serviceTier : toolState . serviceTier ,
83+ temperature : toolState . temperature ,
84+ topP : toolState . topP ,
85+ } ,
86+ ] )
87+ return
88+ }
89+
6490 if ( 'delta' in toolState ) {
6591 try {
6692 toolState . delta =
@@ -191,6 +217,19 @@ export function Chat() {
191217 args = { event }
192218 />
193219 )
220+ } else if ( 'type' in event && event . type === 'reasoning' ) {
221+ return (
222+ < ReasoningMessage
223+ key = { `reasoning-${ event . effort } -${ event . summary || '' } ` }
224+ effort = { event . effort }
225+ summary = { event . summary }
226+ model = { event . model }
227+ serviceTier = { event . serviceTier }
228+ temperature = { event . temperature }
229+ topP = { event . topP }
230+ isLoading = { streaming && idx === renderEvents . length - 1 }
231+ />
232+ )
194233 } else if ( 'type' in event && event . type === 'assistant' ) {
195234 const assistantEvent = event as Extract <
196235 StreamEvent ,
0 commit comments