From ec1f3efb3ba803027fcf1837667ea827cd06c2b9 Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Sun, 12 Oct 2025 16:00:04 +0800 Subject: [PATCH] Update cwb_index.js --- CharacterWorldBook/cwb_index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CharacterWorldBook/cwb_index.js b/CharacterWorldBook/cwb_index.js index 69a03e6..ed9847c 100644 --- a/CharacterWorldBook/cwb_index.js +++ b/CharacterWorldBook/cwb_index.js @@ -44,6 +44,15 @@ export async function initializeCharacterWorldBook($cwbSettingsPanel) { updateCardUpdateStatusDisplay($cwbSettingsPanel); }); + eventSource.on(event_types.CHARACTER_CHANGED, async () => { + console.log('[CWB] Detected character change. Resetting state and updating UI.'); + setTimeout(async () => { + const newChatName = await getLatestChatName(); + await resetScriptStateForNewChat($cwbSettingsPanel, newChatName); + updateCardUpdateStatusDisplay($cwbSettingsPanel); + }, 150); + }); + console.log('[CWB] Character World Book feature initialized successfully.'); } catch (error) {