Migrate Chat Persistence from localStorage to IndexedDB to Fix QuotaExceededError
I encountered a QuotaExceededError when I sent a new message, which was because. This occured because the chat state (managed via Zustand's persist middleware in stores/chat.ts) is stored in localStorage under the key 'supermemory-chats'. Since my chat history containing messages and tool outputs was large enough, I got this error.
Overall, this limits scalability of the current chat persistence users with extensive chat data and it can lead to loss of chat history if they delete the localStorage to make room for new chats.
To resolve this, I migrated the persistence layer from localStorage to IndexedDB, which offers significantly higher storage limits (as described in this stackexchange post) and it has better performance for larger datasets.
I refactored the code to use the lightweight idb-keyval library as an IndexedDB wrapper, which integrates directly with Zustand's createJSONStorage. This adapter also includes automatic migration logic to transfer any existing data from localStorage to IndexedDB on first access.
How to use the Graphite Merge Queue
Add the label Main to this PR to add it to the merge queue.
You must have a Graphite account in order to use the merge queue. Sign up using this link.
An organization admin has enabled the Graphite Merge Queue in this repository.
Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.
@MaheshtheDev should be fixed now!