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

update_rename_thread_func #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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