Keep local edits from delaying cache refresh

1154224f7b8872e08761c775d378cccf2c5de83b

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

2 files changed, +8 -5Ignore whitespace
public/scripts/extensions/keepalive/index.js+7 -4
@@ -540,7 +540,10 @@ function onMessageReceived(_messageId, type) {
540}540}
541541
542function onChatContentChanged() {542function 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.
544 if (armed && isKeepaliveEnabledForActive()) {547 if (armed && isKeepaliveEnabledForActive()) {
545 queueJobRefresh();548 queueJobRefresh();
546 }549 }
@@ -581,9 +584,9 @@ async function init() {
581 // not send a new message (regenerate/swipe/continue) are armed by onGenerationStarted instead.584 // not send a new message (regenerate/swipe/continue) are armed by onGenerationStarted instead.
582 eventSource.on(event_types.MESSAGE_SENT, onMessageSent);585 eventSource.on(event_types.MESSAGE_SENT, onMessageSent);
583586
584 // Activity resets the backend deadline but never arms keepalive on its own. A completed587 // Only actual text-provider generations reset the cache deadline. Local chat edits still
585 // generation or a chat edit also refreshes the stored request so the server always replays588 // refresh the stored request so the server replays the latest prompt without pretending that
586 // the latest prompt assembled by the UI.589 // those edits refreshed the provider cache.
587 eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);590 eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);
588 eventSource.on(event_types.GENERATION_STARTED, onGenerationStarted);591 eventSource.on(event_types.GENERATION_STARTED, onGenerationStarted);
589 eventSource.on(event_types.GENERATION_ENDED, onGenerationEnded);592 eventSource.on(event_types.GENERATION_ENDED, onGenerationEnded);
public/scripts/extensions/keepalive/manifest.json+1 -1
@@ -6,7 +6,7 @@
6 "js": "index.js",6 "js": "index.js",
7 "css": "",7 "css": "",
8 "author": "SillyTavern",8 "author": "SillyTavern",
9 "version": "1.1.4",9 "version": "1.1.5",
10 "homePage": "https://github.com/SillyTavern/SillyTavern",10 "homePage": "https://github.com/SillyTavern/SillyTavern",
11 "hooks": {11 "hooks": {
12 "activate": "init"12 "activate": "init"