Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files1226 unmodified lines12271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249105 unmodified lines1355135613571358135913609 unmodified lines13701371137213731374137513761377137813791380138113821226 unmodified lines* Returns HTML with <details> dropdowns for each thinking block.* `thinkingDuration` is the number of seconds to display (null = still thinking).*/function renderMarkdownWithThinking(md, thinkingDuration = null) {const segments = extractThinkingBlocks(md);return segments.map(seg => {if (seg.type === 'thinking') {const durLabel = thinkingDuration != null? `thinking for ${thinkingDuration}s`: `thinking…`;const spinnerOrArrow = thinkingDuration != null? `<span class="thinking-arrow" aria-hidden="true">▶</span>`: `<span class="thinking-spinner" aria-hidden="true"></span>`;const thinkingHtml = renderMarkdown(seg.content.trim());return `<details class="thinking-dropdown"><summary class="thinking-summary">${spinnerOrArrow} <span>${esc(durLabel)}</span></summary><div class="thinking-content">${thinkingHtml}</div></details>`;}return renderMarkdown(seg.content);}).join('');}105 unmodified linesasync function animateThinkingBlock(parentEl, thinkingText, delay) {const details = document.createElement('details');details.className = 'thinking-dropdown';const summary = document.createElement('summary');summary.className = 'thinking-summary';9 unmodified linesconst startTime = performance.now();// Stream the thinking content in chunksawait animateMarkdownChunked(contentDiv, thinkingText.trim(), delay);const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);// Replace spinner with arrow + final timesummary.innerHTML = `<span class="thinking-arrow" aria-hidden="true">▶</span> <span>thinking for ${elapsed}s</span>`;}/**1226 unmodified lines12271228122912301231123212331234123512361237123812391240124112421243124412451246105 unmodified lines13521353135413551356135713589 unmodified lines1368136913701371137213731374137513761377137813791226 unmodified lines* Returns HTML with <details> dropdowns for each thinking block.* `thinkingDuration` is the number of seconds to display (null = still thinking).*/function renderMarkdownWithThinking(md) {const segments = extractThinkingBlocks(md);return segments.map(seg => {if (seg.type === 'thinking') {const trimmed = seg.content.trim();if (!trimmed) return '';const thinkingHtml = renderMarkdown(trimmed);return `<details class="thinking-dropdown"><summary class="thinking-summary"><span class="thinking-arrow" aria-hidden="true">▶</span> <span>thought</span></summary><div class="thinking-content">${thinkingHtml}</div></details>`;}const trimmed = seg.content.trim();return trimmed ? renderMarkdown(trimmed) : '';}).join('');}105 unmodified linesasync function animateThinkingBlock(parentEl, thinkingText, delay) {const details = document.createElement('details');details.className = 'thinking-dropdown';details.open = true; // start openedconst summary = document.createElement('summary');summary.className = 'thinking-summary';9 unmodified linesconst startTime = performance.now();await animateMarkdownChunked(contentDiv, thinkingText.trim(), delay);const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);summary.innerHTML = `<span class="thinking-arrow" aria-hidden="true">▶</span> <span>thinking for ${elapsed}s</span>`;details.open = false; // auto-close after finishing}/**
templates/index.html+9-12