@wendongfly/myhi 1.3.164 → 1.3.165
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 +46 -10
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -1528,16 +1528,32 @@
|
|
|
1528
1528
|
const t = text.trimStart();
|
|
1529
1529
|
if (t.startsWith('This session is being continued from a previous conversation')) return 'compact';
|
|
1530
1530
|
if (t.startsWith('[Request interrupted by user')) return 'interrupt'; // 含 "...for tool use" 变体
|
|
1531
|
+
// claude 本地 slash 命令注入的合成 user 事件(1.3.165):命令回显与免责声明——
|
|
1532
|
+
// 发 /context 这类本地命令时 claude 会在流里回 <command-name> 回显 + <local-command-caveat> 说明
|
|
1533
|
+
if (t.startsWith('<command-name>')) return 'command';
|
|
1534
|
+
if (t.startsWith('<local-command-caveat>') || t.startsWith('Caveat:')) return 'caveat';
|
|
1535
|
+
if (t.startsWith('<system-reminder>') || t.startsWith('<local-command-stdout>')) return 'noise';
|
|
1531
1536
|
return null;
|
|
1532
1537
|
}
|
|
1533
1538
|
|
|
1534
1539
|
function buildSyntheticUserEl(content) {
|
|
1535
1540
|
const el = document.createElement('div');
|
|
1536
|
-
|
|
1541
|
+
const kind = syntheticUserKind(content);
|
|
1542
|
+
if (kind === 'interrupt') {
|
|
1537
1543
|
el.className = 'msg msg-status';
|
|
1538
1544
|
el.textContent = '— ⏹ 请求已中断 —';
|
|
1539
1545
|
return el;
|
|
1540
1546
|
}
|
|
1547
|
+
if (kind === 'command') {
|
|
1548
|
+
// 本地命令回显:状态行显示执行了什么命令(用户自己发的命令已有气泡,这是 claude 的回显)
|
|
1549
|
+
el.className = 'msg msg-status';
|
|
1550
|
+
const name = (content.match(/<command-name>([^<]*)<\/command-name>/) || [])[1] || '命令';
|
|
1551
|
+
el.textContent = `— ⌘ ${name} —`;
|
|
1552
|
+
return el;
|
|
1553
|
+
}
|
|
1554
|
+
if (kind === 'caveat' || kind === 'noise') {
|
|
1555
|
+
return null; // 给模型看的免责声明/系统提醒/命令输出回显,对用户是纯噪音,不渲染
|
|
1556
|
+
}
|
|
1541
1557
|
el.className = 'msg msg-synthetic';
|
|
1542
1558
|
const head = document.createElement('div');
|
|
1543
1559
|
head.className = 'syn-head';
|
|
@@ -2248,9 +2264,27 @@
|
|
|
2248
2264
|
break;
|
|
2249
2265
|
// 服务端主动发起的消息(自动接力发出的草稿)—— 渲染成用户气泡,
|
|
2250
2266
|
// 跟你自己按回车发出来的长得一样,能看见原文而不只是一行系统提示。
|
|
2251
|
-
|
|
2252
|
-
|
|
2267
|
+
// claude 注入的合成 user 事件(压缩摘要/中断/本地命令回显与免责声明)不是用户发言:
|
|
2268
|
+
// 新 CLI 下这类事件带顶层 content,必须分类分流,否则长成蓝色用户气泡(1.3.165)。
|
|
2269
|
+
case 'user': {
|
|
2270
|
+
// 只有字符串 content 才可能是真人/草稿发言;claude 原生 user 事件带数组 content
|
|
2271
|
+
// (tool_result 块)不是用户说话,别渲染成气泡
|
|
2272
|
+
if (msg.content && typeof msg.content === 'string') {
|
|
2273
|
+
endStream();
|
|
2274
|
+
const kind = syntheticUserKind(msg.content);
|
|
2275
|
+
if (kind === 'compact' || kind === 'interrupt') {
|
|
2276
|
+
const sel = buildSyntheticUserEl(msg.content);
|
|
2277
|
+
if (sel) { chatArea.appendChild(sel); trimMessages(); scrollToBottom(); }
|
|
2278
|
+
} else if (kind === 'command') {
|
|
2279
|
+
const sel = buildSyntheticUserEl(msg.content);
|
|
2280
|
+
if (sel) addStatusMessage(sel.textContent);
|
|
2281
|
+
} else if (!kind) {
|
|
2282
|
+
addInputMessage(msg.content);
|
|
2283
|
+
}
|
|
2284
|
+
// caveat/noise:纯噪音,不渲染
|
|
2285
|
+
}
|
|
2253
2286
|
break;
|
|
2287
|
+
}
|
|
2254
2288
|
case 'assistant':
|
|
2255
2289
|
removeThinking();
|
|
2256
2290
|
if (msg.message?.usage) {
|
|
@@ -2402,11 +2436,12 @@
|
|
|
2402
2436
|
endStream(); // 每条历史消息都是独立的,不要流式合并
|
|
2403
2437
|
if (subaRoute(msg)) continue; // 子代理内部历史消息归入对应面板
|
|
2404
2438
|
if (msg.type === 'user' && msg.content) {
|
|
2405
|
-
// claude
|
|
2406
|
-
|
|
2407
|
-
|
|
2439
|
+
// claude 注入的合成消息(压缩摘要/中断/命令回显/免责声明)渲染成系统状态行或不渲染,不长成用户发言
|
|
2440
|
+
const sel = buildSyntheticUserEl(msg.content);
|
|
2441
|
+
if (sel) {
|
|
2442
|
+
chatArea.appendChild(sel);
|
|
2408
2443
|
trimMessages(); scrollToBottom();
|
|
2409
|
-
} else {
|
|
2444
|
+
} else if (!syntheticUserKind(msg.content)) {
|
|
2410
2445
|
addInputMessage(msg.content);
|
|
2411
2446
|
}
|
|
2412
2447
|
} else if (msg.type === 'assistant' && msg.message?.content) {
|
|
@@ -2490,9 +2525,10 @@
|
|
|
2490
2525
|
const frag = document.createDocumentFragment();
|
|
2491
2526
|
for (const msg of d.messages) {
|
|
2492
2527
|
if (msg.type === 'user' && msg.content) {
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2528
|
+
const sel = buildSyntheticUserEl(msg.content);
|
|
2529
|
+
if (sel) {
|
|
2530
|
+
frag.appendChild(sel);
|
|
2531
|
+
} else if (!syntheticUserKind(msg.content)) {
|
|
2496
2532
|
const el = document.createElement('div');
|
|
2497
2533
|
el.className = 'msg msg-input';
|
|
2498
2534
|
el.innerHTML = `<div><div class="bubble">${escHtml(msg.content)}</div><div class="meta">${msg.timestamp ? new Date(msg.timestamp).toLocaleString('zh-CN') : ''}</div></div>`;
|
package/package.json
CHANGED