-
Notifications
You must be signed in to change notification settings - Fork 209
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
Chat: Edit button to rename history chats #1818
Conversation
Thanks @philipp-spiess for adding the reviewers :) |
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 |
Thanks for the review, @kalanchan. |
@deepak2431 is it possible to add a test for the new change as well? 👀 |
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.
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?
vscode/package.json
Outdated
{ | ||
"command": "cody.chat.history.edit", | ||
"category": "Cody", | ||
"title": "Edit 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.
"title": "Edit Chat", | |
"title": "Rename Chat", |
vscode/package.json
Outdated
"category": "Cody", | ||
"title": "Edit Chat", | ||
"group": "Cody", | ||
"icon": "$(wand)", |
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.
"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 => { |
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.
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
?
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.
Yes, we can pass that @toolmantim. I will implement this.
@abeatrix Yeah, I think it would be possible to add tests. I will add one for this. |
@toolmantim Thanks for the review! I will take care of the changes you suggested.
This would be great to have. Yeah, it would be possible to display the Edit button there too.
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! |
@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. |
Some unexpected Git issues happened while resolving merge conflicts. Working to fix it! |
All good to review now! |
@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 :). |
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.
nice this is great thank you @deepak2431!! MVP!!
CleanShot.2023-11-21.at.15.37.24.2.mp4
@deepak2431 There should be one now in main :) |
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.
🙌🏼
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 Edit: Got it working now! |
@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? |
@deepak2431 Thanks! Will take a look at the test and let you know if i found anything suspicious! |
vscode/src/services/treeViewItems.ts
Outdated
@@ -57,6 +58,19 @@ export function createCodyChatTreeItems(userHistory: UserLocalHistory): CodySide | |||
return chatTreeItems.reverse() | |||
} | |||
|
|||
export async function updateChatHistoryLastInteractionMessage(chatID: string, message: string): Promise<void> { |
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.
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
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.
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 :)
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.
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.
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.
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?
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.
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?
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.
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:
- The history gets updated after each transcript response update, and so does the chats history, which undefine the value of chatTitle.
- When the response is aborted, the notifyTurnComplete function resets the title again to undefined.
- 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?
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.
@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.
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.
I guess this solution works fine with SimpleChatContext
enabled 👀
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 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?
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.
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 :)
@abeatrix @deepak2431 yeah, we wouldn't want to alter the chat transcript. A new property sounds right. |
@abeatrix Updated as per the discussion. It works all good now. I saw that the 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 :) |
@sourcegraph/cody-vscode I didn't get a chance to review this before my PTO, would appreciate some eyes on this to unblock 🙇♀️ |
@philipp-spiess Can you have a look at it please whenever you have some time? |
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.
LGTM! One comment inline; let me try to run the tests
vscode/src/chat/MessageProvider.ts
Outdated
@@ -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' |
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.
This looks like a strange default, should we use "Untitled" instead?
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.
yeah, agree with you. Let me make the change.
@philipp-spiess Thanks for the review. Just made the suggested changes. Do have a look :) |
@deepak2431 Awesome stuff as usual :) |
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