Repository navigation
fix(sop): publish new workflows as v1 and label auto layout #1320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -473,6 +473,14 @@ func workflowNeedsPublish(v domain.WorkflowDefinition) bool { | |
| return v.Status != "published" || workflowPublishedRevision(v) != v.Revision | ||
| } | ||
|
|
||
| func nextWorkflowVersion(v domain.WorkflowDefinition) int { | ||
| // Newly saved drafts already carry version 1 for compatibility. | ||
| if v.Version < 1 || (v.Version == 1 && workflowPublishedRevision(v) == 0) { | ||
| return 1 | ||
| } | ||
| return v.Version + 1 | ||
| } | ||
|
|
||
| // PublishWorkflow is idempotent until the saved definition changes. | ||
| func (r *CatalogRepo) PublishWorkflow(id string) (domain.WorkflowDefinition, error) { | ||
| var published domain.WorkflowDefinition | ||
|
|
@@ -498,8 +506,8 @@ func (r *CatalogRepo) publishStoredWorkflow(id string) (domain.WorkflowDefinitio | |
| if !workflowNeedsPublish(v) { | ||
| return v, nil | ||
| } | ||
| v.Version = nextWorkflowVersion(v) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] 首发前的试跑会计入正式 v1 的统计 草稿在首发前可以试跑,这些运行的快照与首发后的快照现在都携带 |
||
| v.Status = "published" | ||
| v.Version++ | ||
| if err := r.putWorkflow(v, true); err != nil { | ||
| return domain.WorkflowDefinition{}, err | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,7 +145,7 @@ html[data-theme="dark"] #flowView{ | |
| #flowView .fd-body{position:relative;flex:1;display:flex;min-height:0;min-width:0} | ||
|
|
||
| /* palette */ | ||
| #flowView .fd-palette{position:relative;z-index:12;width:256px;flex:none;display:flex;flex-direction:column;min-height:0;border-right:1px solid var(--fd-line);background:var(--fd-surface);transition:width .2s var(--fd-ease)} | ||
| #flowView .fd-palette{position:relative;z-index:12;width:min(256px,38%);flex:none;display:flex;flex-direction:column;min-height:0;border-right:1px solid var(--fd-line);background:var(--fd-surface);transition:width .2s var(--fd-ease)} | ||
| #flowView .fd-pal-head{display:flex;align-items:center;gap:6px;padding:12px 12px 6px} | ||
| #flowView .fd-pal-body{flex:1;overflow:auto;padding:2px 8px 12px} | ||
| #flowView .fd-pal-group+.fd-pal-group{margin-top:6px} | ||
|
|
@@ -280,7 +280,8 @@ html[data-theme="dark"] #flowView{ | |
| /* floating chrome */ | ||
| #flowView .fd-chrome{position:absolute;z-index:15;display:flex;align-items:center;gap:2px;padding:4px;border:1px solid var(--fd-line);border-radius:11px;background:var(--fd-glass);-webkit-backdrop-filter:blur(12px) saturate(1.4);backdrop-filter:blur(12px) saturate(1.4);box-shadow:var(--fd-shadow);white-space:nowrap;transition:right .24s var(--fd-ease),left .24s var(--fd-ease),opacity .2s} | ||
| #flowView .fd-tr{top:12px;right:12px} | ||
| #flowView .fd-bl{left:12px;bottom:12px} | ||
| #flowView .fd-bl{left:12px;bottom:12px;max-width:calc(100% - 24px);flex-wrap:wrap} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] 节点属性面板会遮住「自动整理」按钮 在 Chrome 的 1060 px 和 1080 px 视口打开节点属性时,工具栏仍按整个画布的宽度排版。按钮加上文字后,点击按钮中央会命中属性面板。基线在相同条件下可点击。工具栏换行需要按扣除右侧面板后的可用宽度计算。 |
||
| #flowView #canvasArrange{height:30px;padding:0 8px} | ||
| #flowView .fd-sep{width:1px;height:18px;margin:0 4px;background:var(--fd-line-2);flex:none} | ||
| #flowView .fd-zoomv{min-width:46px;height:30px;padding:0 4px;border:0;border-radius:7px;background:none;color:var(--fd-ink-2);font:500 12px/1 ui-monospace,SFMono-Regular,Menlo,monospace;cursor:pointer} | ||
| #flowView .fd-zoomv:hover{background:var(--fd-hover)} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,23 @@ async function importMcpJsonFile(e){ | |
| }catch(err){toast(err.message||'JSON 无效')} | ||
| } | ||
| function closeRevisionHistory(){$('#revisionModal')?.classList.remove('open');state.revisionSelected=null} | ||
| function revisionPayload(rev){ | ||
| if(typeof rev.payload!=='string')return rev.payload; | ||
| try{return JSON.parse(rev.payload)}catch{return {}} | ||
| } | ||
| async function openRevisionHistory(kind,id,name){ | ||
| if(!id)return toast('先保存再看历史'); | ||
| state.revisionKind=kind;state.revisionEntity=id;state.revisionSelected=null; | ||
| $('#revisionTitle').textContent=`${name||id} 的版本历史`; | ||
| const items=await api(kind==='workflow'?`/api/workflows/${encodeURIComponent(id)}/revisions`:`/api/agents/${encodeURIComponent(id)}/revisions`); | ||
| state.revisionItems=items||[]; | ||
| $('#revisionList').innerHTML=items.length?items.map(r=>`<button type="button" class="revision-item" data-rev="${escapeHTML(r.id)}"><b>${escapeHTML(r.summary||r.name)}</b><small>v${r.version}${r.revision?` · #${r.revision}`:''} · ${new Date(r.createdAt).toLocaleString()}</small></button>`).join(''):'<p class="prop-hint">还没有历史。保存一次修改后才会留下上一版。</p>'; | ||
| $('#revisionList').innerHTML=items.length?items.map(r=>{ | ||
| const workflow=kind==='workflow'&&revisionPayload(r); | ||
| const initialDraft=workflow?.status&&!workflowVersionLabel(workflow); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] 版本历史会把已归档的快照显示成草稿 流程设置允许把未发布的 SOP 直接归档。后续保存写入历史的 |
||
| const summary=initialDraft?r.name:r.summary||r.name; | ||
| const version=initialDraft?lfT('草稿','Draft'):`v${r.version}`; | ||
| return `<button type="button" class="revision-item" data-rev="${escapeHTML(r.id)}"><b>${escapeHTML(summary)}</b><small>${version}${r.revision?` · #${r.revision}`:''} · ${new Date(r.createdAt).toLocaleString()}</small></button>`; | ||
| }).join(''):'<p class="prop-hint">还没有历史。保存一次修改后才会留下上一版。</p>'; | ||
| $('#revisionDiff').textContent='选择一个历史版本,查看和当前的差异。'; | ||
| $('#revisionRestore').disabled=true; | ||
| $('#revisionList').onclick=ev=>{const btn=ev.target.closest('[data-rev]');if(btn)showRevisionDiff(btn.dataset.rev)}; | ||
|
|
@@ -28,7 +38,7 @@ function showRevisionDiff(id){ | |
| let current={}; | ||
| if(state.revisionKind==='workflow')current=state.workflow||{}; | ||
| else current=(state.data.agents||[]).find(a=>a.id===state.revisionEntity)||{}; | ||
| let prev=rev.payload;if(typeof prev==='string'){try{prev=JSON.parse(prev)}catch{prev={}}} | ||
| const prev=revisionPayload(rev); | ||
| $('#revisionDiff').textContent=lineDiff(JSON.stringify(prev,null,2),JSON.stringify(current,null,2)); | ||
| $('#revisionRestore').disabled=false; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] 评测副本的首次发布会跳过 v1
应用评测建议时,
ensureProjectWorkflow创建的项目副本会保留源 SOP 的Version。从 v4 生成的草稿副本没有发布记录,本地走发布接口验证,首次发布返回了 v5。首发逻辑需要覆盖这类已经保存的未发布副本。