From 190f3d77298bcc98321009c0d0c9f26f5a1ac869 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 12 Mar 2025 10:33:46 +0900 Subject: [PATCH] Enhance cold storage handling by updating chat data structure and ensuring compatibility with existing data formats --- src/ts/process/coldstorage.svelte.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/ts/process/coldstorage.svelte.ts b/src/ts/process/coldstorage.svelte.ts index b110442a..2f2ce395 100644 --- a/src/ts/process/coldstorage.svelte.ts +++ b/src/ts/process/coldstorage.svelte.ts @@ -215,12 +215,29 @@ export async function makeColdData(){ if(greatestTime < coldTime){ const id = crypto.randomUUID() - await setColdStorageItem(id, chat.message) + await setColdStorageItem(id, { + message: chat.message, + hypaV2Data: chat.hypaV2Data, + hypaV3Data: chat.hypaV3Data, + scriptstate: chat.scriptstate, + localLore: chat.localLore + }) chat.message = [{ time: currentTime, data: coldStorageHeader + id, role: 'char' }] + chat.hypaV2Data = { + chunks:[], + mainChunks: [], + lastMainChunkID: 0, + } + chat.hypaV3Data = { + summaries:[] + } + chat.scriptstate = {} + chat.localLore = [] + } } } @@ -237,10 +254,17 @@ export async function preLoadChat(characterIndex:number, chatIndex:number){ //bring back from cold storage const coldDataKey = chat.message[0].data.slice(coldStorageHeader.length) const coldData = await getColdStorageItem(coldDataKey) - if(coldData){ + if(coldData && Array.isArray(coldData)){ chat.message = coldData chat.lastDate = Date.now() } + else if(coldData){ + chat.message = coldData.message + chat.hypaV2Data = coldData.hypaV2Data + chat.hypaV3Data = coldData.hypaV3Data + chat.scriptstate = coldData.scriptstate + chat.localLore = coldData.localLore + } await setColdStorageItem(coldDataKey + '_accessMeta', { lastAccess: Date.now() })