@wendongfly/myhi 1.3.139 → 1.3.141

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
@@ -746,14 +746,14 @@
746
746
  </div>
747
747
  <!-- 就地新增:不必先在消息框打字再"提取",直接在这儿写 -->
748
748
  <div style="border-top:1px solid var(--surface2);padding:0.5rem 0.2rem">
749
- <textarea id="inbox-new-text" rows="3" spellcheck="false" placeholder="写下临时想法…(可带图片,随时记,多条排队)"
749
+ <textarea id="inbox-new-text" rows="3" spellcheck="false" placeholder="写下临时想法… 截图可直接 Ctrl+V 粘进来 (能连着记多条)"
750
750
  style="width:100%;box-sizing:border-box;background:var(--surface2);color:var(--text);border:1px solid var(--border);border-radius:8px;padding:0.5rem;font-size:0.82rem;resize:vertical"></textarea>
751
751
  <div id="inbox-new-img" style="display:none;align-items:center;gap:0.4rem;margin-top:0.35rem;font-size:0.7rem;color:var(--text2)">
752
752
  <span>📷</span><span id="inbox-new-img-name" style="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"></span>
753
753
  <button class="dr-btn" onclick="clearInboxNewImage()">移除</button>
754
754
  </div>
755
755
  <div style="display:flex;align-items:center;gap:0.5rem;margin-top:0.45rem;flex-wrap:wrap">
756
- <button class="dr-btn" onclick="document.getElementById('inbox-new-file').click()">📷 加图片</button>
756
+ <button class="dr-btn" onclick="document.getElementById('inbox-new-file').click()" title="也可以直接 Ctrl+V 粘贴截图">📷 选图片</button>
757
757
  <input type="file" id="inbox-new-file" accept="image/*" style="display:none"
758
758
  onchange="uploadInboxImage(this.files[0]); this.value='';">
759
759
  <label style="display:flex;align-items:center;gap:0.3rem;font-size:0.7rem;color:var(--muted);cursor:pointer">
@@ -2331,6 +2331,10 @@
2331
2331
  });
2332
2332
 
2333
2333
  socket.on('agent:busy', (busy) => {
2334
+ // currentSession 是 joined 那一刻的快照,busy 字段不会自己更新。
2335
+ // 不同步的话:进页面时 AI 恰好在跑 → busy 永远停在 true → 之后每次回车
2336
+ // 都被当成"忙"转存草稿,消息再也发不出去(取回→又存草稿的死循环)。
2337
+ if (currentSession) currentSession.busy = busy;
2334
2338
  if (busy) { showThinking(); setWorkState('thinking'); }
2335
2339
  else { removeThinking(); setWorkState('idle'); }
2336
2340
  });
@@ -2410,7 +2414,8 @@
2410
2414
 
2411
2415
  // AI 还在跑这一轮(可能正开着子代理,整轮 result 未到,服务端 isBusy 会拒收):
2412
2416
  // 不再把输入连同刚上传的图片一起丢掉,转存草稿,本轮干完再取回。
2413
- if (currentSession?.mode === 'agent' && (workState !== 'idle' || currentSession?.busy)) {
2417
+ // 判定只看 workState —— 它由 agent:busy 事件驱动,joined 时已用会话真实忙闲初始化。
2418
+ if (currentSession?.mode === 'agent' && workState !== 'idle') {
2414
2419
  saveDraftFromInput('busy');
2415
2420
  return;
2416
2421
  }
@@ -3481,7 +3486,7 @@
3481
3486
  const tip = document.getElementById('draft-tip');
3482
3487
  if (!tip) return;
3483
3488
  const n = myDrafts().length;
3484
- const idle = workState === 'idle' && !currentSession?.busy;
3489
+ const idle = workState === 'idle';
3485
3490
  if (!n || !idle || _draftTipDismissed) { tip.style.display = 'none'; return; }
3486
3491
  document.getElementById('draft-tip-text').textContent =
3487
3492
  `本任务有 ${n} 条待发草稿 —— 点这里取回`;
@@ -3581,18 +3586,20 @@
3581
3586
  if (box) box.style.display = 'none';
3582
3587
  };
3583
3588
 
3584
- window.uploadInboxImage = async function(file) {
3589
+ // file 可能来自文件选择器,也可能是 Ctrl+V 粘贴来的 blob(后者 name 常为空)
3590
+ window.uploadInboxImage = async function(file, fallbackName) {
3585
3591
  if (!file) return;
3592
+ const name = file.name || fallbackName || 'paste.png';
3586
3593
  const box = document.getElementById('inbox-new-img');
3587
3594
  const nameEl = document.getElementById('inbox-new-img-name');
3588
3595
  box.style.display = 'flex';
3589
- nameEl.textContent = '上传中… ' + file.name;
3596
+ nameEl.textContent = '上传中… ' + name;
3590
3597
  try {
3591
3598
  const form = new FormData();
3592
- form.append('image', file, file.name);
3599
+ form.append('image', file, name);
3593
3600
  const r = await fetch(`/upload?sessionId=${SESSION_ID}`, { method: 'POST', body: form });
3594
3601
  const d = await r.json();
3595
- if (d.path) { _inboxNewImage = { path: d.path, name: file.name }; nameEl.textContent = file.name; }
3602
+ if (d.path) { _inboxNewImage = { path: d.path, name }; nameEl.textContent = name; }
3596
3603
  else { _inboxNewImage = null; nameEl.textContent = '上传失败:' + (d.error || '未知'); }
3597
3604
  } catch (e) {
3598
3605
  _inboxNewImage = null;
@@ -3701,7 +3708,11 @@
3701
3708
  } catch {}
3702
3709
  await refreshInbox();
3703
3710
  renderInbox();
3704
- addStatusMessage(on ? '📥 这条已设为「自动接力」:本轮干完会自动发出' : '📥 已取消自动接力');
3711
+ addStatusMessage(on
3712
+ ? (workState === 'idle'
3713
+ ? '📥 已设为「自动接力」——会话当前空闲,马上就会发出'
3714
+ : '📥 这条已设为「自动接力」:本轮干完会自动发出')
3715
+ : '📥 已取消自动接力');
3705
3716
  };
3706
3717
 
3707
3718
  // 改投:会话结束了 / 当初记错任务了,把草稿挪到当前会话名下
@@ -4654,6 +4665,15 @@
4654
4665
  const blob = item.getAsFile();
4655
4666
  if (!blob) continue;
4656
4667
  e.preventDefault(); // 阻止浏览器把图片当文本塞进 textarea
4668
+ // 草稿箱抽屉开着 → 截图归草稿,而不是塞进下面的消息框
4669
+ // (记草稿时配图的常见姿势就是"截个图 Ctrl+V",不是去文件选择器里翻)
4670
+ if (document.getElementById('inbox-sheet')?.classList.contains('open')) {
4671
+ try {
4672
+ await window.uploadInboxImage(blob, 'paste.png');
4673
+ document.getElementById('inbox-new-text')?.focus();
4674
+ } catch (err) { addStatusMessage('上传失败: ' + err.message); }
4675
+ return;
4676
+ }
4657
4677
  addStatusMessage('粘贴图片上传中...');
4658
4678
  try {
4659
4679
  await uploadImageBlob(blob, 'paste.png');