@wendongfly/myhi 1.3.140 → 1.3.142

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
@@ -2050,6 +2050,11 @@
2050
2050
  }
2051
2051
  }
2052
2052
  break;
2053
+ // 服务端主动发起的消息(自动接力发出的草稿)—— 渲染成用户气泡,
2054
+ // 跟你自己按回车发出来的长得一样,能看见原文而不只是一行系统提示。
2055
+ case 'user':
2056
+ if (msg.content) { endStream(); addInputMessage(msg.content); }
2057
+ break;
2053
2058
  case 'assistant':
2054
2059
  removeThinking();
2055
2060
  if (msg.message?.content) {
@@ -2331,6 +2336,10 @@
2331
2336
  });
2332
2337
 
2333
2338
  socket.on('agent:busy', (busy) => {
2339
+ // currentSession 是 joined 那一刻的快照,busy 字段不会自己更新。
2340
+ // 不同步的话:进页面时 AI 恰好在跑 → busy 永远停在 true → 之后每次回车
2341
+ // 都被当成"忙"转存草稿,消息再也发不出去(取回→又存草稿的死循环)。
2342
+ if (currentSession) currentSession.busy = busy;
2334
2343
  if (busy) { showThinking(); setWorkState('thinking'); }
2335
2344
  else { removeThinking(); setWorkState('idle'); }
2336
2345
  });
@@ -2410,7 +2419,8 @@
2410
2419
 
2411
2420
  // AI 还在跑这一轮(可能正开着子代理,整轮 result 未到,服务端 isBusy 会拒收):
2412
2421
  // 不再把输入连同刚上传的图片一起丢掉,转存草稿,本轮干完再取回。
2413
- if (currentSession?.mode === 'agent' && (workState !== 'idle' || currentSession?.busy)) {
2422
+ // 判定只看 workState —— 它由 agent:busy 事件驱动,joined 时已用会话真实忙闲初始化。
2423
+ if (currentSession?.mode === 'agent' && workState !== 'idle') {
2414
2424
  saveDraftFromInput('busy');
2415
2425
  return;
2416
2426
  }
@@ -3481,7 +3491,7 @@
3481
3491
  const tip = document.getElementById('draft-tip');
3482
3492
  if (!tip) return;
3483
3493
  const n = myDrafts().length;
3484
- const idle = workState === 'idle' && !currentSession?.busy;
3494
+ const idle = workState === 'idle';
3485
3495
  if (!n || !idle || _draftTipDismissed) { tip.style.display = 'none'; return; }
3486
3496
  document.getElementById('draft-tip-text').textContent =
3487
3497
  `本任务有 ${n} 条待发草稿 —— 点这里取回`;
@@ -3703,7 +3713,11 @@
3703
3713
  } catch {}
3704
3714
  await refreshInbox();
3705
3715
  renderInbox();
3706
- addStatusMessage(on ? '📥 这条已设为「自动接力」:本轮干完会自动发出' : '📥 已取消自动接力');
3716
+ addStatusMessage(on
3717
+ ? (workState === 'idle'
3718
+ ? '📥 已设为「自动接力」——会话当前空闲,马上就会发出'
3719
+ : '📥 这条已设为「自动接力」:本轮干完会自动发出')
3720
+ : '📥 已取消自动接力');
3707
3721
  };
3708
3722
 
3709
3723
  // 改投:会话结束了 / 当初记错任务了,把草稿挪到当前会话名下