Skip to content
Open
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
15 changes: 10 additions & 5 deletions frontend/app/components/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,19 @@ export function ChatWindow() {
const getThreadName = (messageValue: string) =>
messageValue.length > 20 ? messageValue.slice(0, 20) + "..." : messageValue;

const renameThread = async (messageValue: string) => {
// NOTE: we're only setting this on the first message
if (currentThread == null || messages.length > 1) {
const renameThread = async (messageValue: string): Promise<void> => {
// currentThread exists and if there is only one message
if (!currentThread || messages.length > 1) {
return;
}
const threadName = getThreadName(messageValue);
await updateThread(currentThread["thread_id"], threadName);
try {
const threadName = getThreadName(messageValue);
await updateThread(currentThread.thread_id, threadName);
} catch (error) {
console.error('Failed to rename thread:', error);
}
};


const sendMessage = async (message?: string) => {
if (messageContainerRef.current) {
Expand Down