From 2b99a7299c9c9af84886a907a3dd22b43954ae96 Mon Sep 17 00:00:00 2001 From: Cogent Apps <127109874+cogentapps@users.noreply.github.com> Date: Tue, 7 Mar 2023 11:26:20 -0800 Subject: [PATCH] fix bugs related to system prompt and titles --- src/chat-manager.ts | 9 ++++++++- src/components/page.tsx | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/chat-manager.ts b/src/chat-manager.ts index 1ab7a19..10d7506 100644 --- a/src/chat-manager.ts +++ b/src/chat-manager.ts @@ -237,13 +237,20 @@ export class Search { const output: any[] = []; for (const item of searchResults) { const chatID = item.id; - const chat = this.chats.get(chatID); + let chat = this.chats.get(chatID); if (!chat) { continue; } + chat = { ...chat }; + let description = chat.messages?.first?.content || ''; description = ellipsize(description, 400); + + if (!chat.title) { + chat.title = ellipsize(description, 100); + } + if (!chat.title || !description) { continue; } diff --git a/src/components/page.tsx b/src/components/page.tsx index 70b1d51..71adbd5 100644 --- a/src/components/page.tsx +++ b/src/components/page.tsx @@ -81,7 +81,8 @@ export default function ChatPage(props: any) { if (id) { saveParameters(id, parameters); } - }, [parameters]); + saveParameters('', parameters); + }, [id, parameters]); const onNewMessage = useCallback(async (message?: string) => { if (props.share) {