@@ -172,8 +172,8 @@ const CodeBlock = ({
172172 const codeRef = useRef < HTMLElement > ( null ) ;
173173
174174 useEffect ( ( ) => {
175- if ( codeRef . current && ( window as any ) . hljs ) {
176- ( window as any ) . hljs . highlightElement ( codeRef . current ) ;
175+ if ( codeRef . current && ( globalThis as any ) . hljs ) {
176+ ( globalThis as any ) . hljs . highlightElement ( codeRef . current ) ;
177177 }
178178 } , [ content , isTruncated ] ) ;
179179
@@ -410,6 +410,15 @@ const ElapsedTime = ({
410410 </ div >
411411) ;
412412
413+ const TYPE_COLORS = {
414+ assistant : { bg : '#dbeafe' , text : '#1e40af' } ,
415+ user : { bg : '#f3e8ff' , text : '#6b21a8' } ,
416+ system : { bg : '#e0e7ff' , text : '#3730a3' } ,
417+ result : { bg : '#dcfce7' , text : '#166534' } ,
418+ tool : { bg : '#fef3c7' , text : '#92400e' } ,
419+ prompt : { bg : '#fce7f3' , text : '#9f1239' } ,
420+ } as const ;
421+
413422const Turn = ( {
414423 children,
415424 type,
@@ -420,7 +429,7 @@ const Turn = ({
420429 isMCP = false ,
421430} : {
422431 children : React . ReactNode ;
423- type : string ;
432+ type : keyof typeof TYPE_COLORS ;
424433 title : string ;
425434 subtitle ?: string ;
426435 tokenCount ?: string ;
@@ -429,16 +438,7 @@ const Turn = ({
429438} ) => {
430439 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
431440
432- const typeColors : Record < string , { bg : string ; text : string } > = {
433- assistant : { bg : '#dbeafe' , text : '#1e40af' } ,
434- user : { bg : '#f3e8ff' , text : '#6b21a8' } ,
435- system : { bg : '#e0e7ff' , text : '#3730a3' } ,
436- result : { bg : '#dcfce7' , text : '#166534' } ,
437- tool : { bg : '#fef3c7' , text : '#92400e' } ,
438- prompt : { bg : '#fce7f3' , text : '#9f1239' } ,
439- } ;
440-
441- const colors = typeColors [ type ] || typeColors . assistant ;
441+ const colors = TYPE_COLORS [ type ] ?? TYPE_COLORS . assistant ;
442442
443443 return (
444444 < div
@@ -771,10 +771,9 @@ function groupToolCallsWithResults(turns: ConversationMessage[]): Array<{
771771 } > = [ ] ;
772772 const usedResultIndices = new Set < number > ( ) ;
773773
774- for ( let i = 0 ; i < turns . length ; i ++ ) {
774+ for ( const [ i , turn ] of turns . entries ( ) ) {
775775 if ( usedResultIndices . has ( i ) ) continue ;
776776
777- const turn = turns [ i ] ;
778777 const toolUseContent =
779778 turn . type === 'assistant' &&
780779 'message' in turn &&
0 commit comments