diff --git a/apps/chat-e2e/src/testData/import/ai_dial_chat_history_1-9_version.json b/apps/chat-e2e/src/testData/import/ai_dial_chat_history_1-9_version.json index a14e3636c8..c9e0f42d5b 100644 --- a/apps/chat-e2e/src/testData/import/ai_dial_chat_history_1-9_version.json +++ b/apps/chat-e2e/src/testData/import/ai_dial_chat_history_1-9_version.json @@ -29,6 +29,18 @@ }, "selectedAddons": [], "assistantModelId": "" + }, + { + "id": "bc66971f-fd89-44db-8d3b-3efa893cc587", + "name": "New Conversation", + "messages": [], + "model": { + "id": "gpt-4", + "name": "GPT-4" + }, + "prompt": "", + "temperature": 1, + "folderId": null } ], "folders": [ diff --git a/apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts b/apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts index d4c0781d67..80b09768e5 100644 --- a/apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts +++ b/apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts @@ -24,7 +24,6 @@ dialTest( 'Create new conversation and send new message', async ({ dialHomePage, - header, conversations, talkToEntities, entitySettings, @@ -34,33 +33,14 @@ dialTest( addons, }) => { const expectedAddons = ModelsUtil.getAddons(); + const request = 'test request'; + await dialTest.step( - 'Create new conversation and verify it is moved under Today section in chat bar', + 'Verify the list of recent entities and default settings for default model', async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await header.createNewConversation(); - - const todayConversations = await conversations.getTodayConversations(); - expect - .soft( - todayConversations.length, - ExpectedMessages.newConversationCreated, - ) - .toBe(2); - for (const todayConversation of todayConversations) { - expect - .soft(todayConversation, ExpectedMessages.conversationOfToday) - .toEqual( - expect.stringContaining(ExpectedConstants.newConversationTitle), - ); - } - }, - ); - await dialTest.step( - 'Verify the list of recent entities and default settings for default model', - async () => { const expectedDefaultRecentEntities = []; for (const entity of recentModelIds) { expectedDefaultRecentEntities.push( @@ -110,7 +90,7 @@ dialTest( await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); - await chat.sendRequestWithKeyboard('test request'); + await chat.sendRequestWithKeyboard(request); const messagesCount = await chatMessages.chatMessages.getElementsCount(); expect @@ -118,5 +98,21 @@ dialTest( .toBe(2); }, ); + + await dialTest.step( + 'Verify new conversation is moved under Today section in chat bar', + async () => { + const todayConversations = await conversations.getTodayConversations(); + expect + .soft( + todayConversations.length, + ExpectedMessages.newConversationCreated, + ) + .toBe(1); + expect + .soft(todayConversations[0], ExpectedMessages.conversationOfToday) + .toBe(request); + }, + ); }, ); diff --git a/apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts b/apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts index 13156191e7..5b03b24076 100644 --- a/apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts +++ b/apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts @@ -33,12 +33,9 @@ dialTest( 'hidden', ); - const todayConversations = await conversations.getTodayConversations(); + const todayConversationsCount = await conversations.getEntitiesCount(); expect - .soft( - todayConversations.includes(conversationInFolder.conversations[0].name), - ExpectedMessages.conversationOfToday, - ) - .toBeFalsy(); + .soft(todayConversationsCount, ExpectedMessages.entitiesCountIsValid) + .toBe(0); }, ); diff --git a/apps/chat/src/store/conversations/conversations.reducers.ts b/apps/chat/src/store/conversations/conversations.reducers.ts index 905d28034a..b509c37ec7 100644 --- a/apps/chat/src/store/conversations/conversations.reducers.ts +++ b/apps/chat/src/store/conversations/conversations.reducers.ts @@ -216,9 +216,6 @@ export const conversationsSlice = createSlice({ }>, ) => { state.isActiveNewConversationRequest = true; - state.conversations = state.conversations.filter( - (conv) => !isEntityIdLocal(conv), - ); }, deleteConversations: ( state, @@ -350,9 +347,15 @@ export const conversationsSlice = createSlice({ suspendHideSidebar?: boolean; }>, ) => { + const hasNew = payload.conversations.some((conv) => + isEntityIdLocal(conv), + ); + const existedConversation = hasNew + ? state.conversations.filter((conv) => !isEntityIdLocal(conv)) + : state.conversations; state.conversations = combineEntities( payload.conversations, - state.conversations, + existedConversation, ); }, clearConversations: (state) => { diff --git a/apps/chat/src/store/models/models.reducers.ts b/apps/chat/src/store/models/models.reducers.ts index 34f2564b41..895ba426d4 100644 --- a/apps/chat/src/store/models/models.reducers.ts +++ b/apps/chat/src/store/models/models.reducers.ts @@ -278,7 +278,10 @@ export const modelsSlice = createSlice({ const rootSelector = (state: RootState): ModelsState => state.models; const selectModelsIsLoading = createSelector([rootSelector], (state) => { - return state.status === UploadStatus.LOADING; + return ( + state.status === UploadStatus.LOADING || + state.status === UploadStatus.UNINITIALIZED + ); }); const selectIsModelsLoaded = createSelector([rootSelector], (state) => {