Fix empty chat if creating new assistant
| @@ -281,7 +281,7 @@ async function getRecentChats() { | ||
| 281 | 281 | return data; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | export async function openPermanentAssistantChat({ tryCreate = true, created = false } = {}) { |
| 285 | 285 | const avatar = getPermanentAssistantAvatar(); |
| 286 | 286 | const characterId = characters.findIndex(x => x.avatar === avatar); |
| 287 | 287 | if (characterId === -1) { |
| @@ -293,7 +293,7 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) { | ||
| 293 | 293 | try { |
| 294 | 294 | console.log(`Character not found for avatar ID: ${avatar}. Creating new assistant.`); |
| 295 | 295 | await createPermanentAssistant(); |
| 296 | 296 | return openPermanentAssistantChat({ tryCreate: false, created: true }); |
| 297 | 297 | } |
| 298 | 298 | catch (error) { |
| 299 | 299 | console.error('Error creating permanent assistant:', error); |
| @@ -304,7 +304,9 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) { | ||
| 304 | 304 | |
| 305 | 305 | try { |
| 306 | 306 | await selectCharacterById(characterId); |
| 307 | - await doNewChat({ deleteCurrentChat: false }); | |
| 307 | + if (!created) { | |
| 308 | + await doNewChat({ deleteCurrentChat: false }); | |
| 309 | + } | |
| 308 | 310 | console.log(`Opened permanent assistant chat for ${neutralCharacterName}.`, getCurrentChatId()); |
| 309 | 311 | } catch (error) { |
| 310 | 312 | console.error('Error opening permanent assistant chat:', error); |