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
🚀feat: Archive conversations #2590
🚀feat: Archive conversations #2590
Conversation
This commit adds a new mutation function `useArchiveConversationMutation()` for archiving conversations. This function takes the ID string of the conversation to be archived and returns a mutation result object. Upon successful archiving, it removes and refreshes the conversation from the query data cache. While ChatGPT PATCHes the archived status by sending `{is_archived: true}` to the URL `/backend-api/conversation/$conversation_id`, this implementation uses the `dataService.updateConversation(payload)` with a POST method, aligning with the existing code conventions.
…getConvosByPage method This commit adds a new field `is_archived` with a default value of false to the Conversation schema. It also modifies the `getConvosByPage` method within the Conversation API to adjust the query to only target conversations where `is_archived` is set to false or where the `is_archived` field does not exist. The function `getConvosQueried`, which returns conversations for a specified Conversation ID, was determined not to require consideration of whether `is_archived` is true or false, and thus was not modified.
To enhance the versatility of the DotsIcon component, this commit introduces the ability to specify a className prop, allowing for greater customization.
…lete buttons Added a new Edit Button to the conversations, similar to the ChatGPT UI, which groups options for editing the conversation title and deleting conversations. This grouping is accessible through a dialogue that appears when the three-dot icon is clicked.
…options Enhanced the Delete Button component to accept a `className` for customization and an optional `appendLabel`. The DeleteButton component is used by both `Convo.tsx` and `Conversation.tsx`, but currently only `Convo.tsx` is active and `Conversation.tsx `is apparently not used; removing `Conversation.tsx` may eliminate the need for the `appendLabel` property in the future.
Added the ability to optionally display labels; the Rename Button component is used by both `Convo.tsx` and `Conversation.tsx`, but currently only `Convo.tsx` is active and `Conversation.tsx `is apparently not used; removing `Conversation.tsx` may eliminate the need for the `appendLabel` property in the future.
* Refactor the is_archived property of conversation to camelCase (isArchived) to adhere to the existing code conventions * Modify the function that retrieves conversations to accept the isArchived parameter
I thought I could divert dataService.updateConversation, but added a new archiveConversation because the request types are different. It might be better to make them common, but to avoid side effects, I added a new function this time. Added process to deleteConversationMutation to delete archived conversations
…mponent The Cancel button is not needed when displaying the archive list, so I made the Cancel button optional.
…component This commit modifies the Nav component to add the ability to filter out archived conversations when fetching data. This is done by adding `isArchived: false` to the query parameters for both the `useConversationsInfiniteQuery()` and `useSearchInfiniteQuery()` hooks, effectively excluding any archived conversations from the results returned.
* Add Tooltip to DeleteButton component * Display Tooltip when DeleteButton only shows an Icon without text
To be compatible with the ChatGPT UI, no confirmation dialog is displayed when ArchiveButton is clicked. The basic behavior conforms to DeleteButton and RenameButton.
Modify the Nav of the conversation list to include a dropdown that contains the Rename and Delete options, similar to the ChatGPT UI. Additionally, an Archive button has been added adjacent to the dropdown menu.
Adds the `ArchivedChatsTable` component, which displays a table of archived chats. It has been implemented to be as compatible with the ChatGPT UI as possible.
Resolve an issue where tooltips were not visible when displayed over a Dialog. The z-index of `DialogPrimitive.Portal` in `Dialog.tsx` is set to 999. Since the rationale for this value is unclear, the z-index of the tooltip has been increased to 1000 to guarantee its visibility above the Dialog component.
Thanks so much for this, awesome job! Looks very clean and thank you for using existing infinite query and adding all the localizations. Played around with it a bit, I think this is a good way to introduce the feature, and then later improve it |
…archive-conversations
…archive-conversations
…archive-conversations
@ohneda When I get a chance, I will see if I can easily add time-to-live (TTL) expiry to the archived documents, while also allowing removing that expiry if unarchived, before merging or shortly after merging this. It would be helpful if you can look into this as well! See how I do this for files here: Lines 27 to 47 in 25fceb7
Removing: Lines 49 to 61 in 25fceb7
|
@danny-avila Yes, I think that's possible. Just to confirm, are you suggesting that archived conversations have a set expiration date, after which they cannot be accessed anymore? For example, if the expiration is set to one month, any conversation archived for one month would automatically be removed from the archive list, correct? |
Yup, they would be deleted but on second thought, maybe this isn't what's desired via archiving, after re-reading how it works for ChatGPT: https://help.openai.com/en/articles/8809935-how-chat-retention-works-in-chatgpt Scratch that thought, I just thought it would be a good way to introduce some simple retention. Don't worry about my earlier comment, I'll merge this after the conflicts are resolved, thanks for your work on this! |
…archive-conversations
…archive-conversations
* 🔧chore: add internationalization labels for archive feature * ✨ feat: Add function to useArchiveConversationMutation() This commit adds a new mutation function `useArchiveConversationMutation()` for archiving conversations. This function takes the ID string of the conversation to be archived and returns a mutation result object. Upon successful archiving, it removes and refreshes the conversation from the query data cache. While ChatGPT PATCHes the archived status by sending `{is_archived: true}` to the URL `/backend-api/conversation/$conversation_id`, this implementation uses the `dataService.updateConversation(payload)` with a POST method, aligning with the existing code conventions. * ✨ feat(api): add is_archived field to Conversation schema and update getConvosByPage method This commit adds a new field `is_archived` with a default value of false to the Conversation schema. It also modifies the `getConvosByPage` method within the Conversation API to adjust the query to only target conversations where `is_archived` is set to false or where the `is_archived` field does not exist. The function `getConvosQueried`, which returns conversations for a specified Conversation ID, was determined not to require consideration of whether `is_archived` is true or false, and thus was not modified. * ♻️ refactor: add className prop to DotsIcon component To enhance the versatility of the DotsIcon component, this commit introduces the ability to specify a className prop, allowing for greater customization. * ✨ feat(ui): add Edit Button to group Title change and Conversation delete buttons Added a new Edit Button to the conversations, similar to the ChatGPT UI, which groups options for editing the conversation title and deleting conversations. This grouping is accessible through a dialogue that appears when the three-dot icon is clicked. * ♻️ refactor(ui): enhance Delete Button to accept className and label options Enhanced the Delete Button component to accept a `className` for customization and an optional `appendLabel`. The DeleteButton component is used by both `Convo.tsx` and `Conversation.tsx`, but currently only `Convo.tsx` is active and `Conversation.tsx `is apparently not used; removing `Conversation.tsx` may eliminate the need for the `appendLabel` property in the future. * ♻️ refactor(ui): enhance RenameButton to accept label options Added the ability to optionally display labels; the Rename Button component is used by both `Convo.tsx` and `Conversation.tsx`, but currently only `Convo.tsx` is active and `Conversation.tsx `is apparently not used; removing `Conversation.tsx` may eliminate the need for the `appendLabel` property in the future. * 🔧 chors: additional localization labels * ♻️ refactor: change is_archived property of conversation to camelCase * Refactor the is_archived property of conversation to camelCase (isArchived) to adhere to the existing code conventions * Modify the function that retrieves conversations to accept the isArchived parameter * ♻️ refactor: add archiveConversation mutation I thought I could divert dataService.updateConversation, but added a new archiveConversation because the request types are different. It might be better to make them common, but to avoid side effects, I added a new function this time. Added process to deleteConversationMutation to delete archived conversations * ✨ feat: Add the function to hide a cancel button in DialogTemplate component The Cancel button is not needed when displaying the archive list, so I made the Cancel button optional. * ♻️ refactor: Add support for filtering archived conversations in Nav component This commit modifies the Nav component to add the ability to filter out archived conversations when fetching data. This is done by adding `isArchived: false` to the query parameters for both the `useConversationsInfiniteQuery()` and `useSearchInfiniteQuery()` hooks, effectively excluding any archived conversations from the results returned. * ♻️ refactor: add Tooltip to DeleteButton * Add Tooltip to DeleteButton component * Display Tooltip when DeleteButton only shows an Icon without text * ✨ feat(ui): add ArchiveButton component for archiving conversations To be compatible with the ChatGPT UI, no confirmation dialog is displayed when ArchiveButton is clicked. The basic behavior conforms to DeleteButton and RenameButton. * ✨ feat(ui): add Archive button to list of conversations Modify the Nav of the conversation list to include a dropdown that contains the Rename and Delete options, similar to the ChatGPT UI. Additionally, an Archive button has been added adjacent to the dropdown menu. * ✨ feat: Add ArchivedChatsTable component Adds the `ArchivedChatsTable` component, which displays a table of archived chats. It has been implemented to be as compatible with the ChatGPT UI as possible. * 🚑 fix(tooltip): increase z-index to ensure visibility over Dialog Resolve an issue where tooltips were not visible when displayed over a Dialog. The z-index of `DialogPrimitive.Portal` in `Dialog.tsx` is set to 999. Since the rationale for this value is unclear, the z-index of the tooltip has been increased to 1000 to guarantee its visibility above the Dialog component. * 🔧 chors: add internationalization labels
Summary
This Pull Request introduces an archiving feature for conversations, similar to the ChatGPT's archiving functionality.
Changes made:
Key modifications include:
archivedConversations
for archived conversations management.useUpdateConversationMutation
, but due to different post-request handling, I opted to createuseArchiveConversationMutation
.DialogPrimitive.Portal
being set to 999. Adjusted the tooltip’s z-index to 1000 to solve this issue. Please revert if the adjustment creates any discrepancies.Known Issue:
Change Type
Please delete any irrelevant options.
Testing
While I have not written unit tests for these changes, I have verified the following functionalities manually:
isArchived: true
property to the conversation document in mongodb.isArchived
property is absent, it defaults toisArchived: false
(ensuring backward compatibility).Checklist