mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Run parsing at least once before rendering reasoning DOM on continue
This commit is contained in:
@@ -3204,13 +3204,21 @@ class StreamingProcessor {
|
|||||||
this.promptReasoning = promptReasoning;
|
this.promptReasoning = promptReasoning;
|
||||||
}
|
}
|
||||||
|
|
||||||
#checkDomElements(messageId) {
|
/**
|
||||||
|
* Initializes DOM elements for the current message.
|
||||||
|
* @param {number} messageId Current message ID
|
||||||
|
* @param {boolean?} continueOnReasoning If continuing on reasoning
|
||||||
|
*/
|
||||||
|
async #checkDomElements(messageId, continueOnReasoning = null) {
|
||||||
if (this.messageDom === null || this.messageTextDom === null) {
|
if (this.messageDom === null || this.messageTextDom === null) {
|
||||||
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
|
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
|
||||||
this.messageTextDom = this.messageDom?.querySelector('.mes_text');
|
this.messageTextDom = this.messageDom?.querySelector('.mes_text');
|
||||||
this.messageTimerDom = this.messageDom?.querySelector('.mes_timer');
|
this.messageTimerDom = this.messageDom?.querySelector('.mes_timer');
|
||||||
this.messageTokenCounterDom = this.messageDom?.querySelector('.tokenCounterDisplay');
|
this.messageTokenCounterDom = this.messageDom?.querySelector('.tokenCounterDisplay');
|
||||||
}
|
}
|
||||||
|
if (continueOnReasoning) {
|
||||||
|
await this.reasoningHandler.process(messageId, false, this.promptReasoning);
|
||||||
|
}
|
||||||
this.reasoningHandler.updateDom(messageId);
|
this.reasoningHandler.updateDom(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3230,7 +3238,8 @@ class StreamingProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onStartStreaming(text) {
|
async onStartStreaming(text) {
|
||||||
if (this.type === 'continue' && this.promptReasoning.prefixReasoning) {
|
const continueOnReasoning = !!(this.type === 'continue' && this.promptReasoning.prefixReasoning);
|
||||||
|
if (continueOnReasoning) {
|
||||||
this.reasoningHandler.initContinue(this.promptReasoning);
|
this.reasoningHandler.initContinue(this.promptReasoning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3242,7 +3251,7 @@ class StreamingProcessor {
|
|||||||
} else {
|
} else {
|
||||||
await saveReply(this.type, text, true, '', [], '');
|
await saveReply(this.type, text, true, '', [], '');
|
||||||
messageId = chat.length - 1;
|
messageId = chat.length - 1;
|
||||||
this.#checkDomElements(messageId);
|
await this.#checkDomElements(messageId, continueOnReasoning);
|
||||||
this.markUIGenStarted();
|
this.markUIGenStarted();
|
||||||
}
|
}
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
@@ -3275,7 +3284,7 @@ class StreamingProcessor {
|
|||||||
this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
|
this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
} else {
|
} else {
|
||||||
const mesChanged = chat[messageId]['mes'] !== processedText;
|
const mesChanged = chat[messageId]['mes'] !== processedText;
|
||||||
this.#checkDomElements(messageId);
|
await this.#checkDomElements(messageId);
|
||||||
this.#updateMessageBlockVisibility();
|
this.#updateMessageBlockVisibility();
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
chat[messageId]['mes'] = processedText;
|
chat[messageId]['mes'] = processedText;
|
||||||
|
Reference in New Issue
Block a user