From 3a65e7700ce96922e7f6ea7cb36b7bb17e5c9cc5 Mon Sep 17 00:00:00 2001 From: Denys_Kolomiitsev <143205282+denys-kolomiitsev@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:32:13 +0100 Subject: [PATCH] fix(overlay): fix set recent models ids and model id in overlay mode (Issue #2794) (#2905) --- .../src/tests/overlay/modelIdFeature.test.ts | 15 ++------ apps/chat/src/store/overlay/overlay.epics.ts | 36 +++++++++++-------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/apps/chat-e2e/src/tests/overlay/modelIdFeature.test.ts b/apps/chat-e2e/src/tests/overlay/modelIdFeature.test.ts index 6f23785859..6f080e03d1 100644 --- a/apps/chat-e2e/src/tests/overlay/modelIdFeature.test.ts +++ b/apps/chat-e2e/src/tests/overlay/modelIdFeature.test.ts @@ -6,7 +6,6 @@ import { GeneratorUtil, ModelsUtil } from '@/src/utils'; import { expect } from '@playwright/test'; const expectedModelId = 'gpt-4'; -const fallbackModelId = 'gpt-35-turbo'; dialOverlayTest( `[Overlay] Defaults set in the code: modelID is used for new conversation.\n` + @@ -26,22 +25,12 @@ dialOverlayTest( overlayAgentInfoAssertion, talkToAgentDialogAssertion, setTestIds, - localStorageManager, }) => { setTestIds('EPMRTC-3781', 'EPMRTC-4693'); const randomAgentRequest = 'test'; - const recentModelIds = ModelsUtil.getRecentModelIds().filter( - (m) => m !== expectedModelId, + const randomModelId = GeneratorUtil.randomArrayElement( + ModelsUtil.getRecentModelIds().filter((m) => m !== expectedModelId), ); - if (!recentModelIds.length) { - // recentModelIds can be empty - await localStorageManager.setRecentModelsIds( - ModelsUtil.getModel(fallbackModelId)!, - ); - } - const randomModelId = recentModelIds.length - ? GeneratorUtil.randomArrayElement(recentModelIds) - : fallbackModelId; const randomModel = ModelsUtil.getOpenAIEntity(randomModelId)!; const expectedModel = ModelsUtil.getModel(expectedModelId)!; diff --git a/apps/chat/src/store/overlay/overlay.epics.ts b/apps/chat/src/store/overlay/overlay.epics.ts index 616f7d5273..53d078b6d2 100644 --- a/apps/chat/src/store/overlay/overlay.epics.ts +++ b/apps/chat/src/store/overlay/overlay.epics.ts @@ -415,21 +415,27 @@ const setOverlayOptionsEpic: AppEpic = (action$, state$) => } } - if (modelId) { - actions.push(of(ModelsActions.updateRecentModels({ modelId }))); + const shouldLogIn = AuthSelectors.selectIsShouldLogin(state$.value); - actions.push( - of( - SettingsActions.setOverlayDefaultModelId({ - overlayDefaultModelId: modelId, - }), - ), - ); - } - if (overlayConversationId) { - actions.push( - of(SettingsActions.setOverlayConversationId(overlayConversationId)), - ); + if (!shouldLogIn) { + if (modelId) { + actions.push(of(ModelsActions.updateRecentModels({ modelId }))); + + actions.push( + of( + SettingsActions.setOverlayDefaultModelId({ + overlayDefaultModelId: modelId, + }), + ), + ); + } + if (overlayConversationId) { + actions.push( + of( + SettingsActions.setOverlayConversationId(overlayConversationId), + ), + ); + } } // after all actions will send notify that settings are set @@ -439,7 +445,7 @@ const setOverlayOptionsEpic: AppEpic = (action$, state$) => ), of(OverlayActions.signInOptionsSet({ signInOptions })), iif( - () => !AuthSelectors.selectIsShouldLogin(state$.value), + () => !shouldLogIn, of(ConversationsActions.initSelectedConversations()), EMPTY, ),