Skip to content

Commit b587b98

Browse files
fix: Fix for Chat history thread title is saved with space (#1436)
Co-authored-by: Pavan Kumar <v-kupavan.microsoft.com>
1 parent a9997b0 commit b587b98

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

code/backend/api/chat_history.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ async def rename_conversation():
143143

144144
# update the title
145145
title = request_json.get("title", None)
146-
if not title:
147-
return (jsonify({"error": "title is required"}), 400)
146+
if not title or title.strip() == "":
147+
return jsonify({"error": "title is required"}), 400
148148
conversation["title"] = title
149149
updated_conversation = await cosmos_conversation_client.upsert_conversation(
150150
conversation
@@ -321,7 +321,10 @@ async def delete_all_conversations():
321321

322322
except Exception as e:
323323
logger.exception("Exception in /delete" + str(e))
324-
return (jsonify({"error": "Error while deleting all history conversation"}), 500)
324+
return (
325+
jsonify({"error": "Error while deleting all history conversation"}),
326+
500,
327+
)
325328

326329

327330
@bp_chat_history_response.route("/history/update", methods=["POST"])

code/frontend/src/pages/chat/ChatHistoryListItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export const ChatHistoryListItemCell: React.FC<
126126

127127
const handleSaveEdit = async (e: any) => {
128128
e.preventDefault();
129-
if (errorRename || renameLoading) {
129+
if (errorRename || renameLoading || _.trim(editTitle) === "") {
130130
return;
131131
}
132132

@@ -219,7 +219,7 @@ export const ChatHistoryListItemCell: React.FC<
219219
disabled={errorRename ? true : false}
220220
/>
221221
</Stack.Item>
222-
{editTitle && (
222+
{_.trim(editTitle) && (
223223
<Stack.Item>
224224
<Stack
225225
aria-label="action button group"

0 commit comments

Comments
 (0)