Skip to content

Commit

Permalink
fix: Fix for Chat history thread title is saved with space (Azure-Sam…
Browse files Browse the repository at this point in the history
…ples#1436)

Co-authored-by: Pavan Kumar <v-kupavan.microsoft.com>
  • Loading branch information
Pavan-Microsoft authored Oct 25, 2024
1 parent a9997b0 commit b587b98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions code/backend/api/chat_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down
4 changes: 2 additions & 2 deletions code/frontend/src/pages/chat/ChatHistoryListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -219,7 +219,7 @@ export const ChatHistoryListItemCell: React.FC<
disabled={errorRename ? true : false}
/>
</Stack.Item>
{editTitle && (
{_.trim(editTitle) && (
<Stack.Item>
<Stack
aria-label="action button group"
Expand Down

0 comments on commit b587b98

Please sign in to comment.