From c436fc629914a9ce72dda9a09a85276f22160045 Mon Sep 17 00:00:00 2001 From: Webifi Date: Sun, 28 May 2023 15:54:45 -0500 Subject: [PATCH] Move chat state values out of settings --- src/lib/Chat.svelte | 21 ++++++++++++--------- src/lib/Settings.svelte | 15 ++------------- src/lib/Storage.svelte | 6 +++++- src/lib/Types.svelte | 4 ++-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/lib/Chat.svelte b/src/lib/Chat.svelte index 686919b..1f474d3 100644 --- a/src/lib/Chat.svelte +++ b/src/lib/Chat.svelte @@ -124,12 +124,13 @@ } else { console.log('Speech recognition not supported') } - if (chatSettings.startSession) { + if (chat.startSession) { const profile = getProfile('') // get default profile applyProfile(chatId, profile.profile as any) - if (chatSettings.startSession) { - setChatSettingValueByKey(chatId, 'startSession', false) - // Auto start the session out of band + if (chat.startSession) { + chat.startSession = false + saveChatStore() + // Auto start the session setTimeout(() => { submitForm(false, true) }, 0) } } @@ -349,7 +350,8 @@ if (updating) return if (!skipInput) { - setChatSettingValueByKey(chatId, 'sessionStarted', true) + chat.sessionStarted = true + saveChatStore() if (input.value !== '') { // Compose the input message const inputMessage: Message = { role: 'user', content: input.value, uuid: uuidv4() } @@ -505,9 +507,10 @@ const closeSettings = () => { showSettingsModal = 0 showProfileMenu = false - if (chat.settings.startSession) { - setChatSettingValueByKey(chatId, 'startSession', false) - submitForm(false, true) + if (chat.startSession) { + chat.startSession = false + saveChatStore() + submitForm(false, true) } } @@ -556,7 +559,7 @@ window.alert('Unable to change:\n' + e.message) } } - if (setting.key === 'profile' && chatSettings.sessionStarted && + if (setting.key === 'profile' && chat.sessionStarted && (getProfile(el.value).characterName !== chatSettings.characterName)) { const val = chatSettings[setting.key] if (window.confirm('Personality change will not correctly apply to existing chat session.\n Continue?')) { diff --git a/src/lib/Settings.svelte b/src/lib/Settings.svelte index 7a01119..62f9593 100644 --- a/src/lib/Settings.svelte +++ b/src/lib/Settings.svelte @@ -1,6 +1,6 @@