From 523942e6de7c9da58963a44e585b93682cb94e11 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 03:39:39 +0000 Subject: [PATCH 1/6] Fix scheduler first runs and walkthrough UI regressions Co-Authored-By: Claude Code --- internal/schedule/schedule_cases_test.go | 7 ++++++- internal/schedule/service.go | 18 ++++++++++-------- internal/schedule/service_test.go | 6 ++++-- web/app.js | 5 +++-- web/app/issues.js | 10 ++++++++-- web/hui_dialog_test.js | 5 ++++- web/issues_list_test.js | 6 ++++++ 7 files changed, 41 insertions(+), 16 deletions(-) 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 fc902df09..3d84f4ac4 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 e3239f86c..1b97bd2a5 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 e5d60edca..71cd9dc5a 100644 --- a/web/app.js +++ b/web/app.js @@ -218,6 +218,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?.(); @@ -267,7 +268,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; @@ -288,7 +289,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/issues.js b/web/app/issues.js index daf565a5b..5360f62b7 100644 --- a/web/app/issues.js +++ b/web/app/issues.js @@ -133,6 +133,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(); @@ -154,8 +161,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=`
${state.issueSelectionMode?`
${issueSelectAllCheckbox('全选本页可删除的需求')}
`:''}编号标题来源责任人仓库优先级关联 SOP当前环节进度操作
${paged.items.map(issueRow).join('')||`
${huiIcon('search')}${emptyTitle}

${emptyHint}

`}
${pager}
`; 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/issues_list_test.js b/web/issues_list_test.js index 52ac130be..2e5538abb 100644 --- a/web/issues_list_test.js +++ b/web/issues_list_test.js @@ -20,6 +20,12 @@ 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 tones = [ [{ key: 'active', label: '编码实现' }, 'info', 'lamp'], From e09e25de01c2520e171c99e8c3d6574f4ae60807 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 03:46:59 +0000 Subject: [PATCH 2/6] Show pending approval on active SOP cards Co-Authored-By: Claude Code --- web/app/dashboards.js | 2 +- web/app/sops.js | 11 +++++++++-- web/sop_catalog_test.js | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) 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/sops.js b/web/app/sops.js index 33c8886cb..5e62b869a 100644 --- a/web/app/sops.js +++ b/web/app/sops.js @@ -172,9 +172,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}版本
${escapeHTML(w.owner||'平台')}${escapeHTML(tags)}${primary}${sopCardMoreButton(w)}
`; } +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} SOP
已闭环${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} SOPs${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'?'还没有共享给当前项目的 SOP。把本项目模板设为共享后,其他项目会在这里看到。':'当前项目还没有 SOP。可以新建,或从共享模板 / 通用模板复制一份。'; 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'); From a5d7879b40e6b4bd63c9293991fbdf6d9bea8081 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 03:50:49 +0000 Subject: [PATCH 3/6] Return to issue details after saving edits Co-Authored-By: Claude Code --- web/app/issue-drawer.js | 2 +- web/app/issues.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/app/issue-drawer.js b/web/app/issue-drawer.js index d414e67c6..2dda349d2 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 5360f62b7..c06b0145c 100644 --- a/web/app/issues.js +++ b/web/app/issues.js @@ -484,7 +484,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(''); @@ -702,7 +704,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)?'该需求已有进行中的任务,确定额外发起一次重新运行吗?':'该需求已经处理过,确定整条 SOP 重新运行吗?',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='启动 SOP'}} 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('请先确认澄清结论后再触发 SOP')} const sandboxStatus=sopSandboxPendingText(workflowId||issue?.workflowId||defaultSOPForIssue(issue)); From 8030a61bf58320e0f7e6b7527bbfdc516fdf1e32 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 03:56:20 +0000 Subject: [PATCH 4/6] Include unfinished runs in period usage totals Co-Authored-By: Claude Code --- web/app/observability.js | 9 ++++++--- web/observability_insights_test.js | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/app/observability.js b/web/app/observability.js index 47279283f..a53906c20 100644 --- a/web/app/observability.js +++ b/web/app/observability.js @@ -131,9 +131,12 @@ function obsStepPeriodKey(key,grain,delta){ return day.toISOString().slice(0,10); } function obsTraceEventAt(t){ - const raw=t?.finishedAt||t?.createdAt; - const at=raw?new Date(raw):null; - return at&&!Number.isNaN(at.getTime())?at:null; + for(const raw of [t?.finishedAt,t?.createdAt]){ + if(!raw||String(raw).startsWith('0001-01-01T00:00:00'))continue; + const at=new Date(raw); + if(Number.isFinite(at.getTime()))return at; + } + return null; } function obsTraceInRange(t,range){ if(!range)return true; diff --git a/web/observability_insights_test.js b/web/observability_insights_test.js index 25d60b222..2ab7e4944 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'); From 04acb124ded58b6f5875866e72f61edb9cb2c8ee Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 04:31:10 +0000 Subject: [PATCH 5/6] fix(web): add English strings for new issue list empty state issueListEmptyState() was added in this PR but web/i18n-en.js was not updated with the two new keys. The search-not-found empty state now shows translated text in English UI. Co-Authored-By: Claude Code --- web/i18n-en.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/i18n-en.js b/web/i18n-en.js index e7a99c4d4..fbe28dde0 100644 --- a/web/i18n-en.js +++ b/web/i18n-en.js @@ -533,4 +533,6 @@ 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.", }); From cdba90a451c89b4c36ee3413d054f4c996bd6320 Mon Sep 17 00:00:00 2001 From: roberttwang Date: Thu, 26 Nov 2026 05:10:34 +0000 Subject: [PATCH 6/6] fix(web): reset the issue dispatch button to the LOOP label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After dispatching from the issue editor the button text was reset to '启动 SOP', reverting the #1286 rename while index.html labels it '启动 LOOP'. Restore the LOOP wording and assert it in issues_list_test. Co-Authored-By: Claude Code --- web/app/issues.js | 2 +- web/issues_list_test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/app/issues.js b/web/app/issues.js index 22c81e30a..bbe05269a 100644 --- a/web/app/issues.js +++ b/web/app/issues.js @@ -717,7 +717,7 @@ async function saveIssue(e){ 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='启动 SOP'}} +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)); const dismiss=sandboxStatus?toast(sandboxStatus,'info',0):null; diff --git a/web/issues_list_test.js b/web/issues_list_test.js index 2e5538abb..c5e84f474 100644 --- a/web/issues_list_test.js +++ b/web/issues_list_test.js @@ -26,6 +26,9 @@ 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'],