@@ -291,7 +291,12 @@ export function useChatController({
291
291
}
292
292
}
293
293
294
+ // Reset all relevant state to ensure clean state for new requests
294
295
updateChatStateAction ( currentSession , "input" ) ;
296
+ updateCanContinue ( false , currentSession ) ;
297
+ setUncaughtError ( currentSession , null ) ;
298
+ setLoadingError ( currentSession , null ) ;
299
+ resetRegenerationState ( currentSession ) ;
295
300
} , [ currentMessageHistory , currentMessageTree ] ) ;
296
301
297
302
const onSubmit = useCallback (
@@ -399,14 +404,24 @@ export function useChatController({
399
404
message : "Please wait for the content to upload" ,
400
405
type : "error" ,
401
406
} ) ;
407
+ } else if (
408
+ currentChatState == "streaming" ||
409
+ currentChatState == "loading"
410
+ ) {
411
+ // If we're in streaming/loading state, it might be a stale state after stopping
412
+ // Force reset the state to input to allow new requests
413
+ updateChatStateAction ( frozenSessionId , "input" ) ;
414
+ updateCanContinue ( false , frozenSessionId ) ;
415
+ setUncaughtError ( frozenSessionId , null ) ;
416
+ setLoadingError ( frozenSessionId , null ) ;
417
+ resetRegenerationState ( frozenSessionId ) ;
402
418
} else {
403
419
setPopup ( {
404
420
message : "Please wait for the response to complete" ,
405
421
type : "error" ,
406
422
} ) ;
423
+ return ;
407
424
}
408
-
409
- return ;
410
425
}
411
426
412
427
clientScrollToBottom ( ) ;
0 commit comments