Run parsing at least once before rendering reasoning DOM on continue
| @@ -3204,13 +3204,21 @@ class StreamingProcessor { | ||
| 3204 | 3204 | this.promptReasoning = promptReasoning; |
| 3205 | 3205 | } |
| 3206 | 3206 | |
| 3207 | - #checkDomElements(messageId) { | |
| 3207 | + /** | |
| 3208 | + * Initializes DOM elements for the current message. | |
| 3209 | + * @param {number} messageId Current message ID | |
| 3210 | + * @param {boolean?} continueOnReasoning If continuing on reasoning | |
| 3211 | + */ | |
| 3212 | + async #checkDomElements(messageId, continueOnReasoning = null) { | |
| 3208 | 3213 | if (this.messageDom === null || this.messageTextDom === null) { |
| 3209 | 3214 | this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`); |
| 3210 | 3215 | this.messageTextDom = this.messageDom?.querySelector('.mes_text'); |
| 3211 | 3216 | this.messageTimerDom = this.messageDom?.querySelector('.mes_timer'); |
| 3212 | 3217 | this.messageTokenCounterDom = this.messageDom?.querySelector('.tokenCounterDisplay'); |
| 3213 | 3218 | } |
| 3219 | + if (continueOnReasoning) { | |
| 3220 | + await this.reasoningHandler.process(messageId, false, this.promptReasoning); | |
| 3221 | + } | |
| 3214 | 3222 | this.reasoningHandler.updateDom(messageId); |
| 3215 | 3223 | } |
| 3216 | 3224 | |
| @@ -3230,7 +3238,8 @@ class StreamingProcessor { | ||
| 3230 | 3238 | } |
| 3231 | 3239 | |
| 3232 | 3240 | async onStartStreaming(text) { |
| 3233 | 3241 | ifconst continueOnReasoning = !!(this.type === 'continue' && this.promptReasoning.prefixReasoning) {; |
| 3242 | + if (continueOnReasoning) { | |
| 3234 | 3243 | this.reasoningHandler.initContinue(this.promptReasoning); |
| 3235 | 3244 | } |
| 3236 | 3245 | |
| @@ -3242,7 +3251,7 @@ class StreamingProcessor { | ||
| 3242 | 3251 | } else { |
| 3243 | 3252 | await saveReply(this.type, text, true, '', [], ''); |
| 3244 | 3253 | messageId = chat.length - 1; |
| 3245 | 3254 | await this.#checkDomElements(messageId, continueOnReasoning); |
| 3246 | 3255 | this.markUIGenStarted(); |
| 3247 | 3256 | } |
| 3248 | 3257 | hideSwipeButtons(); |
| @@ -3275,7 +3284,7 @@ class StreamingProcessor { | ||
| 3275 | 3284 | this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true })); |
| 3276 | 3285 | } else { |
| 3277 | 3286 | const mesChanged = chat[messageId]['mes'] !== processedText; |
| 3278 | 3287 | await this.#checkDomElements(messageId); |
| 3279 | 3288 | this.#updateMessageBlockVisibility(); |
| 3280 | 3289 | const currentTime = new Date(); |
| 3281 | 3290 | chat[messageId]['mes'] = processedText; |