| 673 | } |
| 674 | |
| 675 | function getOrCreateThinkingBlock() { |
| 676 | const children = Array.from(currentAssistantMsg.children).filter( |
| 677 | (c) => !c.classList.contains("loading-indicator") |
| 678 | ); |
| 679 | let lastChild = children[children.length - 1]; |
| 680 | |
| 681 | if (!lastChild || !lastChild.classList.contains("thinking-card")) { |
| 682 | lastChild = document.createElement("div"); |
| 683 | lastChild.className = "tool-card thinking-card collapsed"; |
| 684 | lastChild.dataset.mdContent = ""; |
| 685 | |
| 686 | lastChild.innerHTML = ` |
| 687 | <div class="tool-header thinking-header"> |
| 688 | <span class="tool-chevron"> |
| 689 | <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg> |
| 690 | </span> |
| 691 | <span class="tool-icon">🧠</span> |
| 692 | <span class="tool-name" style="color: var(--text-secondary);">Thinking Process</span> |
| 693 | </div> |
| 694 | <div class="tool-content thinking-content markdown-body"></div> |
| 695 | `; |
| 696 | |
| 697 | lastChild.querySelector(".tool-header").addEventListener("click", () => { |
| 698 | lastChild.classList.toggle("collapsed"); |
| 699 | }); |
| 700 | |
| 701 | const indicator = currentAssistantMsg.querySelector(".loading-indicator"); |
| 702 | if (indicator) { |
| 703 | currentAssistantMsg.insertBefore(lastChild, indicator); |
| 704 | } else { |
| 705 | currentAssistantMsg.appendChild(lastChild); |
| 706 | } |
| 707 | } |
| 708 | return lastChild; |
| 709 | } |
| 710 | |
| 711 | function getOrCreateTextBlock() { |
| 712 | const children = Array.from(currentAssistantMsg.children).filter( |