Fix empty chat if creating new assistant

21252cf2dda79bd94ed06c9b37b34308c7073f4f

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -2Showing whitespace changes
public/scripts/welcome-screen.js+4 -2
@@ -281,7 +281,7 @@ async function getRecentChats() {
281281 return data;
282282}
283283
284284export async function openPermanentAssistantChat({ tryCreate = true, created = false } = {}) {
285285 const avatar = getPermanentAssistantAvatar();
286286 const characterId = characters.findIndex(x => x.avatar === avatar);
287287 if (characterId === -1) {
@@ -293,7 +293,7 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) {
293293 try {
294294 console.log(`Character not found for avatar ID: ${avatar}. Creating new assistant.`);
295295 await createPermanentAssistant();
296296 return openPermanentAssistantChat({ tryCreate: false, created: true });
297297 }
298298 catch (error) {
299299 console.error('Error creating permanent assistant:', error);
@@ -304,7 +304,9 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) {
304304
305305 try {
306306 await selectCharacterById(characterId);
307+ if (!created) {
307308 await doNewChat({ deleteCurrentChat: false });
309+ }
308310 console.log(`Opened permanent assistant chat for ${neutralCharacterName}.`, getCurrentChatId());
309311 } catch (error) {
310312 console.error('Error opening permanent assistant chat:', error);