Fix history injection for prewarm extensions

- Use persistent event listeners instead of once() to inject into ALL generations
- Don't clear context map on GENERATION_ENDED so prewarm gets the same context
- Remove unused onGenerationEndedCleanup function
This commit is contained in:
tomt610
2026-01-10 19:33:26 +00:00
parent db97f012b0
commit b9a15722d6
3 changed files with 44 additions and 23 deletions
+11 -1
View File
@@ -151,7 +151,8 @@ import {
onMessageSwiped,
updatePersonaAvatar,
clearExtensionPrompts,
onGenerationEnded
onGenerationEnded,
initHistoryInjection
} from './src/systems/integration/sillytavern.js';
// Old state variable declarations removed - now imported from core modules
@@ -1018,6 +1019,15 @@ jQuery(async () => {
// Non-critical - continue anyway
}
// Initialize history injection event listeners
// This must be done before event registration so listeners are ready
try {
initHistoryInjection();
} catch (error) {
console.error('[RPG Companion] History injection init failed:', error);
// Non-critical - continue without it
}
// Register all event listeners
try {
registerAllEvents({