| 1348 | 1348 | for (const event of [event_types.GENERATION_STOPPED, event_types.GENERATION_ENDED, event_types.CHAT_CHANGED]) { |
| 1349 | 1349 | eventSource.on(event, () => PromptReasoning.clearLatest()); |
| 1350 | 1350 | } |
| 1351 | + |
| 1352 | + eventSource.makeFirst(event_types.IMPERSONATE_READY, async () => { |
| 1353 | + if (!power_user.reasoning.auto_parse) { |
| 1354 | + return; |
| 1355 | + } |
| 1356 | + |
| 1357 | + const sendTextArea = /** @type {HTMLTextAreaElement} */ (document.getElementById('send_textarea')); |
| 1358 | + |
| 1359 | + if (!sendTextArea) { |
| 1360 | + console.warn('[Reasoning] Send textarea not found'); |
| 1361 | + return; |
| 1362 | + } |
| 1363 | + |
| 1364 | + console.debug('[Reasoning] Auto-parsing reasoning block for impersonation'); |
| 1365 | + |
| 1366 | + if (!sendTextArea.value) { |
| 1367 | + console.debug('[Reasoning] Reasoning is empty, skipping'); |
| 1368 | + return; |
| 1369 | + } |
| 1370 | + |
| 1371 | + sendTextArea.value = removeReasoningFromString(sendTextArea.value); |
| 1372 | + sendTextArea.dispatchEvent(new Event('input', { bubbles: true })); |
| 1373 | + }); |
| 1351 | 1374 | } |
| 1352 | 1375 | |
| 1353 | 1376 | /** |