@@ -35,43 +35,6 @@ interface DetailsCardProps {
3535 metadata ?: SBChatMessageMetadata ;
3636}
3737
38- const ThinkingStepsScroller = ( { thinkingSteps, isStreaming, isThinking } : { thinkingSteps : SBChatMessagePart [ ] [ ] , isStreaming : boolean , isThinking : boolean } ) => {
39- const { scrollRef, contentRef, scrollToBottom } = useStickToBottom ( ) ;
40- const [ shouldStick , setShouldStick ] = useState ( isThinking ) ;
41- const prevIsThinking = usePrevious ( isThinking ) ;
42-
43- useEffect ( ( ) => {
44- if ( prevIsThinking && ! isThinking ) {
45- scrollToBottom ( ) ;
46- setShouldStick ( false ) ;
47- } else if ( ! prevIsThinking && isThinking ) {
48- setShouldStick ( true ) ;
49- }
50- } , [ isThinking , prevIsThinking , scrollToBottom ] ) ;
51-
52- return (
53- < div ref = { scrollRef } className = "max-h-[300px] overflow-y-auto px-6 py-2" >
54- < div ref = { shouldStick ? contentRef : undefined } >
55- { thinkingSteps . length === 0 ? (
56- isStreaming ? (
57- < Skeleton className = "h-24 w-full" />
58- ) : (
59- < p className = "text-sm text-muted-foreground" > No thinking steps</ p >
60- )
61- ) : thinkingSteps . map ( ( step , index ) => (
62- < div key = { index } >
63- { step . map ( ( part , index ) => (
64- < div key = { index } className = "mb-2" >
65- < StepPartRenderer part = { part } />
66- </ div >
67- ) ) }
68- </ div >
69- ) ) }
70- </ div >
71- </ div >
72- ) ;
73- }
74-
7538const DetailsCardComponent = ( {
7639 chatId,
7740 isExpanded,
@@ -191,7 +154,7 @@ const DetailsCardComponent = ({
191154 </ CollapsibleTrigger >
192155 < CollapsibleContent >
193156 < CardContent className = "mt-2 p-0" >
194- < ThinkingStepsScroller
157+ < ThinkingSteps
195158 thinkingSteps = { thinkingSteps }
196159 isStreaming = { isStreaming }
197160 isThinking = { isThinking }
@@ -206,6 +169,44 @@ const DetailsCardComponent = ({
206169export const DetailsCard = memo ( DetailsCardComponent , isEqual ) ;
207170
208171
172+ const ThinkingSteps = ( { thinkingSteps, isStreaming, isThinking } : { thinkingSteps : SBChatMessagePart [ ] [ ] , isStreaming : boolean , isThinking : boolean } ) => {
173+ const { scrollRef, contentRef, scrollToBottom } = useStickToBottom ( ) ;
174+ const [ shouldStick , setShouldStick ] = useState ( isThinking ) ;
175+ const prevIsThinking = usePrevious ( isThinking ) ;
176+
177+ useEffect ( ( ) => {
178+ if ( prevIsThinking && ! isThinking ) {
179+ scrollToBottom ( ) ;
180+ setShouldStick ( false ) ;
181+ } else if ( ! prevIsThinking && isThinking ) {
182+ setShouldStick ( true ) ;
183+ }
184+ } , [ isThinking , prevIsThinking , scrollToBottom ] ) ;
185+
186+ return (
187+ < div ref = { scrollRef } className = "max-h-[350px] overflow-y-auto px-6 py-2" >
188+ < div ref = { shouldStick ? contentRef : undefined } >
189+ { thinkingSteps . length === 0 ? (
190+ isStreaming ? (
191+ < Skeleton className = "h-24 w-full" />
192+ ) : (
193+ < p className = "text-sm text-muted-foreground" > No thinking steps</ p >
194+ )
195+ ) : thinkingSteps . map ( ( step , index ) => (
196+ < div key = { index } >
197+ { step . map ( ( part , index ) => (
198+ < div key = { index } className = "mb-2" >
199+ < StepPartRenderer part = { part } />
200+ </ div >
201+ ) ) }
202+ </ div >
203+ ) ) }
204+ </ div >
205+ </ div >
206+ ) ;
207+ }
208+
209+
209210export const StepPartRenderer = ( { part } : { part : SBChatMessagePart } ) => {
210211 switch ( part . type ) {
211212 case 'reasoning' :
0 commit comments