diff --git a/internal/schedule/schedule_cases_test.go b/internal/schedule/schedule_cases_test.go
index b8de9ece6..54b82fb3a 100644
--- a/internal/schedule/schedule_cases_test.go
+++ b/internal/schedule/schedule_cases_test.go
@@ -16,7 +16,12 @@ func TestJobDueBranches(t *testing.T) {
}{
{domain.ScheduleJob{}, false},
{domain.ScheduleJob{Enabled: true, LastStatus: "running"}, false},
- {domain.ScheduleJob{Enabled: true}, true},
+ {domain.ScheduleJob{Enabled: true}, false},
+ {domain.ScheduleJob{Enabled: true, CreatedAt: now.Add(-time.Hour + time.Millisecond), IntervalSec: 3600}, false},
+ {domain.ScheduleJob{Enabled: true, CreatedAt: now.Add(-time.Hour), IntervalSec: 3600}, true},
+ {domain.ScheduleJob{Enabled: true, CreatedAt: now.Add(-2 * time.Hour), LastRunAt: now.Add(-time.Minute), IntervalSec: 3600}, false},
+ {domain.ScheduleJob{Enabled: true, CreatedAt: now.Add(-time.Minute), Cron: "0 9 * * 1"}, false},
+ {domain.ScheduleJob{Enabled: true, CreatedAt: now.Add(-time.Minute), Cron: "0 20 * * *"}, true},
{domain.ScheduleJob{Enabled: true, LastRunAt: now.Add(-31 * time.Second), IntervalSec: 1}, true},
{domain.ScheduleJob{Enabled: true, LastRunAt: now.Add(-29 * time.Second), IntervalSec: 1}, false},
{domain.ScheduleJob{Enabled: true, Cron: "bad", LastRunAt: now.Add(-time.Hour)}, false},
diff --git a/internal/schedule/service.go b/internal/schedule/service.go
index 6d26dce84..b023746aa 100644
--- a/internal/schedule/service.go
+++ b/internal/schedule/service.go
@@ -195,21 +195,23 @@ func jobDue(job domain.ScheduleJob, now time.Time) bool {
if job.LastStatus == "running" {
return false
}
+ base := job.LastRunAt
+ if base.IsZero() {
+ // The first timer run follows the configured schedule, just like later runs.
+ base = job.CreatedAt
+ }
+ if base.IsZero() {
+ return false
+ }
if cron := strings.TrimSpace(job.Cron); cron != "" {
- if job.LastRunAt.IsZero() {
- return true
- }
- next, err := cronexpr.Next(cron, job.LastRunAt)
+ next, err := cronexpr.Next(cron, base)
return err == nil && !next.After(now)
}
interval := time.Duration(job.IntervalSec) * time.Second
if interval < 30*time.Second {
interval = 30 * time.Second
}
- if job.LastRunAt.IsZero() {
- return true
- }
- return now.Sub(job.LastRunAt) >= interval
+ return now.Sub(base) >= interval
}
func (s *Service) RunJob(id string) (domain.ScheduleJob, error) {
return s.runJob(id, "timer")
diff --git a/internal/schedule/service_test.go b/internal/schedule/service_test.go
index 77936f0c5..a77a9662f 100644
--- a/internal/schedule/service_test.go
+++ b/internal/schedule/service_test.go
@@ -768,7 +768,8 @@ func TestCronDropsOccurrencesDuringRun(t *testing.T) {
t.Fatalf("next cron must run: err=%v", err)
}
// Another job's run does not delay a job that never ran.
- if _, err := svc.claimJob(neverRun.ID, finish); err != nil {
+ other, _ := st.ScheduleJob(neverRun.ID)
+ if _, err := svc.claimJob(neverRun.ID, other.CreatedAt.Add(time.Hour)); err != nil {
t.Fatalf("other job must not wait for this one: err=%v", err)
}
got, _ := st.ScheduleJob(job.ID)
@@ -815,7 +816,8 @@ func TestTimerRunsAsyncAndSkipsOverlap(t *testing.T) {
return "ok", nil
})
returned := make(chan struct{})
- go func() { svc.runDueJobs(); close(returned) }()
+ stored, _ := st.ScheduleJob(job.ID)
+ go func() { svc.runDueJobsAt(stored.CreatedAt.Add(time.Minute)); close(returned) }()
select {
case <-returned:
case <-time.After(2 * time.Second):
diff --git a/web/app.js b/web/app.js
index 9bb600f5b..9c7d7755f 100644
--- a/web/app.js
+++ b/web/app.js
@@ -221,6 +221,7 @@ function afNextDialog(){
window.HuiPopover?.closeAll?.();
window.HuiTooltip?.hide?.();
modal.classList.add('open');
+ modal.dataset.explicitConfirm=opened.explicitConfirm?'1':'0';
const focus=opened.focus||okBtn;
focus.focus();
if(opened.select)focus.select?.();
@@ -270,7 +271,7 @@ function bindConfirmModal(modal){
else if(!e.shiftKey&&at===items.length-1){e.preventDefault();items[0].focus()}
return;
}
- if(e.key!=='Enter')return;
+ if(e.key!=='Enter'||modal.dataset.explicitConfirm==='1')return;
const tag=e.target?.tagName;
if(tag==='BUTTON'||tag==='SELECT')return;
if(tag==='TEXTAREA'&&!(e.ctrlKey||e.metaKey))return;
@@ -294,7 +295,7 @@ function afConfirm(options){
if(danger)setConfirmIcon('danger','trash');
else if(opt.info)setConfirmIcon('info','info');
else setConfirmIcon('warn','warning');
- return {focus:okBtn};
+ return {focus:danger?$('#confirmCancelBtn'):okBtn,explicitConfirm:danger};
});
}
diff --git a/web/app/dashboards.js b/web/app/dashboards.js
index d2d7fcbfe..80f8b4452 100644
--- a/web/app/dashboards.js
+++ b/web/app/dashboards.js
@@ -7,4 +7,4 @@ function formatTimestamp(value){
}
function duration(ms){ms=Number(ms||0);if(!ms)return '—';if(ms<1000)return `${ms}ms`;if(ms<60000)return `${(ms/1000).toFixed(1)}s`;if(ms<3600000)return `${(ms/60000).toFixed(1)}m`;return `${(ms/3600000).toFixed(1)}h`}
function metricsIssueSource(issue){return String(issue?.source||issue?.externalRef?.source||'').toLowerCase()}
-function metricHealth(m, liveCount=0){if(liveCount)return {key:'active',label:'运行中',hint:`${liveCount} 个实例执行中`};if(!m?.totalRuns)return {key:'never',label:'从未运行',hint:'需要首次验证'};if(m.waitingRuns)return {key:'active',label:'待审批',hint:`${m.waitingRuns} 个实例等待门禁`};if(m.failedRuns&&m.lastRunStatus==='failed')return {key:'blocked',label:'有阻塞',hint:'最近运行失败'};if(m.succeededRuns)return {key:'closed',label:'已闭环',hint:`${percent(m.closureRate)} 闭环率`};return {key:'blocked',label:'未闭环',hint:'尚无成功运行'}}
+function metricHealth(m, liveCount=0){if(m?.waitingRuns)return {key:'active',label:'待审批',hint:`${m.waitingRuns} 个实例等待门禁`};if(liveCount)return {key:'active',label:'运行中',hint:`${liveCount} 个实例执行中`};if(!m?.totalRuns)return {key:'never',label:'从未运行',hint:'需要首次验证'};if(m.failedRuns&&m.lastRunStatus==='failed')return {key:'blocked',label:'有阻塞',hint:'最近运行失败'};if(m.succeededRuns)return {key:'closed',label:'已闭环',hint:`${percent(m.closureRate)} 闭环率`};return {key:'blocked',label:'未闭环',hint:'尚无成功运行'}}
diff --git a/web/app/issue-drawer.js b/web/app/issue-drawer.js
index c3cf398e1..eaa89344d 100644
--- a/web/app/issue-drawer.js
+++ b/web/app/issue-drawer.js
@@ -175,7 +175,7 @@ function renderIssueDetailTab(){
host.innerHTML=panes[state.issueDetailTab]||'
暂无内容
';
if(state.issueDetailTab==='conversations')void renderIssueConversations(issue,host);
renderedIssueClarifyKey=clarifyKey;
- host.querySelectorAll('[data-edit-issue]').forEach(b=>b.onclick=()=>{closeIssueDrawer();openIssue(issue)});
+ host.querySelectorAll('[data-edit-issue]').forEach(b=>b.onclick=()=>{const tab=state.issueDetailTab;closeIssueDrawer();openIssue(issue,tab)});
host.querySelectorAll('[data-dispatch-issue]').forEach(b=>b.onclick=()=>triggerIssue(b.dataset.dispatchIssue,b.dataset.workflow));
host.querySelectorAll('[data-retrigger-issue]').forEach(b=>b.onclick=()=>retriggerIssue(b.dataset.retriggerIssue,b.dataset.workflow));
host.querySelectorAll('[data-chat-issue]').forEach(b=>b.onclick=()=>openIssueInChatById(b.dataset.chatIssue));
diff --git a/web/app/issues.js b/web/app/issues.js
index e587b2ed1..d0e1ef855 100644
--- a/web/app/issues.js
+++ b/web/app/issues.js
@@ -145,6 +145,13 @@ function filteredIssues(){
return [...issues].sort((a,b)=>issueHealthRank(a)-issueHealthRank(b)||(priority[a.priority]??4)-(priority[b.priority]??4)||(b.number||0)-(a.number||0));
}
+function issueListEmptyState(query, runFilter){
+ if(query)return ['没有符合搜索条件的工作项','请尝试其他关键词,或清空搜索查看当前筛选下的工作项。'];
+ if(runFilter==='attention')return ['没有需要介入的工作项','待确认澄清结论、门禁失败、运行失败或已中断的工作项会显示在这里。'];
+ if(runFilter==='mr')return ['没有待处理 MR 的需求','已提 MR 但还没合入的需求会显示在这里。'];
+ return ['当前项目没有匹配的工作项','从 GitHub 同步,或在本平台新建需求。'];
+}
+
function renderIssues(){
const tapdImport=document.querySelector("#importTAPDIssue");if(tapdImport)tapdImport.hidden=!currentProject()?.tapdWorkspaceId;
watchClarifyingIssues();
@@ -166,8 +173,7 @@ function renderIssues(){
bindIssueSelection(visibleIssues);
return;
}
- const emptyTitle=state.issueRunFilter==='attention'?'没有需要介入的工作项':state.issueRunFilter==='mr'?'没有待处理 MR 的需求':'当前项目没有匹配的工作项';
- const emptyHint=state.issueRunFilter==='attention'?'待确认澄清结论、门禁失败、运行失败或已中断的工作项会显示在这里。':state.issueRunFilter==='mr'?'已提 MR 但还没合入的需求会显示在这里。':'从 GitHub 同步,或在本平台新建需求。';
+ const [emptyTitle,emptyHint]=issueListEmptyState(state.issueQuery,state.issueRunFilter);
const keyWidth=issueKeyColumnWidth(paged.items);
const pager=pagerHTML('issues',paged)||(paged.total?``:'');
board.innerHTML=``;
@@ -487,7 +493,9 @@ function fillIssueAssignees(projectId,value=''){
picker.innerHTML=userCombobox('assigneeUserId',selected,'使用项目 Owner');
bindUserSearches(f);
}
-function openIssue(issue=null){
+let issueEditorReturn=null;
+function openIssue(issue=null,returnToTab=null){
+ issueEditorReturn=issue?.id&&returnToTab?{id:issue.id,tab:returnToTab,view:activeViewName(),projectId:state.projectFilter}:null;
state.selectedIssue=issue?.id||null;
const f=$('#issueForm'),projects=state.data.projects||[];
f.elements.projectId.innerHTML=projects.map(p=>``).join('');
@@ -705,7 +713,19 @@ async function persistIssue(issue){
rememberIssue(saved, id);
return saved;
}
-async function saveIssue(e){e.preventDefault();const button=e.currentTarget.querySelector('button[type="submit"]');try{button.disabled=true;button.textContent='正在保存…';const saved=await persistIssue(issueFromForm());state.selectedIssue=saved.id;$('#issueModal').classList.remove('open');renderIssues();toast('需求已保存')}catch(err){toast(err.message)}finally{button.disabled=false;button.textContent='保存'}}
+async function saveIssue(e){
+ e.preventDefault();
+ const button=e.currentTarget.querySelector('button[type="submit"]'),returnTo=issueEditorReturn;
+ try{
+ button.disabled=true;button.textContent='正在保存…';
+ const saved=await persistIssue(issueFromForm());
+ const modal=$('#issueModal');
+ const restore=returnTo&&returnTo===issueEditorReturn&&modal.classList.contains('open')&&returnTo.id===saved.id&&returnTo.view===activeViewName()&&returnTo.projectId===state.projectFilter;
+ state.selectedIssue=saved.id;
+ modal.classList.remove('open');renderIssues();toast('需求已保存');
+ if(restore)void openIssueDetail(saved.id,returnTo.tab);
+ }catch(err){toast(err.message)}finally{button.disabled=false;button.textContent='保存'}
+}
async function dispatchIssue(){try{let issue=issueFromForm();const blocked=issueExecutionBlocked(issue);if(blocked)return toast(blocked);const current=latestIssueTask(issue),rerun=!!current;if(current&&!await afConfirm({title:'重新运行确认',message:['queued','dispatched','running'].includes(current.status)?'该需求已有进行中的任务,确定额外发起一次重新运行吗?':'该需求已经处理过,确定整条 LOOP 重新运行吗?',confirmText:'确认重新运行'}))return;const button=$('#dispatchIssue');button.disabled=true;button.textContent='正在调度…';issue=await persistIssue(issue);button.textContent=sopSandboxPendingText(issue.workflowId||defaultSOPForIssue(issue))||'正在调度…';const task=await api(`/api/issues/${issue.id}/dispatch`,{method:'POST',body:JSON.stringify({rerun,workflowId:issue.workflowId||''})});issue.latestTaskId=task.id;issue.status='in_progress';const idx=state.data.issues.findIndex(i=>i.id===issue.id);if(idx>=0)state.data.issues[idx]=issue;if(!state.data.tasks)state.data.tasks=[];const existingTaskIdx=state.data.tasks.findIndex(t=>t.id===task.id);if(existingTaskIdx>=0)state.data.tasks[existingTaskIdx]=task;else state.data.tasks.unshift(task);if(task.runId){startLiveRun(task.runId);try{const run=await api(`/api/runs/${encodeURIComponent(task.runId)}`,{silent:true});if(run?.id){if(!state.data.runs)state.data.runs=[];const rIdx=state.data.runs.findIndex(r=>r.id===run.id);if(rIdx>=0)state.data.runs[rIdx]={...state.data.runs[rIdx],...run};else state.data.runs=sortRunsDescending([run,...state.data.runs]);}}catch(e){}}$('#issueModal').classList.remove('open');renderIssues();await openIssueDetail(issue.id,'sop');toast(rerun?'已创建重新运行':'已创建执行任务并启动工作流','ok');Promise.all([refreshIssues(),refreshRuns(true)]).catch(()=>{});}catch(err){toast(err.message)}finally{const button=$('#dispatchIssue');button.disabled=false;button.textContent='启动 LOOP'}}
async function dispatchIssueById(issueId,rerun=false,workflowId=''){try{const issue=(state.data.issues||[]).find(i=>i.id===issueId),blocked=issueExecutionBlocked(issue);if(blocked)return toast(blocked);if(clarificationNeedsConfirm(issue)){openIssueDetail(issueId,'clarify');return toast('请先确认澄清结论后再触发 LOOP')}
const sandboxStatus=sopSandboxPendingText(workflowId||issue?.workflowId||defaultSOPForIssue(issue));
diff --git a/web/app/sops.js b/web/app/sops.js
index 791448cf9..9c0fcb9ce 100644
--- a/web/app/sops.js
+++ b/web/app/sops.js
@@ -175,9 +175,13 @@ function genericSOPCard(w){
const tags=(w.tags||[]).filter(t=>!t.startsWith('generic-source:')).join(' · ')||'通用模板';
return `${sopCardHead(sopStatusBadge(w),'平台维护 · 与项目无关',sopBadge(`v${w.version||1}`,'neutral',''))}${sopCardTitle(w)}${escapeHTML(w.description||'平台提供的通用流程模板')}
${sopRunRequirementChips(w)}${genericRequirementChips(w)}${nodes.length}节点${agentCount}角色节点${gates}人工门禁v${w.version||1}版本
`;
}
+function sopCatalogRunState(id,metrics,live){
+ const runs=live.filter(r=>r.workflowId===id);
+ return {metrics:{...metrics.get(id),waitingRuns:runs.filter(r=>r.status==='waiting').length},liveCount:runs.length};
+}
function sopCatalogCard(w,metrics,live){
if(catalogGeneric(w))return genericSOPCard(w);
- const m=metrics.get(w.id)||{},liveCount=live.filter(r=>r.workflowId===w.id).length;
+ const {metrics:m,liveCount}=sopCatalogRunState(w.id,metrics,live);
return catalogOwned(w.projectId)?projectSOPCard(w,m,liveCount):sharedSOPCard(w,m,liveCount);
}
// --- 流程模板卡片 · ⋯ 菜单 -----------------------------------------------------
@@ -494,7 +498,10 @@ function renderSOPCatalog(){
const scopeLabel=state.sopScope==='generic'?'通用':state.sopScope==='shared'?'共享':'项目';
$('#sopOverview').innerHTML=`本项目运行${totalRuns}${workflows.length} 条${scopeLabel} LOOP
已闭环${succeeded}${totalRuns?percent(succeeded*100/totalRuns):'暂无运行'}
进行中 / 待审批${active}实时更新 · 不含中断残留
失败运行${failed}${totalRuns?percent(failed*100/totalRuns):'0%'}
Token 消耗${formatTokens(tokens)}当前项目累计
`;
const filter=$('#sopHealthFilter')?.value||'all',sort=$('#sopSort')?.value||'recent';
- if(filter!=='all')workflows=workflows.filter(w=>metricHealth(metrics.get(w.id), live.filter(r=>r.workflowId===w.id).length).key===filter);
+ if(filter!=='all')workflows=workflows.filter(w=>{
+ const {metrics:m,liveCount}=sopCatalogRunState(w.id,metrics,live);
+ return metricHealth(m,liveCount).key===filter;
+ });
workflows.sort((a,b)=>{const x=metrics.get(a.id)||{},y=metrics.get(b.id)||{};if(sort==='runs')return (y.totalRuns||0)-(x.totalRuns||0);if(sort==='closure')return (y.closureRate||0)-(x.closureRate||0);if(sort==='failures')return (y.failedRuns||0)-(x.failedRuns||0);return new Date(y.lastRunAt||0)-new Date(x.lastRunAt||0)});
$('#sopStats').innerHTML=`${workflows.length} LOOPs${workflows.filter(w=>w.status==='published').length} 已发布${new Set(workflows.map(w=>w.owner).filter(Boolean)).size} 负责人`;
const empty=state.sopScope==='generic'?'通用模板暂时不可用。它们由平台维护、与项目无关,所有项目都能复制使用。':state.sopScope==='shared'?'还没有共享给当前项目的 LOOP。把本项目模板设为共享后,其他项目会在这里看到。':'当前项目还没有 LOOP。可以新建,或从共享模板 / 通用模板复制一份。';
diff --git a/web/hui_dialog_test.js b/web/hui_dialog_test.js
index 8f4082d5e..7e7f35286 100644
--- a/web/hui_dialog_test.js
+++ b/web/hui_dialog_test.js
@@ -43,7 +43,10 @@ assert.doesNotMatch(block, /window\.(confirm|prompt|alert)\b/, 'no native dialog
assert.strictEqual($('#confirmIconWrap').className, 'confirm-icon-wrap danger');
assert.strictEqual($('#confirmIcon svg').getAttribute('data-icon'), 'trash', 'Harness icon, not an emoji');
assert.ok($('#confirmPromptWrap').hidden);
- assert.strictEqual(document.activeElement, $('#confirmOkBtn'));
+ assert.strictEqual(document.activeElement, $('#confirmCancelBtn'), 'danger confirms focus the safe action');
+ key(card, 'Enter');
+ assert.ok(open(), 'Enter outside the buttons cannot confirm a dangerous action');
+ key($('#confirmCancelBtn'), 'Tab', { shiftKey: true });
key($('#confirmOkBtn'), 'Tab');
assert.strictEqual(document.activeElement, $('#confirmCancelBtn'), 'Tab wraps inside the dialog');
diff --git a/web/i18n-en.js b/web/i18n-en.js
index a45637a32..6f5caf1e8 100644
--- a/web/i18n-en.js
+++ b/web/i18n-en.js
@@ -1163,6 +1163,8 @@ Object.assign(window.LF_I18N_EN, {
"对话处理": "Handled in chat",
"在对话里澄清和改代码": "Clarify and change code in chat",
"这条需求不使用 LOOP,在对话里澄清需求、直接改代码;定时任务不会自动认领它。": "This requirement uses no LOOP: clarify and change code in chat; scheduled jobs won't pick it up.",
+ "没有符合搜索条件的工作项": "No work items match your search",
+ "请尝试其他关键词,或清空搜索查看当前筛选下的工作项。": "Try other keywords, or clear the search to see the work items in the current filter.",
});
// 执行机器 page: static copy in index.html. runners.js renders its dynamic copy with lfT.
Object.assign(window.LF_I18N_EN, {
diff --git a/web/issues_list_test.js b/web/issues_list_test.js
index 52ac130be..c5e84f474 100644
--- a/web/issues_list_test.js
+++ b/web/issues_list_test.js
@@ -20,6 +20,15 @@ const ctx = {
vm.createContext(ctx);
vm.runInContext(slice('function issueStatusIcon(', 'function issueStatusText('), ctx);
vm.runInContext(slice('function issueKeyColumnWidth(', 'function issueTagTone('), ctx);
+vm.runInContext(slice('function issueListEmptyState(', 'function renderIssues('), ctx);
+assert.match(ctx.issueListEmptyState('missing', '')[1], /清空搜索/);
+assert.match(ctx.issueListEmptyState('missing', 'attention')[0], /搜索条件/);
+assert.match(ctx.issueListEmptyState('', 'attention')[0], /需要介入/);
+assert.match(ctx.issueListEmptyState('', 'mr')[0], /待处理 MR/);
+assert.match(ctx.issueListEmptyState('', '')[1], /GitHub/);
+const dispatchIssueSrc = slice('async function dispatchIssue(', 'async function dispatchIssueById(');
+assert.match(dispatchIssueSrc, /button\.textContent='启动 LOOP'/, 'dispatch button label resets to the LOOP wording used in index.html');
+assert.doesNotMatch(dispatchIssueSrc, /启动 SOP/);
const tones = [
[{ key: 'active', label: '编码实现' }, 'info', 'lamp'],
diff --git a/web/observability_insights_test.js b/web/observability_insights_test.js
index aa0fac2eb..f9c091634 100644
--- a/web/observability_insights_test.js
+++ b/web/observability_insights_test.js
@@ -36,6 +36,12 @@ ctx.state.analytics={runTraces:[
]};
const scoped=ctx.obsScopedView();
assert.equal(scoped.total,2);assert.equal(scoped.tokens,120);assert.equal(scoped.succeeded,2);
+const unfinished = {status:'waiting',createdAt:'2026-10-08T01:00:00Z',finishedAt:'0001-01-01T00:00:00Z'};
+const period = {from:new Date('2026-10-08T00:00:00Z'),to:new Date('2026-10-09T00:00:00Z')};
+assert.equal(ctx.obsTraceInRange(unfinished,period),true);
+assert.equal(ctx.obsTraceInRange({...unfinished,finishedAt:'2026-10-09T00:00:00Z'},period),false);
+assert.equal(ctx.obsTraceInRange({...unfinished,finishedAt:'invalid'},period),true);
+assert.equal(ctx.obsTraceInRange({finishedAt:'0001-01-01T00:00:00Z'},period),false);
assert.equal(scoped.demo.coveredRuns,1);assert.equal(scoped.demo.coveredSucceededRuns,1);
assert.equal(scoped.demo.automatedSucceededRuns,0);assert.equal(scoped.demo.averageHumanInterventions,1);
assert.equal(scoped.p95,1000,'unknown external active duration must not become wall-clock duration');
diff --git a/web/sop_catalog_test.js b/web/sop_catalog_test.js
index ee23e0cb9..651dc42ee 100644
--- a/web/sop_catalog_test.js
+++ b/web/sop_catalog_test.js
@@ -100,6 +100,12 @@ const tone = (m, live = 0) => ctx.sopHealthTone(ctx.metricHealth(m, live)).tone;
assert.strictEqual(tone({ totalRuns: 3 }, 1), 'info');
assert.ok(ctx.sopHealthBadge(ctx.metricHealth({}, 1)).includes('sop-lamp'), 'running breathes');
assert.strictEqual(tone({ totalRuns: 3, waitingRuns: 1 }), 'warn');
+const waiting = { workflowId: 'own', status: 'waiting' };
+const runningRun = { workflowId: 'own', status: 'running' };
+const staleMetrics = new Map([['own', { totalRuns: 3, waitingRuns: 0 }]]);
+assert.match(ctx.sopCatalogCard(wf('own'), staleMetrics, [waiting]), /sop-badge-label">待审批/);
+assert.match(ctx.sopCatalogCard(wf('own'), staleMetrics, [waiting, runningRun]), /sop-badge-label">待审批/);
+assert.match(ctx.sopCatalogCard(wf('own'), staleMetrics, [runningRun]), /sop-badge-label">运行中/);
assert.strictEqual(tone({ totalRuns: 3, succeededRuns: 3 }), 'success');
assert.strictEqual(tone({ totalRuns: 3, failedRuns: 1, succeededRuns: 2, lastRunStatus: 'failed' }), 'error');
assert.strictEqual(tone({ totalRuns: 2, cancelledRuns: 2 }), 'error');