khoj-ai / khoj

Your AI second brain. Get answers to your questions, whether they be online or in your own notes. Use online AI models (e.g gpt4) or private, local LLMs (e.g llama3). Self-host locally or use our cloud instance. Access from Obsidian, Emacs, Desktop app, Web or Whatsapp.
https://khoj.dev
GNU Affero General Public License v3.0
12.63k stars 640 forks source link

Do not create new chat session when an old chat session is deleted #669

Closed debanjum closed 6 months ago

debanjum commented 6 months ago

Issue

Previously deleting a chat session from the side panel on desktop, web app would sometimes result in also creating a new chat session

Fix

get_conversation_by_user shouldn't return new conversation if conversation with requested id not found.

It should only return new conversation if no specific conversation is requested and no conversations found for user at all

Miscellaneous Improvements

Repro

sabaimran commented 6 months ago

I took a second look at the code. The method aget_conversation_by_user, which is in the hot path for the /chat/ endpoint hasn't been updated. For that one, it'll still create a new conversation if/when the conversation_id doesn't come back with a match.

debanjum commented 6 months ago

I took a second look at the code. The method aget_conversation_by_user, which is in the hot path for the /chat/ endpoint hasn't been updated. For that one, it'll still create a new conversation if/when the conversation_id doesn't come back with a match.

Great catch! Fixed in #677