From fcc1c2d5b63c34e5c15887f79ebbbf03c85a3d8b Mon Sep 17 00:00:00 2001 From: arafatkatze Date: Tue, 24 Dec 2024 23:49:22 +0400 Subject: [PATCH 1/3] Adding fixing save chat session overwriting --- vscode/src/chat/chat-view/ChatsController.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vscode/src/chat/chat-view/ChatsController.ts b/vscode/src/chat/chat-view/ChatsController.ts index d3b6c849f312..e3a346dc9a74 100644 --- a/vscode/src/chat/chat-view/ChatsController.ts +++ b/vscode/src/chat/chat-view/ChatsController.ts @@ -446,8 +446,10 @@ export class ChatsController implements vscode.Disposable { return } + // For single chat deletion await chatHistory.deleteChat(authStatus, chatID) - this.disposeChat(chatID, true) + // Don't save the session when disposing after delete + this.disposeChat(chatID, true, { skipSave: true }) } /** @@ -535,7 +537,11 @@ export class ChatsController implements vscode.Disposable { }) } - private disposeChat(chatID: string, includePanel: boolean): void { + private disposeChat( + chatID: string, + includePanel: boolean, + options: { skipSave?: boolean } = {} + ): void { if (chatID === this.activeEditor?.sessionID) { this.activeEditor = undefined } @@ -549,7 +555,7 @@ export class ChatsController implements vscode.Disposable { removedProvider.dispose() } - if (includePanel && chatID === this.panel?.sessionID) { + if (includePanel && chatID === this.panel?.sessionID && !options.skipSave) { this.panel.clearAndRestartSession() } } From 2fb48f061a98fb7dd276ba51d916446945fbf3b8 Mon Sep 17 00:00:00 2001 From: arafatkatze Date: Fri, 27 Dec 2024 21:23:16 +0400 Subject: [PATCH 2/3] adding test --- vscode/test/e2e/chat-history.test.ts | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/vscode/test/e2e/chat-history.test.ts b/vscode/test/e2e/chat-history.test.ts index 8ba6a4b4090a..a9eb27c5d0e7 100644 --- a/vscode/test/e2e/chat-history.test.ts +++ b/vscode/test/e2e/chat-history.test.ts @@ -34,3 +34,42 @@ test.extend({ await expect(newHistoryItem).toBeVisible() await newHistoryItem.click() }) + +test.extend({ + // list of events we expect this test to log, add to this list as needed + expectedV2Events: [ + 'cody.extension:installed', + 'cody.auth.login:clicked', + 'cody.auth.login:firstEver', + 'cody.auth.login.token:clicked', + 'cody.auth:connected', + 'cody.chat-question:submitted', + 'cody.chat-question:executed', + 'cody.chatResponse:noCode', + ], +})('delete chat from sidebar history view', async ({ page, sidebar }) => { + await sidebarSignin(page, sidebar) + + const sidebarChat = getChatSidebarPanel(page) + + const sidebarTabHistoryButton = sidebarChat.getByTestId('tab-history') + + // Ensure the chat view is ready before we start typing + await expect(sidebarTabHistoryButton).toBeVisible() + + const chatInput = getChatInputs(sidebarChat).first() + await chatInput.fill('Hey') + await chatInput.press('Enter') + + await sidebarTabHistoryButton.click() + + const newHistoryItem = sidebarChat.getByRole('button', { name: 'Hey' }) + await expect(newHistoryItem).toBeVisible() + await newHistoryItem.click() + + const deleteButton = sidebarChat.getByRole('button', { name: 'Delete chat' }) + await expect(deleteButton).toBeVisible() + await deleteButton.click() + + await expect(newHistoryItem).not.toBeVisible() +}) From 7205eb73714404e0e3db8d2118a679ee4f003b57 Mon Sep 17 00:00:00 2001 From: arafatkatze Date: Fri, 27 Dec 2024 22:23:02 +0400 Subject: [PATCH 3/3] adding test --- vscode/test/e2e/chat-history.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/vscode/test/e2e/chat-history.test.ts b/vscode/test/e2e/chat-history.test.ts index a9eb27c5d0e7..324ff37aaef8 100644 --- a/vscode/test/e2e/chat-history.test.ts +++ b/vscode/test/e2e/chat-history.test.ts @@ -65,7 +65,6 @@ test.extend({ const newHistoryItem = sidebarChat.getByRole('button', { name: 'Hey' }) await expect(newHistoryItem).toBeVisible() - await newHistoryItem.click() const deleteButton = sidebarChat.getByRole('button', { name: 'Delete chat' }) await expect(deleteButton).toBeVisible()