-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding fixing save chat session overwriting #6457
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,41 @@ test.extend<ExpectedV2Events>({ | |
await expect(newHistoryItem).toBeVisible() | ||
await newHistoryItem.click() | ||
}) | ||
|
||
test.extend<ExpectedV2Events>({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
// 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() | ||
|
||
const deleteButton = sidebarChat.getByRole('button', { name: 'Delete chat' }) | ||
await expect(deleteButton).toBeVisible() | ||
await deleteButton.click() | ||
|
||
await expect(newHistoryItem).not.toBeVisible() | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked into the code yet but wonder if it would work if we dispose the chat before we deleting the chat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I could possibly write some kind of "number of times called" kind of test on chatcontroller but I would ideally love to have webview based UI test(see slack)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While disposing before deleting seems like a good approach to prevent race conditions, it doesn't fully solve the problem. Here's why:
The race condition still exists because:
disposeChat() triggers a save operation as part of its cleanup
Then we immediately try to delete the chat history
These operations can overlap since saves are asynchronous
That's why the current solution uses a skipSave flag:
This ensures we're not trying to save and delete the same chat data simultaneously. Simply changing the order of operations (dispose then delete) isn't enough to prevent the race condition.