File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
packages/app/src/react/features/ai-chat Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ export const SystemMessage: FC<ISystemMessageProps> = (props) => {
3434
3535 const contentRef = useRef < HTMLDivElement > ( null ) ;
3636
37+ if ( ! message ) return null ; // if message is empty, return null
38+
3739 return (
3840 < div className = "system-message-bubble relative" >
3941 { isError ? (
Original file line number Diff line number Diff line change @@ -308,6 +308,23 @@ export const useChat = (config: IUseChatConfig): IUseChatReturn => {
308308 setIsProcessing ( true ) ;
309309 clearError ( ) ;
310310
311+ // Remove any previous error messages and loading messages before sending new message
312+ setMessages ( ( prev ) => {
313+ // Check if there are any error messages (indicates stopped generation)
314+ const hasErrorMessages = prev . some ( ( msg ) => msg . type === 'error' ) ;
315+
316+ // Remove error messages
317+ const filtered = prev . filter ( ( msg ) => msg . type !== 'error' ) ;
318+
319+ // If there were error messages and the last message is loading,
320+ if ( hasErrorMessages && filtered . length > 0 ) {
321+ const lastMessage = filtered [ filtered . length - 1 ] ;
322+ if ( lastMessage . type === 'loading' ) return filtered . slice ( 0 , - 1 ) ;
323+ }
324+
325+ return filtered ;
326+ } ) ;
327+
311328 // Upload files if present
312329 let attachments : IFileAttachment [ ] = [ ] ;
313330 if ( files && files . length > 0 ) {
You can’t perform that action at this time.
0 commit comments