Update Refresh RPG Info buttons in index.js to call commitTrackerDataFromPriorMessage() before updateRPGData()

This commit is contained in:
Daryl
2026-02-26 17:59:45 -04:00
parent c307f1a1bc
commit 03345b81f4
2 changed files with 26 additions and 1 deletions
+23 -1
View File
@@ -42,7 +42,7 @@ import {
setMusicPlayerContainer,
clearSessionAvatarPrompts
} from './src/core/state.js';
import { loadSettings, saveSettings, saveChatData, loadChatData, updateMessageSwipeData } from './src/core/persistence.js';
import { loadSettings, saveSettings, saveChatData, loadChatData, updateMessageSwipeData, commitTrackerDataFromPriorMessage } from './src/core/persistence.js';
import { registerAllEvents } from './src/core/events.js';
// Generation & Parsing modules
@@ -800,6 +800,17 @@ async function initUI() {
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
return;
}
const currentChat = getContext().chat;
let lastAssistantIndex = -1;
for (let i = currentChat.length - 1; i >= 0; i--) {
if (!currentChat[i].is_user && !currentChat[i].is_system) {
lastAssistantIndex = i;
break;
}
}
if (lastAssistantIndex !== -1) {
commitTrackerDataFromPriorMessage(lastAssistantIndex);
}
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
});
@@ -808,6 +819,17 @@ async function initUI() {
if (!extensionSettings.enabled) {
return;
}
const currentChat = getContext().chat;
let lastAssistantIndex = -1;
for (let i = currentChat.length - 1; i >= 0; i--) {
if (!currentChat[i].is_user && !currentChat[i].is_system) {
lastAssistantIndex = i;
break;
}
}
if (lastAssistantIndex !== -1) {
commitTrackerDataFromPriorMessage(lastAssistantIndex);
}
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
});