${escapeHTML(item.rationale||'')}
${escapeHTML(item.target||'')} ${escapeHTML(item.action||'')} ${item.nodeId?('· '+escapeHTML(item.nodeId)):''}${patch?`预览补丁
${escapeHTML(JSON.stringify(patch,null,2))}diff --git a/docs/api/orchestration.md b/docs/api/orchestration.md index 8ded2ca50..b102e2188 100644 --- a/docs/api/orchestration.md +++ b/docs/api/orchestration.md @@ -289,7 +289,7 @@ curl -u "$AGENTFLOW_USER:$AGENTFLOW_PASS" -X POST \ ### `GET /api/runs/{runId}/eval/stream` -SSE:`thought` / `done` / `error`。 +SSE 的 `thought` 事件报告平台阶段,`stage` 依次为 `queued`、`collecting`、`evaluating`、`validating`,`text` 为阶段说明。评测完成后发送 `done`,失败时发送 `error`。 ### `POST /api/runs/{runId}/eval/apply` diff --git a/internal/httpapi/run_eval.go b/internal/httpapi/run_eval.go index cf280fca2..0d73dfc2e 100644 --- a/internal/httpapi/run_eval.go +++ b/internal/httpapi/run_eval.go @@ -190,6 +190,9 @@ func (h *runsHandlers) streamRunEval(c *gin.Context) { c.Status(http.StatusOK) for _, ev := range replay { writeSSE(c, ev.Type, ev.Payload) + if ev.Type == "done" || ev.Type == "error" { + return + } } notify := c.Request.Context().Done() for { @@ -439,6 +442,8 @@ func (h *runsHandlers) runEvalJob(ctx context.Context, job *runEvalJob, rec doma hub.mu.Unlock() }() hub := h.evalHub() + emit := func(event string, payload any) { job.publish(event, payload) } + emitRunEvalStage(emit, "queued", "评测已提交,正在等待执行") select { case hub.tokens <- struct{}{}: defer func() { <-hub.tokens }() @@ -447,8 +452,7 @@ func (h *runsHandlers) runEvalJob(ctx context.Context, job *runEvalJob, rec doma job.publish("error", map[string]string{"error": "评测排队超时"}) return } - emit := func(event string, payload any) { job.publish(event, payload) } - emit("thought", map[string]string{"kind": "thinking", "text": "正在整理本次 SOP 轨迹…"}) + emitRunEvalStage(emit, "collecting", "正在整理本次 SOP 轨迹") exec := currentRunEvalExec() if exec == nil { exec = h.executeRunEval @@ -482,19 +486,13 @@ func (h *runsHandlers) executeRunEval(ctx context.Context, rec domain.RunEvalRec facts := runeval.BuildFacts(run, catalog) rec.Facts = facts _ = h.repo.PutRunEval(rec) - emit("thought", map[string]string{"kind": "thinking", "text": "正在用 " + rec.Model + " 评测…"}) system, prompt := runeval.BuildPrompt(rec.Policy, facts) - raw, _, err := runAssistantCLI(ctx, assistantCLIRequest{Prompt: prompt, Model: rec.Model, SystemPrompt: system, UserID: user.ID, ReviewOnly: true}, user, func(ev assistantStreamEvent) { - if emit == nil { - return - } - if text := strings.TrimSpace(ev.Text); text != "" { - emit("thought", map[string]string{"kind": ev.Kind, "text": text}) - } - }) + emitRunEvalStage(emit, "evaluating", "正在用 "+rec.Model+" 分析并评分") + raw, _, err := runAssistantCLI(ctx, assistantCLIRequest{Prompt: prompt, Model: rec.Model, SystemPrompt: system, UserID: user.ID, ReviewOnly: true}, user, nil) if err != nil { return domain.RunEvalResult{}, err } + emitRunEvalStage(emit, "validating", "正在校验评分并保存报告") result, err := runeval.ParseModelResult(raw, rec.Policy) if err != nil { return domain.RunEvalResult{}, err @@ -502,6 +500,10 @@ func (h *runsHandlers) executeRunEval(ctx context.Context, rec domain.RunEvalRec return result, nil } +func emitRunEvalStage(emit func(string, any), stage, text string) { + emit("thought", map[string]string{"kind": "thinking", "stage": stage, "text": text}) +} + func (h *runsHandlers) failRunEval(rec domain.RunEvalRecord, message string) { rec.Status = domain.RunEvalFailed rec.Error = message diff --git a/internal/httpapi/run_eval_cases_test.go b/internal/httpapi/run_eval_cases_test.go index 9f4540924..80163f43b 100644 --- a/internal/httpapi/run_eval_cases_test.go +++ b/internal/httpapi/run_eval_cases_test.go @@ -7,6 +7,7 @@ import ( "errors" "net/http" "net/http/httptest" + "strings" "testing" "time" @@ -328,7 +329,7 @@ func TestRunEvalLiveStreamAndPersistenceErrors(t *testing.T) { } h := &runsHandlers{deps: &deps{repo: f.s}, evalJobs: newRunEvalHub()} job := &runEvalJob{runID: run.ID, evalID: "eval", subs: map[chan runEvalJobEvent]struct{}{}, done: make(chan struct{})} - job.publish("thought", map[string]string{"text": "replay"}) + emitRunEvalStage(job.publish, "collecting", "正在整理本次 SOP 轨迹") h.evalJobs.jobs[run.ID] = job router := gin.New() router.GET("/api/runs/:id/eval/stream", h.streamRunEval) @@ -354,6 +355,10 @@ func TestRunEvalLiveStreamAndPersistenceErrors(t *testing.T) { if rec.Code != http.StatusOK { t.Fatalf("live eval stream = %d: %s", rec.Code, rec.Body.String()) } + body := rec.Body.String() + if !strings.Contains(body, `"stage":"collecting"`) || !strings.Contains(body, "event: done") { + t.Fatalf("missing eval stage or completion: %s", body) + } case <-time.After(time.Second): t.Fatal("live eval stream did not finish") } diff --git a/internal/runeval/prompt.go b/internal/runeval/prompt.go index c7132aee7..9494ad7bb 100644 --- a/internal/runeval/prompt.go +++ b/internal/runeval/prompt.go @@ -24,10 +24,12 @@ func BuildPrompt(policy domain.RunEvalPolicy, facts domain.RunEvalFacts) (system b.WriteString("规则:\n") b.WriteString(fmt.Sprintf("- 准入线 %d 分。dimensions 每维填写 0-100 的整数,必须覆盖全部维度。总分由服务端按权重计算。\n", policy.Threshold)) b.WriteString("- findings 用中文,指向具体 nodeId 和 digest seq / event。severity 只能是 info/warn/error。\n") - b.WriteString("- summary 必须包含这次 run 的质量结论,以及如果没有可应用补丁时应该怎么改。\n") - b.WriteString("- recommendations 可为空。可应用时 action 只能是:update_node、upsert_gate、remove_gate、append_task_prompt(追加到角色 prompt)。\n") - b.WriteString("- target 为 workflow 或 agent。改节点重试用 update_node + set.maxAttempts/maxReworks/onFailure/retryStrategy。\n") - b.WriteString("- 门禁只属于角色;改门禁用 target=agent + upsert_gate/remove_gate,并给 gate.id 和 targetId。\n") + b.WriteString("- summary 用简洁中文,先给本次运行的质量结论,再说明最影响结果的问题或后续动作。不要重复罗列所有分数。\n") + b.WriteString("- recommendations 可为空。每条包含中文 title(用一句话说清改什么)和 rationale(说明依据及原因)。title 不要用操作代码。\n") + b.WriteString("- 可回写建议必须给出真实 targetId 和完整修改内容。targetId 和 nodeId 从 facts 取值。缺少可执行修改时,只给 title、rationale 和相关 nodeId。\n") + b.WriteString("- 调整节点策略:target=workflow、action=update_node、nodeId、set,set 中只放要更新的 maxAttempts/maxReworks/onFailure/retryStrategy。\n") + b.WriteString("- 追加角色任务说明:target=agent、action=append_task_prompt、text,text 填写实际要追加的完整正文。\n") + b.WriteString("- 修改角色门禁:target=agent、action=upsert_gate、gate,gate 包含 id/name/mode/required 及适用的 stage/commands/executionScope/onFailure。移除门禁用 action=remove_gate 并给出 gate.id。\n") b.WriteString("- 不要整份重写 SOP 或角色,不要改边或删节点。\n") b.WriteString("评分维度:\n") for _, dim := range policy.Dimensions { diff --git a/web/app/runs.js b/web/app/runs.js index 9c787dae3..547775fed 100644 --- a/web/app/runs.js +++ b/web/app/runs.js @@ -296,7 +296,7 @@ function renderRuns(){ function showRunDetail(id){ if(!id)return; stopQueuedRunRefresh(); - if(state.selectedRun!==id){stopLiveRun();stopPreviewPoll();state.runWorkspace=null} + if(state.selectedRun!==id){stopLiveRun();stopPreviewPoll();stopRunEvalStream();state.runWorkspace=null} state.selectedRun=id; syncRunHash(id); $('#runsView')?.classList.add('detail-open'); @@ -318,6 +318,7 @@ function showRunDetail(id){ }).catch(e=>toast(e.message,'err')); } function showRunList(){ + stopRunEvalStream(); stopLiveRun(); stopPreviewPoll(); state.selectedRun=null; @@ -330,7 +331,7 @@ function showRunList(){ } function selectRun(id,keepPages=false){ if(!id)return; - if(state.selectedRun!==id)stopPreviewPoll(); + if(state.selectedRun!==id){stopPreviewPoll();stopRunEvalStream()} if(!keepPages&&state.selectedRun!==id){state.runLogs=null;state.runTelemetry=null;state.runWorkspace=null;state.selectedRunNode=null} state.selectedRun=id; const summary=(state.data.runs||[]).find(x=>x.id===id); @@ -1342,92 +1343,288 @@ async function downloadRunLogs(runId){ toast('已导出全部 Worker 日志,可发给 AI 复盘'); }catch(e){toast(e.message,'err')} } -function defaultRunEval(){return{enabled:true,version:1,threshold:70,dimensions:[ - {id:'control',name:'控制流健康',question:'节点是否多次循环、返工或打回?',weight:25}, - {id:'latency',name:'耗时与等待',question:'单节点是否占了大部分执行时间?',weight:20}, - {id:'tools',name:'工具浪费',question:'是否有同工具连续失败或空转调用?',weight:20}, - {id:'tokens',name:'Token 效率',question:'Token 是否集中在单一节点?',weight:15}, - {id:'recovery',name:'错误恢复',question:'相同错误是否反复出现?',weight:10}, - {id:'delivery',name:'交付完整',question:'终态、产物和验证信号是否齐全?',weight:10} -]}} -function runEvalApplyable(rec){if(!rec||rec.status==='applied')return false;const action=((rec.target||'')+'.'+(rec.action||'')).replace(/^\./,'').toLowerCase();const full=rec.action&&rec.action.includes('.')?rec.action.toLowerCase():action;return ['workflow.update_node','agent.upsert_gate','agent.remove_gate','agent.append_instructions','agent.append_task_prompt'].includes(full)} -function runEvalPaneHTML(run){ - const rec=state.runEval?.runId===run.id?state.runEval:null,busy=!!state.runEvalBusy,thoughts=state.runEvalThoughts||[]; - const dims=rec?.policy?.dimensions||defaultRunEval().dimensions; - const isTerminal=['succeeded','failed','cancelled'].includes(run.status); +function defaultRunEval(){ + return {version:1,threshold:70,dimensions:[ + {id:'control',name:'控制流健康',question:'节点是否多次循环、返工或打回?',weight:25}, + {id:'latency',name:'耗时与等待',question:'单节点是否占了大部分执行时间?',weight:20}, + {id:'tools',name:'工具浪费',question:'是否有同工具连续失败或空转调用?',weight:20}, + {id:'tokens',name:'Token 效率',question:'Token 是否集中在单一节点?',weight:15}, + {id:'recovery',name:'错误恢复',question:'相同错误是否反复出现?',weight:10}, + {id:'delivery',name:'交付完整',question:'终态、产物和验证信号是否齐全?',weight:10} + ]}; +} - const heroCard=`
基于大模型深度审视全链路 Trace,交叉评估目标达成度、产物契约与门禁防线,自动生成可确认落地的规则补丁与 SOP 优化建议。
- +const RUN_EVAL_STAGES=[ + {id:'queued',label:'等待执行',description:'评测已提交,正在等待可用的执行名额。'}, + {id:'collecting',label:'整理运行轨迹',description:'正在汇总本次运行的节点、工具调用和交付记录。'}, + {id:'evaluating',label:'分析并评分',description:'正在检查流程、耗时、资源用量与交付质量。'}, + {id:'validating',label:'校验并保存',description:'正在校验评分和建议,随后保存评测报告。'} +]; +const RUN_EVAL_ACTION_LABELS={ + 'workflow.update_node':'调整节点策略', + 'agent.upsert_gate':'新增或更新角色门禁', + 'agent.remove_gate':'移除角色门禁', + 'agent.append_instructions':'追加角色任务说明', + 'agent.append_task_prompt':'追加角色任务说明' +}; +const RUN_EVAL_FAILURE_LABELS={fail:'标记失败',reject:'驳回',loop:'返工重跑',human:'转人工确认'}; +const runEvalSubmitting=new Set(); +const runEvalApplying=new Map(); +let runEvalModelChoice; +let runEvalStream; + +function runEvalAction(item){ + const target=(item.target||'').trim().toLowerCase(); + const action=(item.action||'').trim().toLowerCase(); + return target&&action&&!action.includes('.')?target+'.'+action:action; +} + +function runEvalBadge(tone,label,icon){ + return `${icon?runIconSlot(icon,12,'hui-badge-glyph'):''}${label}`; +} + +function runEvalModelLabel(model){ + if(!model)return ''; + const catalog=window.AgentFlowAssistantModels?.catalog(); + const item=catalog?.models.find(item=>item.id===model||`${item.engine}:${item.id}`===model); + return item?.name||model; +} + +function runEvalPaneHTML(run){ + const rec=state.runEval?.runId===run.id?state.runEval:null; + const policy=rec?.policy||defaultRunEval(); + const dims=policy.dimensions?.length?policy.dimensions:defaultRunEval().dimensions; + const terminal=['succeeded','failed','cancelled'].includes(run.status); + const submitting=runEvalSubmitting.has(run.id); + const running=submitting||rec?.status==='running'; + const label=rec?.status==='succeeded'?'重新评测':rec?.status==='failed'?'重试评测':'启动智能评测'; + const toolbar=`${escapeHTML(rec.error||'评测未返回结果。')}
+ ${escapeHTML(d.question)}
${runEvalProgressMessage(stream,submitting)}
+SOP 执行全部节点完成后,将汇聚完整的链路 Trace、Token 消耗分布与交付物契约,届时可在此一键启动质量与准入评测。
${escapeHTML(result.summary)}
`:''} + +本次评测没有记录诊断发现。
'} +本次评测没有提出改进建议。
'} +正在分析节点流转拓扑、工具调用频次、异常返工日志与产物交付契约
${escapeHTML(rec.error||'模型未返回结果')}请检查所选 CLI 的凭据、安装状态或网络后重新评测。
${escapeHTML(finding.message||'')}
+ ${finding.evidence?`${escapeHTML(finding.evidence)}
+ 系统将基于当前 SOP 规则策略自动对本次运行的以下 6 个核心维度进行打分与归因诊断:
${escapeHTML(d.question)}
${escapeHTML(f.message||'')}
${f.nodeId?`节点:${escapeHTML(f.nodeId)}${f.evidence?' · 证据:'+escapeHTML(f.evidence):''}`:''}本次评测未发现阻止落地的缺陷,无需额外规则补丁。
${escapeHTML(rec.result.summary)}
点击「应用此修改」可直接将治理规则回写到 SOP 流程或角色定义中
${escapeHTML(item.rationale||'')}
${escapeHTML(item.target||'')} ${escapeHTML(item.action||'')} ${item.nodeId?('· '+escapeHTML(item.nodeId)):''}${patch?`${escapeHTML(JSON.stringify(patch,null,2))}${escapeHTML(item.rationale)}
`:''} + ${item.applyError?`${escapeHTML(item.applyError)}
`:''} +${escapeHTML(text)}`:''}
+ ${commands?`${escapeHTML(commands)}`:''}
+ ${info.canApply?`${escapeHTML(t)}
`).join('')}}catch(e){}}; - es.addEventListener('thought',onThought); - const finish=async()=>{es.close();if(state.runEvalStream===es)state.runEvalStream=null;state.runEvalBusy=false;await loadRunEval(runId)}; - es.addEventListener('done',finish); - es.addEventListener('error',async ev=>{if(ev.data){try{const p=JSON.parse(ev.data);if(p.error)toast(p.error,'err')}catch(e){}}await finish()}); + attachRunEvalStream(run.id,rec.id); + }catch(e){ + if(runEvalIsCurrent(run.id))toast(e.message,'err'); + }finally{ + runEvalSubmitting.delete(run.id); + paintRunEvalPane(run.id); + } +} + +function stopRunEvalStream(){ + runEvalStream?.source.close(); + runEvalStream=null; +} + +function paintRunEvalProgress(stream){ + if(!runEvalIsCurrent(stream.runId))return; + const progress=$('#runDetail')?.querySelector('[data-run-eval-progress]'); + if(!progress)return; + progress.querySelector('.run-eval-steps').innerHTML=runEvalStepsHTML(stream.stage); + const status=progress.querySelector('[role="status"]'); + const message=runEvalProgressMessage(stream,false); + if(status.textContent!==message)status.textContent=message; + progress.querySelector('[data-reconnect-run-eval]').hidden=stream.source.readyState!==2; + hydrateRunIcons(progress); } + +function attachRunEvalStream(runId,evalId){ + if(runEvalStream?.runId===runId&&runEvalStream.evalId===evalId&&runEvalStream.source.readyState!==2)return; + stopRunEvalStream(); + const source=new EventSource(`/api/runs/${encodeURIComponent(runId)}/eval/stream`); + const stream={runId,evalId,source,stage:0,reconnecting:false}; + runEvalStream=stream; + const current=()=>runEvalStream===stream&&runEvalIsCurrent(runId)&&state.runEval?.id===evalId; + const finish=rec=>{ + if(!current())return; + stopRunEvalStream(); + state.runEval={...rec,runId}; + paintRunEvalPane(runId); + }; + source.addEventListener('thought',event=>{ + if(!current())return; + let payload; + try{payload=JSON.parse(event.data)}catch{return} + const stage=RUN_EVAL_STAGES.findIndex(step=>step.id===payload?.stage); + if(stage<=stream.stage)return; + stream.stage=stage; + paintRunEvalProgress(stream); + }); + source.addEventListener('open',()=>{ + if(!current()||!stream.reconnecting)return; + stream.reconnecting=false; + paintRunEvalProgress(stream); + }); + source.addEventListener('done',event=>{ + if(!current())return; + let rec; + try{rec=JSON.parse(event.data)}catch{} + if(rec?.id!==evalId){ + stopRunEvalStream(); + loadRunEval(runId); + return; + } + finish(rec.status==='running'?{...rec,status:'failed',error:'评测已中断,请重新评测。'}:rec); + }); + source.addEventListener('error',event=>{ + if(!current())return; + if(event.data){ + let error; + try{error=JSON.parse(event.data)?.error}catch{} + finish({...state.runEval,status:'failed',error}); + return; + } + stream.reconnecting=true; + paintRunEvalProgress(stream); + }); +} + async function applyRunEvalRec(run,recId){ - if(!await afConfirm({title:'应用评测建议',message:'确认把这条建议写进当前 SOP 或角色?不会改这次运行的历史快照。',confirmText:'确认应用'}))return; + const rec=state.runEval; + if(!runEvalIsCurrent(run.id)||rec?.runId!==run.id||rec.status!=='succeeded'|| + runEvalApplying.has(run.id)||runEvalSubmitting.has(run.id))return; + const recommendation=rec.result?.recommendations?.find(item=>item.id===recId); + if(!recommendation)return; + const info=runEvalRecommendation(run,rec,recommendation); + if(!info.canApply)return; + runEvalApplying.set(run.id,recId); + let writing=false,applied=false; try{ - const rec=await api(`/api/runs/${encodeURIComponent(run.id)}/eval/apply`,{method:'POST',body:JSON.stringify({evalId:state.runEval?.id,recommendationIds:[recId]})}); - state.runEval={...rec,runId:run.id}; - const [workflows,agents]=await Promise.all([api('/api/workflows',{silent:true}),api('/api/agents',{silent:true})]); - state.data.workflows=workflows;state.data.agents=agents; - toast('已写回当前定义','ok'); - const host=$('#runDetail'),pane=host?.querySelector('[data-run-pane="eval"]'); - if(pane){pane.innerHTML=runEvalPaneHTML(run);bindRunEvalPane(run,host)} - }catch(e){toast(e.message,'err')} + const destination=`${info.scope} · ${info.name}`; + const copyNote=info.usesCopy?'\n将写入当前项目的评测副本':''; + if(!await afConfirm({title:'应用评测建议',message:`将建议写入以下目标?\n${destination}${copyNote}`,confirmText:'确认回写'}))return; + if(!runEvalIsCurrent(run.id)||state.runEval?.id!==rec.id)return; + writing=true; + paintRunEvalPane(run.id); + const updated=await api(`/api/runs/${encodeURIComponent(run.id)}/eval/apply`,{ + method:'POST',body:JSON.stringify({evalId:rec.id,recommendationIds:[recId]}) + }); + if(runEvalIsCurrent(run.id)&&state.runEval?.id===rec.id)state.runEval={...updated,runId:run.id}; + const outcome=updated.result?.recommendations?.find(item=>item.id===recId); + applied=outcome?.status==='applied'; + if(applied)toast('建议已回写','ok'); + else if(!outcome?.applyError)toast('回写未完成,请刷新评测结果后重试。','err'); + }catch(e){ + toast(e.message,'err'); + }finally{ + runEvalApplying.delete(run.id); + if(writing)paintRunEvalPane(run.id); + } + if(!applied)return; + const [workflows,agents]=await Promise.allSettled([api('/api/workflows',{silent:true}),api('/api/agents',{silent:true})]); + if(workflows.status==='fulfilled')state.data.workflows=workflows.value; + if(agents.status==='fulfilled')state.data.agents=agents.value; + paintRunEvalPane(run.id); } + function openRunEvalTarget(target,id){ - if(target==='agent'){state.selectedAgent=id;switchView('agents');const agent=(state.data.agents||[]).find(a=>a.id===id);if(agent&&typeof openAgentWizard==='function')openAgentWizard(agent);return} - const wf=(state.data.workflows||[]).find(w=>w.id===id); - if(wf){state.workflow=clone(wf);state.selectedNode=null;switchView('flow');renderAll()} + if(target==='agent'){ + const agent=(state.data.agents||[]).find(agent=>agent.id===id); + if(!agent)return toast('暂时无法打开回写后的角色,请刷新后再试。','err'); + state.selectedAgent=id; + switchView('agents'); + if(typeof openAgentWizard==='function')openAgentWizard(agent); + return; + } + const workflow=(state.data.workflows||[]).find(workflow=>workflow.id===id); + if(!workflow)return toast('暂时无法打开回写后的 SOP,请刷新后再试。','err'); + state.workflow=clone(workflow); + state.selectedNode=null; + switchView('flow'); + renderAll(); } + let artifactPreviewRequest; function bindArtifactPreview(){ const modal=$('#artifactModal'); diff --git a/web/i18n-en.js b/web/i18n-en.js index 9803a1882..8ca530820 100644 --- a/web/i18n-en.js +++ b/web/i18n-en.js @@ -328,3 +328,85 @@ Object.assign(window.LF_I18N_EN, { "选择月份": "Select month", "选择周": "Select week", }); + +Object.assign(window.LF_I18N_EN, { + "SOP 运行评测": "SOP run evaluation", + "重试评测": "Retry evaluation", + "评测中…": "Evaluating…", + "运行结束后可评测": "Available when the run ends", + "评测会使用本次运行的完整轨迹和交付记录。": "The evaluation uses the complete run trace and delivery records.", + "评测进度": "Evaluation progress", + "整理运行轨迹": "Collect trace", + "分析并评分": "Analyze and score", + "校验并保存": "Validate and save", + "评测已提交,正在等待可用的执行名额。": "Evaluation submitted. Waiting for an execution slot.", + "正在汇总本次运行的节点、工具调用和交付记录。": "Collecting steps, tool calls, and delivery records.", + "正在检查流程、耗时、资源用量与交付质量。": "Checking flow, timing, resource usage, and delivery quality.", + "正在校验评分和建议,随后保存评测报告。": "Validating scores and recommendations before saving the report.", + "正在提交评测…": "Submitting evaluation…", + "评测连接已断开。": "The evaluation connection closed.", + "正在重新连接评测…": "Reconnecting to the evaluation…", + "重新连接": "Reconnect", + "评测已中断,请重新评测。": "Evaluation interrupted. Start a new evaluation.", + "评测失败": "Evaluation failed", + "评测未返回结果。": "The evaluation returned no result.", + "评分维度": "Scoring dimensions", + "评测结论": "Evaluation result", + "维度得分": "Dimension scores", + "准入线": "Passing score", + "已达标": "Passed", + "未达标": "Below threshold", + "评测模型": "Model", + "评测耗时": "Evaluation time", + "规则版本": "Policy version", + "Token 效率": "Token efficiency", + "错误恢复": "Error recovery", + "交付完整": "Delivery completeness", + "Token 是否集中在单一节点?": "Did one step consume most of the tokens?", + "诊断发现": "Findings", + "本次评测没有记录诊断发现。": "No findings were recorded.", + "严重问题": "Critical", + "待改进": "Needs improvement", + "观察项": "Observation", + "运行诊断": "Run finding", + "查看证据": "View evidence", + "本次评测没有提出改进建议。": "No recommendations were made.", + "优化建议": "Recommendation", + "调整节点策略": "Update step policy", + "新增或更新角色门禁": "Add or update role gate", + "移除角色门禁": "Remove role gate", + "追加角色任务说明": "Append role instructions", + "已回写": "Applied", + "回写失败": "Apply failed", + "可回写": "Ready to apply", + "仅供参考": "Advisory", + "查看并应用": "Review and apply", + "查看改动": "View change", + "执行命令": "Commands", + "将写入当前项目的评测副本": "Applies to the evaluation copy in this project.", + "打开角色": "Open role", + "打开 SOP": "Open SOP", + "应用建议": "Apply recommendation", + "正在回写…": "Applying…", + "将建议写入以下目标?": "Apply this recommendation to the following target?", + "确认回写": "Confirm and apply", + "建议已回写": "Recommendation applied", + "回写未完成,请刷新评测结果后重试。": "Apply did not complete. Refresh the evaluation and try again.", + "暂时无法打开回写后的角色,请刷新后再试。": "Could not open the updated role. Refresh and try again.", + "暂时无法打开回写后的 SOP,请刷新后再试。": "Could not open the updated SOP. Refresh and try again.", + "最大尝试次数": "Maximum attempts", + "最大返工次数": "Maximum reworks", + "失败处理": "On failure", + "标记失败": "Mark as failed", + "返工重跑": "Rework and retry", + "定向修复": "Targeted fix", + "完整重跑": "Full retry", + "门禁标识": "Gate ID", + "门禁名称": "Gate name", + "门禁类型": "Gate type", + "执行时机": "When to run", + "节点执行后": "After step execution", + "发布前": "Before publication", + "运行工作区": "Run workspace", + "是否必需": "Required", +}); diff --git a/web/index.html b/web/index.html index 76303facc..310a923ec 100644 --- a/web/index.html +++ b/web/index.html @@ -19,7 +19,7 @@ - + diff --git a/web/product-v4.css b/web/product-v4.css index d53334e2b..2cf30f1c8 100644 --- a/web/product-v4.css +++ b/web/product-v4.css @@ -1931,567 +1931,306 @@ html[data-theme="dark"] .agent-studio-v2{box-shadow:0 18px 56px rgba(0,0,0,.42), .issue-clarify-composer{margin-top:14px;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--panel)}.issue-clarify-composer textarea{width:100%;box-sizing:border-box;resize:vertical;border:0;outline:0;background:transparent;color:var(--text);font:inherit}.issue-clarify-composer>div{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px}.issue-clarify-composer span{color:var(--muted);font-size:11px} /* Clarification quality: informational only, never a gate. */ .clarify-bar{display:flex;align-items:center;gap:8px;font-size:12px}.clarify-bar>span{flex:0 0 92px;color:var(--muted)}.clarify-bar>i{flex:1;height:6px;border-radius:999px;background:var(--panel-3);overflow:hidden}.clarify-bar>i>b{display:block;height:100%;background:var(--blue)}.clarify-bar>em{flex:0 0 28px;text-align:right;font-style:normal;font-variant-numeric:tabular-nums} -/* ==================== 智能评测与架构巡检 面板 2.0 ==================== */ +/* Run evaluation */ .run-eval-section { - padding: 24px 28px 40px !important; - display: flex !important; - flex-direction: column !important; - gap: 22px !important; - background: var(--v3-surface) !important; - min-height: 520px; - box-sizing: border-box; -} - -/* 顶部 Command & Action Hero 架构卡片 */ -.run-eval-hero { - position: relative !important; - z-index: 10 !important; - display: flex; - align-items: center; - justify-content: space-between; - gap: 28px; - padding: 22px 26px; - border-radius: 16px; - background: linear-gradient(135deg, color-mix(in srgb, var(--v3-accent) 7%, var(--v3-surface)) 0%, color-mix(in srgb, #8b5cf6 6%, var(--v3-surface)) 100%); - border: 1px solid color-mix(in srgb, var(--v3-accent) 25%, var(--v3-line)); - box-shadow: 0 4px 20px -2px rgba(91, 140, 255, 0.08); -} -.run-eval-hero-info { - flex: 1 1 auto; - min-width: 0; -} -.run-eval-badge { - display: inline-flex; - align-items: center; - gap: 6px; - padding: 3px 10px; - border-radius: 999px; - background: color-mix(in srgb, var(--v3-accent) 14%, transparent); - color: var(--v3-accent-ink); - font-size: 11px; - font-weight: 700; - letter-spacing: 0.02em; - margin-bottom: 8px; -} -.run-eval-badge svg { - color: var(--v3-accent); -} -.run-eval-hero-info h2 { - margin: 0 0 6px; - font-size: 18px; - font-weight: 750; - color: var(--v3-ink); - letter-spacing: -0.01em; -} -.run-eval-hero-info p { - margin: 0 0 12px; - font-size: 12.5px; - color: var(--v3-ink-2); - line-height: 1.5; - max-width: 600px; -} -.run-eval-hero-meta { + display: grid; + gap: 16px; + max-width: 1240px; + margin: 0 auto; + padding: 16px clamp(12px, 2vw, 26px) 28px; + color: var(--hui-text); + font: 13px/1.5 var(--hui-sans); + overflow-wrap: anywhere; + container: run-eval / inline-size; +} + +.run-eval-toolbar, +.run-eval-controls, +.run-eval-panel-head, +.run-eval-row-head, +.run-eval-target, +.run-eval-live, +.run-eval-report-meta { display: flex; align-items: center; - gap: 14px; flex-wrap: wrap; - font-size: 11.5px; - color: var(--v3-ink-3); - font-weight: 550; -} -.run-eval-hero-meta span { - display: inline-flex; - align-items: center; - gap: 5px; -} -.run-eval-hero-meta .dot { - width: 5px; - height: 5px; - border-radius: 50%; - background: var(--v3-accent); + gap: 8px 12px; +} + +.run-eval-toolbar, +.run-eval-panel-head, +.run-eval-row-head, +.run-eval-live { justify-content: space-between; } + +.run-eval-toolbar h3, +.run-eval-panel h4, +.run-eval-section p { margin: 0; } + +.run-eval-toolbar h3 { font-size: 16px; font-weight: 650; } +.run-eval-controls { min-width: 0; max-width: 100%; flex-wrap: nowrap; } +.run-eval-picker { width: 310px; } +.run-eval-picker .select { + height: 34px; + min-height: 34px; + border-color: var(--hui-border-strong); + border-radius: 7px; + color: var(--hui-text); + background-color: var(--hui-surface); +} + +.run-eval-section .button { + min-height: 34px; + border-radius: 7px; + box-shadow: none; + font-size: 12px; + font-weight: 600; + white-space: nowrap; } -/* Hero 右侧操作控制卡 */ -.run-eval-hero-action-card { - position: relative !important; - z-index: 12 !important; - flex: 0 0 auto; - display: flex; - flex-direction: column; - gap: 8px; - background: var(--v3-surface); - padding: 14px 16px; - border-radius: 12px; - border: 1px solid var(--v3-line); - box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05); -} -.eval-control-label { - font-size: 11px; - font-weight: 650; - color: var(--v3-ink-3); - text-transform: uppercase; - letter-spacing: 0.03em; +.run-eval-section .button.small { min-height: 28px; } +.run-eval-section .button.primary:not(.danger) { + background: var(--hui-accent); + border-color: var(--hui-accent); + color: var(--hui-on-accent); } -.run-eval-toolbar-row { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 10px; -} -.run-eval-picker { flex: 0 1 352px; max-width: 100%; } -.run-eval-launch-btn { - height: 36px !important; - padding: 0 18px !important; - font-size: 12.5px !important; - font-weight: 700 !important; - border-radius: 8px !important; - background: linear-gradient(135deg, #4f46e5, #7c3aed) !important; - border: none !important; - color: #fff !important; - display: inline-flex !important; - align-items: center !important; - gap: 7px !important; - box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3) !important; - transition: all 0.18s ease !important; - cursor: pointer !important; -} -.run-eval-launch-btn:hover:not(:disabled) { - transform: translateY(-1px) !important; - box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45) !important; - filter: brightness(1.05) !important; -} -.run-eval-launch-btn:disabled { - opacity: 0.5 !important; - cursor: not-allowed !important; + +.run-eval-section .button.ghost { + background: var(--hui-surface); + border-color: var(--hui-border-strong); + color: var(--hui-text); } -.eval-control-hint { - font-size: 10px; - color: var(--v3-ink-3); - text-align: right; + +.run-eval-section .button.primary:hover:not(:disabled) { background: var(--hui-accent-hover); } +.run-eval-section .button.ghost:hover:not(:disabled) { background: var(--hui-soft); } +.run-eval-section .button:hover:not(:disabled) { transform: none; box-shadow: none; } +.run-eval-section .button[hidden] { display: none; } + +.run-eval-section :is(button, select, summary):focus-visible { + outline: 2px solid var(--hui-focus-ring); + outline-offset: 2px; } -/* 评测未启动时的 6 维度全景预览看板 */ -.run-eval-pre-dashboard { - display: flex; - flex-direction: column; - gap: 16px; - padding: 22px 24px; +.run-eval-panel { + min-width: 0; + padding: 18px 20px; + border: 1px solid var(--hui-border); border-radius: 14px; - border: 1px solid var(--v3-line); - background: var(--v3-surface); -} -.eval-pre-title-row { - display: flex; - align-items: center; - justify-content: space-between; - gap: 16px; - padding-bottom: 14px; - border-bottom: 1px solid var(--v3-line); + background: var(--hui-surface); + box-shadow: var(--hui-panel-shadow); } -.eval-pre-title { - display: flex; - align-items: center; + +.run-eval-panel-head h4 { font-size: 14px; font-weight: 650; } +.run-eval-panel-head h4 > span:not([data-run-icon]) { margin-inline-start: 5px; color: var(--hui-muted); font-size: 12px; font-weight: 500; } + +.run-eval-meta, +.run-eval-report-meta, +.run-eval-target { color: var(--hui-muted); font-size: 12px; } + +.run-eval-meta b, +.run-eval-report-meta b, +.run-eval-target b { color: var(--hui-secondary); font-weight: 550; } + +.run-eval-notice { display: flex; align-items: flex-start; gap: 12px; } +.run-eval-notice p { color: var(--hui-muted); margin-top: 4px; } + +.run-eval-criteria, +.run-eval-steps, +.run-eval-scores, +.run-eval-list { padding: 0; margin: 0; list-style: none; } + +.run-eval-criteria { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; + margin-top: 14px; } -.eval-pre-icon { - font-size: 22px; - line-height: 1; -} -.eval-pre-title h3 { - margin: 0; - font-size: 14px; - font-weight: 700; - color: var(--v3-ink); -} -.eval-pre-title p { - margin: 3px 0 0; - font-size: 11.5px; - color: var(--v3-ink-3); -} -.eval-policy-tag { - padding: 4px 12px; - border-radius: 999px; - background: var(--v3-soft); - border: 1px solid var(--v3-line); - font-size: 11px; - color: var(--v3-ink-2); -} -.eval-policy-tag b { - color: var(--v3-accent); + +.run-eval-criteria li { + padding: 11px 13px; + border: 1px solid var(--hui-border); + border-radius: 8px; } -.run-eval-dim-grid { +.run-eval-criteria li > div { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; } +.run-eval-criteria li > div span { color: var(--hui-muted); font-size: 12px; } +.run-eval-criteria p { margin-top: 3px; color: var(--hui-secondary); font-size: 12px; } + +.run-eval-steps { display: grid; - grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); - gap: 14px; -} -.eval-dim-card { - display: flex; - flex-direction: column; - gap: 8px; - padding: 14px 16px; - border-radius: 10px; - background: var(--v3-soft); - border: 1px solid var(--v3-line); - transition: all 0.15s ease; -} -.eval-dim-card:hover { - border-color: color-mix(in srgb, var(--v3-accent) 40%, var(--v3-line)); - transform: translateY(-1px); - background: var(--v3-surface); -} -.eval-dim-head { - display: flex; - align-items: center; - justify-content: space-between; - gap: 8px; -} -.eval-dim-name { - font-size: 13px; - font-weight: 700; - color: var(--v3-ink); -} -.eval-dim-weight { - font-size: 10px; - font-weight: 650; - padding: 1px 7px; - border-radius: 4px; - background: var(--v3-surface); - border: 1px solid var(--v3-line); - color: var(--v3-ink-3); -} -.eval-dim-q { - margin: 0; - font-size: 11.5px; - color: var(--v3-ink-2); - line-height: 1.5; -} -.eval-pre-footer-tip { - display: flex; - align-items: flex-start; - gap: 10px; - padding: 12px 16px; - border-radius: 9px; - background: color-mix(in srgb, #8b5cf6 8%, var(--v3-surface)); - border: 1px solid color-mix(in srgb, #8b5cf6 25%, transparent); - font-size: 11.5px; - color: var(--v3-ink-2); - line-height: 1.55; -} -.eval-pre-footer-tip p { - margin: 0; -} -.eval-pre-footer-tip b { - color: #7c3aed; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 12px; + margin-top: 18px; } -/* 正在评测状态 */ -.run-eval-evaluating-card { - padding: 24px 28px; - border-radius: 14px; - border: 1px solid color-mix(in srgb, var(--v3-accent) 35%, var(--v3-line)); - background: var(--v3-surface); - display: flex; - flex-direction: column; - gap: 18px; -} -.evaluating-pulse-head { - display: flex; - align-items: center; - gap: 14px; -} -.evaluating-spinner { - width: 28px; - height: 28px; - border-radius: 50%; - border: 3px solid color-mix(in srgb, var(--v3-accent) 20%, transparent); - border-top-color: var(--v3-accent); - animation: afSpin 0.8s linear infinite; - flex-shrink: 0; -} -@keyframes afSpin { - to { transform: rotate(360deg); } -} -.evaluating-pulse-head h4 { - margin: 0; - font-size: 15px; - font-weight: 700; - color: var(--v3-ink); -} -.evaluating-pulse-head p { - margin: 3px 0 0; - font-size: 12px; - color: var(--v3-ink-3); -} -.run-eval-thoughts { - display: flex; - flex-direction: column; - gap: 8px; - padding: 14px 18px; - border-radius: 10px; - background: var(--v3-soft); - border: 1px solid var(--v3-line); - max-height: 220px; - overflow-y: auto; -} -.thought-item { - display: flex; - align-items: center; - gap: 10px; +.run-eval-steps li { + position: relative; + display: grid; + justify-items: start; + gap: 7px; + color: var(--hui-muted); font-size: 12px; - color: var(--v3-ink-2); - line-height: 1.4; -} -.thought-dot { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--v3-accent); - flex-shrink: 0; + font-weight: 550; } -/* 错误卡片 */ -.run-eval-error-card { - padding: 20px 24px; - border-radius: 12px; - background: #fef2f2; - border: 1px solid #fecaca; - color: #991b1b; -} -.run-eval-error-card pre { - margin: 10px 0; - padding: 12px; - background: #ffffff; - border-radius: 8px; - font-size: 12px; - overflow: auto; -} -.error-tip { - margin: 0; - font-size: 11.5px; - color: #b91c1c; +.run-eval-steps li:not(:last-child)::after { + content: ""; + position: absolute; + inset-inline: 27px -5px; + top: 9px; + height: 1px; + background: var(--hui-border-strong); } -/* 评测结果卡片组 */ -.run-eval-result-grid { +.run-eval-step-mark { display: grid; - grid-template-columns: 1.25fr 1fr; - gap: 20px; -} -.run-eval-scorecard { - display: flex; - gap: 22px; - padding: 20px 24px; - border-radius: 14px; - background: var(--v3-surface); - border: 1px solid var(--v3-line); -} -.eval-score-ring-wrap { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - flex: 0 0 100px; - height: 100px; - border-radius: 16px; - background: var(--v3-soft); - border: 2px solid var(--v3-line); - text-align: center; -} -.eval-score-ring-wrap.good { - border-color: #10b981; - background: color-mix(in srgb, #10b981 8%, var(--v3-surface)); -} -.eval-score-ring-wrap.good .eval-score-num { color: #059669; } -.eval-score-ring-wrap.fair { - border-color: #f59e0b; - background: color-mix(in srgb, #f59e0b 8%, var(--v3-surface)); -} -.eval-score-ring-wrap.fair .eval-score-num { color: #d97706; } -.eval-score-ring-wrap.weak { - border-color: #ef4444; - background: color-mix(in srgb, #ef4444 8%, var(--v3-surface)); + place-items: center; + width: 19px; + height: 19px; + border: 1px solid var(--hui-border-strong); + border-radius: 50%; + color: var(--hui-accent-hover); } -.eval-score-ring-wrap.weak .eval-score-num { color: #dc2626; } -.eval-score-num { - font-size: 36px; - font-weight: 850; - line-height: 1; - letter-spacing: -0.02em; -} -.eval-score-label { - font-size: 11px; - font-weight: 700; - margin-top: 4px; - color: var(--v3-ink-2); +.run-eval-steps .is-complete .run-eval-step-mark { + background: var(--hui-accent-soft); + border-color: var(--hui-accent-soft); } -.eval-score-details { - flex: 1; - display: flex; - flex-direction: column; - gap: 12px; -} -.eval-score-meta { - display: flex; - align-items: center; - gap: 16px; - font-size: 11.5px; - color: var(--v3-ink-3); - padding-bottom: 8px; - border-bottom: 1px solid var(--v3-line); -} -.eval-score-meta b { - color: var(--v3-ink); -} -.eval-dims-bars { - display: flex; - flex-direction: column; - gap: 8px; -} -.clarify-bar i b.high { background: #10b981 !important; } -.clarify-bar i b.med { background: #f59e0b !important; } -.clarify-bar i b.low { background: #ef4444 !important; } -/* AI 架构师评估总述卡片 */ -.run-eval-summary-card { - padding: 20px 24px; - border-radius: 14px; - background: color-mix(in srgb, var(--v3-accent) 4%, var(--v3-surface)); - border: 1px solid color-mix(in srgb, var(--v3-accent) 22%, var(--v3-line)); - display: flex; - flex-direction: column; - gap: 8px; -} -.summary-head { - display: flex; - align-items: center; - gap: 8px; - font-size: 13px; - font-weight: 750; - color: var(--v3-ink); -} -.summary-icon { - font-size: 16px; -} -.run-eval-summary-card p { - margin: 0; - font-size: 12.5px; - color: var(--v3-ink-2); - line-height: 1.65; -} +.run-eval-steps li.is-complete::after { background: var(--hui-accent); } +.run-eval-steps li[aria-current] { color: var(--hui-text); font-weight: 650; } -/* 关键发现 */ -.run-eval-findings-box { - padding: 20px 24px; - border-radius: 14px; - background: var(--v3-surface); - border: 1px solid var(--v3-line); -} -.findings-box-head h4 { - margin: 0 0 14px; - font-size: 14px; - font-weight: 750; - color: var(--v3-ink); +.run-eval-steps li[aria-current] .run-eval-step-mark { + border: 2px solid var(--hui-accent-soft); + border-top-color: var(--hui-accent); + animation: run-eval-spin 900ms linear infinite; } -.findings-box-head h4 span { - font-weight: 500; - color: var(--v3-ink-3); - font-size: 12px; + +@keyframes run-eval-spin { to { transform: rotate(360deg); } } + +.run-eval-live { + margin-top: 16px; + padding-top: 12px; + border-top: 1px solid var(--hui-border); + color: var(--hui-secondary); } -.run-eval-findings { - list-style: none; - padding: 0; + +.run-eval-section pre { margin: 0; - display: flex; - flex-direction: column; - gap: 10px; -} -.finding-item { - padding: 12px 16px; - border-radius: 9px; - background: var(--v3-soft); - border: 1px solid var(--v3-line); - display: flex; - flex-direction: column; - gap: 5px; + padding: 10px 12px; + max-height: 220px; + overflow: auto; + border-radius: 7px; + background: var(--hui-soft); + color: var(--hui-text); + font: 12px/1.6 var(--hui-sans); + white-space: pre-wrap; + overflow-wrap: anywhere; } -.finding-head { + +.run-eval-failed h4 { display: flex; align-items: center; gap: 7px; color: var(--hui-error); } +.run-eval-failed pre { margin-top: 10px; } + +.run-eval-report-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; } + +.run-eval-verdict { display: flex; flex-direction: column; } +.run-eval-score { display: flex; - align-items: center; + align-items: baseline; + flex-wrap: wrap; + gap: 4px; + margin: 8px 0 12px; + color: var(--hui-muted); + font-variant-numeric: tabular-nums; +} + +.run-eval-score strong { color: var(--hui-text); font-size: 44px; line-height: 1.1; font-weight: 650; letter-spacing: -.03em; } +.run-eval-score-threshold { margin-inline-start: 8px; padding-inline-start: 12px; border-inline-start: 1px solid var(--hui-border-strong); font-size: 12px; } +.run-eval-score-threshold b { color: var(--hui-text); } + +.run-eval-summary { color: var(--hui-text); font-size: 14px; line-height: 1.65; white-space: pre-wrap; } +.run-eval-report-meta { margin-top: auto; padding-top: 14px; } + +.run-eval-scores { display: grid; gap: 9px; margin-top: 14px; } +.run-eval-scores li { display: grid; grid-template-columns: minmax(72px, 8em) minmax(20px, 1fr) 3ch; gap: 9px; align-items: center; font-size: 12px; } +.run-eval-scores b { text-align: end; font-variant-numeric: tabular-nums; } +.run-eval-bar { height: 5px; border-radius: 999px; overflow: hidden; background: var(--hui-soft); } +.run-eval-bar i { display: block; height: 100%; border-radius: inherit; background: var(--hui-accent); } + +.run-eval-list-panel { padding-block: 0; } +.run-eval-list-panel > .run-eval-panel-head { min-height: 50px; padding: 10px 0; } + +.run-eval-row { display: grid; gap: 6px; padding: 12px 0 14px; border-top: 1px solid var(--hui-border); } +.run-eval-row-head > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; } +.run-eval-row-head > b, +.run-eval-row-head > div b { font-size: 13px; font-weight: 650; } +.run-eval-row-head .hui-badge { flex-shrink: 0; } +.run-eval-node { color: var(--hui-muted); font-size: 12px; } +.run-eval-node::before { content: "·"; padding-inline: 0 6px; } +.run-eval-row p { color: var(--hui-secondary); white-space: pre-wrap; line-height: 1.65; } +.run-eval-empty { padding: 0 0 16px; color: var(--hui-muted); } + +.run-eval-row-actions { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + align-items: start; gap: 8px; } -.finding-badge { - padding: 2px 7px; + +.run-eval-row-actions > button { grid-column: 2; display: inline-flex; align-items: center; gap: 4px; } +.run-eval-row-actions:empty { display: none; } + +.run-eval-disclosure summary { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 4px 4px 4px 0; + list-style: none; border-radius: 4px; - font-size: 10.5px; - font-weight: 700; -} -.finding-badge.error { - background: #fef2f2; - color: #dc2626; - border: 1px solid #fecaca; -} -.finding-badge.warn { - background: #fffbeb; - color: #d97706; - border: 1px solid #fde68a; -} -.finding-badge.info { - background: #eff6ff; - color: #2563eb; - border: 1px solid #bfdbfe; -} -.finding-dim { - font-size: 12.5px; - color: var(--v3-ink); -} -.finding-msg { - margin: 0; + color: var(--hui-accent-hover); font-size: 12px; - color: var(--v3-ink-2); - line-height: 1.5; -} -.finding-evidence { - font-size: 11px; - color: var(--v3-ink-3); -} - -/* 改进建议 */ -.run-eval-recs-box { - padding: 20px 24px; - border-radius: 14px; - background: var(--v3-surface); - border: 1px solid var(--v3-line); -} -.recs-head h4 { - margin: 0; - font-size: 14px; - font-weight: 750; - color: var(--v3-ink); -} -.recs-head p { - margin: 3px 0 14px; - font-size: 11.5px; - color: var(--v3-ink-3); -} -.recs-list { - display: flex; - flex-direction: column; - gap: 12px; + font-weight: 550; + cursor: pointer; } +.run-eval-disclosure summary::-webkit-details-marker { display: none; } +.run-eval-disclosure[open] summary [data-run-icon] { transform: rotate(90deg); } +.run-eval-disclosure > pre { margin-top: 4px; font-family: var(--hui-mono); } -@media(max-width: 960px) { - .run-eval-hero { - flex-direction: column; - align-items: stretch; - } - .run-eval-hero-action-card { - width: 100%; - } - .run-eval-result-grid { - grid-template-columns: 1fr; - } +.run-eval-patch { + margin-top: 4px; + padding: 10px; + border: 1px solid var(--hui-border); + border-radius: 8px; + background: var(--hui-canvas); +} +.run-eval-patch dl { margin: 0; display: grid; gap: 4px; } +.run-eval-patch dl div { display: grid; grid-template-columns: minmax(72px, 9em) 1fr; gap: 8px; } +.run-eval-patch dt, +.run-eval-patch-label { color: var(--hui-muted); font-size: 12px; } +.run-eval-patch dd { margin: 0; min-width: 0; } +.run-eval-patch-label { margin-block: 8px 4px; } +.run-eval-patch-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; } +.run-eval-patch-actions > span { margin-inline-end: auto; color: var(--hui-muted); font-size: 12px; } +.run-eval-row .run-eval-apply-error { color: var(--hui-error); } + +@container run-eval (max-width: 690px) { + .run-eval-report-grid { grid-template-columns: minmax(0, 1fr); } + .run-eval-criteria { grid-template-columns: repeat(2, minmax(0, 1fr)); } +} + +@container run-eval (max-width: 460px) { + .run-eval-panel { padding-inline: 14px; } + .run-eval-controls { width: 100%; flex-wrap: wrap; } + .run-eval-picker { width: min(310px, 100%); } + .run-eval-criteria, + .run-eval-steps { grid-template-columns: minmax(0, 1fr); } + .run-eval-steps li { display: flex; align-items: center; } + .run-eval-steps li:not(:last-child)::after { inset-inline: 9px auto; top: 22px; width: 1px; height: 6px; } + .run-eval-row-actions { display: flex; flex-direction: column; align-items: flex-start; } + .run-eval-row-actions > details { width: 100%; } +} + +@media (prefers-reduced-motion: reduce), (forced-colors: active) { + .run-eval-steps li[aria-current] .run-eval-step-mark { animation: none; } } .clarify-history{margin-top:12px;border:1px solid var(--line);border-radius:12px;background:var(--panel)} .clarify-history>summary{padding:11px 14px;color:var(--muted);font-size:12px;cursor:pointer;list-style:none} diff --git a/web/run_queue_test.js b/web/run_queue_test.js index ca4c0b741..78fd15264 100644 --- a/web/run_queue_test.js +++ b/web/run_queue_test.js @@ -84,8 +84,23 @@ async function main() { assert.equal(race.state.runStream,streamB);assert.deepEqual(raceCalls,[]);assert.equal(race.state.activeRun.id,'b');assert.equal(race.state.data.runs[0].status,'queued'); for (const name of ['showRunDetail','selectRun']) { - const streams=[],context={state:{data:{runs:[]}},$:()=>({hidden:false,classList:{add:()=>{}},dataset:{}}),document:{querySelector:()=>({setAttribute:()=>{}})},stopQueuedRunRefresh:()=>{},stopLiveRun:()=>{},stopPreviewPoll:()=>{},syncRunHash:()=>{},api:async()=>({id:'r',status:'queued'}),shouldPatchRunLive:()=>false,renderRunDetail:()=>{},renderRuns:()=>{},startLiveRun:id=>streams.push(id),toast:()=>{}}; - load(context,['loadRunMachineMetadata',name]);context[name]('r');await flush();assert.deepEqual(streams,['r'],name); + const streams=[]; + let evaluationClosed=false; + const context={ + state:{selectedRun:'previous',data:{runs:[]}}, + runEvalStream:{source:{close:()=>{evaluationClosed=true}}}, + $:()=>({hidden:false,classList:{add:()=>{}},dataset:{}}), + document:{querySelector:()=>({setAttribute:()=>{}})}, + stopQueuedRunRefresh:()=>{},stopLiveRun:()=>{},stopPreviewPoll:()=>{},syncRunHash:()=>{}, + api:async()=>({id:'r',status:'queued'}),shouldPatchRunLive:()=>false, + renderRunDetail:()=>{},renderRuns:()=>{},startLiveRun:id=>streams.push(id),toast:()=>{}, + }; + load(context,['loadRunMachineMetadata','stopRunEvalStream',name]); + context[name]('r'); + await flush(); + assert.deepEqual(streams,['r'],name); + assert.equal(evaluationClosed,true,name); + assert.equal(context.runEvalStream,null,name); } const liveState={selectedRun:'r',data:{runs:[]}},intervals=new Map();let timer=0,status='queued',applied=[]; const polling={state:liveState,api:async()=>({id:'r',status}),setInterval:fn=>{intervals.set(++timer,fn);return timer},clearInterval:id=>intervals.delete(id),patchCachedRun:()=>{},applyRunPayload:r=>applied.push(r.status),refreshRunPagesDelta:async()=>{},renderRuns:()=>{},renderIssueDetailTab:()=>{}}; diff --git a/web/syntax_test.go b/web/syntax_test.go index 9bdd1ab51..c320de06a 100644 --- a/web/syntax_test.go +++ b/web/syntax_test.go @@ -1099,8 +1099,17 @@ func TestRequirementDirectCreateUI(t *testing.T) { t.Fatalf("requirement composer behavior is missing %q", want) } } + composerJS, err := os.ReadFile("app/composer.js") + if err != nil { + t.Fatal(err) + } + for _, gone := range []string{`查看完整度详情`, `准入线`, `没有固定轮数`} { + if strings.Contains(composer, gone) || strings.Contains(string(composerJS), gone) { + t.Fatalf("requirement composer must not keep %q", gone) + } + } for _, gone := range []string{ - `查看完整度详情`, `准入线`, `composerAssessmentView`, `invalidateRequirementAnalysis`, `没有固定轮数`, `composerCreateReady`, `setComposerRetryMode`, `composerClarifyRetry`, `state.reqCreateMode`, `createIssueDirect`, `setChatCreateEnabled`, `syncReqComposerLayout`, + `composerAssessmentView`, `invalidateRequirementAnalysis`, `composerCreateReady`, `setComposerRetryMode`, `composerClarifyRetry`, `state.reqCreateMode`, `createIssueDirect`, `setChatCreateEnabled`, `syncReqComposerLayout`, `function goReqStep(`, `function startReqClarify(`, `function sendChatClarify(`, `function pickReqOption(`, `function submitReqAnswers(`, `function reclarifyRequirement(`, `'/api/chat-clarify'`, } { if strings.Contains(code, gone) { diff --git a/webtest/tests/run-evaluation.test.mjs b/webtest/tests/run-evaluation.test.mjs new file mode 100644 index 000000000..bfff15953 --- /dev/null +++ b/webtest/tests/run-evaluation.test.mjs @@ -0,0 +1,152 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { loadApp } from '../lib/load-app.mjs'; + +const run = { + id: 'run-eval', status: 'succeeded', workflowId: 'sop', + executionContext: { projectId: 'project' }, + workflowSnapshot: { + id: 'sop', name: '交付流程', + nodes: [{ id: 'verify', name: '验证交付', agentId: 'reviewer' }], + }, +}; + +function mount(app, selected = run) { + app.evaluate(`{ + const run = ${JSON.stringify(selected)}; + state.selectedRun = run.id; + state.activeRun = run; + const host = document.querySelector('#runDetail'); + host.innerHTML = '