File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 603603 } else if (type === ' chat:active' ) {
604604 if (! data ?.active ) {
605605 taskIds = null ;
606+ if (chatIdProp && ! $temporaryChatEnabled && hasPendingAssistantLeaf ()) {
607+ await loadChat ();
608+ }
606609 }
607610 } else if (type === ' chat:completion' ) {
608611 chatCompletionEventHandler (data , message , event .chat_id );
866869 } catch {}
867870 };
868871
872+ const hasPendingAssistantLeaf = () =>
873+ Object .values (history .messages ).some (
874+ (message ) =>
875+ message ?.role === ' assistant' && ! message .done && (message .childrenIds ?.length ?? 0 ) === 0
876+ );
877+
869878 const handleSocketConnect = async () => {
870879 if (! chatIdProp || $temporaryChatEnabled ) {
871880 return ;
872881 }
873882
874- const currentMessage = history .currentId ? history .messages [history .currentId ] : null ;
875- if (currentMessage ?.role !== ' assistant' || currentMessage .done ) {
883+ if (! hasPendingAssistantLeaf ()) {
876884 return ;
877885 }
878886
You can’t perform that action at this time.
0 commit comments