Keep local edits from delaying cache refresh

1154224f7b8872e08761c775d378cccf2c5de83b

permissionBRICK <40219477+permissionBRICK@users.noreply.github.com>

2 files changed, +8 -5Showing whitespace changes
public/scripts/extensions/keepalive/index.js+7 -4
@@ -540,7 +540,10 @@ function onMessageReceived(_messageId, type) {
540540}
541541
542542function onChatContentChanged() {
543- markActivity();
543+ // Editing, deleting, or swiping local chat content does not contact the text provider and
544+ // therefore cannot refresh its prompt cache. Rebuild the replay payload, but preserve the
545+ // deadline from the last real text generation/keepalive. This also keeps image-message edits
546+ // and gallery activity from postponing text keepalives.
544547 if (armed && isKeepaliveEnabledForActive()) {
545548 queueJobRefresh();
546549 }
@@ -581,9 +584,9 @@ async function init() {
581584 // not send a new message (regenerate/swipe/continue) are armed by onGenerationStarted instead.
582585 eventSource.on(event_types.MESSAGE_SENT, onMessageSent);
583586
584- // Activity resets the backend deadline but never arms keepalive on its own. A completed
587+ // Only actual text-provider generations reset the cache deadline. Local chat edits still
585588 // generation or a chat edit also refreshesrefresh the stored request so the server always replays the latest prompt without pretending that
586589 // the latest promptthose assemblededits byrefreshed the UIprovider cache.
587590 eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);
588591 eventSource.on(event_types.GENERATION_STARTED, onGenerationStarted);
589592 eventSource.on(event_types.GENERATION_ENDED, onGenerationEnded);
public/scripts/extensions/keepalive/manifest.json+1 -1
@@ -6,7 +6,7 @@
66 "js": "index.js",
77 "css": "",
88 "author": "SillyTavern",
99 "version": "1.1.45",
1010 "homePage": "https://github.com/SillyTavern/SillyTavern",
1111 "hooks": {
1212 "activate": "init"