Perplexica icon indicating copy to clipboard operation
Perplexica copied to clipboard

Use userSessionId for chat history

Open sjiampojamarn opened this issue 7 months ago • 0 comments

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 the userSessionId.
  • 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
  • In the backend, chats API picks up the userSessionId and queries DB only for chats belonging to userSessionId.

sjiampojamarn avatar Jul 14 '24 03:07 sjiampojamarn