@@ -33,7 +33,7 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
33
33
const { t } = useTranslation ( 'chat' ) ;
34
34
35
35
const {
36
- state : { selectedConversation, conversations, currentMessage } ,
36
+ state : { selectedConversation, conversations, currentMessage, messageIsStreaming } ,
37
37
dispatch : homeDispatch ,
38
38
} = useContext ( HomeContext ) ;
39
39
@@ -215,6 +215,14 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
215
215
rehypePlugins = { [ rehypeMathjax ] }
216
216
components = { {
217
217
code ( { node, inline, className, children, ...props } ) {
218
+ if ( children . length ) {
219
+ if ( children [ 0 ] == '▍' ) {
220
+ return < span className = "animate-pulse cursor-default mt-1" > ▍</ span >
221
+ }
222
+
223
+ children [ 0 ] = ( children [ 0 ] as string ) . replace ( "`▍`" , "▍" )
224
+ }
225
+
218
226
const match = / l a n g u a g e - ( \w + ) / . exec ( className || '' ) ;
219
227
220
228
return ! inline ? (
@@ -253,7 +261,9 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit }) =
253
261
} ,
254
262
} }
255
263
>
256
- { message . content }
264
+ { `${ message . content } ${
265
+ messageIsStreaming && messageIndex == ( selectedConversation ?. messages . length ?? 0 ) - 1 ? '`▍`' : ''
266
+ } `}
257
267
</ MemoizedReactMarkdown >
258
268
259
269
< div className = "md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start" >
0 commit comments