Skip to content

Commit 55ec50e

Browse files
fix(chat): fix blinking on click "New conversation" (Issue #2676) (#2677)
Co-authored-by: Irina_Kartun <[email protected]>
1 parent 7a0ac6d commit 55ec50e

File tree

5 files changed

+46
-35
lines changed

5 files changed

+46
-35
lines changed

apps/chat-e2e/src/testData/import/ai_dial_chat_history_1-9_version.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
},
3030
"selectedAddons": [],
3131
"assistantModelId": ""
32+
},
33+
{
34+
"id": "bc66971f-fd89-44db-8d3b-3efa893cc587",
35+
"name": "New Conversation",
36+
"messages": [],
37+
"model": {
38+
"id": "gpt-4",
39+
"name": "GPT-4"
40+
},
41+
"prompt": "",
42+
"temperature": 1,
43+
"folderId": null
3244
}
3345
],
3446
"folders": [

apps/chat-e2e/src/tests/monitoring/createNewConversation.test.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dialTest(
2424
'Create new conversation and send new message',
2525
async ({
2626
dialHomePage,
27-
header,
2827
conversations,
2928
talkToEntities,
3029
entitySettings,
@@ -34,33 +33,14 @@ dialTest(
3433
addons,
3534
}) => {
3635
const expectedAddons = ModelsUtil.getAddons();
36+
const request = 'test request';
37+
3738
await dialTest.step(
38-
'Create new conversation and verify it is moved under Today section in chat bar',
39+
'Verify the list of recent entities and default settings for default model',
3940
async () => {
4041
await dialHomePage.openHomePage();
4142
await dialHomePage.waitForPageLoaded();
42-
await header.createNewConversation();
43-
44-
const todayConversations = await conversations.getTodayConversations();
45-
expect
46-
.soft(
47-
todayConversations.length,
48-
ExpectedMessages.newConversationCreated,
49-
)
50-
.toBe(2);
51-
for (const todayConversation of todayConversations) {
52-
expect
53-
.soft(todayConversation, ExpectedMessages.conversationOfToday)
54-
.toEqual(
55-
expect.stringContaining(ExpectedConstants.newConversationTitle),
56-
);
57-
}
58-
},
59-
);
6043

61-
await dialTest.step(
62-
'Verify the list of recent entities and default settings for default model',
63-
async () => {
6444
const expectedDefaultRecentEntities = [];
6545
for (const entity of recentModelIds) {
6646
expectedDefaultRecentEntities.push(
@@ -110,13 +90,29 @@ dialTest(
11090
await dialHomePage.mockChatTextResponse(
11191
MockedChatApiResponseBodies.simpleTextBody,
11292
);
113-
await chat.sendRequestWithKeyboard('test request');
93+
await chat.sendRequestWithKeyboard(request);
11494
const messagesCount =
11595
await chatMessages.chatMessages.getElementsCount();
11696
expect
11797
.soft(messagesCount, ExpectedMessages.messageCountIsCorrect)
11898
.toBe(2);
11999
},
120100
);
101+
102+
await dialTest.step(
103+
'Verify new conversation is moved under Today section in chat bar',
104+
async () => {
105+
const todayConversations = await conversations.getTodayConversations();
106+
expect
107+
.soft(
108+
todayConversations.length,
109+
ExpectedMessages.newConversationCreated,
110+
)
111+
.toBe(1);
112+
expect
113+
.soft(todayConversations[0], ExpectedMessages.conversationOfToday)
114+
.toBe(request);
115+
},
116+
);
121117
},
122118
);

apps/chat-e2e/src/tests/monitoring/deleteFolderWithConversations.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ dialTest(
3333
'hidden',
3434
);
3535

36-
const todayConversations = await conversations.getTodayConversations();
36+
const todayConversationsCount = await conversations.getEntitiesCount();
3737
expect
38-
.soft(
39-
todayConversations.includes(conversationInFolder.conversations[0].name),
40-
ExpectedMessages.conversationOfToday,
41-
)
42-
.toBeFalsy();
38+
.soft(todayConversationsCount, ExpectedMessages.entitiesCountIsValid)
39+
.toBe(0);
4340
},
4441
);

apps/chat/src/store/conversations/conversations.reducers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ export const conversationsSlice = createSlice({
216216
}>,
217217
) => {
218218
state.isActiveNewConversationRequest = true;
219-
state.conversations = state.conversations.filter(
220-
(conv) => !isEntityIdLocal(conv),
221-
);
222219
},
223220
deleteConversations: (
224221
state,
@@ -350,9 +347,15 @@ export const conversationsSlice = createSlice({
350347
suspendHideSidebar?: boolean;
351348
}>,
352349
) => {
350+
const hasNew = payload.conversations.some((conv) =>
351+
isEntityIdLocal(conv),
352+
);
353+
const existedConversation = hasNew
354+
? state.conversations.filter((conv) => !isEntityIdLocal(conv))
355+
: state.conversations;
353356
state.conversations = combineEntities(
354357
payload.conversations,
355-
state.conversations,
358+
existedConversation,
356359
);
357360
},
358361
clearConversations: (state) => {

apps/chat/src/store/models/models.reducers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ export const modelsSlice = createSlice({
278278
const rootSelector = (state: RootState): ModelsState => state.models;
279279

280280
const selectModelsIsLoading = createSelector([rootSelector], (state) => {
281-
return state.status === UploadStatus.LOADING;
281+
return (
282+
state.status === UploadStatus.LOADING ||
283+
state.status === UploadStatus.UNINITIALIZED
284+
);
282285
});
283286

284287
const selectIsModelsLoaded = createSelector([rootSelector], (state) => {

0 commit comments

Comments
 (0)