Merge pull request #82 from munimunigamer/auto-update-ext

Fixed auto updating with external api mode
This commit is contained in:
Spicy Marinara
2026-01-06 01:01:16 +01:00
committed by GitHub
3 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -78,11 +78,11 @@ export async function onGenerationStarted(type, data) {
const lastMessage = chat && chat.length > 0 ? chat[chat.length - 1] : null; const lastMessage = chat && chat.length > 0 ? chat[chat.length - 1] : null;
// For SEPARATE mode only: Check if we need to commit extension data // For SEPARATE/EXTERNAL mode: Check if we need to commit extension data
// BUT: Only do this for the MAIN generation, not the tracker update generation // BUT: Only do this for the MAIN generation, not the tracker update generation
// If isGenerating is true, this is the tracker update generation (second call), so skip flag logic // If isGenerating is true, this is the tracker update generation (second call), so skip flag logic
// console.log('[RPG Companion DEBUG] Before generating:', lastGeneratedData.characterThoughts, ' , committed - ', committedTrackerData.characterThoughts); // console.log('[RPG Companion DEBUG] Before generating:', lastGeneratedData.characterThoughts, ' , committed - ', committedTrackerData.characterThoughts);
if (extensionSettings.generationMode === 'separate' && !isGenerating) { if ((extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') && !isGenerating) {
if (!lastActionWasSwipe) { if (!lastActionWasSwipe) {
// User sent a new message - commit lastGeneratedData before generation // User sent a new message - commit lastGeneratedData before generation
// console.log('[RPG Companion] 📝 COMMIT: New message - committing lastGeneratedData'); // console.log('[RPG Companion] 📝 COMMIT: New message - committing lastGeneratedData');
@@ -246,8 +246,8 @@ export async function onGenerationStarted(type, data) {
// Clear Spotify prompt if disabled // Clear Spotify prompt if disabled
setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false);
} }
} else if (extensionSettings.generationMode === 'separate') { } else if (extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') {
// In SEPARATE mode, inject the contextual summary for main roleplay generation // In SEPARATE/EXTERNAL mode, inject the contextual summary for main roleplay generation
const contextSummary = generateContextualSummary(); const contextSummary = generateContextualSummary();
if (contextSummary) { if (contextSummary) {
+4 -4
View File
@@ -89,8 +89,8 @@ export function onMessageSent() {
setLastActionWasSwipe(false); setLastActionWasSwipe(false);
// console.log('[RPG Companion] 🟢 EVENT: onMessageSent - lastActionWasSwipe =', lastActionWasSwipe); // console.log('[RPG Companion] 🟢 EVENT: onMessageSent - lastActionWasSwipe =', lastActionWasSwipe);
// In separate mode with auto-update disabled, commit displayed tracker when user sends a message // In separate/external mode with auto-update disabled, commit displayed tracker when user sends a message
if (extensionSettings.generationMode === 'separate' && !extensionSettings.autoUpdate) { if ((extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') && !extensionSettings.autoUpdate) {
// Commit whatever is currently displayed in lastGeneratedData // Commit whatever is currently displayed in lastGeneratedData
if (lastGeneratedData.userStats || lastGeneratedData.infoBox || lastGeneratedData.characterThoughts) { if (lastGeneratedData.userStats || lastGeneratedData.infoBox || lastGeneratedData.characterThoughts) {
committedTrackerData.userStats = lastGeneratedData.userStats; committedTrackerData.userStats = lastGeneratedData.userStats;
@@ -210,8 +210,8 @@ export async function onMessageReceived(data) {
// Save to chat metadata // Save to chat metadata
saveChatData(); saveChatData();
} }
} else if (extensionSettings.generationMode === 'separate') { } else if (extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') {
// In separate mode, also parse Spotify URLs from the main roleplay response // In separate/external mode, also parse Spotify URLs from the main roleplay response
const lastMessage = chat[chat.length - 1]; const lastMessage = chat[chat.length - 1];
if (lastMessage && !lastMessage.is_user) { if (lastMessage && !lastMessage.is_user) {
const responseText = lastMessage.mes; const responseText = lastMessage.mes;
+3 -3
View File
@@ -421,8 +421,8 @@ export function updateGenerationModeUI() {
$('#rpg-manual-update').show(); $('#rpg-manual-update').show();
$('#rpg-external-api-settings').slideDown(200); $('#rpg-external-api-settings').slideDown(200);
$('#rpg-separate-mode-settings').slideUp(200); $('#rpg-separate-mode-settings').slideUp(200);
// Disable auto-update toggle (not applicable in external mode) // Enable auto-update toggle (works in external mode too)
$('#rpg-toggle-auto-update').prop('disabled', true); $('#rpg-toggle-auto-update').prop('disabled', false);
$('#rpg-auto-update-container').css('opacity', '0.5'); $('#rpg-auto-update-container').css('opacity', '1');
} }
} }