LibreChat icon indicating copy to clipboard operation
LibreChat copied to clipboard

🚀feat: Archive conversations

Open ohneda opened this issue 9 months ago • 1 comments

Summary

This Pull Request introduces an archiving feature for conversations, similar to the ChatGPT's archiving functionality.

SCR-20240430-rrej

Changes made:

  • Changed the "Rename" and "Delete" buttons to be in a dropdown menu.
  • Added an "Archive" button.
  • Added a new section, "Archived Chats," under Settings -> General, where users can manage archived conversations.
  • Archived conversations can be restored.
  • Did not include the “Archive all” feature available in ChatGPT. I may consider adding it based on feedback after this PR is merged.

Key modifications include:

  • Introduced a new query key archivedConversations for archived conversations management.
  • Originally planned to reuse useUpdateConversationMutation, but due to different post-request handling, I opted to create useArchiveConversationMutation.
  • Addressed a tooltip display issue:
    • Fixed a bug where tooltips were not displayed on Dialog du to the z-index of 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.
  • Internationalization:
    • Added the necessary keys and values for new features in multiple languages, mostly translated automatically by Copilot. I performed partial verifications using Google Translate but further validation might be needed.

Known Issue:

  • Including archived conversations in search results
    • The implementation details around excluding archived conversations from search results have not been examined yet, but it should be feasible to adjust this upon request.

Change Type

Please delete any irrelevant options.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update
  • [x] Translation update
  • [ ] Documentation update

Testing

While I have not written unit tests for these changes, I have verified the following functionalities manually:

  • An "Archive" button has been added to the conversation list in the navigation.
  • Clicking the "Archive" button archives the conversation and removes it from the conversation list.
  • The "Rename" and "Delete" buttons, now in a dropdown, function correctly.
  • Added a section titled "Archived Chats" under Settings -> General.
  • Clicking the "Manage" button under "Archived Chats" displays a list of archived conversations.
  • If there are no archived conversations, the message "You have no archived conversations." is displayed.
  • Initially displays the first 25 archived conversations.
  • More conversations are paginated in increments of 25 upon scrolling.
  • Each archived conversation in the list has an "Unarchive" and a "Delete" button on the right, with tooltips displayed on mouseover.
  • Clicking the "Unarchive" button removes the conversation from the archived list and adds it back to the conversation list.
  • Clicking the "Delete" button prompts a confirmation dialog before deletion.
  • Archiving a conversation adds an isArchived: true property to the conversation document in mongodb.
  • If the isArchived property is absent, it defaults to isArchived: false (ensuring backward compatibility).

Checklist

  • [x] My code adheres to this project's style guidelines
  • [x] I have performed a self-review of my own code
  • [ ] I have commented in any complex areas of my code
  • [ ] I have made pertinent documentation changes
  • [x] My changes do not introduce new warnings
  • [ ] I have written tests demonstrating that my changes are effective or that my feature works
  • [x] Local unit tests pass with my changes
  • [ ] Any changes dependent on mine have been merged and published in downstream modules.
  • [ ] New documents have been locally validated with mkdocs

ohneda avatar May 01 '24 03:05 ohneda

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

danny-avila avatar May 01 '24 05:05 danny-avila

@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: Adding: https://github.com/danny-avila/LibreChat/blob/25fceb78b7a90f91e88b643656600ef7fefa8dd0/api/models/File.js#L27-L47

Removing:

https://github.com/danny-avila/LibreChat/blob/25fceb78b7a90f91e88b643656600ef7fefa8dd0/api/models/File.js#L49-L61

danny-avila avatar May 05 '24 15:05 danny-avila

@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?

ohneda avatar May 06 '24 03:05 ohneda

@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!

danny-avila avatar May 06 '24 03:05 danny-avila