From f431c8fb0043a06826343181ce97eb2df3fff1c1 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 23 Feb 2024 12:14:58 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20fix:=20Correct=20Expected=20Beha?= =?UTF-8?q?vior=20for=20Modular=20Chat=20Feature=20(#1871)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chat/Menus/Endpoints/MenuItem.tsx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/client/src/components/Chat/Menus/Endpoints/MenuItem.tsx b/client/src/components/Chat/Menus/Endpoints/MenuItem.tsx index ed8d59597c..33775a9b23 100644 --- a/client/src/components/Chat/Menus/Endpoints/MenuItem.tsx +++ b/client/src/components/Chat/Menus/Endpoints/MenuItem.tsx @@ -65,16 +65,18 @@ const MenuItem: FC = ({ getEndpointField(endpointsConfig, currentEndpoint, 'type') ?? currentEndpoint; const newEndpointType = getEndpointField(endpointsConfig, newEndpoint, 'type') ?? newEndpoint; - if ( - isExistingConversation && - (modularEndpoints.has(endpoint ?? '') || - modularEndpoints.has(currentEndpointType ?? '') || - isAssistantSwitch) && - (modularEndpoints.has(newEndpoint ?? '') || - modularEndpoints.has(newEndpointType ?? '') || - isAssistantSwitch) && - (endpoint === newEndpoint || modularChat || isAssistantSwitch) - ) { + const hasEndpoint = modularEndpoints.has(currentEndpoint ?? ''); + const hasCurrentEndpointType = modularEndpoints.has(currentEndpointType ?? ''); + const isCurrentModular = hasEndpoint || hasCurrentEndpointType || isAssistantSwitch; + + const hasNewEndpoint = modularEndpoints.has(newEndpoint ?? ''); + const hasNewEndpointType = modularEndpoints.has(newEndpointType ?? ''); + const isNewModular = hasNewEndpoint || hasNewEndpointType || isAssistantSwitch; + + const endpointsMatch = currentEndpoint === newEndpoint; + const shouldSwitch = endpointsMatch || modularChat || isAssistantSwitch; + + if (isExistingConversation && isCurrentModular && isNewModular && shouldSwitch) { template.endpointType = newEndpointType; const currentConvo = getDefaultConversation({