Fix plot progression buttons to trigger continuation without RPG tracker prompts

This commit is contained in:
Spicy_Marinara
2025-10-15 09:17:47 +02:00
parent 8e624a807d
commit 21e7ff85f9
+27 -22
View File
@@ -588,6 +588,7 @@ async function sendPlotProgression(type) {
$('#rpg-plot-random, #rpg-plot-natural').prop('disabled', true).css('opacity', '0.5'); $('#rpg-plot-random, #rpg-plot-natural').prop('disabled', true).css('opacity', '0.5');
// Store original enabled state and temporarily disable extension // Store original enabled state and temporarily disable extension
// This prevents RPG tracker instructions from being injected during plot progression
const wasEnabled = extensionSettings.enabled; const wasEnabled = extensionSettings.enabled;
extensionSettings.enabled = false; extensionSettings.enabled = false;
@@ -612,23 +613,29 @@ async function sendPlotProgression(type) {
- These HTML/CSS/JS elements must be rendered directly without enclosing them in code fences.`; - These HTML/CSS/JS elements must be rendered directly without enclosing them in code fences.`;
} }
// Inject the plot prompt as a quiet prompt // Use extension prompt system to inject our plot progression instruction
// This replaces the default continuation message // Since extensionSettings.enabled = false, onGenerationStarted won't inject RPG tracker prompts
setExtensionPrompt('rpg-plot-progression', prompt, extension_prompt_types.IN_CHAT, 0, false, extension_prompt_roles.USER); setExtensionPrompt('rpg-plot-progression', prompt, extension_prompt_types.IN_CHAT, 0, false);
// Trigger a continuation with the custom prompt // Trigger continuation by clicking the Continue button
// The quiet_prompt parameter allows extension prompts to override the default continuation message // Find and click the actual continue button in SillyTavern's UI
// Since extensionSettings.enabled = false, onGenerationStarted won't inject RPG prompts const $continueButton = $('#option_continue');
// Check if Generate function exists (newer versions only) if ($continueButton.length > 0) {
if (typeof window.Generate === 'function') { $continueButton.trigger('click');
await window.Generate('continue', { quiet_prompt: prompt });
} else { } else {
// Fallback for older versions - use generateRaw // Fallback: try alternative continue button selectors
await generateRaw(prompt, '', false, false, ''); const $altContinueButton = $('.mes_continue');
if ($altContinueButton.length > 0) {
$altContinueButton.last().trigger('click');
} else {
console.warn('[RPG Companion] Could not find continue button');
}
} }
// Clear the temporary prompt after generation // Clear the extension prompt after a short delay to let generation start
setExtensionPrompt('rpg-plot-progression', '', extension_prompt_types.IN_CHAT, 0, false); setTimeout(() => {
setExtensionPrompt('rpg-plot-progression', '', extension_prompt_types.IN_CHAT, 0, false);
}, 500);
// console.log('[RPG Companion] Plot progression generation triggered'); // console.log('[RPG Companion] Plot progression generation triggered');
} catch (error) { } catch (error) {
@@ -636,15 +643,13 @@ async function sendPlotProgression(type) {
// Clear the prompt in case of error // Clear the prompt in case of error
setExtensionPrompt('rpg-plot-progression', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-plot-progression', '', extension_prompt_types.IN_CHAT, 0, false);
} finally { } finally {
// Restore original enabled state // Restore original enabled state and re-enable buttons after a delay
extensionSettings.enabled = wasEnabled; setTimeout(() => {
extensionSettings.enabled = wasEnabled;
// Re-enable buttons $('#rpg-plot-random, #rpg-plot-natural').prop('disabled', false).css('opacity', '1');
$('#rpg-plot-random, #rpg-plot-natural').prop('disabled', false).css('opacity', '1'); }, 1000);
} }
} }/**
/**
* Sets up the dice roller functionality. * Sets up the dice roller functionality.
*/ */
function setupDiceRoller() { function setupDiceRoller() {
@@ -1579,7 +1584,7 @@ async function updateRPGData() {
(!committedTrackerData.infoBox || committedTrackerData.infoBox === 'Info Box\n---\n' || committedTrackerData.infoBox === '') && (!committedTrackerData.infoBox || committedTrackerData.infoBox === 'Info Box\n---\n' || committedTrackerData.infoBox === '') &&
(!committedTrackerData.characterThoughts || committedTrackerData.characterThoughts === 'Present Characters\n---\n' || committedTrackerData.characterThoughts === '') (!committedTrackerData.characterThoughts || committedTrackerData.characterThoughts === 'Present Characters\n---\n' || committedTrackerData.characterThoughts === '')
); );
if (hasNoRealData || hasOnlyPlaceholderData) { if (hasNoRealData || hasOnlyPlaceholderData) {
committedTrackerData.userStats = parsedData.userStats; committedTrackerData.userStats = parsedData.userStats;
committedTrackerData.infoBox = parsedData.infoBox; committedTrackerData.infoBox = parsedData.infoBox;