Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +9 -12
templates/index.html
CHANGED
|
@@ -1227,23 +1227,20 @@
|
|
| 1227 |
* Returns HTML with <details> dropdowns for each thinking block.
|
| 1228 |
* `thinkingDuration` is the number of seconds to display (null = still thinking).
|
| 1229 |
*/
|
| 1230 |
-
function renderMarkdownWithThinking(md
|
| 1231 |
const segments = extractThinkingBlocks(md);
|
| 1232 |
return segments.map(seg => {
|
| 1233 |
if (seg.type === 'thinking') {
|
| 1234 |
-
const
|
| 1235 |
-
|
| 1236 |
-
|
| 1237 |
-
const spinnerOrArrow = thinkingDuration != null
|
| 1238 |
-
? `<span class="thinking-arrow" aria-hidden="true">▶</span>`
|
| 1239 |
-
: `<span class="thinking-spinner" aria-hidden="true"></span>`;
|
| 1240 |
-
const thinkingHtml = renderMarkdown(seg.content.trim());
|
| 1241 |
return `<details class="thinking-dropdown">
|
| 1242 |
-
<summary class="thinking-summary">
|
| 1243 |
<div class="thinking-content">${thinkingHtml}</div>
|
| 1244 |
</details>`;
|
| 1245 |
}
|
| 1246 |
-
|
|
|
|
| 1247 |
}).join('');
|
| 1248 |
}
|
| 1249 |
|
|
@@ -1355,6 +1352,7 @@
|
|
| 1355 |
async function animateThinkingBlock(parentEl, thinkingText, delay) {
|
| 1356 |
const details = document.createElement('details');
|
| 1357 |
details.className = 'thinking-dropdown';
|
|
|
|
| 1358 |
|
| 1359 |
const summary = document.createElement('summary');
|
| 1360 |
summary.className = 'thinking-summary';
|
|
@@ -1370,13 +1368,12 @@
|
|
| 1370 |
|
| 1371 |
const startTime = performance.now();
|
| 1372 |
|
| 1373 |
-
// Stream the thinking content in chunks
|
| 1374 |
await animateMarkdownChunked(contentDiv, thinkingText.trim(), delay);
|
| 1375 |
|
| 1376 |
const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
|
| 1377 |
|
| 1378 |
-
// Replace spinner with arrow + final time
|
| 1379 |
summary.innerHTML = `<span class="thinking-arrow" aria-hidden="true">▶</span> <span>thinking for ${elapsed}s</span>`;
|
|
|
|
| 1380 |
}
|
| 1381 |
|
| 1382 |
/**
|
|
|
|
| 1227 |
* Returns HTML with <details> dropdowns for each thinking block.
|
| 1228 |
* `thinkingDuration` is the number of seconds to display (null = still thinking).
|
| 1229 |
*/
|
| 1230 |
+
function renderMarkdownWithThinking(md) {
|
| 1231 |
const segments = extractThinkingBlocks(md);
|
| 1232 |
return segments.map(seg => {
|
| 1233 |
if (seg.type === 'thinking') {
|
| 1234 |
+
const trimmed = seg.content.trim();
|
| 1235 |
+
if (!trimmed) return '';
|
| 1236 |
+
const thinkingHtml = renderMarkdown(trimmed);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1237 |
return `<details class="thinking-dropdown">
|
| 1238 |
+
<summary class="thinking-summary"><span class="thinking-arrow" aria-hidden="true">▶</span> <span>thought</span></summary>
|
| 1239 |
<div class="thinking-content">${thinkingHtml}</div>
|
| 1240 |
</details>`;
|
| 1241 |
}
|
| 1242 |
+
const trimmed = seg.content.trim();
|
| 1243 |
+
return trimmed ? renderMarkdown(trimmed) : '';
|
| 1244 |
}).join('');
|
| 1245 |
}
|
| 1246 |
|
|
|
|
| 1352 |
async function animateThinkingBlock(parentEl, thinkingText, delay) {
|
| 1353 |
const details = document.createElement('details');
|
| 1354 |
details.className = 'thinking-dropdown';
|
| 1355 |
+
details.open = true; // start opened
|
| 1356 |
|
| 1357 |
const summary = document.createElement('summary');
|
| 1358 |
summary.className = 'thinking-summary';
|
|
|
|
| 1368 |
|
| 1369 |
const startTime = performance.now();
|
| 1370 |
|
|
|
|
| 1371 |
await animateMarkdownChunked(contentDiv, thinkingText.trim(), delay);
|
| 1372 |
|
| 1373 |
const elapsed = ((performance.now() - startTime) / 1000).toFixed(1);
|
| 1374 |
|
|
|
|
| 1375 |
summary.innerHTML = `<span class="thinking-arrow" aria-hidden="true">▶</span> <span>thinking for ${elapsed}s</span>`;
|
| 1376 |
+
details.open = false; // auto-close after finishing
|
| 1377 |
}
|
| 1378 |
|
| 1379 |
/**
|