Skip to content
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

Chat: Edit button to rename history chats #1818

Merged
merged 22 commits into from
Dec 11, 2023
Merged

Chat: Edit button to rename history chats #1818

merged 22 commits into from
Dec 11, 2023

Conversation

deepak2431
Copy link
Contributor

@deepak2431 deepak2431 commented Nov 19, 2023

This PR closes #1763.

An edit button has been added to rename the chat from the history tree view.

Test plan

REC-20231120164044.mp4
REC-20231120164313.mp4

@philipp-spiess philipp-spiess requested a review from a team November 20, 2023 11:19
@deepak2431 deepak2431 marked this pull request as ready for review November 20, 2023 11:19
@deepak2431
Copy link
Contributor Author

Thanks @philipp-spiess for adding the reviewers :)
Mentioning @abeatrix @kalanchan too to take a look.

@kalanchan
Copy link
Contributor

the renaming on the side bar looks thank you!

@deepak2431 could you also propagate the name change to the Cody chat panel as well?

CleanShot.2023-11-20.at.10.13.41.mp4

@deepak2431
Copy link
Contributor Author

Thanks for the review, @kalanchan.
Sure, I will make those changes.

@abeatrix
Copy link
Contributor

@deepak2431 is it possible to add a test for the new change as well? 👀

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @deepak2431, this is a good idea! Left some comments on labels and icons.

Non-blocking q's:

  • Is it possible to add the "Rename Chat" action to the right click context menu on the chat tab too? So you can do it from the chat view, or from the treeview.
  • Does the treeview provider allow you to rename it directly in the treeview, same as renaming files?

{
"command": "cody.chat.history.edit",
"category": "Cody",
"title": "Edit Chat",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": "Edit Chat",
"title": "Rename Chat",

"category": "Cody",
"title": "Edit Chat",
"group": "Cody",
"icon": "$(wand)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"icon": "$(wand)",
"icon": "$(edit)",

@@ -165,6 +165,15 @@ export class ChatPanelsManager implements vscode.Disposable {
}
}

public async editChatHistory(chatID: string): Promise<void> {
await vscode.window.showInputBox({ prompt: 'Enter new chat history name' }).then(async message => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await vscode.window.showInputBox({ prompt: 'Enter new chat history name' }).then(async message => {
await vscode.window.showInputBox({ prompt: 'Enter new chat name' }).then(async message => {

Could we also pass in the current title as value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can pass that @toolmantim. I will implement this.

@deepak2431
Copy link
Contributor Author

@deepak2431 is it possible to add a test for the new change as well? 👀

@abeatrix Yeah, I think it would be possible to add tests. I will add one for this.

@deepak2431
Copy link
Contributor Author

@toolmantim Thanks for the review! I will take care of the changes you suggested.

Is it possible to add the "Rename Chat" action to the right-click context menu on the chat tab too? So you can do it from the chat view or the treeview.

This would be great to have. Yeah, it would be possible to display the Edit button there too.

Does the treeview provider allow you to rename it directly in the treeview, same as renaming files?

Based on my findings, I couldn't see in the docs that Treeview provider allows to directly rename the rendered tree data view title. But I think there might be some other workaround to do this using WebView may be. Would ask @abeatrix to add her views on this too!

@abeatrix
Copy link
Contributor

@deepak2431 i think you're right, from what I've gathered that's currently not supported.

There is also a GitHub issue opened for this feature request.

@deepak2431
Copy link
Contributor Author

Some unexpected Git issues happened while resolving merge conflicts. Working to fix it!

@deepak2431
Copy link
Contributor Author

All good to review now!
@toolmantim Made the minor changes you suggested.
@kalanchan The edit changes are now propagated to the Chat Panel.

@deepak2431
Copy link
Contributor Author

@deepak2431 is it possible to add a test for the new change as well? 👀

@abeatrix Yeah, I think it would be possible to add tests. I will add one for this.

@abeatrix I can see that currently, there's no test suite for the new ChatPanel provider where I could add the test for this change. So, I'm not sure about adding one :).
Let me know if I am missing anything!

Copy link
Contributor

@kalanchan kalanchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice this is great thank you @deepak2431!! MVP!!

CleanShot.2023-11-21.at.15.37.24.2.mp4

@abeatrix
Copy link
Contributor

@deepak2431 There should be one now in main :)

Copy link
Contributor

@toolmantim toolmantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌🏼

@deepak2431
Copy link
Contributor Author

deepak2431 commented Nov 22, 2023

@deepak2431 There should be one now in main :)

Yes, I can see that now. It's been a while since I wrote e2e test, so I just wanted to ask after you run pnpm test:e2e --debug. After that, how do you start the record? I am trying to record it, but the selectors don't appear when I am in the Chat or try to sign in using the server URL and token manually.
It would be great if you could share any docs I can reference or a short loom :)

Edit: Got it working now!

@deepak2431
Copy link
Contributor Author

@abeatrix I have added the test, but it's getting stuck while filling the input box. I checked it a few times but couldn't see what's wrong there. Can you please have a look?

@abeatrix
Copy link
Contributor

@deepak2431 Thanks! Will take a look at the test and let you know if i found anything suspicious!

@@ -57,6 +58,19 @@ export function createCodyChatTreeItems(userHistory: UserLocalHistory): CodySide
return chatTreeItems.reverse()
}

export async function updateChatHistoryLastInteractionMessage(chatID: string, message: string): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this is the expected behavior where renaming the conversation would change the actual chat history. I believe this should work as the rename feature in chat GPT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong here, but as we are using the last interaction human message as a treeview history label, we are just updating that here, nothing to the assistant response. So, that's what I thought of as a solution to this.

Another solution I tried was to store the history treeview in the localStorage and then make the update or render the view accordingly. Still, in that case, I thought it was like repeating the same thing we are doing with the chatHistory, so I switched to this solution.

Let me know WDYT. If there's any other solution which we can use here, I am open to hearing about it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see the issue here as when the conversation is clicked to view again, the last interaction message is also updated to the updated title.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more solution I can think of is that instead of updating the chat history, we can keep a map of <chatID, updatedTitle> in the local history, and when we are creating the codyTreeItems or rendering the Chat panel, just check here first, if it is defined then use the updated title else use the last human message. WDYT @abeatrix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm instead of storing them separately, what do you think about adding a new title field (maybe optional?) for Transcript / TranscriptJSON so we can store everything together?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tok

So, I tried this today to use an optional field under TransScript JSON, but there are a few issues I am seeing while implementing this solution:

  1. The history gets updated after each transcript response update, and so does the chats history, which undefine the value of chatTitle.
  2. When the response is aborted, the notifyTurnComplete function resets the title again to undefined.
  3. During session restore, we create a new session ID in that case again chat title is reset to undefined.

Sorry for all the back and forth 😢

I took a look at the PR and I think the issues you mentioned above is due to the old chat history setup, so you shouldn't run into the same issue with the new ChatHistoryManager. With that, we should be able to set the optional chatTitle per Transcript (like chatModel in Transcript) and have everything in one place! Does that sound good to you? Or do you think storing them separately is more ideal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abeatrix No problem. This PR took longer than expected, I think, due to a different history setup and chat manager :)
So, I saw the new ChatHistoryManager. But using that still makes it undefined, and I am a bit unsure how this new SimpleChatPanelProvider replaces the old one. It would be great if you could brief me about it.

For you to have a look, I have updated this PR with the implemented solution of using chatTitle with the Transcript. And I agree this is a good way to do it, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this solution works fine with SimpleChatContext enabled 👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I saw the new ChatHistoryManager. But using that still makes it undefined, and I am a bit unsure how this new SimpleChatPanelProvider replaces the old one. It would be great if you could brief me about it.

Awesome! It's looking good! And yea sorry for all the massive changes, I also find it confusing 😅 But ultimately we str aiming to retire the current chatPanelProvider and move to SimpleChatPanelProvider. Instead of adding a separate function to handle chat title in history manager, I was thinking of storing it in Transcript. Here is an example of what i've envisioned: #1997 --the change in my PR doesn't work correctly as renaming the chat would generate a new chat history item because of how we are still using the old way to fetch and store history, but I hope this gives you an idea on how to get it to work with the new chat history manager and SimpleChatPanelProvider! What do you think about this approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look, @abeatrix. I looked over your referenced draft PR, and I got it now that, what was your suggested direction for the solution when you mentioned saving everything at once with the Transcript. This is a good approach, and it can help later too if we need to extend the Chat History Title somewhere. For example, in #1692, it would be helpful.

I will update this PR soon by making those changes :)

