Bc-AI commited on
Commit
94d0c5a
Β·
verified Β·
1 Parent(s): d77ec0c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +6 -4
index.html CHANGED
@@ -1087,6 +1087,7 @@ let isStreaming = false;
1087
  let thinkTokens = 0;
1088
  let genTokens = 0;
1089
  let promptTokens = 0;
 
1090
 
1091
  // ── DECORATIVE TICK RING (signature gauge marks) ──────────────────────────
1092
  (function drawTicks() {
@@ -1271,18 +1272,19 @@ function addAssistantMsg() {
1271
  div.className = 'msg msg-assistant';
1272
  div.innerHTML = `
1273
  <div class="msg-label">MiniCoder-1</div>
1274
- <div class="msg-bubble" id="current-bubble">
1275
  <span class="cursor"></span>
1276
  </div>
1277
  `;
1278
  document.getElementById('chat-area').appendChild(div);
 
1279
  scrollBottom();
1280
  return div;
1281
  }
1282
 
1283
  // ── UPDATE ASSISTANT BUBBLE ───────────────────────────────────────────────
1284
  function updateBubble(raw, streaming) {
1285
- const bubble = document.getElementById('current-bubble');
1286
  if (!bubble) return;
1287
 
1288
  const { thinkContent, answerContent, thinkTokEst } = parseResponse(raw);
@@ -1413,7 +1415,7 @@ async function sendMessage() {
1413
  }
1414
  }
1415
  } catch (e) {
1416
- const bubble = document.getElementById('current-bubble');
1417
  if (bubble) bubble.innerHTML = `<span style="color:var(--danger)">Error: ${e.message}</span>`;
1418
  updateStatus('Error', null, null, null, 0);
1419
  }
@@ -1427,7 +1429,7 @@ async function sendMessage() {
1427
  async function stopGen() {
1428
  await fetch('/stop', { method: 'POST' });
1429
  updateStatus('Stopped', null, null, null, thinkTokens);
1430
- const bubble = document.getElementById('current-bubble');
1431
  if (bubble) {
1432
  bubble.querySelectorAll('.cursor').forEach(c => c.remove());
1433
  }
 
1087
  let thinkTokens = 0;
1088
  let genTokens = 0;
1089
  let promptTokens = 0;
1090
+ let currentBubbleEl = null; // tracks the live assistant bubble (ids repeat across turns, so we can't rely on getElementById)
1091
 
1092
  // ── DECORATIVE TICK RING (signature gauge marks) ──────────────────────────
1093
  (function drawTicks() {
 
1272
  div.className = 'msg msg-assistant';
1273
  div.innerHTML = `
1274
  <div class="msg-label">MiniCoder-1</div>
1275
+ <div class="msg-bubble">
1276
  <span class="cursor"></span>
1277
  </div>
1278
  `;
1279
  document.getElementById('chat-area').appendChild(div);
1280
+ currentBubbleEl = div.querySelector('.msg-bubble'); // point future updates at THIS turn's bubble
1281
  scrollBottom();
1282
  return div;
1283
  }
1284
 
1285
  // ── UPDATE ASSISTANT BUBBLE ───────────────────────────────────────────────
1286
  function updateBubble(raw, streaming) {
1287
+ const bubble = currentBubbleEl;
1288
  if (!bubble) return;
1289
 
1290
  const { thinkContent, answerContent, thinkTokEst } = parseResponse(raw);
 
1415
  }
1416
  }
1417
  } catch (e) {
1418
+ const bubble = currentBubbleEl;
1419
  if (bubble) bubble.innerHTML = `<span style="color:var(--danger)">Error: ${e.message}</span>`;
1420
  updateStatus('Error', null, null, null, 0);
1421
  }
 
1429
  async function stopGen() {
1430
  await fetch('/stop', { method: 'POST' });
1431
  updateStatus('Stopped', null, null, null, thinkTokens);
1432
+ const bubble = currentBubbleEl;
1433
  if (bubble) {
1434
  bubble.querySelectorAll('.cursor').forEach(c => c.remove());
1435
  }