From b587b98acdb8c8d6919ca0c1ed6a24e1f57e0a86 Mon Sep 17 00:00:00 2001 From: Pavan-Microsoft Date: Fri, 25 Oct 2024 13:58:34 +0530 Subject: [PATCH] fix: Fix for Chat history thread title is saved with space (#1436) Co-authored-by: Pavan Kumar --- code/backend/api/chat_history.py | 9 ++++++--- code/frontend/src/pages/chat/ChatHistoryListItem.tsx | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/backend/api/chat_history.py b/code/backend/api/chat_history.py index a0a67f82d..2aba1a8a4 100644 --- a/code/backend/api/chat_history.py +++ b/code/backend/api/chat_history.py @@ -143,8 +143,8 @@ async def rename_conversation(): # update the title title = request_json.get("title", None) - if not title: - return (jsonify({"error": "title is required"}), 400) + if not title or title.strip() == "": + return jsonify({"error": "title is required"}), 400 conversation["title"] = title updated_conversation = await cosmos_conversation_client.upsert_conversation( conversation @@ -321,7 +321,10 @@ async def delete_all_conversations(): except Exception as e: logger.exception("Exception in /delete" + str(e)) - return (jsonify({"error": "Error while deleting all history conversation"}), 500) + return ( + jsonify({"error": "Error while deleting all history conversation"}), + 500, + ) @bp_chat_history_response.route("/history/update", methods=["POST"]) diff --git a/code/frontend/src/pages/chat/ChatHistoryListItem.tsx b/code/frontend/src/pages/chat/ChatHistoryListItem.tsx index 9f1af7ca1..253231d4e 100644 --- a/code/frontend/src/pages/chat/ChatHistoryListItem.tsx +++ b/code/frontend/src/pages/chat/ChatHistoryListItem.tsx @@ -126,7 +126,7 @@ export const ChatHistoryListItemCell: React.FC< const handleSaveEdit = async (e: any) => { e.preventDefault(); - if (errorRename || renameLoading) { + if (errorRename || renameLoading || _.trim(editTitle) === "") { return; } @@ -219,7 +219,7 @@ export const ChatHistoryListItemCell: React.FC< disabled={errorRename ? true : false} /> - {editTitle && ( + {_.trim(editTitle) && (