nx-kv 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/web/frontend/components/md/attach-modal.jsx +3 -2
- package/src/web/frontend/components/md/composer-panel.jsx +164 -1
- package/src/web/frontend/page/dir/task.jsx +3 -2
- package/src/web/public/assets/{Introduction-EDM3eqXe.js → Introduction-ChO8BjCo.js} +1 -1
- package/src/web/public/assets/{bar-P_ky_qA9.js → bar-DIcUTKGF.js} +1 -1
- package/src/web/public/assets/{cloud-Bl7EJoQ_.js → cloud-B_Zurubz.js} +1 -1
- package/src/web/public/assets/composer-launch-DFD4_RlG.js +1 -0
- package/src/web/public/assets/composer-panel-C_TqQ6UQ.js +1 -0
- package/src/web/public/assets/{dag-NSMkkWrt.js → dag-cynQzBs4.js} +1 -1
- package/src/web/public/assets/{dir-ClkYDLql.js → dir-BZ_B_vda.js} +1 -1
- package/src/web/public/assets/{group-DqBGGAEA.js → group-plgfiTpl.js} +1 -1
- package/src/web/public/assets/{index-CLsU9Lad.js → index-BmANFdAR.js} +2 -2
- package/src/web/public/assets/{md-panes-DMs3KANu.js → md-panes-sRhT7DNc.js} +2 -2
- package/src/web/public/assets/{overview-CFGcpG_m.js → overview-BMItQoK-.js} +1 -1
- package/src/web/public/assets/{progress-B0fipz7a.js → progress-BJaEAKUn.js} +1 -1
- package/src/web/public/assets/{refs-DLThlN46.js → refs-_aYVi9zo.js} +1 -1
- package/src/web/public/assets/{repos-BygXrPSp.js → repos-_KRfq-H_.js} +1 -1
- package/src/web/public/assets/{route-crumb-Cyesq6KK.js → route-crumb-DHYbpsO8.js} +1 -1
- package/src/web/public/assets/{settings-KHM4F3Sy.js → settings-3UzVUmIA.js} +1 -1
- package/src/web/public/assets/{status-tag-Bts7p2cp.js → status-tag-CdoKlRNG.js} +1 -1
- package/src/web/public/assets/{task-BoJGRYpA.js → task-DoX0agEw.js} +7 -7
- package/src/web/public/assets/{templates-CdPNcDxd.js → templates-MVbMU84b.js} +1 -1
- package/src/web/public/assets/{tool-bar-Bh3XH8MU.js → tool-bar-BwMNTrR1.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/composer-launch-DOB0Hm0B.js +0 -1
- package/src/web/public/assets/composer-panel-DCV7JGNt.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{S as e,_ as t,d as n,f as r,g as i,l as a,p as o,u as s,v as c,y as l}from"./task-status-BP6y8MVu.js";import{h as u,n as d}from"./md-parse-C2bDc3IZ.js";import{o as f,r as p,t as m}from"./board-view-t8CKtq17.js";import{O as h,T as g,_,a as v,b as y,g as b,i as x,k as S,m as C,o as w,p as T,r as E,s as D,u as O,y as k}from"./index-CLsU9Lad.js";import{t as A}from"./route-crumb-Cyesq6KK.js";import{t as j}from"./graph-DM-zDRdL.js";import{n as ee,r as te,t as M}from"./reopen-text-BylkngqC.js";import{t as N}from"./Introduction-EDM3eqXe.js";import{t as ne}from"./bar-P_ky_qA9.js";var P=e(l(),1),F=c();function I(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function re({isGlobal:e,topic:t,repo:r=null,model:i=null,tasks:a=[],taskCount:s=0,pendingCount:c=0,page:l=0,pageCount:d=1,onPage:f,onNew:p,onOpenTask:m,onDeleteTask:h,onDeleteTasks:g,onCancelTasks:_,onCompleteTasks:v,onReopenTask:x,onTplMenu:S,onImport:C,onProg:w,onMoveTask:T,onOpenDag:E,onOpenFlow:D,onToggleGate:O,downstreamOf:j,onDeleted:ee,onRefs:te,deletedCount:M=0}){let re=e?`全局池`:t?.name||`目录`,L=e?`共享池(无固定目录)`:t?.cwd||`—`,R=String(t?.summary||``).trim(),z=(0,P.useRef)(null),[ie,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(()=>new Set);(0,P.useEffect)(()=>{W(new Set)},[l]);let G=a.map(e=>Number(e.id)),K=G.length>0&&G.every(e=>U.has(e)),q=a.filter(e=>U.has(Number(e.id))),J=q.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ae=e=>{let t=Number(e);W(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},oe=()=>{W(e=>{let t=new Set(e);return K?G.forEach(e=>t.delete(e)):G.forEach(e=>t.add(e)),t})},Y=async e=>{let t=[...U],n=e===`cancel`?_:e===`complete`?v:g;t.length&&n&&await n(t)&&W(new Set)},X=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,Z=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},se=(e,t)=>{z.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),B(Number(t.id))},Q=(e,t)=>{z.current&&X(t)&&Number(t.id)!==z.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,H({id:Number(t.id),zone:Z(e,e.currentTarget)}))},ce=e=>{e.currentTarget.contains(e.relatedTarget)||H(null)},le=(e,t)=>{e.preventDefault();let n=Z(e,e.currentTarget),r=z.current;z.current=null,B(null),H(null),r&&X(t)&&Number(t.id)!==r.id&&T&&T({id:r.id},t.id,n)},$=()=>{z.current=null,B(null),H(null)};return(0,F.jsxs)(`div`,{className:`mdw-land`,children:[(0,F.jsx)(A,{}),(0,F.jsxs)(`div`,{className:`mdw-land-head`,children:[(0,F.jsx)(`div`,{className:`mdw-land-name`,children:re}),(0,F.jsx)(`div`,{className:`mdw-land-path mono`,title:L,children:L}),R?(0,F.jsxs)(`div`,{className:`mdw-land-status-line`,title:R,children:[(0,F.jsx)(`span`,{className:`mdw-land-lab`,children:`现状`}),(0,F.jsx)(`span`,{className:`mdw-land-status`,children:R})]}):null]}),!e&&r?(0,F.jsx)(N,{kind:`repo`,owner:r,model:i}):null,(0,F.jsxs)(`div`,{className:`mdw-land-acts`,children:[(0,F.jsx)(ne,{kind:`dir`,className:`mdw-land-ta`,labels:{more:M>0?`更多 (${M})`:`更多`,deleted:M>0?`已删除任务(${M})`:`已删除任务`},titles:{tpl:`按模板新建一页`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,orch:`打开可视化编排面板`,more:M>0?`更多操作(含 ${M} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{tpl:()=>(0,F.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`按模板新建一页`,"aria-haspopup":`menu`,onClick:e=>S?.(e),children:`模板 ▾`})},actions:{new:p,import:C,progress:w,orch:D,deleted:ee,refs:te}}),(0,F.jsxs)(`span`,{className:`mdw-land-count`,children:[c>0&&(0,F.jsxs)(`b`,{className:`mdw-land-pending`,children:[c,` 待领取`]}),` `,s,` 个任务`]})]}),q.length>0&&(0,F.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,F.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,q.length,` 条`]}),v&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>Y(`complete`),children:[`标为完成选中`,J.length?` (${J.length})`:``]}),_&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>Y(`cancel`),children:[`取消选中`,J.length?` (${J.length})`:``]}),g&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>Y(`delete`),children:[`删除选中 (`,q.length,`)`]}),(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>W(new Set),children:`清空`})]}),(0,F.jsx)(`div`,{className:`mdw-land-table-wrap`,children:(0,F.jsxs)(`table`,{className:`mdw-land-table`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`col`,className:`pick`,children:(0,F.jsx)(`input`,{type:`checkbox`,checked:K,onChange:oe,"aria-label":`全选当前页任务`,title:`全选/取消全选当前页`})}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`},children:`#`}),(0,F.jsx)(`th`,{scope:`col`,children:`任务`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`74px`},children:`状态`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`创建`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`领取`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`}})]})}),(0,F.jsxs)(`tbody`,{children:[a.map(e=>{let t=X(e),r=j&&j[e.id]||[];return(0,F.jsxs)(`tr`,{className:`mdw-land-tr`+(U.has(Number(e.id))?` picked`:``)+(ie===Number(e.id)?` dragging`:``)+(V&&V.id===Number(e.id)?` drop-`+V.zone:``),draggable:t,onDragStart:n=>t&&se(n,e),onDragOver:t=>Q(t,e),onDragLeave:ce,onDrop:t=>le(t,e),onDragEnd:$,onClick:()=>m(e.id),children:[(0,F.jsx)(`td`,{className:`pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,F.jsx)(`input`,{type:`checkbox`,checked:U.has(Number(e.id)),onChange:()=>ae(e.id),"aria-label":`选择任务 #${e.id}`})}),(0,F.jsxs)(`td`,{className:`mono faint`,title:t?`拖动整行可调整队列顺序`:void 0,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`tx`,children:(0,F.jsxs)(`div`,{className:`mdw-tg-row`,children:[(0,F.jsx)(`span`,{className:`mdw-tg-title`,children:u(e.text)}),e.timegoal?.duration?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:`时间目标 ${e.timegoal.duration}(领取即计时,未到点不许标完成)${e.timegoal.prompt?`\n附加要求:${e.timegoal.prompt}`:``}`,children:[`⏱ `,e.timegoal.duration]}):null,e.blocksFollowing?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:r.length?`闸门:未完成前挡住 ${r.length} 个后续任务(#${r.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,r.length?`×${r.length}`:``]}):null,e.status===`pending`&&e.ready===!1?(0,F.jsx)(`span`,{className:`mdw-tg`,title:e.blockBy?.length?`等待依赖完成:#${e.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}):null]})}),(0,F.jsx)(`td`,{children:(0,F.jsx)(`span`,{className:`st `+y(e),title:e.status===`cancelled`?`已取消:被新任务取代或明确作废,原文留档`:e.status===`done`?`已交付`:``,children:k(e)})}),(0,F.jsx)(`td`,{className:`mono faint`,children:I(e.createdAt)}),(0,F.jsx)(`td`,{className:`mono faint`,children:e.consumedAt?I(e.consumedAt):`—`}),(0,F.jsx)(`td`,{className:`act`,children:(0,F.jsxs)(`span`,{className:`act-ops`,children:[t&&(E||O)&&(0,F.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,F.jsx)(n,{items:[{label:`编排依赖…`,onPick:()=>E&&E(e)},{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>O&&O(e)}]})}),x&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)&&(0,F.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),x(e)},children:(0,F.jsx)(o,{name:`refresh`,size:12})}),h&&(0,F.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),h(e)},children:(0,F.jsx)(o,{name:`x`,size:12})})]})})]},e.id)}),!a.length&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:`7`,children:(0,F.jsxs)(`div`,{className:`mdw-land-empty`,children:[`还没有页面:点「+ 新建页」写第一篇,或让 agent 往`,e?`全局池`:`这个目录`,`投递任务。`]})})})]})]})}),s>0&&(0,F.jsx)(`div`,{className:`mdw-land-pager`,children:(0,F.jsx)(b,{page:l,pageCount:d,total:s,onPage:f,unit:`个任务`})})]})}var L=(e,t,n)=>j(e=>n.get(e)||[],e,t);function R({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),o=i(e),s=t.filter(e=>i(e)!==o),[c,l]=(0,P.useState)(!!e.blocksFollowing),[d,f]=(0,P.useState)(()=>new Set((e.blockBy||[]).map(Number))),[p,m]=(0,P.useState)(()=>new Set(s.filter(e=>(e.blockBy||[]).map(Number).includes(o)).map(i))),[h,g]=(0,P.useState)(!1),_=t.findIndex(e=>i(e)===o),v=t.slice(_+1).map(i),y=new Map(t.map(e=>[i(e),i(e)===o?[...d]:(e.blockBy||[]).map(Number)])),b=e=>c||!d.has(i(e))&&L(i(e),o,y),x=e=>!p.has(i(e))&&L(o,i(e),y),S=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),C=()=>l(e=>(e||f(new Set),!e)),w=async()=>{g(!0);try{let e=[{id:o,gate:c,blockBy:[...d]}];if(!c)for(let t of s){let n=i(t),r=p.has(n),a=(t.blockBy||[]).map(Number);r!==a.includes(o)&&e.push({id:n,blockBy:r?[...a,o]:a.filter(e=>e!==o)})}await r(e),n()}catch{}finally{g(!1)}},T=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,F.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!h?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h||n,onChange:()=>r(i(e))}),(0,F.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,F.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,F.jsx)(a,{title:`编排 · #${o} ${u(e.text)||``}`,onClose:n,busy:h,size:`md`,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:h,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:h,onClick:w,children:h?`保存中…`:`保存编排`})]}),children:(0,F.jsxs)(`div`,{className:`mdw-dag`,children:[(0,F.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:c,disabled:h,onChange:C}),(0,F.jsx)(`b`,{children:`闸门`}),(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),c?(0,F.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,v.length,` 个后续任务`,v.length?`:${v.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,d.has(i(e)),b(e),S(f))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,p.has(i(e)),c||x(e),S(m))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function z(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function ie({tasks:e=[],onClose:t,onRestore:n,onPurge:r}){return(0,F.jsx)(a,{title:`已删除任务(${e.length})`,onClose:t,children:e.length===0?(0,F.jsx)(`div`,{className:`mdw-del-empty`,children:`这个目录没有已删除的任务。`}):(0,F.jsx)(`table`,{className:`mdw-del-list`,children:(0,F.jsx)(`tbody`,{children:e.map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsxs)(`td`,{className:`mdw-del-id mono`,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`mdw-del-title`,title:u(e.text),children:u(e.text)||`—`}),(0,F.jsx)(`td`,{className:`mdw-del-time mono`,children:z(e.deletedAt)}),(0,F.jsxs)(`td`,{className:`mdw-del-ops`,children:[(0,F.jsx)(`button`,{type:`button`,className:`btn sm ghost`,title:`恢复到队列原位置`,onClick:()=>n?.(e),children:`恢复`}),(0,F.jsx)(`button`,{type:`button`,className:`btn sm danger`,title:`彻底删除(不可恢复)`,onClick:()=>r?.(e),children:`彻底删除`})]})]},e.id))})})})}var B=20;function V({dirKey:e}){let{dialog:n,node:a}=r(),o=S()||{},c=i(),l=o.rows||[],u=o.refreshLocal,y=o.tpl,b=o.model,k=o.repoData&&o.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,N]=(0,P.useState)(null),[ne,I]=(0,P.useState)(!1),[L,z]=(0,P.useState)(null),V=(0,P.useRef)(null),H=(0,P.useMemo)(()=>A?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,A]),U=(0,P.useMemo)(()=>{if(!H||A)return null;let e=H.repo&&H.repo.key;if(e){let t=k.find(t=>t.key===e);if(t)return t}let t=String(H.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&k.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[H,k,A]),W=(0,P.useMemo)(()=>f((H?.tasks||[]).filter(e=>!e.deletedAt&&!p(e))),[H]),G=_(W,B),K=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo).length,[W]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>A?{key:m}:{cwd:H.cwd},ae=(e,n,r)=>{q(async()=>{await t(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...r===`before`?{beforeId:n}:{afterId:n}}}),u()})},oe=e=>{q(async()=>{await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),u()})},Y=async e=>{try{for(let n of e)await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...n}});c(`编排已保存`),u()}catch(e){throw c(String(e.message||e)),e}},X=(0,P.useMemo)(()=>{let e={},t=W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[W]),Z=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[W]),se=t=>{o.openPage&&o.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=O();T(D(C(e),n),{title:``,body:t}),o.openPage&&o.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{b&&v(b)},le=()=>{b&&h(b,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=A?m:e,ue=E($).templates||y&&y.templates||[],de=()=>{if(!b){c(`工作区未就绪`);return}w(b,{mode:`new`,topic:$,scope:A?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===y?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(x(e.body,{...d,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(y?y.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let n=A?`key=${encodeURIComponent(m)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(H?.cwd||``)}&id=${Number(e.id)}`;return t(`/api/localtasks/item?${n}`).catch(()=>null)},me=r=>{if(!r)return;let i=(r.text||``).split(`
|
|
1
|
+
import{S as e,_ as t,d as n,f as r,g as i,l as a,p as o,u as s,v as c,y as l}from"./task-status-BP6y8MVu.js";import{h as u,n as d}from"./md-parse-C2bDc3IZ.js";import{o as f,r as p,t as m}from"./board-view-t8CKtq17.js";import{O as h,T as g,_,a as v,b as y,g as b,i as x,k as S,m as C,o as w,p as T,r as E,s as D,u as O,y as k}from"./index-BmANFdAR.js";import{t as A}from"./route-crumb-DHYbpsO8.js";import{t as j}from"./graph-DM-zDRdL.js";import{n as ee,r as te,t as M}from"./reopen-text-BylkngqC.js";import{t as N}from"./Introduction-ChO8BjCo.js";import{t as ne}from"./bar-DIcUTKGF.js";var P=e(l(),1),F=c();function I(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function re({isGlobal:e,topic:t,repo:r=null,model:i=null,tasks:a=[],taskCount:s=0,pendingCount:c=0,page:l=0,pageCount:d=1,onPage:f,onNew:p,onOpenTask:m,onDeleteTask:h,onDeleteTasks:g,onCancelTasks:_,onCompleteTasks:v,onReopenTask:x,onTplMenu:S,onImport:C,onProg:w,onMoveTask:T,onOpenDag:E,onOpenFlow:D,onToggleGate:O,downstreamOf:j,onDeleted:ee,onRefs:te,deletedCount:M=0}){let re=e?`全局池`:t?.name||`目录`,L=e?`共享池(无固定目录)`:t?.cwd||`—`,R=String(t?.summary||``).trim(),z=(0,P.useRef)(null),[ie,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(()=>new Set);(0,P.useEffect)(()=>{W(new Set)},[l]);let G=a.map(e=>Number(e.id)),K=G.length>0&&G.every(e=>U.has(e)),q=a.filter(e=>U.has(Number(e.id))),J=q.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),ae=e=>{let t=Number(e);W(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},oe=()=>{W(e=>{let t=new Set(e);return K?G.forEach(e=>t.delete(e)):G.forEach(e=>t.add(e)),t})},Y=async e=>{let t=[...U],n=e===`cancel`?_:e===`complete`?v:g;t.length&&n&&await n(t)&&W(new Set)},X=e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt,Z=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},se=(e,t)=>{z.current={id:Number(t.id)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.id),B(Number(t.id))},Q=(e,t)=>{z.current&&X(t)&&Number(t.id)!==z.current.id&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,H({id:Number(t.id),zone:Z(e,e.currentTarget)}))},ce=e=>{e.currentTarget.contains(e.relatedTarget)||H(null)},le=(e,t)=>{e.preventDefault();let n=Z(e,e.currentTarget),r=z.current;z.current=null,B(null),H(null),r&&X(t)&&Number(t.id)!==r.id&&T&&T({id:r.id},t.id,n)},$=()=>{z.current=null,B(null),H(null)};return(0,F.jsxs)(`div`,{className:`mdw-land`,children:[(0,F.jsx)(A,{}),(0,F.jsxs)(`div`,{className:`mdw-land-head`,children:[(0,F.jsx)(`div`,{className:`mdw-land-name`,children:re}),(0,F.jsx)(`div`,{className:`mdw-land-path mono`,title:L,children:L}),R?(0,F.jsxs)(`div`,{className:`mdw-land-status-line`,title:R,children:[(0,F.jsx)(`span`,{className:`mdw-land-lab`,children:`现状`}),(0,F.jsx)(`span`,{className:`mdw-land-status`,children:R})]}):null]}),!e&&r?(0,F.jsx)(N,{kind:`repo`,owner:r,model:i}):null,(0,F.jsxs)(`div`,{className:`mdw-land-acts`,children:[(0,F.jsx)(ne,{kind:`dir`,className:`mdw-land-ta`,labels:{more:M>0?`更多 (${M})`:`更多`,deleted:M>0?`已删除任务(${M})`:`已删除任务`},titles:{tpl:`按模板新建一页`,import:`把一个 .md 文件导入成任务`,progress:`打开这个目录的进程面板`,orch:`打开可视化编排面板`,more:M>0?`更多操作(含 ${M} 条已删除任务)`:`更多操作`,deleted:`查看并恢复已删除任务`,refs:`查看文档 / reference 列表`},renderers:{tpl:()=>(0,F.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`按模板新建一页`,"aria-haspopup":`menu`,onClick:e=>S?.(e),children:`模板 ▾`})},actions:{new:p,import:C,progress:w,orch:D,deleted:ee,refs:te}}),(0,F.jsxs)(`span`,{className:`mdw-land-count`,children:[c>0&&(0,F.jsxs)(`b`,{className:`mdw-land-pending`,children:[c,` 待领取`]}),` `,s,` 个任务`]})]}),q.length>0&&(0,F.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,F.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,q.length,` 条`]}),v&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已完成(补一条完成记录,原文留档)`:`只有待领取任务可以直接标为完成`,onClick:()=>Y(`complete`),children:[`标为完成选中`,J.length?` (${J.length})`:``]}),_&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!J.length,title:J.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消`,onClick:()=>Y(`cancel`),children:[`取消选中`,J.length?` (${J.length})`:``]}),g&&(0,F.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>Y(`delete`),children:[`删除选中 (`,q.length,`)`]}),(0,F.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>W(new Set),children:`清空`})]}),(0,F.jsx)(`div`,{className:`mdw-land-table-wrap`,children:(0,F.jsxs)(`table`,{className:`mdw-land-table`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`col`,className:`pick`,children:(0,F.jsx)(`input`,{type:`checkbox`,checked:K,onChange:oe,"aria-label":`全选当前页任务`,title:`全选/取消全选当前页`})}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`},children:`#`}),(0,F.jsx)(`th`,{scope:`col`,children:`任务`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`74px`},children:`状态`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`创建`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`116px`},children:`领取`}),(0,F.jsx)(`th`,{scope:`col`,style:{width:`56px`}})]})}),(0,F.jsxs)(`tbody`,{children:[a.map(e=>{let t=X(e),r=j&&j[e.id]||[];return(0,F.jsxs)(`tr`,{className:`mdw-land-tr`+(U.has(Number(e.id))?` picked`:``)+(ie===Number(e.id)?` dragging`:``)+(V&&V.id===Number(e.id)?` drop-`+V.zone:``),draggable:t,onDragStart:n=>t&&se(n,e),onDragOver:t=>Q(t,e),onDragLeave:ce,onDrop:t=>le(t,e),onDragEnd:$,onClick:()=>m(e.id),children:[(0,F.jsx)(`td`,{className:`pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,F.jsx)(`input`,{type:`checkbox`,checked:U.has(Number(e.id)),onChange:()=>ae(e.id),"aria-label":`选择任务 #${e.id}`})}),(0,F.jsxs)(`td`,{className:`mono faint`,title:t?`拖动整行可调整队列顺序`:void 0,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`tx`,children:(0,F.jsxs)(`div`,{className:`mdw-tg-row`,children:[(0,F.jsx)(`span`,{className:`mdw-tg-title`,children:u(e.text)}),e.timegoal?.duration?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:`时间目标 ${e.timegoal.duration}(领取即计时,未到点不许标完成)${e.timegoal.prompt?`\n附加要求:${e.timegoal.prompt}`:``}`,children:[`⏱ `,e.timegoal.duration]}):null,e.blocksFollowing?(0,F.jsxs)(`span`,{className:`mdw-tg`,title:r.length?`闸门:未完成前挡住 ${r.length} 个后续任务(#${r.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,r.length?`×${r.length}`:``]}):null,e.status===`pending`&&e.ready===!1?(0,F.jsx)(`span`,{className:`mdw-tg`,title:e.blockBy?.length?`等待依赖完成:#${e.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}):null]})}),(0,F.jsx)(`td`,{children:(0,F.jsx)(`span`,{className:`st `+y(e),title:e.status===`cancelled`?`已取消:被新任务取代或明确作废,原文留档`:e.status===`done`?`已交付`:``,children:k(e)})}),(0,F.jsx)(`td`,{className:`mono faint`,children:I(e.createdAt)}),(0,F.jsx)(`td`,{className:`mono faint`,children:e.consumedAt?I(e.consumedAt):`—`}),(0,F.jsx)(`td`,{className:`act`,children:(0,F.jsxs)(`span`,{className:`act-ops`,children:[t&&(E||O)&&(0,F.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,F.jsx)(n,{items:[{label:`编排依赖…`,onPick:()=>E&&E(e)},{label:e.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>O&&O(e)}]})}),x&&e.status!==`cancelled`&&!e.childCount&&(e.status===`claimed`||e.status===`done`||e.completedAt)&&(0,F.jsx)(`span`,{className:`op`,role:`button`,tabIndex:-1,title:e.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,"aria-label":`反馈 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),x(e)},children:(0,F.jsx)(o,{name:`refresh`,size:12})}),h&&(0,F.jsx)(`span`,{className:`op danger`,role:`button`,tabIndex:-1,title:`删除此任务(软删除,CLI 可恢复)`,"aria-label":`删除 ${u(e.text)}`,onClick:t=>{t.stopPropagation(),h(e)},children:(0,F.jsx)(o,{name:`x`,size:12})})]})})]},e.id)}),!a.length&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:`7`,children:(0,F.jsxs)(`div`,{className:`mdw-land-empty`,children:[`还没有页面:点「+ 新建页」写第一篇,或让 agent 往`,e?`全局池`:`这个目录`,`投递任务。`]})})})]})]})}),s>0&&(0,F.jsx)(`div`,{className:`mdw-land-pager`,children:(0,F.jsx)(b,{page:l,pageCount:d,total:s,onPage:f,unit:`个任务`})})]})}var L=(e,t,n)=>j(e=>n.get(e)||[],e,t);function R({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),o=i(e),s=t.filter(e=>i(e)!==o),[c,l]=(0,P.useState)(!!e.blocksFollowing),[d,f]=(0,P.useState)(()=>new Set((e.blockBy||[]).map(Number))),[p,m]=(0,P.useState)(()=>new Set(s.filter(e=>(e.blockBy||[]).map(Number).includes(o)).map(i))),[h,g]=(0,P.useState)(!1),_=t.findIndex(e=>i(e)===o),v=t.slice(_+1).map(i),y=new Map(t.map(e=>[i(e),i(e)===o?[...d]:(e.blockBy||[]).map(Number)])),b=e=>c||!d.has(i(e))&&L(i(e),o,y),x=e=>!p.has(i(e))&&L(o,i(e),y),S=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),C=()=>l(e=>(e||f(new Set),!e)),w=async()=>{g(!0);try{let e=[{id:o,gate:c,blockBy:[...d]}];if(!c)for(let t of s){let n=i(t),r=p.has(n),a=(t.blockBy||[]).map(Number);r!==a.includes(o)&&e.push({id:n,blockBy:r?[...a,o]:a.filter(e=>e!==o)})}await r(e),n()}catch{}finally{g(!1)}},T=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,F.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!h?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h||n,onChange:()=>r(i(e))}),(0,F.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,F.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,F.jsx)(a,{title:`编排 · #${o} ${u(e.text)||``}`,onClose:n,busy:h,size:`md`,footer:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:h,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:h,onClick:w,children:h?`保存中…`:`保存编排`})]}),children:(0,F.jsxs)(`div`,{className:`mdw-dag`,children:[(0,F.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:c,disabled:h,onChange:C}),(0,F.jsx)(`b`,{children:`闸门`}),(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),c?(0,F.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,v.length,` 个后续任务`,v.length?`:${v.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,d.has(i(e)),b(e),S(f))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,c?(0,F.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,F.jsx)(`div`,{className:`mdw-dag-list`+(c?` dim`:``),children:s.length?s.map(e=>T(e,p.has(i(e)),c||x(e),S(m))):(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,F.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function z(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/);return n?`${n[1].slice(5)} ${n[2]}`:t.slice(0,16)}function ie({tasks:e=[],onClose:t,onRestore:n,onPurge:r}){return(0,F.jsx)(a,{title:`已删除任务(${e.length})`,onClose:t,children:e.length===0?(0,F.jsx)(`div`,{className:`mdw-del-empty`,children:`这个目录没有已删除的任务。`}):(0,F.jsx)(`table`,{className:`mdw-del-list`,children:(0,F.jsx)(`tbody`,{children:e.map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsxs)(`td`,{className:`mdw-del-id mono`,children:[`#`,e.id]}),(0,F.jsx)(`td`,{className:`mdw-del-title`,title:u(e.text),children:u(e.text)||`—`}),(0,F.jsx)(`td`,{className:`mdw-del-time mono`,children:z(e.deletedAt)}),(0,F.jsxs)(`td`,{className:`mdw-del-ops`,children:[(0,F.jsx)(`button`,{type:`button`,className:`btn sm ghost`,title:`恢复到队列原位置`,onClick:()=>n?.(e),children:`恢复`}),(0,F.jsx)(`button`,{type:`button`,className:`btn sm danger`,title:`彻底删除(不可恢复)`,onClick:()=>r?.(e),children:`彻底删除`})]})]},e.id))})})})}var B=20;function V({dirKey:e}){let{dialog:n,node:a}=r(),o=S()||{},c=i(),l=o.rows||[],u=o.refreshLocal,y=o.tpl,b=o.model,k=o.repoData&&o.repoData.repos||[],A=!e||e===`__GLOBAL__`,[j,N]=(0,P.useState)(null),[ne,I]=(0,P.useState)(!1),[L,z]=(0,P.useState)(null),V=(0,P.useRef)(null),H=(0,P.useMemo)(()=>A?l.find(e=>e.isGlobal)||null:l.find(t=>t.key===e)||null,[l,e,A]),U=(0,P.useMemo)(()=>{if(!H||A)return null;let e=H.repo&&H.repo.key;if(e){let t=k.find(t=>t.key===e);if(t)return t}let t=String(H.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&k.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[H,k,A]),W=(0,P.useMemo)(()=>f((H?.tasks||[]).filter(e=>!e.deletedAt&&!p(e))),[H]),G=_(W,B),K=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo).length,[W]),q=e=>e().catch(e=>c(String(e.message||e))),J=()=>A?{key:m}:{cwd:H.cwd},ae=(e,n,r)=>{q(async()=>{await t(`/api/localtasks/reorder`,{method:`PATCH`,body:{...J(),id:e.id,...r===`before`?{beforeId:n}:{afterId:n}}}),u()})},oe=e=>{q(async()=>{await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),id:e.id,gate:!e.blocksFollowing}}),c(e.blocksFollowing?`#${e.id} 闸门已取消`:`#${e.id} 已设为闸门——挡住所有后续待领取任务`),u()})},Y=async e=>{try{for(let n of e)await t(`/api/localtasks/item`,{method:`PATCH`,body:{...J(),...n}});c(`编排已保存`),u()}catch(e){throw c(String(e.message||e)),e}},X=(0,P.useMemo)(()=>{let e={},t=W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[W]),Z=(0,P.useMemo)(()=>W.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[W]),se=t=>{o.openPage&&o.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=O();T(D(C(e),n),{title:``,body:t}),o.openPage&&o.openPage({dirKey:e,task:n,name:`新任务`})},ce=()=>{b&&v(b)},le=()=>{b&&h(b,{component:`progress`,name:`进程`,config:{dirKey:e||`__GLOBAL__`},location:`right`})},$=A?m:e,ue=E($).templates||y&&y.templates||[],de=()=>{if(!b){c(`工作区未就绪`);return}w(b,{mode:`new`,topic:$,scope:A?[]:[`topic:${$}`],name:``})},fe=[...ue.length?ue.map(e=>({label:(e.id===y?.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>Q(x(e.body,{...d,...e.values||{}}))})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>Q(y?y.defaultBody():``)}],`sep`,{label:`为本${A?`全局池`:`目录`}新建模板…`,icon:`plus`,onClick:de},{label:`管理模板…`,icon:`gear`,onClick:ce}],pe=async e=>{if(e==null)return null;let n=A?`key=${encodeURIComponent(m)}&id=${Number(e.id)}`:`cwd=${encodeURIComponent(H?.cwd||``)}&id=${Number(e.id)}`;return t(`/api/localtasks/item?${n}`).catch(()=>null)},me=r=>{if(!r)return;let i=(r.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${r.id}`;q(async()=>{let a=!!r.completedAt,o=await n({title:a?`反馈 · #${r.id}`:`反馈修改 · #${r.id}`,input:!0,placeholder:a?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(o==null)return;let s=String(o).trim(),l=await pe(r),d=String(l?.text??``).trim()||String(r.text||``).trim(),f=a&&(l?.roundSummary||r.roundSummary)||``;if(!s&&!a&&!d){c(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(a){let n=s?M({base:d,feedback:s,ackSummary:f,feedbackHeading:ee,bold:!0}):``;if(!n){c(`写一下反馈`);return}let a=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:n,forkOf:String(r.id),forkKind:`reopen`}:{cwd:H.cwd,text:n,forkOf:String(r.id),forkKind:`reopen`}}),o=String(a?.task?.id??a?.id??``),l=a?.key||e;o&&T(D(C(l),o),{body:n}),c(`已反馈「${i.replace(/^#\s*/,``)}」→ 新任务 #${o||`?`}`),u();return}let p=await t(`/api/localtasks/reopen`,{method:`POST`,body:{...J(),id:r.id,kind:`reopen`,...s?{feedback:s,feedbackHeading:te,feedbackBold:!1}:{}}}),m=p?.key||e,h=String(p?.task?.id??r.id),g=String(p?.task?.text??``);g&&T(D(C(m),h),{body:g}),c(`已回写「${i.replace(/^#\s*/,``)}」#${h}`+(p?.moved&&p.name?`;归属迁到「${p.name}」`:``)),u()})},he=async r=>{if(!r)return;let i=(r.text||``).split(`
|
|
3
3
|
`).find(e=>e.trim())||`#${r.id}`;await n({title:`删除任务「${i.replace(/^#\s*/,``)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&q(async()=>{if(await t(`/api/localtasks/item`,{method:`DELETE`,body:A?{key:m,id:r.id}:{cwd:H.cwd,id:r.id}}),c(`已删除「${i.replace(/^#\s*/,``)}」`),b){let t=g(b,`page`,{dirKey:e,task:String(r.id)});t&&o.closePanel&&o.closePanel(t.getId())}u()})},ge=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`删除选中的 ${r.length} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})?!1:q(async()=>{let e=await t(`/api/localtasks/items`,{method:`DELETE`,body:{...J(),ids:r}});return c(`已删除 ${e?.count??r.length} 条任务`),u(),!0})},_e=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`取消选中的 ${r.length} 条待领取任务`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`})?!1:q(async()=>{let e=await t(`/api/localtasks/items/cancel`,{method:`POST`,body:{...J(),ids:r}}),n=e?.skipped?.length||0;return c(`已取消 ${e?.count??0} 条任务${n?`,跳过 ${n} 条`:``}`),u(),!0})},ve=async e=>{let r=(e||[]).map(Number).filter(e=>Number.isFinite(e)&&e>0);return!r.length||!await n({title:`把选中的 ${r.length} 条待领取任务标为完成`,message:`只处理待领取任务;已领取/已交付/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`})?!1:q(async()=>{let e=await t(`/api/localtasks/items/close`,{method:`POST`,body:{...J(),ids:r,status:`done`}}),n=e?.skipped?.length||0;return c(`已标为完成 ${e?.count??0} 条任务${n?`,跳过 ${n} 条`:``}`),u(),!0})},ye=(0,P.useMemo)(()=>(H?.tasks||[]).filter(e=>e.deletedAt).slice().reverse(),[H]),be=e=>{e&&q(async()=>{await t(`/api/localtasks/tasks/restore`,{method:`POST`,body:A?{key:m,id:e.id}:{cwd:H.cwd,id:e.id}}),c(`已恢复 #${e.id}「${(e.text||``).split(`
|
|
4
4
|
`).find(e=>e.trim())?.replace(/^#\s*/,``)||``}」`),u()})},xe=async e=>{if(!e)return;let r=(e.text||``).split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,_ as t,f as n,g as r,p as i,v as a,y as o}from"./task-status-BP6y8MVu.js";import{g as ee,n as s,v as c}from"./md-parse-C2bDc3IZ.js";import{N as l,O as u,i as d,k as f,m as p,n as m,o as h,p as g,r as _,s as v,u as te,x as y}from"./index-
|
|
1
|
+
import{S as e,_ as t,f as n,g as r,p as i,v as a,y as o}from"./task-status-BP6y8MVu.js";import{g as ee,n as s,v as c}from"./md-parse-C2bDc3IZ.js";import{N as l,O as u,i as d,k as f,m as p,n as m,o as h,p as g,r as _,s as v,u as te,x as y}from"./index-BmANFdAR.js";import{t as b}from"./status-tag-CdoKlRNG.js";import{t as ne}from"./route-crumb-DHYbpsO8.js";import{t as x}from"./Introduction-ChO8BjCo.js";import{t as S}from"./bar-DIcUTKGF.js";import{t as C}from"./member-picker--32VkTmv.js";var w=e(o(),1),T=l(),E=a();function D({dirKey:e,rows:a,repoData:o,model:l}){let D=r(),{node:re}=n(),O=f()||{},k=m(),A=o&&o.boards||[],j=o&&o.repos||[],M=a||[],[N,ie]=(0,w.useState)(!1),[ae,P]=(0,w.useState)(!1),[F,I]=(0,w.useState)(!1),[L,R]=(0,w.useState)(null),z=(0,w.useRef)(null),B=(0,w.useRef)(null);(0,w.useEffect)(()=>{if(!F)return;let e=e=>{z.current?.contains(e.target)||B.current?.contains(e.target)||I(!1)},t=e=>{e.key===`Escape`&&I(!1)},n=()=>{let e=z.current?.querySelector(`button`);if(!e)return;let t=e.getBoundingClientRect(),n=B.current?.offsetHeight||240,r=window.innerHeight-t.bottom-6,i=r>=n||r>=t.top?t.bottom+6:Math.max(8,t.top-6-n);R({top:i,right:Math.max(8,window.innerWidth-t.right)})};n();let r=requestAnimationFrame(n);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),window.addEventListener(`scroll`,n,!0),()=>{cancelAnimationFrame(r),document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,n,!0)}},[F]);let V=(0,w.useMemo)(()=>A.find(t=>t.id===e)||A.find(t=>t.key===e)||null,[A,e]),H=(0,w.useMemo)(()=>{if(!V)return[];let e=new Map(j.map(e=>[e.key,e])),t=new Map;for(let e of M)!e.isGlobal&&e.repo&&e.repo.key&&(t.has(e.repo.key)||t.set(e.repo.key,e));return(V.repos||[]).map(n=>{let r=e.get(n.key)||null,i=t.get(n.key)||null;return{key:n.key,name:n.name||r&&r.name||n.key,path:n.path||r&&r.path||``,cwd:i&&i.cwd||n.path||r&&r.path||``,desc:n.note||r&&r.desc||``,pending:i&&i.pending||0,waiting:!!(i&&i.waiting),topicKey:i?i.key:``,summary:i&&i.summary||``,tasks:i?(i.tasks||[]).filter(e=>!e.deletedAt):[],present:n.present!==!1,noteDocId:n.noteDocPath?`path:`+n.noteDocPath:`rel:`+n.noteDocRel}})},[V,j,M]);if(!V)return(0,E.jsxs)(`div`,{className:`rp-page`,children:[(0,E.jsx)(ne,{}),(0,E.jsx)(`div`,{className:`rp-empty`,children:`项目组不存在(看板可能被删了)`})]});let U=H.reduce((e,t)=>e+t.pending,0),W=(0,w.useMemo)(()=>{let e=new Map;for(let t of M){if(!t.key||t.isGlobal)continue;let n=(t.tasks||[]).filter(e=>e&&!e.deletedAt&&!e.migratedTo&&e.status===`pending`),r={};n.forEach((e,t)=>{e.blocksFollowing&&(r[e.id]=n.slice(t+1).map(e=>e.id))}),e.set(t.key,{tasks:n,downstream:r})}return e},[M]),G=H.find(e=>e.pending>0)||H[0]||null,K=(0,w.useMemo)(()=>{let e=V?[V.id,V.key,V.name].filter(Boolean):[],t=[],n=[];for(let r of H)for(let i of r.tasks||[]){let a=ee(i.text);a.board&&e.includes(a.board)&&(i.status===`pending`?t:n).push({member:r,task:i,project:a.project||``})}return n.sort((e,t)=>String(t.task.consumedAt||``).localeCompare(String(e.task.consumedAt||``))),{pend:t,done:n}},[V,H]),q=(0,w.useRef)(null),[oe,J]=(0,w.useState)(null),[Y,X]=(0,w.useState)(null),Z=(e,t)=>e.key+`:`+t.id,Q=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},se=(e,t,n)=>{q.current={id:Number(n.id),topicKey:t.topicKey,cwd:t.cwd||t.path||``,row:Z(t,n)},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+n.id),J(Z(t,n))},ce=(e,t,n)=>{let r=q.current;r&&r.row!==Z(t,n)&&(e.preventDefault(),e.dataTransfer.dropEffect=r.topicKey===t.topicKey?`move`:`none`,X({key:Z(t,n),zone:Q(e,e.currentTarget)}))},le=e=>{e.currentTarget.contains(e.relatedTarget)||X(null)},ue=async(e,n,r)=>{e.preventDefault();let i=Q(e,e.currentTarget),a=q.current;if(q.current=null,J(null),X(null),!a||a.row===Z(n,r))return;if(a.topicKey!==n.topicKey){D(`只能在同一项目队列内排序(跨项目请用编排连线)`);return}let o=n.cwd||n.path;if(!n.topicKey||!o){D(`该成员还没有本地队列,无法排序`);return}try{await t(`/api/localtasks/reorder`,{method:`PATCH`,body:{cwd:o,id:a.id,...i===`before`?{beforeId:Number(r.id)}:{afterId:Number(r.id)}}}),O.refreshLocal&&await O.refreshLocal()}catch(e){D(String(e.message||e))}},de=()=>{q.current=null,J(null),X(null)},fe=e=>{if(!V)return;if(!G)return D(`这个组还没有成员——先「添加成员」,再建任务`);let t=te(),n=v(p(V.id),t);g(n,{title:``,body:c(e||k.defaultBody(),{board:V.id,project:G.key})}),O.openPage?.({groupId:V.id,task:t,name:`新任务`})},$=_({topic:G?G.topicKey:``,group:V?V.key:``,repo:G?G.key:``}).templates||k.templates||[],pe=()=>{V&&l&&h(l,{mode:`new`,scope:[`group:${V.key}`],name:``})};return(0,E.jsxs)(`div`,{className:`rp-page`,children:[re,(0,E.jsxs)(`div`,{className:`rp-group-head`,children:[(0,E.jsxs)(`h2`,{children:[(0,E.jsx)(i,{name:`folder`,size:15}),` `,V.name,(0,E.jsxs)(`span`,{className:`rp-chip-count`,children:[H.length,` 个目录`]}),U>0&&(0,E.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,U]})]}),(0,E.jsx)(`div`,{className:`rp-group-acts`,children:(0,E.jsx)(S,{kind:`group`,titles:{progress:`打开本组的任务进程面板`,addMember:`挑项目加进这个组`,orch:`打开可视化编排面板`,refs:`查看文档 / reference 列表`},disabled:{new:!G},renderers:{new:()=>(0,E.jsxs)(`div`,{className:`rp-newtask`,ref:z,children:[(0,E.jsxs)(`button`,{type:`button`,className:`btn small`+(F?` is-open`:``),"aria-haspopup":`menu`,"aria-expanded":F,title:`选择模板新建任务(携带本组语义;MD 编辑页里可选归属项目)`,disabled:!G,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();R({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),I(e=>!e)},children:[`+ 新增任务`,(0,E.jsx)(i,{name:`chevron`,size:11,className:`rp-newtask-caret`+(F?` rot`:``)})]}),F&&G&&L&&(0,T.createPortal)((0,E.jsxs)(`div`,{ref:B,className:`rp-tpl-fly rp-tpl-fly-portal`,role:`menu`,"aria-label":`选择模板新建任务`,style:{top:L.top,right:L.right},children:[(0,E.jsxs)(`div`,{className:`rp-tpl-fly-h`,children:[V.name,` · 可用模板`]}),(0,E.jsx)(`div`,{className:`rp-tpl-fly-list`,children:($.length?$:[{id:`__fallback__`,name:`按默认模板新建`,fallback:!0}]).map(e=>(0,E.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-it`,role:`menuitem`,onClick:()=>{I(!1),fe(e.fallback?``:d(e.body,{...s,...e.values||{}}))},children:(e.id===k.defaultId&&!e.fallback?`✓ `:``)+e.name},e.id))}),(0,E.jsx)(`div`,{className:`rp-tpl-fly-foot`,children:(0,E.jsx)(`button`,{type:`button`,className:`rp-tpl-fly-new`,onClick:()=>{I(!1),pe()},children:`+ 新增模板…`})})]}),document.body)]})},actions:{progress:()=>{l&&u(l,{component:`progress`,name:`进程`,config:{groupKey:e},location:`right`})},addMember:()=>P(!0),orch:()=>{l&&u(l,{component:`dag`,name:`编排`,config:{dirKey:G&&G.topicKey||``,groupId:V&&V.id}})},refs:()=>{l&&V&&u(l,{component:`refs`,name:`文档列表`,config:{boardKey:e,boardName:V.name},location:`right`})}}})})]}),(0,E.jsx)(x,{kind:`board`,owner:V,model:l}),(0,E.jsxs)(`div`,{className:`rp-tasks`,children:[(0,E.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,E.jsx)(i,{name:`list`,size:13}),` 本组任务`,(0,E.jsxs)(`span`,{className:`rp-chip-count`,children:[K.pend.length,` 待领取`]}),K.done.length>0&&(0,E.jsxs)(`span`,{className:`rp-chip-count`,children:[`已领取 `,K.done.length]})]}),K.pend.map(({member:e,task:t})=>{let n=W.get(e.topicKey),r=n&&n.downstream[t.id]||[],a=t.ready===!1,o=Z(e,t);return(0,E.jsxs)(`div`,{className:`rp-proj-row`+(oe===o?` dragging`:``)+(Y&&Y.key===o?` drop-`+Y.zone:``),onDragOver:n=>ce(n,e,t),onDragLeave:le,onDrop:n=>ue(n,e,t),children:[e.topicKey?(0,E.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整本项目队列内顺序`,"aria-label":`拖动排序`,onDragStart:n=>se(n,e,t),onDragEnd:de,onClick:e=>e.stopPropagation(),children:(0,E.jsx)(i,{name:`grip`,size:12})}):(0,E.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),(0,E.jsxs)(`button`,{className:`rp-proj-task`,title:`打开这条任务`,onClick:()=>O.openPage&&O.openPage({groupId:V.id,task:String(t.id),name:`#${t.id}`}),children:[(0,E.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),(0,E.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${e.name}`,children:e.name}),(0,E.jsx)(`span`,{className:`rp-proj-task-tx`,children:y(t)}),t.timegoal&&(0,E.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,E.jsx)(i,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,E.jsxs)(`span`,{className:`rp-tgate`,title:r.length?`闸门:未完成前挡住 ${r.length} 个后续任务(#${r.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,r.length?`×${r.length}`:``]}),a&&(0,E.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),(0,E.jsx)(b,{t})]})]},o)}),!K.pend.length&&(0,E.jsx)(`div`,{className:`rp-proj-none muted`,children:`本组还没有待领取任务——点「+ 新增任务」创建;只有在本组创建的任务(携带本组语义)才会出现在这里。`}),K.done.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{type:`button`,className:`rp-done-toggle`,onClick:()=>ie(e=>!e),children:[(0,E.jsx)(`span`,{className:`tri`+(N?` open`:``),children:`▸`}),` 已领取 `,K.done.length]}),N&&K.done.map(({member:e,task:t})=>(0,E.jsxs)(`button`,{className:`rp-proj-task done`,title:`打开这条任务`,onClick:()=>O.openPage&&O.openPage({groupId:V.id,task:String(t.id),name:`#${t.id}`}),children:[(0,E.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),(0,E.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${e.name}`,children:e.name}),(0,E.jsx)(`span`,{className:`rp-proj-task-tx`,children:y(t)}),(0,E.jsx)(`span`,{className:`rp-tstat live`,children:t.consumedAt||`已领取`})]},e.key+`:`+t.id))]})]}),ae&&V?(0,E.jsx)(C,{board:V,boards:A,repos:j,onClose:()=>P(!1),onChanged:()=>O.refreshRepos&&O.refreshRepos()}):null]})}export{D as default};
|