@@ -642,7 +642,6 @@ const Chat: React.FC<ChatProps> = ({
642642 ] ;
643643 }
644644 }
645- console . log ( "line 66o:updatedMessages:::" , updatedMessages )
646645 saveToDB ( updatedMessages , conversationId , isChatReq ) ;
647646 } catch ( e ) {
648647 console . log ( "Catched with an error while chat and save" , e ) ;
@@ -759,6 +758,8 @@ const Chat: React.FC<ChatProps> = ({
759758 messages . map ( ( msg , index ) => (
760759 < div key = { index } className = { `chat-message ${ msg . role } ` } >
761760 { ( ( ) => {
761+ const isLastAssistantMessage =
762+ msg . role === "assistant" && index === messages . length - 1 ;
762763 if ( ( msg . role === "user" ) && typeof msg . content === "string" ) {
763764 if ( msg . content == "show in a graph by default" ) return null ;
764765 return (
@@ -788,16 +789,25 @@ const Chat: React.FC<ChatProps> = ({
788789 remarkPlugins = { [ remarkGfm , supersub ] }
789790 children = { msg . content }
790791 />
791- < Citations
792- answer = { {
793- answer : msg . content ,
794- citations :
795- msg . role === ASSISTANT
796- ? parseCitationFromMessage ( msg . citations )
797- : [ ] ,
798- } }
799- index = { index }
800- />
792+ { /* Citation Loader: Show only while citations are fetching */ }
793+ { isLastAssistantMessage && generatingResponse ? (
794+ < div className = "typing-indicator" >
795+ < span className = "dot" > </ span >
796+ < span className = "dot" > </ span >
797+ < span className = "dot" > </ span >
798+ </ div >
799+ ) : (
800+ < Citations
801+ answer = { {
802+ answer : msg . content ,
803+ citations :
804+ msg . role === "assistant"
805+ ? parseCitationFromMessage ( msg . citations )
806+ : [ ] ,
807+ } }
808+ index = { index }
809+ />
810+ ) }
801811
802812 < div className = "answerDisclaimerContainer" >
803813 < span className = "answerDisclaimer" >
0 commit comments