server : (webui) introduce conversation branching + idb storage #11792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR:
dexie
librarylocalStorage
to IndexedDB upon running the first timeAuto-migration
Upon launching this new version, the auto migration will be triggered automatically. This will copy all conversations from
localStorage
to IndexedDB. Please note that:localStorage
migratedToIDB
will be stored inlocalStorage
to mark that the migration has already been done, preventing duplicated migrationHow it works
What is conversation "branching"? It is a feature that allows the user to edit an old message in the history, while still keeping the conversation flow.
Inspired by ChatGPT / Claude / Hugging Chat where you edit a message, a new branch of the conversation is created, and the old message is still visible.
We use the same node-based structure like other chat UIs, where each message has a parent and children. A "root" message is the first message in a conversation, which will not be displayed in the UI.
In the above example, assuming that user wants to edit message 2, a new branch will be created:
Message 2 and 6 are siblings, and message 6 is the new branch.
We only need to know the last node (aka leaf) to get the current branch. In the above example, message 5 is the leaf of branch containing message 4 and 5.
For the implementation: