Perplexica
Perplexica copied to clipboard
Use userSessionId for chat history
Currently, all chat history (library) is global for all users. This PR separates them with userSessionId
so the history (library) appears within the user sessions.
High-level logics:
- Add a new column
userSessionId
in the chats table to indicate the chat owner. - In the UI, ChatWindows,
userSessionId
is created or looked up from the localstroage.- Send
userSessionId
to the WebSocket so that the chat record is created along with theuserSessionId
.
- Send
- In the UI, Library page,
userSessionId
is created or looked up from the localstroage.- Send
userSessionId
to api/chats in the header to get the chat history
- Send
- In the backend, chats API picks up the
userSessionId
and queries DB only for chats belonging touserSessionId
.