@toolmantim
Copy link
Contributor

@abeatrix @deepak2431 yeah, we wouldn't want to alter the chat transcript. A new property sounds right.

@deepak2431
Copy link
Contributor Author

@abeatrix I am waiting for this #2059 to merge so I can update my changes according to the updated History Manager.

Also, some build errors are happening in the main branch. Can you look into that, please?
iScreen Shoter - Code - 231204232413
iScreen Shoter - Code - 231204232400

@deepak2431
Copy link
Contributor Author

deepak2431 commented Dec 5, 2023

@abeatrix Updated as per the discussion. It works all good now. I saw that the new history ui test had been disabled for some reason, so I didn't update that for now.

Also, I saw some issues unrelated to this PR, such as how the chatID is being created for new chat in the Treeview and when the chat is revived from the History. So, I would ask you to look in your free time. You might also get a sense of it while reviewing this PR :)

@abeatrix
Copy link
Contributor

abeatrix commented Dec 7, 2023

@sourcegraph/cody-vscode I didn't get a chance to review this before my PTO, would appreciate some eyes on this to unblock 🙇‍♀️

@deepak2431
Copy link
Contributor Author

@philipp-spiess Can you have a look at it please whenever you have some time?

Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One comment inline; let me try to run the tests

@@ -100,6 +100,7 @@ export abstract class MessageProvider extends MessageHandler implements vscode.D
protected platform: Pick<PlatformContext, 'recipes'>

protected chatModel: string | undefined = undefined
protected chatTitle: string | undefined = 'init'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a strange default, should we use "Untitled" instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, agree with you. Let me make the change.

@deepak2431
Copy link
Contributor Author

@philipp-spiess Thanks for the review. Just made the suggested changes. Do have a look :)

@philipp-spiess philipp-spiess merged commit f22d229 into sourcegraph:main Dec 11, 2023
24 of 26 checks passed
@philipp-spiess
Copy link
Contributor

@deepak2431 Awesome stuff as usual :)

@deepak2431 deepak2431 deleted the deepak/rename-chat branch December 11, 2023 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Users can rename chats
5 participants