@wendongfly/myhi 1.3.41 → 1.3.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.html CHANGED
@@ -1405,6 +1405,16 @@
1405
1405
  });
1406
1406
 
1407
1407
  socket.on('agent:history', (history) => {
1408
+ // history 是权威状态。socket 重连(断网/切网/keepalive 超时)会重发整本,
1409
+ // 之前是"追加"语义,会把已有 DOM 翻倍。改成"重置"语义:清空再回放。
1410
+ // 重连发生在流式输出过程中时,把当前 partial 文本快照下来,回放后还原为
1411
+ // 新的流式气泡,让后续 live delta 继续追加,避免丢失已收到的部分内容。
1412
+ const wasStreaming = _streamEl && chatArea.contains(_streamEl);
1413
+ const inflightText = wasStreaming ? _streamText : '';
1414
+
1415
+ chatArea.innerHTML = '';
1416
+ endStream(); endToolGroup(); removeThinking();
1417
+
1408
1418
  for (const msg of history) {
1409
1419
  endStream(); // 每条历史消息都是独立的,不要流式合并
1410
1420
  if (msg.type === 'user' && msg.content) {
@@ -1432,6 +1442,21 @@
1432
1442
  addStatusMessage(`完成${cost}`);
1433
1443
  }
1434
1444
  }
1445
+
1446
+ // 还原断点处的流式气泡,让后续 live delta 接着拼
1447
+ if (inflightText) {
1448
+ _streamText = inflightText;
1449
+ const el = document.createElement('div');
1450
+ el.className = 'msg msg-assistant';
1451
+ const content = document.createElement('div');
1452
+ content.className = 'content';
1453
+ content.innerHTML = renderMarkdown(_streamText);
1454
+ el.appendChild(content);
1455
+ chatArea.appendChild(el);
1456
+ _streamEl = el;
1457
+ _streamedTextThisMessage = true;
1458
+ }
1459
+
1435
1460
  scrollToBottom();
1436
1461
  });
1437
1462