From 21252cf2dda79bd94ed06c9b37b34308c7073f4f Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 13 May 2025 21:44:24 +0300 Subject: [PATCH] Fix empty chat if creating new assistant --- public/scripts/welcome-screen.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/scripts/welcome-screen.js b/public/scripts/welcome-screen.js index 14c93e7ab..82986985a 100644 --- a/public/scripts/welcome-screen.js +++ b/public/scripts/welcome-screen.js @@ -281,7 +281,7 @@ async function getRecentChats() { return data; } -export async function openPermanentAssistantChat({ tryCreate = true } = {}) { +export async function openPermanentAssistantChat({ tryCreate = true, created = false } = {}) { const avatar = getPermanentAssistantAvatar(); const characterId = characters.findIndex(x => x.avatar === avatar); if (characterId === -1) { @@ -293,7 +293,7 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) { try { console.log(`Character not found for avatar ID: ${avatar}. Creating new assistant.`); await createPermanentAssistant(); - return openPermanentAssistantChat({ tryCreate: false }); + return openPermanentAssistantChat({ tryCreate: false, created: true }); } catch (error) { console.error('Error creating permanent assistant:', error); @@ -304,7 +304,9 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) { try { await selectCharacterById(characterId); - await doNewChat({ deleteCurrentChat: false }); + if (!created) { + await doNewChat({ deleteCurrentChat: false }); + } console.log(`Opened permanent assistant chat for ${neutralCharacterName}.`, getCurrentChatId()); } catch (error) { console.error('Error opening permanent assistant chat:', error);