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

Allow users to delete their chat histories #252

Merged
merged 8 commits into from
May 26, 2024

Conversation

milaiwi
Copy link
Contributor

@milaiwi milaiwi commented May 14, 2024

Right now there is no way to delete chat histories. The following PR allows users to:

  • Permanently remove a chat in their history
  • If they are currently viewing the chat and delete it, then setViewChat to false.
  • If they are viewing a chat and delete another chat, then continue viewing the current.

Closes #245

mohamedilaiwi and others added 7 commits May 12, 2024 17:36
…debar

electron/main/storeHandlers: Added remove-chat-history ipcHandler
src/components/ChatsSidebar: Added useEffect to updateAllChatHistories

src/components/FileEditorContainer: Passed setShowChatbot to SidebarManager so we can hide chat only if we're viewing it and choose to delete it.

src/components/MainSidebar: Passed setShowChatbot to ChatsSidebar
Copy link
Collaborator

@samlhuillier samlhuillier left a comment

Choose a reason for hiding this comment

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

Looks mostly good. Added 3 comments. Also, noticing weird bugs with the ordering changing when I toggle between the file sidebar and the chat sidebar. Is that something you've seen? Do you think it was introduced in this PR?

@@ -198,6 +198,38 @@ export const registerStoreHandlers = (
const vaultChatHistories = allChatHistories[vaultDir] || [];
return vaultChatHistories.find((chat) => chat.id === chatId);
});

ipcMain.handle("update-all-chat-history", (event, chatID: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we no longer use this handler. Perhaps remove it?

@@ -289,6 +294,9 @@ contextBridge.exposeInMainWorld("electronStore", {
updateChatHistory: (chatHistory: ChatHistory) => {
ipcRenderer.invoke("update-chat-history", chatHistory);
},
updateAllChatHistories: (chatID: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that this calls the remove handler, perhaps it should be called removeChatHistory?

if (chatID === currentSelectedChatID.current) {
setShowChatbot(false);
}
window.electronStore.updateAllChatHistories(chatID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit but we should probably update the store first and then update the renderer process' record of the chat metadata

@samlhuillier samlhuillier merged commit d680414 into reorproject:main May 26, 2024
0 of 4 checks passed
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.

[Feature Request]Delete chats
3 participants