@iamsamyiok/agents-chat 3.23.0 → 3.24.0
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/app/lib/cards.js +7 -2
- package/app/public/cards.html +6 -3
- package/package.json +1 -1
package/app/lib/cards.js
CHANGED
|
@@ -343,12 +343,17 @@ class CardRunner {
|
|
|
343
343
|
return true;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
// 供前端展示:当前存活进程 +
|
|
346
|
+
// 供前端展示:当前存活进程 + 是否有近期活动
|
|
347
|
+
// 可靠性加固:
|
|
348
|
+
// 1) 死进程过滤——close 事件竞争窗口或异常挂起时,登记表可能残留已退出进程,
|
|
349
|
+
// 以 child.exitCode/killed 为准过滤,绝不显示死 PID(占位阶段 child=null 保留,代表启动中)
|
|
350
|
+
// 2) 活动窗口 15s——AI 长思考期间(无流式输出)不误报「空闲」
|
|
347
351
|
getProcesses() {
|
|
348
352
|
const out = [];
|
|
349
353
|
const now = Date.now();
|
|
350
354
|
for (const [cardId, p] of this.procs) {
|
|
351
|
-
|
|
355
|
+
if (p.child && (p.child.exitCode !== null || p.child.killed)) continue; // 已退出的子进程:不展示
|
|
356
|
+
out.push({ cardId, pid: p.pid || null, working: (now - (p.lastActive || 0)) < 15000 });
|
|
352
357
|
}
|
|
353
358
|
return out;
|
|
354
359
|
}
|
package/app/public/cards.html
CHANGED
|
@@ -931,7 +931,7 @@ $('#trashFab').onclick=openTrash;
|
|
|
931
931
|
$('#trashClose').onclick=()=>$('#trashMask').classList.remove('show');
|
|
932
932
|
$('#trashEmpty').onclick=async()=>{ if(!confirm('确认清空垃圾桶?所有快照及其过程日志将被永久删除,不可恢复。'))return; const r=await post('/api/cards/trash/empty'); toast('已清空 '+r.cleared+' 项'); await loadCards(); };
|
|
933
933
|
|
|
934
|
-
// ---- 进程状态条(PID +
|
|
934
|
+
// ---- 进程状态条(PID + 工作状态,SSE 事件驱动 + 2s 轮询兜底) ----
|
|
935
935
|
async function refreshProcs(){
|
|
936
936
|
try{
|
|
937
937
|
const d = await api('/api/cards/processes');
|
|
@@ -940,8 +940,9 @@ async function refreshProcs(){
|
|
|
940
940
|
const kname = (RUNNER_INFO && RUNNER_INFO.label) || 'opencode';
|
|
941
941
|
if(!procs.length){ bar.innerHTML='<span class="ptitle">进程:</span><span class="proc-empty">无运行中的 '+esc(kname)+' 进程</span>'; return; }
|
|
942
942
|
bar.innerHTML='<span class="ptitle">进程:</span>'+procs.map(p=>{
|
|
943
|
-
const
|
|
944
|
-
|
|
943
|
+
const pidLabel = p.pid ? ('PID '+p.pid) : '启动中…';
|
|
944
|
+
const st = p.working ? '工作中' : '等待输出';
|
|
945
|
+
return `<span class="proc-chip ${p.working?'':'idle'}" title="${p.working?'近 15 秒内有输出活动':'进程存活,暂无新输出(长思考属正常)'}"><span class="dot"></span><span class="pid">${pidLabel}</span><span class="st">${st}</span></span>`;
|
|
945
946
|
}).join('');
|
|
946
947
|
}catch{ /* ignore */ }
|
|
947
948
|
}
|
|
@@ -1006,6 +1007,8 @@ es.onmessage = (e)=>{
|
|
|
1006
1007
|
}
|
|
1007
1008
|
// proc 仅刷新进程条(另有 2s 轮询兜底),不重建看板 DOM
|
|
1008
1009
|
if(ev.type==='proc'){ refreshProcs(); }
|
|
1010
|
+
// 任务结束/编排停止:进程条目随之移除,立即刷新进程条(不等 2s 轮询)
|
|
1011
|
+
if(ev.type==='task_done'||ev.type==='followup_done'||ev.type==='runner_stopped') refreshProcs();
|
|
1009
1012
|
// tool 事件仅在打开对应详情时追加过程日志,避免工具密集时高频全量刷新
|
|
1010
1013
|
if(ev.type==='tool' && OPEN_ID===ev.cardId){
|
|
1011
1014
|
const log=$('#dLog'); if(log.querySelector('.empty')) log.innerHTML='';
|