Skip to content

Commit ab935a2

Browse files
fix: Chat history template name is accepting empty strings as well
1 parent 2f1e57b commit ab935a2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ async def rename_conversation():
682682

683683
## update the title
684684
title = request_json.get("title", None)
685-
if not title:
685+
if not title or title.strip() == "":
686686
return jsonify({"error": "title is required"}), 400
687687
conversation["title"] = title
688688
updated_conversation = await cosmos_conversation_client.upsert_conversation(

frontend/src/components/ChatHistory/ChatHistoryListItem.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { AppStateContext } from '../../state/AppProvider'
2525
import { GroupedChatHistory } from './ChatHistoryList'
2626

2727
import styles from './ChatHistoryPanel.module.css'
28+
import _ from 'lodash'
2829

2930
interface ChatHistoryListItemCellProps {
3031
item?: Conversation
@@ -125,6 +126,17 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
125126
if (errorRename || renameLoading) {
126127
return
127128
}
129+
if (_.trim(editTitle) === "") {
130+
setErrorRename('Error: Title is required.')
131+
setTimeout(() => {
132+
setErrorRename(undefined)
133+
setTextFieldFocused(true)
134+
if (textFieldRef.current) {
135+
textFieldRef.current.focus()
136+
}
137+
}, 5000)
138+
return
139+
}
128140
if (editTitle == item.title) {
129141
setErrorRename('Error: Enter a new title to proceed.')
130142
setTimeout(() => {

0 commit comments

Comments
 (0)