Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix for Chat history thread title is saved with space #1436

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading