nx-kv 0.67.0 → 0.67.1
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 +21 -0
- package/package.json +1 -1
- package/src/modules/localtask/lifecycle/task-ops.ts +4 -3
- package/src/web/frontend/page/dir/task-actions.ts +6 -7
- package/src/web/frontend/page/dir/task-board-section.tsx +4 -3
- package/src/web/frontend/page/dir/task.tsx +9 -2
- package/src/web/public/assets/{composer-panel-D6vBrzCs.js → composer-panel-DWWQD3wE.js} +1 -1
- package/src/web/public/assets/{dag-CZF6sV2_.js → dag-BLxdhwgd.js} +1 -1
- package/src/web/public/assets/{dir-6RhnWw1E.js → dir-CvVny2yZ.js} +1 -1
- package/src/web/public/assets/{group-AF62Z-_G.js → group-CUtdxFrs.js} +1 -1
- package/src/web/public/assets/{index-Bposj22Z.js → index-yhpvk7gl.js} +2 -2
- package/src/web/public/assets/{settings-Bk3clN2f.js → settings-DS1z2peI.js} +1 -1
- package/src/web/public/assets/task-CUqExIXn.js +13 -0
- package/src/web/public/assets/{task-ops-D6E_TgEC.js → task-ops-BoCAzUv1.js} +1 -1
- package/src/web/public/assets/{templates-Dusbff7Z.js → templates-CZDRJJHr.js} +3 -3
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/task-C8nax2rT.js +0 -13
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,l as i,n as a,r as o,t as s}from"./popup-dBtYqEM1.js";import{D as c}from"./repo-form-modal-dZqpHyUj.js";import{n as l}from"./app-context-CngKv8Tc.js";import{l as u}from"./task-status-Cjsm0xF7.js";import{d,f,s as p}from"./md-history-COQu16vy.js";import{t as m}from"./button-Cs6w2CDi.js";import{S as h,h as g,w as _,x as v}from"./index-Bposj22Z.js";import{t as y}from"./graph-BTEfvFz6.js";import{c as b,d as x,f as S,g as C,l as w,m as T,n as E,p as D,r as O,s as ee,t as te,u as k}from"./reopen-text-B2d9SZi0.js";import{t as ne}from"./bar-C0Q_Qe4z.js";var A=r(n(),1),j=t(),M=10;function N({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,A.useState)(!!(o&&o.enabled)),[f,p]=(0,A.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(M)),[h,g]=(0,A.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return M;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):M},v=async t=>{let i=String(e.id??``);g(!0);try{let o=t&&t.enabled!==void 0?t.enabled:u;await c(i,{"get-loop":o?`on`:`off`,...o?{"get-loop-minutes":_(f)}:{}});let s=_(f);a(o?`已保存「${e.name}」的持续 get 设置(${s>0?`${s} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){a(String(e.message||e))}finally{g(!1)}},y=async e=>{d(e),await v({enabled:e})};return(0,j.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,j.jsxs)(`div`,{className:`rp-gl`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,j.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,j.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,j.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,j.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,j.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,j.jsx)(`span`,{children:`阻塞窗口`}),(0,j.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,j.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,j.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,j.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(m,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var P=s,re=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function F({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,A.useState)(!!e.blocksFollowing),[l,d]=(0,A.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,A.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,A.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&re(i(e),a,v),b=e=>!f.has(i(e))&&re(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||d(new Set),!e)),C=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=f.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},w=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,j.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,j.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,j.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,j.jsx)(P,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,j.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,j.jsxs)(`div`,{className:`mdw-dag`,children:[(0,j.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,j.jsx)(`b`,{children:`闸门`}),(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,j.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,j.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,l.has(i(e)),y(e),x(d))):(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,j.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,f.has(i(e)),s||b(e),x(p))):(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,A.useState)(0),a=Math.max(1,Number(t)||1),o=Math.max(1,Math.ceil(n.length/a)),s=Math.min(Math.max(0,r),o-1),c=s*a;return{page:s,pageCount:o,total:n.length,items:n.slice(c,c+a),setPage:i}}function ae({page:e=0,pageCount:t=1,total:n=0,onPage:r,unit:i=`条`}){let a=e=>r&&r(Math.max(0,Math.min(e,t-1)));return t<=1?(0,j.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,j.jsxs)(`span`,{className:`pager`,children:[(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,j.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e>=t-1,onClick:()=>a(e+1),"aria-label":`下一页`,title:`下一页`,children:`›`})]})}function oe({icon:t=`list`,title:n,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:o=``}){let s=Array.isArray(a)?a.length>0:!!a;return(0,j.jsxs)(`div`,{className:`rp-tasks`,children:[(0,j.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,j.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,j.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,j.jsx)(`div`,{className:`rp-proj-none muted`,children:o}):null]})}function se({name:t,counts:n=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:o=null,list:s=null,footer:c=null,extra:l=null}){return(0,j.jsxs)(`div`,{className:`rp-page`,children:[(0,j.jsxs)(`div`,{className:`rp-group-head`,children:[(0,j.jsxs)(`h2`,{children:[(0,j.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,j.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,j.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}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})/),r=n?.[1],i=n?.[2];return r&&i?`${r.slice(5)} ${i}`:t.slice(0,16)}function ce({t,projectTag:n=``,projectTitle:r=``,selectable:i=!1,picked:a=!1,onTogglePick:o,draggable:s=!1,dragHandlers:c=null,dragVisual:l,onOpen:u,showTimes:d=!1,downs:f=[],history:m=!1,ops:h=null,searchCtx:g=null}){let v=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),y=t.status===`pending`&&t.ready===!1;return(0,j.jsxs)(`div`,{className:v,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,j.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,j.jsx)(e,{name:`grip`,size:12})}):(0,j.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,j.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,j.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,j.jsxs)(`div`,{className:`rp-proj-task`+(m?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,j.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,j.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,j.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,j.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,j.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,j.jsxs)(`span`,{className:`rp-tgate`,title:f.length?`闸门:未完成前挡住 ${f.length} 个后续任务(#${f.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,f.length?`×${f.length}`:``]}),y&&(0,j.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,j.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[I(t.createdAt),t.consumedAt?` → ${I(t.consumedAt)}`:``]}),(0,j.jsx)(p,{t}),h?(0,j.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:h}):null]}),g?(0,j.jsx)(`div`,{className:`rp-proj-task-ctx`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:g.lines.map((e,t)=>(0,j.jsxs)(`div`,{className:`ctx-line`+(t===g.hitIndex?` hit`:``),children:[(0,j.jsx)(`span`,{className:`ctx-no`,children:g.hitLineNo-g.hitIndex+t}),(0,j.jsx)(`span`,{className:`ctx-tx`,children:e||`\xA0`})]},t))}):null]})}var le=20;function L({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:p=null,toolActs:m={},onNew:h,newDisabled:g=!1,tplMenuItems:_,onOpenRow:v,onMoveRow:y,onImportFile:b,onTogglePlan:x,onOpenDag:S,onToggleGate:C,onFeedback:w,onDeleteRow:T,onDeleteRows:E,onCancelRows:D,onCompleteRows:O,extra:ee=null}){let te=i(),k=(0,A.useRef)(null),[M,N]=(0,A.useState)(null),[P,re]=(0,A.useState)(``),F=!!String(P).trim(),I=(0,A.useMemo)(()=>F?s.filter(e=>f({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,A.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,A.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,A.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,A.useEffect)(()=>{B(new Set)},[R.page]);let W=s.filter(e=>z.has(e.key)),G=W.filter(e=>(e.task.status===`pending`||e.task.status===`claimed`)&&!e.task.migratedTo&&!e.task.deletedAt),K=W.filter(e=>e.task.status===`pending`&&!e.task.migratedTo&&!e.task.deletedAt),q=G.filter(e=>e.task.status===`claimed`).length,ue=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},J=async e=>{W.length&&e&&await e(W)&&B(new Set)},Y=W.filter(e=>e.task.status===`pending`),fe=W.filter(e=>e.task.status===`plan`),pe=Y.length?Y:fe,me=Y.length?`plan`:`pending`,he=W.length?me===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${fe.length})`:`草稿态`,X=(0,A.useRef)(null),[ge,Z]=(0,A.useState)(null),[Q,$]=(0,A.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{X.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),Z(t.key)},ye=(e,t)=>{X.current&&t.movable&&t.key!==X.current&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,$({key:t.key,zone:_e(e,e.currentTarget)}))},be=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||$(null)},xe=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=X.current;if(X.current=null,Z(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{X.current=null,Z(null),$(null)},Ce=e=>{let t=e.task;return[(t.status===`pending`||t.status===`plan`)&&x?{label:t.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>x([e],t.status===`pending`?`plan`:`pending`)}:null,e.movable&&S?{label:`编排依赖…`,onPick:()=>S(e)}:null,e.movable&&C?{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>C(e)}:null,w&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)?{label:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>w(e)}:null,T?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>T(e)}:null]},we=W.length>0?(0,j.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,j.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void J(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void J(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void J(E),children:[`删除选中 (`,W.length,`)`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,j.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,j.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,j.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,j.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:U,onChange:de,"aria-label":`全选当前页任务`}),`全选本页`]}):null]}),emptyText:F?`没有匹配「${P.trim()}」的任务(标题与正文都搜过了)`:c,children:V.map(e=>{let t=e.movable?{onDragStart:t=>ve(t,e),onDragOver:t=>ye(t,e),onDragLeave:be,onDrop:t=>xe(t,e),onDragEnd:Se}:null;return(0,j.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?d(e.task,P):null,selectable:!0,picked:z.has(e.key),onTogglePick:()=>ue(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:ge===e.key,drop:Q&&Q.key===e.key?Q.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,j.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,j.jsx)(`div`,{className:`mdw-land-pager`,children:(0,j.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{N({x:e.clientX,y:e.clientY})},Oe=()=>(0,j.jsx)(`span`,{className:`rp-newtask`,children:(0,j.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,j.jsx)(`span`,{role:`button`,tabIndex:g?void 0:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),De(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),De(e))},children:(0,j.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ne,{kind:t,labels:{more:`更多`,...m.labels,plan:he},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...m.titles},disabled:m.disabled,renderers:{new:Oe,...m.renderers},actions:{...m.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!pe.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(pe,me)}}}),p]})}),M&&(0,j.jsx)(a,{x:M.x,y:M.y,items:_,onClose:()=>N(null)}),(0,j.jsx)(`input`,{ref:k,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b&&b(t)}}),ee]})}function R(e){return((e.text||``).split(`
|
|
1
|
+
import{a as e,d as t,f as n,h as r,l as i,n as a,r as o,t as s}from"./popup-dBtYqEM1.js";import{D as c}from"./repo-form-modal-dZqpHyUj.js";import{n as l}from"./app-context-CngKv8Tc.js";import{l as u}from"./task-status-Cjsm0xF7.js";import{d,f,s as p}from"./md-history-COQu16vy.js";import{t as m}from"./button-Cs6w2CDi.js";import{S as h,h as g,w as _,x as v}from"./index-yhpvk7gl.js";import{t as y}from"./graph-BTEfvFz6.js";import{c as b,d as x,f as S,g as C,l as w,m as T,n as E,p as D,r as O,s as ee,t as te,u as k}from"./reopen-text-B2d9SZi0.js";import{t as ne}from"./bar-C0Q_Qe4z.js";var A=r(n(),1),j=t(),M=10;function N({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,A.useState)(!!(o&&o.enabled)),[f,p]=(0,A.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(M)),[h,g]=(0,A.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return M;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):M},v=async t=>{let i=String(e.id??``);g(!0);try{let o=t&&t.enabled!==void 0?t.enabled:u;await c(i,{"get-loop":o?`on`:`off`,...o?{"get-loop-minutes":_(f)}:{}});let s=_(f);a(o?`已保存「${e.name}」的持续 get 设置(${s>0?`${s} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){a(String(e.message||e))}finally{g(!1)}},y=async e=>{d(e),await v({enabled:e})};return(0,j.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,j.jsxs)(`div`,{className:`rp-gl`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,j.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,j.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,j.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,j.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,j.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,j.jsx)(`span`,{children:`阻塞窗口`}),(0,j.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,j.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,j.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,j.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(m,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var P=s,re=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function F({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,A.useState)(!!e.blocksFollowing),[l,d]=(0,A.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,A.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,A.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&re(i(e),a,v),b=e=>!f.has(i(e))&&re(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||d(new Set),!e)),C=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=f.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},w=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,j.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,j.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,j.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,j.jsx)(P,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,j.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,j.jsxs)(`div`,{className:`mdw-dag`,children:[(0,j.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,j.jsx)(`b`,{children:`闸门`}),(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,j.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,j.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,l.has(i(e)),y(e),x(d))):(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,j.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,f.has(i(e)),s||b(e),x(p))):(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,A.useState)(0),a=Math.max(1,Number(t)||1),o=Math.max(1,Math.ceil(n.length/a)),s=Math.min(Math.max(0,r),o-1),c=s*a;return{page:s,pageCount:o,total:n.length,items:n.slice(c,c+a),setPage:i}}function ae({page:e=0,pageCount:t=1,total:n=0,onPage:r,unit:i=`条`}){let a=e=>r&&r(Math.max(0,Math.min(e,t-1)));return t<=1?(0,j.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,j.jsxs)(`span`,{className:`pager`,children:[(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,j.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e>=t-1,onClick:()=>a(e+1),"aria-label":`下一页`,title:`下一页`,children:`›`})]})}function oe({icon:t=`list`,title:n,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:o=``}){let s=Array.isArray(a)?a.length>0:!!a;return(0,j.jsxs)(`div`,{className:`rp-tasks`,children:[(0,j.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,j.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,j.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,j.jsx)(`div`,{className:`rp-proj-none muted`,children:o}):null]})}function se({name:t,counts:n=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:o=null,list:s=null,footer:c=null,extra:l=null}){return(0,j.jsxs)(`div`,{className:`rp-page`,children:[(0,j.jsxs)(`div`,{className:`rp-group-head`,children:[(0,j.jsxs)(`h2`,{children:[(0,j.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,j.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,j.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}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})/),r=n?.[1],i=n?.[2];return r&&i?`${r.slice(5)} ${i}`:t.slice(0,16)}function ce({t,projectTag:n=``,projectTitle:r=``,selectable:i=!1,picked:a=!1,onTogglePick:o,draggable:s=!1,dragHandlers:c=null,dragVisual:l,onOpen:u,showTimes:d=!1,downs:f=[],history:m=!1,ops:h=null,searchCtx:g=null}){let v=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),y=t.status===`pending`&&t.ready===!1;return(0,j.jsxs)(`div`,{className:v,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,j.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,j.jsx)(e,{name:`grip`,size:12})}):(0,j.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,j.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,j.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,j.jsxs)(`div`,{className:`rp-proj-task`+(m?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,j.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,j.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,j.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,j.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,j.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,j.jsxs)(`span`,{className:`rp-tgate`,title:f.length?`闸门:未完成前挡住 ${f.length} 个后续任务(#${f.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,f.length?`×${f.length}`:``]}),y&&(0,j.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,j.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[I(t.createdAt),t.consumedAt?` → ${I(t.consumedAt)}`:``]}),(0,j.jsx)(p,{t}),h?(0,j.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:h}):null]}),g?(0,j.jsx)(`div`,{className:`rp-proj-task-ctx`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:g.lines.map((e,t)=>(0,j.jsxs)(`div`,{className:`ctx-line`+(t===g.hitIndex?` hit`:``),children:[(0,j.jsx)(`span`,{className:`ctx-no`,children:g.hitLineNo-g.hitIndex+t}),(0,j.jsx)(`span`,{className:`ctx-tx`,children:e||`\xA0`})]},t))}):null]})}var le=20;function L({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:p=null,toolActs:m={},onNew:h,newDisabled:g=!1,tplMenuItems:_,onOpenRow:v,onMoveRow:y,onImportFile:b,onTogglePlan:x,onOpenDag:S,onToggleGate:C,onFeedback:w,onDeleteRow:T,onDeleteRows:E,onCancelRows:D,onCompleteRows:O,extra:ee=null}){let te=i(),k=(0,A.useRef)(null),[M,N]=(0,A.useState)(null),[P,re]=(0,A.useState)(``),F=!!String(P).trim(),I=(0,A.useMemo)(()=>F?s.filter(e=>f({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,A.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,A.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,A.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,A.useEffect)(()=>{B(new Set)},[R.page]);let W=s.filter(e=>z.has(e.key)),G=W.filter(e=>(e.task.status===`pending`||e.task.status===`claimed`)&&!e.task.migratedTo&&!e.task.deletedAt),K=W.filter(e=>e.task.status===`pending`&&!e.task.migratedTo&&!e.task.deletedAt),q=G.filter(e=>e.task.status===`claimed`).length,ue=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},J=async e=>{W.length&&e&&await e(W)&&B(new Set)},Y=W.filter(e=>e.task.status===`pending`),fe=W.filter(e=>e.task.status===`plan`),pe=Y.length?Y:fe,me=Y.length?`plan`:`pending`,he=W.length?me===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${fe.length})`:`草稿态`,X=(0,A.useRef)(null),[ge,Z]=(0,A.useState)(null),[Q,$]=(0,A.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{X.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),Z(t.key)},ye=(e,t)=>{X.current&&t.movable&&t.key!==X.current&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,$({key:t.key,zone:_e(e,e.currentTarget)}))},be=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||$(null)},xe=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=X.current;if(X.current=null,Z(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{X.current=null,Z(null),$(null)},Ce=e=>{let t=e.task;return[(t.status===`pending`||t.status===`plan`)&&x?{label:t.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>x([e],t.status===`pending`?`plan`:`pending`)}:null,e.movable&&S?{label:`编排依赖…`,onPick:()=>S(e)}:null,e.movable&&C?{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>C(e)}:null,w&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)?{label:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>w(e)}:null,T?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>T(e)}:null]},we=W.length>0?(0,j.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,j.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void J(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void J(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void J(E),children:[`删除选中 (`,W.length,`)`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,j.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,j.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,j.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,j.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:U,onChange:de,"aria-label":`全选当前页任务`}),`全选本页`]}):null]}),emptyText:F?`没有匹配「${P.trim()}」的任务(标题与正文都搜过了)`:c,children:V.map(e=>{let t=e.movable?{onDragStart:t=>ve(t,e),onDragOver:t=>ye(t,e),onDragLeave:be,onDrop:t=>xe(t,e),onDragEnd:Se}:null;return(0,j.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?d(e.task,P):null,selectable:!0,picked:z.has(e.key),onTogglePick:()=>ue(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:ge===e.key,drop:Q&&Q.key===e.key?Q.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,j.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,j.jsx)(`div`,{className:`mdw-land-pager`,children:(0,j.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{N({x:e.clientX,y:e.clientY})},Oe=()=>(0,j.jsx)(`span`,{className:`rp-newtask`,children:(0,j.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,j.jsx)(`span`,{role:`button`,tabIndex:g?void 0:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),De(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),De(e))},children:(0,j.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ne,{kind:t,labels:{more:`更多`,...m.labels,plan:he},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...m.titles},disabled:m.disabled,renderers:{new:Oe,...m.renderers},actions:{...m.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!pe.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(pe,me)}}}),p]})}),M&&(0,j.jsx)(a,{x:M.x,y:M.y,items:_,onClose:()=>N(null)}),(0,j.jsx)(`input`,{ref:k,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b&&b(t)}}),ee]})}function R(e){return((e.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${e.id}`).replace(/^#\s*/,``)}function z(e,t){return e.key&&!e.cwd?`key=${encodeURIComponent(e.key)}&id=${Number(t)}`:`cwd=${encodeURIComponent(e.cwd||``)}&id=${Number(t)}`}function B(e){return{cwd:e.cwd}}function V(e,t,n,r){r&&v(g(h(t||e.docKey),String(n)),{body:r})}async function H(e,t){try{return await t()}catch(t){return e.toast(String(t?.message||t)),!1}}async function U(e,t,n){let{dialog:r,toast:i}=e,a=R(n),o=!!n.completedAt,s=await r({title:o?`反馈 · #${n.id}`:`反馈修改 · #${n.id}`,input:!0,placeholder:o?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(s==null)return;let c=String(s).trim();await H(e,async()=>{let r=await k(z(t,n.id)),s=String(r?.text??``).trim()||String(n.text||``).trim(),l=o&&(r?.roundSummary||n.roundSummary)||``;if(!c&&!o&&!s){i(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(o){let r=c?te({base:s,feedback:c,ackSummary:l,feedbackHeading:E,bold:!0}):``;if(!r){i(`写一下反馈`);return}let o=await ee({...B(t),text:r,forkOf:String(n.id),forkKind:`reopen`}),u=String(o?.task?.id??o?.id??``);V(e,o?.key,u,r),i(`已反馈「${a}」→ 新任务 #${u||`?`}`),e.refresh?.();return}let u=await S({...t,id:n.id,kind:`reopen`,...c?{feedback:c,feedbackHeading:O,feedbackBold:!1}:{}}),d=String(u?.task?.id??n.id);V(e,u?.key,d,String(u?.task?.text??``)),i(`已回写「${a}」#${d}`+(u?.moved&&u.name?`;归属迁到「${u.name}」`:``)),e.refresh?.()})}async function W(e,t,n){let{dialog:r,toast:i}=e;await r({title:`删除任务「${R(n)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&await H(e,async()=>(await T({...t,id:n.id}),i(`已删除「${R(n)}」`),e.onDeleted?.(n),e.refresh?.(),!0))}var G=e=>e.reduce((e,t)=>e+t.ids.length,0);async function K(e,t){let n=G(t);if(!n||!await e.dialog({title:`删除选中的 ${n} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return!1;let r=0;for(let n of t){let t=await H(e,()=>D({...n.scope,ids:n.ids}));if(t===!1)return!1;r+=t.count??n.ids.length}return e.toast(`已删除 ${r} 条任务`),e.refresh?.(),!0}async function q(e,t){let n=G(t);if(!n||!await e.dialog({title:`取消选中的 ${n} 条待领取任务`,message:`只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`}))return!1;let r=0,i=0;for(let n of t){let t=await H(e,()=>b({...n.scope,ids:n.ids}));if(t===!1)return!1;let a=t;r+=a.count??0,i+=a.skipped?.length||0}return e.toast(`已取消 ${r} 条任务${i?`,跳过 ${i} 条`:``}`),e.refresh?.(),!0}async function ue(e,t){let n=G(t);if(!n||!await e.dialog({title:`把选中的 ${n} 条任务标为完成`,message:`待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`}))return!1;let r=0,i=0,a=0;for(let n of t){let t=await H(e,()=>w({...n.scope,ids:n.ids,status:`done`}));if(t===!1)return!1;let o=t;r+=o.count??0,i+=o.skipped?.length||0,a+=o.claimedClosed?.length||0}return e.toast(`已标为完成 ${r} 条任务${a?`(含 ${a} 条已领取)`:``}${i?`,跳过 ${i} 条`:``}`),e.refresh?.(),!0}async function de(e,t,n){let r=!n.blocksFollowing;await H(e,()=>x({...t,id:n.id,gate:r}))&&(e.toast(r?`#${n.id} 已设为闸门——挡住所有后续待领取任务`:`#${n.id} 闸门已取消`),e.refresh?.())}async function J(e,t,n){let r=t.reduce((e,t)=>e+t.ids.length,0);r&&await H(e,async()=>{for(let e of t)for(let t of e.ids)await C({...e.scope,id:Number(t),to:n});return e.toast(n===`plan`?`已把 ${r} 条任务转为草稿(不进队列)`:`已把 ${r} 条草稿转回待领取`),e.refresh?.(),!0})}async function Y(e,t,n){try{for(let e of n)await x({...t,...e});e.toast(`编排已保存`),e.refresh?.()}catch(t){throw e.toast(String(t?.message||t)),t}}export{U as a,Y as c,N as d,W as i,L as l,ue as n,J as o,K as r,de as s,q as t,F as u};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-dBtYqEM1.js";import{D as o}from"./tool-bar-DPXnjdQF.js";import{n as s}from"./app-context-CngKv8Tc.js";import{d as c}from"./task-status-Cjsm0xF7.js";import{a as l,i as u,n as d,r as f,t as p,u as m}from"./md-history-COQu16vy.js";import{t as h}from"./button-Cs6w2CDi.js";import{t as g}from"./list-search-DFvFY408.js";import{n as _,t as v}from"./route-crumb-BKq2jry0.js";import{d as y,m as b}from"./index-
|
|
3
|
-
`).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``)).filter(Boolean).slice(0,2).join(` · `)}function k(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let w=n.templates||[],T=m(w,y,e=>[e.name,O(e.body),(e.scope||[]).join(` `)]),E=async(e,t)=>{if(!_){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},k=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await E(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,C.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:_,onClick:()=>x(`#/templates/new`),children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!w.length&&(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),w.length>1?(0,C.jsx)(`div`,{className:`tpl-search`,children:(0,C.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:T.length,className:`wide`})}):null,(0,C.jsxs)(`div`,{className:`tpl-list`,children:[T.map(t=>{let r=t.id===n.defaultId,i=u===t.id,a=f===t.id;return(0,C.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,C.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,C.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,C.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,C.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>p(a?null:t.id),children:(0,C.jsx)(e,{name:`monitor`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:_,onClick:()=>d(i?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:_,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:_,onClick:()=>E(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:_,onClick:()=>k(t),children:(0,C.jsx)(e,{name:`trash`,size:14})})]})]}),(0,C.jsx)(`div`,{className:`tpl-card-sum`,children:O(t.body)||`(空模板)`}),i&&(0,C.jsx)(`div`,{className:`tpl-card-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,C.jsx)(`div`,{className:`tpl-preview`,children:(0,C.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(t.body)}})})]},t.id)}),w.length&&!T.length?(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function A({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,S.useMemo)(()=>x(t?.id),[t?.id]),c=y(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,_]=(0,S.useState)(null),[w,T]=(0,S.useState)(null),[E,O]=(0,S.useState)(!1),k=c.templates||[],A=m(k,l,e=>[e.name,e.body,(e.scope||[]).join(` `)]),j=async(e,t)=>{if(!E){O(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{O(!1)}}},M=async(e,t)=>{if(e===t)return;let n=k.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await j(()=>i.reorder(n)))},N=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-yhpvk7gl.js","assets/popup-dBtYqEM1.js","assets/popup-BAvk7J7u.css","assets/tool-bar-DPXnjdQF.js","assets/tool-bar-CLIs9Dr0.css","assets/repo-form-modal-dZqpHyUj.js","assets/button-Cs6w2CDi.js","assets/button-DA4lNJeC.css","assets/doc-CVIVBV6n.js","assets/app-context-CngKv8Tc.js","assets/task-status-Cjsm0xF7.js","assets/md-history-COQu16vy.js","assets/use-rail-drag-B6J0iqFK.js","assets/list-search-DFvFY408.js","assets/route-crumb-BKq2jry0.js","assets/board-view-C8OQhkyi.js","assets/doc-DgYKv2wo.css","assets/index-DiTnp6Kh.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-dBtYqEM1.js";import{D as o}from"./tool-bar-DPXnjdQF.js";import{n as s}from"./app-context-CngKv8Tc.js";import{d as c}from"./task-status-Cjsm0xF7.js";import{a as l,i as u,n as d,r as f,t as p,u as m}from"./md-history-COQu16vy.js";import{t as h}from"./button-Cs6w2CDi.js";import{t as g}from"./list-search-DFvFY408.js";import{n as _,t as v}from"./route-crumb-BKq2jry0.js";import{d as y,m as b}from"./index-yhpvk7gl.js";import{t as x}from"./manage-session-CS8UvmUd.js";var S=r(n(),1),C=t(),w={topic:`目录`,repo:`项目`,group:`组`};function T(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,S.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function E(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a=w[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function D({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:i=`setp`}){let o=a(),s=T(),c=r||s,[l,u]=(0,S.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=i,h=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,g=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},_=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await g([...d,e]),u(null)},v=(0,S.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,C.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,C.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>g(d.filter(t=>t!==e)),children:[E(e,c),` ×`]},e))}),(0,C.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,C.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&g([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:w[e]},e)),h?(0,C.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,h]}):null]}),l&&(0,C.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:v.length?v.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>_(e.entry),children:[(0,C.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,C.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,C.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function O(e){return String(e||``).split(`
|
|
3
|
+
`).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``)).filter(Boolean).slice(0,2).join(` · `)}function k(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let w=n.templates||[],T=m(w,y,e=>[e.name,O(e.body),(e.scope||[]).join(` `)]),E=async(e,t)=>{if(!_){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},k=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await E(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,C.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:_,onClick:()=>x(`#/templates/new`),children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!w.length&&(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),w.length>1?(0,C.jsx)(`div`,{className:`tpl-search`,children:(0,C.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:T.length,className:`wide`})}):null,(0,C.jsxs)(`div`,{className:`tpl-list`,children:[T.map(t=>{let r=t.id===n.defaultId,i=u===t.id,a=f===t.id;return(0,C.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,C.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,C.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,C.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,C.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>p(a?null:t.id),children:(0,C.jsx)(e,{name:`monitor`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:_,onClick:()=>d(i?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:_,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:_,onClick:()=>E(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:_,onClick:()=>k(t),children:(0,C.jsx)(e,{name:`trash`,size:14})})]})]}),(0,C.jsx)(`div`,{className:`tpl-card-sum`,children:O(t.body)||`(空模板)`}),i&&(0,C.jsx)(`div`,{className:`tpl-card-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,C.jsx)(`div`,{className:`tpl-preview`,children:(0,C.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(t.body)}})})]},t.id)}),w.length&&!T.length?(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function A({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,S.useMemo)(()=>x(t?.id),[t?.id]),c=y(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,_]=(0,S.useState)(null),[w,T]=(0,S.useState)(null),[E,O]=(0,S.useState)(!1),k=c.templates||[],A=m(k,l,e=>[e.name,e.body,(e.scope||[]).join(` `)]),j=async(e,t)=>{if(!E){O(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{O(!1)}}},M=async(e,t)=>{if(e===t)return;let n=k.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await j(()=>i.reorder(n)))},N=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-yhpvk7gl.js`).then(e=>e.p);return{openTemplateEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])).then(({openTemplateEditor:t})=>{n.model&&t(n.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},P=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,C.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,C.jsx)(v,{}),(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,P]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`只显示本主题可见的模板。拖动左侧把手调整顺序,点图标改可见范围;搜索框会同步隐藏不匹配的行。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:E,onClick:N,children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,C.jsx)(`div`,{className:`tpl-mng-search`,children:(0,C.jsx)(g,{value:l,onChange:u,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤本主题模板`,count:A.length,className:`wide`})}),k.length?(0,C.jsx)(`div`,{className:`tpl-mng-list`,children:A.map(t=>{let r=t.id===i?.defaultId;return(0,C.jsxs)(`div`,{className:[`tpl-mng-row`,d===t.id?`is-dragging`:``,p===t.id&&d!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{f(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,_(t.id)},onDrop:e=>{e.preventDefault(),_(null),d&&M(d,t.id),f(null)},onDragEnd:()=>{f(null),_(null)},children:[(0,C.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,C.jsx)(e,{name:`grip`,size:14})}),(0,C.jsxs)(`div`,{className:`tpl-mng-main`,children:[(0,C.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,C.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`})]}),(t.scope||[]).length>0&&!w&&(0,C.jsxs)(`div`,{className:`tpl-mng-scope-sum muted`,children:[`可见:`,(t.scope||[]).join(` / `)]})]}),(0,C.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`可见范围`,onClick:()=>T(w===t.id?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>n.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:E,onClick:()=>j(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:E,onClick:()=>j(()=>i.remove(t.id),`已删除「${t.name}」`),children:(0,C.jsx)(e,{name:`trash`,size:14})})]}),w===t.id&&(0,C.jsx)(`div`,{className:`tpl-mng-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>i.update(t.id,{scope:e})})})]},t.id)})}):(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}var j=e=>`tpl:${e||`new`}`,M=`## 背景
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## 验收
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
|
|
13
13
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
14
14
|
<link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-yhpvk7gl.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/popup-dBtYqEM1.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/tool-bar-DPXnjdQF.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/button-Cs6w2CDi.js">
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,t as o,u as s}from"./popup-dBtYqEM1.js";import{D as c,f as l,n as u,u as d}from"./tool-bar-DPXnjdQF.js";import{n as f}from"./app-context-CngKv8Tc.js";import{d as p,g as m,h,l as g,m as _,s as v}from"./task-status-Cjsm0xF7.js";import{C as y,E as b,T as x,a as S,b as C,i as w,n as T,r as E,s as D,t as O,w as k}from"./md-history-COQu16vy.js";import{i as A,r as ee,t as j}from"./use-rail-drag-B6J0iqFK.js";import{t as te}from"./route-crumb-BKq2jry0.js";import{C as ne,S as re,_ as ie,b as ae,g as oe,h as M,v as N,x as P,y as F}from"./index-Bposj22Z.js";import{a as se,i as I,n as L,o as R}from"./composer-launch-BF3_hyn5.js";import{a as z,d as B,f as V,g as ce,i as H,l as le,m as ue,n as de,o as U,r as fe,s as pe,t as me,u as W}from"./reopen-text-B2d9SZi0.js";import{n as G,r as K,t as he}from"./task-utils-Dh33OFKe.js";import{n as ge}from"./group-project-memo-G-O6sPRw.js";var q=r(n(),1);function _e(e){return s(`/api/localtasks/chain?${e}`)}function ve(e){return s(`/api/localtasks/timegoal-log?${e}`)}function ye(e){return s(`/api/localtasks/clone`,{method:`POST`,body:e})}function be(e){return s(`/api/localtasks/fork`,{method:`POST`,body:e})}function xe(e){return s(`/api/localtasks/attachments?${e}`)}function Se(e){return s(`/api/docs/mdfile?attachment=${encodeURIComponent(e)}`)}function Ce(e){return s(`/api/localtasks/preview`,{method:`POST`,body:e})}function we(e){let t=String(e??``).split(`
|
|
2
|
-
`),n=z(t[0]);return n?{head:n,body:t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
|
|
3
|
-
`)}:null}function Te(e){let t=k(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=we(a);if(o&&H(o.head)===`summary`){let e=o.head.round;r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&H(o.head)===`feedback`){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
|
|
4
|
-
`:``)+a:r.feedbackText+=(r.feedbackText?`
|
|
5
|
-
`:``)+a)}),n.filter(e=>e.ackText!==``)}function Ee(e){let t=String(e?.ackText||``).split(`
|
|
6
|
-
`).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e?.round??1} 轮 · ${n}`}var J=t();function De(e,t,n){return!e||t<0?null:e.querySelector(`.mdw-lp-block[data-i="${t}"]`)||[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1)[n]||null}function Oe({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(0),{railRef:s,pos:c,dragging:l,draggedRef:u,handleProps:d}=j(),f=(0,q.useMemo)(()=>(e||[]).map(e=>({...e,title:Ee(e)})),[e]);(0,q.useEffect)(()=>{let e=t;if(!e||!f.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of f){let i=De(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,f]);let p=(0,q.useCallback)(e=>{let r=t,i=r?De(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return f.length?(0,J.jsxs)(`aside`,{ref:s,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:c?{left:c.x,top:c.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(u.current){u.current=!1;return}i(e=>!e)},...d,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:f.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>p(e)},e.round))}),r&&(0,J.jsx)(`div`,{className:`doc-rail-panel`,children:(0,J.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,J.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),f.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>p(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var ke=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function Ae({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,J.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,J.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[ke.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,J.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,J.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`cap`,children:`选区`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,J.jsx)(`div`,{className:`sep`}),(0,J.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sep`}),(0,J.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var je=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function Me({onClose:e}){return(0,J.jsx)(o,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,J.jsx)(`div`,{className:`mdw-sheet-cols`,children:je.map(e=>(0,J.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,J.jsx)(`h4`,{children:e.title}),(0,J.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,J.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,J.jsx)(`dt`,{children:(0,J.jsx)(`kbd`,{children:e})}),(0,J.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var Y=148,Ne=58,X=20,Pe=46,Fe={origin:`起点`,reopen:`反馈`,feedback:`反馈`,comment:`评论`,fork:`分支`},Ie={pending:`待领取`,claimed:`已领取`,done:`已完成`,cancelled:`已取消`,plan:`草稿`},Le={origin:`#6B7078`,reopen:`#B4703A`,feedback:`#B4703A`,comment:`#3F6E9E`,fork:`#7A5FA8`},Re={pending:`#8A8F98`,claimed:`#C99A2E`,done:`#2F6F5E`,cancelled:`#C0392B`,plan:`#9AA0A8`};function ze(e){let t=e.children||[];if(!t.length)return Y;let n=t.reduce((e,t)=>e+ze(t),0)+X*(t.length-1);return Math.max(Y,n)}function Be(e){let t=String(e||``).trim();if(!t)return``;let n=/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/.exec(t);return n?`${n[2]}-${n[3]} ${n[4]}:${n[5]}`:t.slice(0,16)}function Ve({root:e,onOpen:t}){let n=[],r=[],i=0,a=(e,t)=>{let o=ze(e),s=e.children||[],c={id:String(e.id),x:0,y:t*104,depth:t,kind:String(e.forkKind||(t===0?`origin`:``)),status:String(e.status||``),label:String(e.excerpt||`#${e.id}`),time:Be(e.createdAt),current:!!e.current,missing:!!e.missing,node:e};if(!s.length)c.x=i+(o-Y)/2,i+=o+X;else{let e=i,n=s.map(e=>a(e,t+1)),l=n[0],u=n[n.length-1];c.x=(l.x+u.x)/2,c.x=Math.min(Math.max(c.x,e),e+o-Y);for(let e of n)r.push({from:c,to:e});i=Math.max(i,e+o+X)}return n.push(c),c};a(e,0);let o=Math.max(Y,i-X)+24,s=(Math.max(0,...n.map(e=>e.depth))+1)*104-Pe+24;return(0,J.jsx)(`div`,{className:`mdw-chain-graph-wrap`,children:(0,J.jsxs)(`svg`,{className:`mdw-chain-graph`,width:o+8,height:s+8,viewBox:`-12 -12 ${o} ${s}`,role:`img`,"aria-label":`任务链树图`,children:[r.map((e,t)=>{let n=e.from.x+Y/2,r=e.from.y+Ne,i=e.to.x+Y/2,a=e.to.y,o=r+(a-r)/2;return(0,J.jsx)(`path`,{d:`M ${n} ${r} V ${o} H ${i} V ${a}`,fill:`none`,stroke:`var(--line, #D8D6D0)`,strokeWidth:`1.4`},`e${t}`)}),n.map(e=>{let n=Le[e.kind]||`#6B7078`,r=Re[e.status]||`#8A8F98`,i=Fe[e.kind]||(e.depth===0?`起点`:`?`),a=Ie[e.status]||e.status||``;return(0,J.jsxs)(`g`,{className:`mdw-chain-node`+(e.current?` is-current`:``)+(e.missing?` is-missing`:``),transform:`translate(${e.x}, ${e.y})`,onClick:()=>{!e.current&&!e.missing&&t?.(e.node)},style:{cursor:e.current||e.missing?`default`:`pointer`},children:[(0,J.jsx)(`title`,{children:`#${e.id} ${i}${a?` · `+a:``}\n${e.label}${e.time?`
|
|
7
|
-
`+e.time:``}${e.current?`
|
|
8
|
-
(当前任务)`:``}`}),(0,J.jsx)(`rect`,{width:Y,height:Ne,rx:`8`,fill:e.current?`var(--soft, #F4F6F4)`:`var(--paper, #FFFFFF)`,stroke:e.current?`var(--mdw-accent, #2F6F5E)`:`var(--line, #D8D6D0)`,strokeWidth:e.current?2:1}),(0,J.jsx)(`rect`,{x:`8`,y:`7`,width:i.length*12+12,height:`16`,rx:`8`,fill:n,opacity:`0.12`}),(0,J.jsx)(`text`,{x:`14`,y:`19`,fontSize:`10`,fontWeight:`600`,fill:n,children:i}),(0,J.jsxs)(`text`,{x:138,y:`19`,fontSize:`10`,fill:`var(--faint, #8A8F98)`,textAnchor:`end`,children:[`#`,e.id]}),(0,J.jsx)(`text`,{x:`10`,y:`37`,fontSize:`11.5`,fill:`var(--ink, #16181C)`,children:e.label.length>15?e.label.slice(0,15)+`…`:e.label}),(0,J.jsx)(`circle`,{cx:`13`,cy:`47`,r:`3`,fill:r}),(0,J.jsx)(`text`,{x:`21`,y:`50`,fontSize:`10`,fill:`var(--ink-2, #454A52)`,children:a}),e.time?(0,J.jsx)(`text`,{x:138,y:`50`,fontSize:`9.5`,fill:`var(--faint, #8A8F98)`,textAnchor:`end`,children:e.time}):null]},`n${e.id}`)})]})})}var He={origin:`起点`,reopen:`反馈`,feedback:`反馈`,comment:`评论`,fork:`分支`,current:`当前`};function Ue({nodes:e=[],onOpenNode:t}){return e.length?(0,J.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=He[n.kind||``]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,J.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,J.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,J.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,J.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,J.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,J.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,J.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,J.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function We({open:e,nodes:t,tree:n,onOpenNode:r,onClose:i}){return e?(0,J.jsxs)(o,{title:`任务链`,onClose:i,size:`lg`,className:`mdw-chain-modal`,children:[(0,J.jsxs)(`p`,{className:`mdw-chain-hint`,children:[n?`单向树:每条任务至多一个来源(评论 / 反馈 / 分支),后代分叉并列。点任意节点旁路打开。`:`从早到晚排列。点非当前节点可在旁路打开内容。`,` `,`agent 实收提示词为交付重排版(最新轮在前);原始意图读正文的 WARNING 块。`]}),n?(0,J.jsx)(Ve,{root:n,onOpen:e=>{r?.({...e,taskId:e.id,dirKey:e.key,kind:e.forkKind}),i?.()}}):(0,J.jsx)(Ue,{nodes:t,onOpenNode:e=>{r?.(e),i?.()}})]}):null}function Ge({id:e,isDraft:t,topicKey:n,task:r,taskRow:i}){let[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{o(null)},[e]);let s=i?.timegoal||null,c=a||{duration:s?.duration||``,prompt:s?.prompt||``},l=t||!!i&&i.status===`pending`,u=t||!!i&&i.status!==`done`&&i.status!==`cancelled`&&(i.status===`pending`||!!s),d=!t&&!!s&&r!=null,[f,p]=(0,q.useState)({busy:!1,error:``,data:null}),m=(0,q.useCallback)(()=>{!t&&n&&r!=null&&(p(e=>({...e,busy:!0,error:``})),ve(new URLSearchParams({id:String(r),key:String(n)}).toString()).then(e=>p(t=>({...t,data:e,busy:!1}))).catch(e=>p(t=>({...t,busy:!1,error:String(e.message||e)}))))},[t,n,r]);return(0,q.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:a,setGoalDraft:o,goal:c,goalEditable:l,goalPromptEditable:u,declaredGoal:s,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function Ke({isDraft:e,task:t,taskRow:n,topicKey:r,topic:i,groupAnchored:a,groupId:o,app:s,model:c,historyId:l,toast:u}){let[f,p]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){p(null);return}let n=!1;return _e(`cwd=${encodeURIComponent(i?.cwd||``)}&id=${Number(t)}`).then(e=>{n||p(e)}).catch(()=>{n||p(null)}),()=>{n=!0}},[e,t,i?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let m=(0,q.useMemo)(()=>e||!f?null:f.tree||null,[e,f]),h=(0,q.useMemo)(()=>{if(e||!n)return[];let i=(String(n.text||``).split(`
|
|
9
|
-
`).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),a=Array.isArray(n.history)?n.history:[];if(a.length){let e=a.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return e.push({historyId:null,kind:`current`,at:n.lastReopenedAt||n.createdAt||``,excerpt:i,attachmentCount:0,current:!0}),e}let o=Array.isArray(f?.ancestors)?[...f.ancestors].reverse():[],s=Array.isArray(f?.children)?f.children:[];if(!o.length&&!s.length&&!n.forkOf)return[];let c=[];for(let e of o)e.missing||c.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});c.push({historyId:null,kind:`current`,at:n.createdAt||``,excerpt:i,attachmentCount:0,current:!0,taskId:Number(t),dirKey:r});for(let e of s)c.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return c},[e,n,f,t,r]),g=(0,q.useMemo)(()=>{if(l==null||!n)return null;let e=Number(l);return(n.history||[]).find(t=>Number(t.id)===e)||null},[l,n]),_=Array.isArray(f?.children)?f.children:[],v=_.length===0,y=_.length?_[_.length-1]??null:null;return{chainApi:f,chainNodes:h,chainTree:m,historyNode:g,chainChildren:_,isChainTip:v,latestChild:y,openLatestRound:(0,q.useCallback)(()=>{y&&s.openPage&&(a?s.openPage({groupId:o,task:String(y.id),name:`#${y.id}`}):s.openPage({dirKey:String(y.key||r||``),task:String(y.id),name:`#${y.id}`}))},[y,s.openPage,a,o,r]),openHistoryBeside:(0,q.useCallback)(n=>{let i=c||s.model;if(i&&!e){if(n?.current){u(`当前节点就是本页`);return}if(n?.historyId!=null){d(i,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:r,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){d(i,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}u(`这个节点没有可打开的内容`)}},[c,s.model,e,r,t,u])}}function qe({id:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(``);return(0,q.useEffect)(()=>{n(null),r.current=``},[e]),(0,q.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,q.useCallback)((e,t,i,a,o={})=>{r.current=t,n({kind:e,text:t,...o,x:Math.min(window.innerWidth-300,Math.max(8,i)),y:Math.min(window.innerHeight-240,Math.max(8,a))})},[]),onEditorTextSel:(0,q.useCallback)(e=>{if(!e?.text||e.text.length<1){n(null);return}r.current=e.text,n({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},[]),closeSelMenu:(0,q.useCallback)(()=>{n(null),r.current=``},[])}}function Je({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,q.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,q.useLayoutEffect)(()=>{let e=c.current;if(!e){s(!1);return}let t=()=>{i||s(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[i,t?.roundSummary,t?.completedAt,n,r]),{ackOpen:i,setAckOpen:a,ackOverflow:o,reviewSumRef:c,ackLong:l}}function Ye({doc:e,id:t,isDraft:n,task:r,taskRow:i,topicKey:o,topic:s,boardCtx:u,docFm:d,groupAnchored:f,groupId:p,rows:b,app:S,model:C,tabId:w,tpl:T,refreshLocal:E,markDirty:D,histRef:k,editorApiRef:A,attachAreaRef:ee,setDirty:j,goal:te,goalEditable:ne,goalPromptEditable:ie,declaredGoal:oe,guard:L,dialog:R,showDockTab:z}){let V=a(),H=(0,q.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=_(t),i=Object.keys(r).length>0,a=h(t);return a=x(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?m(a,r):a},[]),de=(0,q.useCallback)(()=>{let e=(te.duration||``).trim(),t=(te.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!n){let n=oe?.duration||``,r=oe?.prompt||``,i=e!==n;return!i&&t===r?{}:i?ne?e?{duration:e,goalPrompt:t}:{clearGoal:!0}:{error:`已领取计时,时长不可改(附加要求仍可直接改)`}:ie?{goalPrompt:t}:{}}return e?{duration:e,goalPrompt:t}:{}},[te,ne,ie,n,oe]),U=(0,q.useCallback)(()=>L(async()=>{if(!e)return;let i=(e.title||``).trim()||`未命名任务`,a=_(e.body),l=H(i,e.body),d=a.project?b.find(e=>e.repo&&e.repo.key===a.project):null,m=!!(u&&a.project&&u.members.some(e=>e.key===a.project)),h=de();if(h.error){V(h.error);return}if(!n){let n=await B({cwd:d?d.cwd:s?.cwd,id:Number(r),text:l,...h});if(n?.moved){let a=n.key||o,s=String(n.task?.id??r),u=M(re(a),s);se(s,e.attachments),ae(t,u,{title:i,body:n.task?.text||l}),C&&w&&C.doAction(c.updateNodeAttributes(w,{config:f?{groupId:p,task:s}:{dirKey:a,task:s}})),S.onNavigate&&S.onNavigate(f?`#/group/${encodeURIComponent(p||``)}?task=${encodeURIComponent(s)}`:`#/dir/${encodeURIComponent(a||``)}?task=${encodeURIComponent(s)}`),j(!1),O(k.current,u),V(`已改归属项目:任务迁到「${n.name}」#${s}`),E?.();return}se(r,e.attachments),P(t,{title:i,body:l}),j(!1),O(k.current,t),V(h.clearGoal?`已同步 MD · 时间目标已清除`:h.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),E?.();return}let g=await pe({...m?{text:l,board:u.board.id,project:a.project}:a.project?{text:l,project:a.project}:{cwd:s?.cwd,text:l},...h}),y=g?.task?.id??g?.id;if(y!=null){let n=g?.key||o,r=re(n);se(y,e.attachments);let a=M(r,String(y));ae(t,a,{title:i,body:l}),C&&w&&C.doAction(c.updateNodeAttributes(w,{config:f?{groupId:p,task:String(y)}:{dirKey:n,task:String(y)}})),S.onNavigate&&S.onNavigate(f?`#/group/${encodeURIComponent(p||``)}?task=${encodeURIComponent(String(y))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(y))}`),j(!1),O(k.current,a)}V(`已提交:${v(i)}`),E?.()}),[e,t,n,r,o,s,u,f,p,b,S,C,w,E,k,j,H,de,L,V]),fe=(0,q.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await L(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await pe({cwd:s?.cwd,text:r});V(`已导入:${e.name}`),E?.();let a=i?.task?.id??i?.id;a!=null&&S.openPage&&(f?S.openPage({groupId:p,task:String(a),name:`#${a}`}):S.openPage({dirKey:o,task:String(a),name:`#${a}`}))})},[f,d.project,s?.cwd,o,p,S,E,L,V]),me=(0,q.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${r}`;await R({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&L(async()=>{await ue({cwd:s?.cwd,id:Number(r)}),V(`已删除「${t}」`);let e=w&&(C||S.model||null)?.getNodeById?.(w),n=e&&e.getConfig&&e.getConfig()||{};typeof e?.getWindowId==`function`&&e.getWindowId()===`float`||n.beside||!S.onNavigate?C&&w&&C.doAction(c.deleteTab(w)):f?S.onNavigate(`#/group/`+encodeURIComponent(p||``)):S.onNavigate(`#/dir/`+encodeURIComponent(o||``)),E?.()})},[e,n,r,s,C,w,S,f,p,o,E,L,V,R]),W=String(i?.status??``),G=!n&&!!i&&(W===`pending`||W===`claimed`),K=!n&&!!i&&W===`pending`,he=G||K,ge=(0,q.useCallback)(t=>{(t===`done`?!G:!K)||L(async()=>{let n=e?.title||`#${r}`,a={cwd:s?.cwd};if(t===`done`){let e=W===`claimed`,t=String(i?.claimedByName||i?.claimedBy||``).trim(),o=await R({title:`标为完成「${n}」`,message:e?`该任务正被${t?` ${t} `:` agent `}领取中。你是最终验收方——确认它已经做完、直接标为完成?可写一句完成总结(agent 稍后的回执会被忽略,不算冲突)。`:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(o==null)return;await le({...a,ids:[Number(r)],status:`done`,summary:String(o).trim()}),V(`已标为完成 #${r}`)}else{if(!await R({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await le({...a,ids:[Number(r)],status:`cancelled`}),V(`已取消 #${r}`)}E?.()})},[G,K,e,r,s,W,i,E,L,V,R]),_e=!n&&!!i&&(W===`pending`||W===`plan`);return{composeText:H,goalPatchOf:de,submit:U,importMd:fe,delTask:me,canComplete:G,canCancel:K,canCloseTask:he,closeTask:ge,canPlan:_e,togglePlan:(0,q.useCallback)(()=>{if(!_e)return;let e=W===`plan`?`pending`:`plan`;L(async()=>{let t={cwd:s?.cwd};await ce({...t,id:Number(r),to:e}),V(e===`plan`?`已把 #${r} 转成草稿态(不进队列)`:`已把 #${r} 转回待领取`),E?.()})},[_e,W,r,s,L,V,E]),addFiles:(0,q.useCallback)(async(i,a={})=>{if(!e)return;let{items:o,imageInserts:c,fileInserts:l}=await I(i),u=F(t)||e,d=u.body||``,f=c.join(``),p=d,m=null;if(f){let e=y(d,f,a);p=e.body,m=e.insertAt+f.length}l.length&&(p=y(p,l.join(``),{}).body);let h={};if(p!==d&&(h.body=p),o.length&&(h.attachments=[...u.attachments||[],...o]),Object.keys(h).length){if(P(t,h),a.mode===`edit`&&m!=null&&requestAnimationFrame(()=>{A.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(m,m)}catch{}}),!n){h.attachments&&se(r,h.attachments);let e=H(u.title,h.body||p);P(t,{body:e,title:g(e)});try{await B({cwd:s?.cwd,id:Number(r),text:e}),j(!1),E?.(),V(o.length?`已添加附件并同步(${o.length})`:`已同步附件`)}catch(e){D(),V(`附件已插入,同步失败:${e.message||e}`)}return}D()}},[e,t,n,r,s,j,E,D,H,A,V]),newTask:(0,q.useCallback)(()=>{let e=N(),t=M(re(f?p:o),e),n={};u&&u.board&&u.board.id&&(n.board=u.board.id),d.project&&(n.project=d.project),P(t,{title:``,body:m(T?T.defaultPick().body:``,n)}),S.openPage&&S.openPage(f?{groupId:p,task:e,name:`新任务`}:{dirKey:o,task:e,name:`新任务`})},[u,d.project,f,p,o,S,T]),cloneCur:(0,q.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){V(`草稿没有可克隆的队列任务`);return}L(async()=>{let t=await ye({id:Number(r),cwd:s?.cwd});V(`已克隆为新任务 #${t.task?.id??t.id}`),E?.();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(f?S.openPage({groupId:p,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,r,s,f,p,o,S,e,E,L,V]),forkCur:(0,q.useCallback)(()=>{if(n||r==null||/^draft/i.test(String(r))){V(`草稿没有可 Fork 的队列任务`);return}L(async()=>{let t=await be({id:Number(r),cwd:s?.cwd});V(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),E?.();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(f?S.openPage({groupId:p,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,r,s,f,p,o,S,e,E,L,V]),openProgress:(0,q.useCallback)(()=>{let e=C||S.model;if(!e)return;let t=d&&d.board?String(d.board):``;l(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:r==null?void 0:String(r)}:{dirKey:o,task:r==null?void 0:String(r)},location:`right`})},[C,S.model,d,r,o]),openAttachPanel:(0,q.useCallback)(()=>{z(`attach`),setTimeout(()=>ee.current?.open(),0)},[z,ee])}}function Xe({doc:e,isDraft:t,task:n,taskRow:r,topicKey:i,topic:o,dirKey:s,groupAnchored:l,groupId:u,app:d,model:f,tabId:p,refreshLocal:m,closeSelMenu:h,lastSel:_,selMenu:v,dirty:y,setDirty:b,guard:x}){let S=a(),C=(0,q.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=`cwd=${encodeURIComponent(o?.cwd||``)}&id=${Number(n)}`;return W(e).catch(()=>null)},[t,n,o?.cwd]),w=(0,q.useCallback)(()=>{let t=f||d.model;t&&L(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(r?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:i||s||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>T(e)})},[f,d.model,n,e,r,i,s]),T=(0,q.useCallback)(({text:a,attachments:s=[],inserts:c=``}={})=>{let f=String(a||``).trim();if(h(),!f&&!(s&&s.length)){S(`写一下反馈`);return}let p=e?.title||`#${n}`;x(async()=>{let a=await C(),h=String(a?.text??``).trim()||String(e?.body??``).trim();if(!h&&!t){S(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let _=f||`(见附件)`;c&&(_=`${_}${c}`);let v={base:h,feedback:_,ackSummary:a?.roundSummary||r?.roundSummary||``,feedbackHeading:de,bold:!0},y=me(v),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await pe({cwd:o?.cwd,text:y,...b}),w=String(x?.task?.id??x?.id??``);if(!w){S(`反馈已提交,但未拿到新任务编号`),m?.();return}let T=x?.key||i;P(M(re(T),w),{title:g(y),body:y}),s?.length&&se(w,s),S(`已反馈「${p}」→ 新任务 #${w}`),m?.(),d.openPage&&(l?d.openPage({groupId:u,task:w,name:`${p.slice(0,24)}(反馈)`}):d.openPage({dirKey:T,task:w,name:`${p.slice(0,24)}(反馈)`}))})},[e,n,r,t,o,i,l,u,d,m,h,x,S,C]),E=(0,q.useCallback)(({text:r,attachments:a=[],inserts:s=``,quote:l}={})=>{let u=String(r||``).trim(),d=String(l||_.current||``).trim();if(h(),!u&&!(a&&a.length)){S(`写一下要提的问题`);return}if(!d&&!u){S(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){S(`草稿先提交成任务再评论`);return}let v=e?.title||`#${n}`;x(async()=>{let t=!y&&!s&&!(a&&a.length),r;if(!t){let t=await C(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){S(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let i={base:n,feedback:[U(d),u||`(见附件)`,s].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`),ackSummary:``,feedbackHeading:fe,bold:!1};r=me(i)}let l=await V({cwd:o?.cwd,id:Number(n),...r?{text:r}:{},kind:`comment`,quote:d,feedback:u,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}),h=l?.key||i,_=String(l?.task?.id??n),x=String(l?.task?.text??r??``);x&&P(M(re(h),_),{title:g(x),body:x}),a?.length&&se(_,[...e?.attachments||[],...a]),f&&p&&h!==i&&f.doAction(c.updateNodeAttributes(p,{config:{dirKey:h,task:_}})),b(!1),S(`已回写评论「${v}」#${_}`),m?.()})},[e,n,t,o,i,f,p,m,h,_,y,b,x,S,C]);return{fetchServerTask:C,openFeedback:w,spawnFeedbackTask:T,submitCommentInPlace:E,openCommentFromToolbar:(0,q.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(v?.text?String(v.text):``);if(!t){S(`先划选一段再评论`);return}_.current=t;let r=f||d.model;r&&(L(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:i||s||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>E({...e,quote:t})}),h())},[e,n,i,s,f,d.model,_,v,E,h,S])}}function Ze({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,q.useMemo)(()=>e?_(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,q.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1];if(!l)return null;let u=l.trim(),d=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:g(e.text||``)===u||String(e.text||``).includes(`# ${u}`));return d?{dirKey:n,task:String(d.id),name:`#${d.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,q.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(e=>!!e).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}var Qe=o;function $e({state:e,onClose:t}){let n=a(),r=e?.data,i=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},o=r?.switches||{},s=r?[`ack ${o.ack?.on?`开(${o.ack.count} 条)`:`关`}`,`模板 全部内置(插件类)`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,c=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,J.jsxs)(Qe,{title:c,size:`wide`,onClose:t,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:i,disabled:!r,children:`复制原文`}),(0,J.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,J.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,J.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,J.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,J.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,J.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,J.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,J.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,J.jsx)(`div`,{className:`mdw-prev-switch`,children:s})]})]})}var et=A;function tt({attachments:e}){let t=e.filter(e=>e.kind===`mdfile`),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)({}),o=async e=>{if(r(e),!i[e]||i[e].error){a(t=>({...t,[e]:{html:``,path:``,stale:!1,missing:!1,loading:!0}}));try{let t=await Se(e);a(n=>({...n,[e]:{html:p(String(t.body||``)),path:String(t.absPath||``),stale:!!t.stale,missing:!!t.missing}}))}catch(t){a(n=>({...n,[e]:{html:``,path:``,stale:!1,missing:!1,error:t.message||String(t)}}))}}};if(!t.length)return(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:"没有 md 附件——用 `nx-kv localtask attach --mdfile <本地 md 路径>` 挂一个外部 md 文件。"});let s=n?i[n]:null;return(0,J.jsxs)(`div`,{className:`mdw-md-tab`,children:[(0,J.jsx)(`div`,{className:`mdw-md-list`,role:`list`,children:t.map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`mdw-md-item${n===String(e.id)?` is-on`:``}`,onClick:()=>o(String(e.id)),title:e.absPath||``,children:[(0,J.jsx)(`span`,{className:`mdw-md-item-name`,children:e.name||`md`}),(0,J.jsxs)(`span`,{className:`mdw-md-item-path mono`,children:[e.absPath||`(路径为空)`,e.missing?` · 文件已不在`:``]})]},String(e.id)))}),(0,J.jsxs)(`div`,{className:`mdw-md-view`,children:[n?null:(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`选一条 md 看预览。`}),s?.loading?(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,s?.error?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,s.error]}):null,s&&!s.loading&&!s.error?s.missing?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`源文件已不在:`,s.path||`(路径为空)`]}):(0,J.jsxs)(`div`,{className:`mdw-md-render`,children:[s.stale?(0,J.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,J.jsx)(`article`,{dangerouslySetInnerHTML:{__html:s.html}})]}):null]})]})}function nt({dockOpen:t,dockTab:n,dockH:r,dockRef:i,dockMax:a,showDockTab:o,onDockDragStart:s,toggleDockMax:c,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,doc:v,id:y,model:b,app:x,refreshLocal:S,markDirty:w,saveDoc:T,persistAtt:E,attachAreaRef:D,reviewBarRef:O,reviewSumRef:k,taskRow:A,ackOpen:ee,setAckOpen:j,ackOverflow:te,ackLong:ne,ackHtml:re,isChainTip:ie,latestChild:ae,openFeedback:oe,openLatestRound:M,attachments:N}){if(!t)return null;let P=N.filter(e=>e.kind===`mdfile`).length;return(0,J.jsxs)(`div`,{className:`mdw-dock`,ref:i,style:{height:`${r}px`},children:[(0,J.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:c}),(0,J.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,J.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`attach`,className:`mdw-dock-tab${n===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),children:`附件`}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`md`,className:`mdw-dock-tab${n===`md`?` is-on`:``}`,onClick:()=>o(`md`),title:`只聚合 kind='mdfile' 的附件(md 预览)`,children:[`md`,P?(0,J.jsx)(`span`,{className:`mdw-dock-tab-num`,children:P}):null]}),d?(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`check`,className:`mdw-dock-tab${n===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,J.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`feedback`,className:`mdw-dock-tab${n===`feedback`?` is-on`:``}`,onClick:()=>o(`feedback`),children:`反馈`})]}),(0,J.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,J.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:c,title:a?`还原面板高度`:`最大化面板高度`,"aria-label":a?`还原面板高度`:`最大化面板高度`,children:(0,J.jsx)(e,{name:a?`collapse`:`expand`,title:void 0})}),(0,J.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,J.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,J.jsxs)(`div`,{className:`mdw-dock-body`,children:[n===`attach`?m?(0,J.jsx)(R,{attachments:v.attachments,onRemove:e=>{let t=(v.attachments||[]).filter(t=>t.id!==e);w(),T(y,{attachments:t}),m||E(h,t)}}):g?(0,J.jsx)(et,{ref:D,host:`task`,hostId:Number(h),hostCwd:g.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0,repo:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:S,onOpenTask:e=>{x.openPage&&e&&e.seq!=null&&x.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=C(e);b&&t&&l(b,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,n===`md`?(0,J.jsx)(tt,{attachments:N}):null,n===`check`?(0,J.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,J.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,J.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,J.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,J.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,G(e.elapsedSec),` · 剩余 `,G(e.remainingSec)]}),e.summary?(0,J.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,J.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,n===`feedback`?!m&&A?.completedAt?(0,J.jsxs)(`div`,{className:`mdw-review`,ref:O,children:[(0,J.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,J.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,J.jsx)(`span`,{className:`mdw-review-at mono`,children:A.completedAt}),A.roundSummary?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{ref:k,className:`mdw-review-sum${ee?` is-open`:``}`,title:ee||!(te||ne)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:re}}),(te||ne||ee)&&(0,J.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>j(e=>!e),children:ee?`收起`:`展开全文`})]}):null]}),(0,J.jsxs)(`div`,{className:`mdw-review-acts`,children:[(0,J.jsx)(`button`,{type:`button`,className:`ghost`,onClick:oe,title:`新开一条任务携带反馈(原任务不动;链在此分叉成树)`,children:`反馈`}),!ie&&ae?(0,J.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:M,title:`这条任务已有后续轮次——去最新一轮 #${ae.id}(反馈也可以留在这里,会从本节点分叉)`,children:[`去最新一轮 #`,ae.id]}):null]})]}):(0,J.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]})}function rt({dockOpen:t,dockTab:n,showDockTab:r,setDockOpen:i,canShowGoalLog:a,goalLog:o,openGoalLog:s,isDraft:c,taskRow:l,mdCount:u=0}){return(0,J.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`attach`?` is-on`:``}`,onClick:()=>r(`attach`),title:`附件(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`list`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`md`?` is-on`:``}`,onClick:()=>r(`md`),title:`md 附件预览(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`overview`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`md`}),u>0?(0,J.jsx)(`span`,{className:`mdw-sbar-num`,children:u}):null]}),a?(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`clock`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,J.jsx)(`span`,{className:`mdw-sbar-num`,children:o.data?.count??0})]}):null,(0,J.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`feedback`?` is-on`:``}`,onClick:()=>r(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,J.jsx)(e,{name:`edit`,title:void 0}),(0,J.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,J.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,J.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,J.jsx)(D,{t:l,title:void 0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${t?` is-open`:``}`,onClick:()=>i(e=>!e),title:t?`收起信息面板`:`展开信息面板`,"aria-expanded":t,"aria-label":t?`收起信息面板`:`展开信息面板`,children:(0,J.jsx)(e,{name:`chevron`,title:void 0})})]})}function it({goal:e,setGoalDraft:t,goalEditable:n,goalPromptEditable:r,declaredGoal:i,openGoalLog:a,markDirty:o,task:s}){let c=(e.duration||``).trim(),l=(e.prompt||``).trim(),u=!!r;return{goalBadge:c||l?{label:`⏱ ${c||`目标`}`,title:l||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,时长不可改(附加要求仍可编辑)`)}:null,goalMenu:n||u||i?(0,J.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,J.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,J.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),o()}}):(0,J.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:`已领取计时,时长不可改`,children:[i?.duration||`—`,` · 已领取计时`]}),u?(0,J.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选;领取后仍可改,下一轮 check 即生效)`,onChange:n=>{t({...e,prompt:n.target.value}),o()}}):i?.prompt?(0,J.jsx)(`span`,{className:`mdw-goal-ro`,title:`任务已到终态,附加要求不可改`,children:i.prompt}):null,i&&s!=null?(0,J.jsx)(`button`,{type:`button`,className:`ghost`,onClick:a,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}var at={origin:`起点`,reopen:`反馈`,comment:`评论`};function ot({historyId:e,historyNode:t,closeBesideSelf:n}){let r=at[String(t?.kind??``)]||`节点`,i=t?K(t.text||``,t.attachments||[]):``;return(0,J.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,J.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,J.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,J.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,J.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,J.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,J.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,J.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,J.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,J.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function st({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){if(!e)return null;let o=e.members.find(e=>e.key===t.project);return(0,J.jsxs)(`div`,{className:`mdw-goal`,children:[(0,J.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,J.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{ge(e.board.id,n.target.value),P(i,{body:m(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,J.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,J.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:o?.name||t.project||`—`})]})}function ct({task:e,app:t,groupAnchored:n,groupId:r,dirKey:i}){return(0,J.jsx)(`div`,{className:`mdw`,children:(0,J.jsxs)(`div`,{className:`pad stack`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,J.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):`#/dir/`+encodeURIComponent(i||``)),children:`回到目录`})})]})})}function lt({onClose:e}){return(0,J.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,J.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,J.jsx)(`span`,{className:`grow`}),(0,J.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}var ut=We;function dt({dirKey:e,groupId:t,task:n,beside:r=!1,tabId:o,model:s,historyId:l=null}){let p=f(),h=a(),{dialog:_,node:v}=i(),y=p.rows||[],x=p.refreshLocal,C=p.tpl,D=!(!t||e),O=(0,q.useMemo)(()=>D?he(y,p.repoData&&p.repoData.boards||[],t,n):null,[D,y,p.repoData,t,n]),A=O&&O.topic&&O.topic.key||e||``,j=ie(n),ae=re(D&&j?t:A),N=M(ae,n),F=(0,q.useMemo)(()=>D?O&&O.topic||null:y.find(e=>e.key===A)||null,[y,A,D,O]),I=(0,q.useMemo)(()=>(F?.tasks||[]).find(e=>String(e.id)===String(n))||null,[F,n]),R=ne(),z=R[N]||null,B=z&&z.mode===`edit`?`edit`:`split`,{dockOpen:V,setDockOpen:ce,dockTab:H,dockH:le,dockRef:ue,dockMax:de,showDockTab:U,onDockDragStart:fe,toggleDockMax:pe}=ee(),{goalDraft:me,setGoalDraft:W,goal:G,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,goalLog:ye,loadGoalLog:be,canShowGoalLog:Se}=Ge({id:N,isDraft:j,topicKey:A,task:n,taskRow:I}),{chainNodes:we,chainTree:Ee,historyNode:De,isChainTip:ke,latestChild:je,openLatestRound:Y,openHistoryBeside:Ne}=Ke({isDraft:j,task:n,taskRow:I,topicKey:A,topic:F,groupAnchored:D,groupId:t,app:p,model:s||null,historyId:l,toast:h}),{selMenu:X,setSelMenu:Pe,lastSel:Fe,placeSelMenu:Ie,onEditorTextSel:Le,closeSelMenu:Re}=qe({id:N}),{ackOpen:ze,setAckOpen:Be,ackOverflow:Ve,reviewSumRef:He,ackLong:Ue}=Je({id:N,taskRow:I,dockTab:H,dockOpen:V}),[We,Qe]=(0,q.useState)(null),[et,tt]=(0,q.useState)(!1),[at,dt]=(0,q.useState)(!1),[ft,pt]=(0,q.useState)(!1),mt=(0,q.useRef)(null),ht=(0,q.useRef)(null),gt=(0,q.useRef)(null),_t=(0,q.useRef)(null),vt=(0,q.useRef)(null),yt=(0,q.useRef)(null),bt=(0,q.useRef)(new Map),[Z,xt]=(0,q.useState)([]);(0,q.useEffect)(()=>{let e=!0,t=I;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return A?n.set(`key`,A):t.cwd&&n.set(`cwd`,t.cwd),xe(n.toString()).then(t=>{e&&xt(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&xt([])}),()=>{e=!1}},[I,A]);let St=(0,q.useMemo)(()=>z?K(b(z.body),Z.length?Z:z.attachments):``,[z,Z]),Ct=(0,q.useMemo)(()=>I?.roundSummary?K(I.roundSummary):``,[I?.roundSummary]),wt=(0,q.useMemo)(()=>z?Te(z.body):[],[z&&z.body]),[Tt,Et]=(0,q.useState)(null);(0,q.useEffect)(()=>{let e=_t.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Et(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Et(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[z&&z.mode]);let Dt=(0,q.useCallback)(e=>e().catch(e=>h(String(e.message||e))),[h]),Q=(0,q.useCallback)(()=>pt(!0),[]),{docFm:Ot,parentRef:$,boardCtx:kt}=Ze({doc:z,beside:r,topicKey:A,topic:F,task:n,app:p});(0,q.useEffect)(()=>{R[N]||(j?oe(N,{title:``,body:C?m(C.defaultPick().body,D?{board:t}:{}):``}):I&&oe(N,{title:g(I.text),body:I.text}))},[N,j,I,D,t]);let{composeText:At,submit:jt,importMd:Mt,delTask:Nt,canComplete:Pt,canCancel:Ft,closeTask:It,canPlan:Lt,togglePlan:Rt,addFiles:zt,newTask:Bt,cloneCur:Vt,forkCur:Ht,openProgress:Ut,openAttachPanel:Wt}=Ye({doc:z,id:N,isDraft:j,task:n,taskRow:I,topicKey:A,topic:F,boardCtx:kt,docFm:Ot,groupAnchored:D,groupId:t,rows:y,app:p,model:s||null,tabId:o,tpl:C,refreshLocal:x,markDirty:Q,histRef:bt,editorApiRef:yt,attachAreaRef:gt,setDirty:pt,goal:G,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,guard:Dt,dialog:_,showDockTab:U}),{openFeedback:Gt,submitCommentInPlace:Kt,openCommentFromToolbar:qt}=Xe({doc:z,isDraft:j,task:n,taskRow:I,topicKey:A,topic:F,dirKey:e,groupAnchored:D,groupId:t,app:p,model:s||null,tabId:o,refreshLocal:x,closeSelMenu:Re,lastSel:Fe,selMenu:X,dirty:ft,setDirty:pt,guard:Dt}),Jt=(0,q.useCallback)(()=>{U(`check`),be()},[U,be]),{goalBadge:Yt,goalMenu:Xt}=it({goal:G,goalDraft:me,setGoalDraft:W,goalEditable:ge,goalPromptEditable:_e,declaredGoal:ve,openGoalLog:Jt,markDirty:Q,task:n}),Zt=(0,q.useCallback)(()=>{Qe({busy:!0}),Ce({cwd:F?.cwd,key:A,...j?{text:At((z?.title||``).trim()||`未命名任务`,z?.body||``)}:{id:Number(n)}}).then(e=>Qe({data:e})).catch(e=>Qe({error:String(e.message||e)}))},[F?.cwd,A,j,z?.title,z?.body,n,At]),Qt=(e,t=`typing`)=>{if(!z)return;T(bt.current,N,{title:z.title,body:z.body},t),Q();let n={title:e};B!==`split`&&/^# (?!#)/m.test(z.body)&&(n.body=z.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),P(N,n)},$t=(e,t=`op`)=>{if(!z)return;T(bt.current,N,{title:z.title,body:z.body},t),Q();let n={body:e};B!==`split`&&(n.title=g(e)),P(N,n)},en=()=>{if(!z)return;let e=w(bt.current,N,{title:z.title,body:z.body});e&&(P(N,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>yt.current?.caretFromDiff?.(z.body,e.body)))},tn=()=>{if(!z)return;let e=E(bt.current,N,{title:z.title,body:z.body});e&&(P(N,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>yt.current?.caretFromDiff?.(z.body,e.body)))},nn=e=>{if(!z||B===`edit`)return;let t=e.target instanceof Element?e.target:null;if(t?.closest(`#mdw-sel-menu`)||t?.closest(`textarea`))return;let n=window.getSelection(),r=String(n||``).trim();if(!r||r.length<1){Pe(null);return}if(!n)return;if(!_t.current?.contains(n.anchorNode)){Pe(null);return}let i=e=>e?.nodeType===3?e.parentElement:e,a=i(n.anchorNode)?.closest?.(`.mdw-lp-block`),o=i(n.focusNode)?.closest?.(`.mdw-lp-block`),s=null;if(a&&o&&a!==o&&_t.current?.contains(o)){let e=Number(a.getAttribute(`data-i`)),t=Number(o.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(s=[Math.min(e,t),Math.max(e,t)])}let c=n.getRangeAt(0),l=c.getClientRects(),u=l[l.length-1]??c.getBoundingClientRect();Ie(`task`,r,u.right-60,u.bottom+8,s?{blockRange:s}:{})},rn=(0,q.useCallback)(()=>{if(!$){h(`这条任务没有可定位的原文`);return}let e=s||p.model;e&&d(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,s,p.model,h]),an=(0,q.useCallback)(()=>{let e=s||p.model;e&&o&&e.doAction(c.deleteTab(o))},[s,p.model,o]),on=e=>{ht.current&&(ht.current.accept=e),ht.current?.click()};return(0,q.useEffect)(()=>{if(!$||r)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),rn())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,r,rn]),l==null?z?(0,J.jsxs)(`div`,{className:`mdw${r?` is-beside`:``}`,"data-mode":B,onMouseUp:nn,children:[v,We&&(0,J.jsx)($e,{state:We,onClose:()=>Qe(null)}),(0,J.jsx)(ut,{open:at,nodes:we,tree:Ee,onOpenNode:Ne,onClose:()=>dt(!1)}),r&&(0,J.jsx)(lt,{onClose:an}),(0,J.jsxs)(`div`,{className:`mdw-main`,children:[(0,J.jsxs)(`div`,{className:`mdw-top`,children:[(0,J.jsx)(te,{}),(0,J.jsxs)(`div`,{className:`mdw-head`,children:[(0,J.jsx)(`div`,{className:`mdw-title`,children:j?z.title||`新 MD 任务`:z.title||`任务`}),(0,J.jsxs)(`div`,{className:`mdw-path`,children:[F?.cwd||F?.name||`—`,F?.cwdExists===!1&&(0,J.jsxs)(`span`,{className:`mdw-path-warn`,title:`工作目录已不存在:目录被删除或磁盘未挂载。任务本身还在,只是不再有对应目录。`,children:[` `,`· 目录已不存在`]}),j?` / (${n})`:` / #${n}`,ft?` · 未保存`:``]})]})]}),(0,J.jsx)(st,{boardCtx:kt,docFm:Ot,goalEditable:ge,doc:z,id:N,markDirty:Q}),(0,J.jsx)(u,{mode:B,onMode:e=>P(N,{mode:e}),showMark:B!==`edit`,submitLabel:j?`提交为任务`:`保存并同步`,onNew:Bt,onSubmit:jt,onChain:j?null:()=>dt(!0),onPreview:Zt,onImg:()=>on(`image/*`),onAtt:()=>j?on(`image/*,.pdf,.zip,.txt,.json,.csv`):Wt(),onImport:()=>mt.current?.click(),onClone:j?null:Vt,onFork:j?null:Ht,onComplete:Pt?()=>It(`done`):null,onPlan:Lt?Rt:null,planLabel:String(I?.status||``)===`plan`?`转回待领取`:`转为草稿(plan)`,onCancelTask:Ft?()=>It(`cancel`):null,onMark:qt,onDraft:()=>h(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:j?null:Nt,onOverview:()=>p.onNavigate&&p.onNavigate(`#/overview`),onProg:Ut,onSource:$?rn:null,onShortcuts:()=>tt(!0),goalBadge:Yt,goalMenu:Xt}),(0,J.jsx)(S,{ref:_t,mode:B,title:z.title,body:z.body,previewHtml:St,onTitle:Qt,onBody:$t,attachments:Z.length?[...z.attachments,...Z]:z.attachments,docKey:N,editorApiRef:yt,onFiles:zt,onTextSel:Le,onSave:jt,onUndo:en,onRedo:tn,onCloseSelMenu:Re,attachHost:j?null:{host:`task`,hostId:Number(n),hostCwd:F?.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0,repo:!0},taskOptions:(F?.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,J.jsx)(nt,{dockOpen:V,dockTab:H,dockH:le,dockRef:ue,dockMax:de,showDockTab:U,onDockDragStart:fe,toggleDockMax:pe,setDockOpen:ce,canShowGoalLog:Se,goalLog:ye,openGoalLog:Jt,isDraft:j,task:n,topic:F,topicKey:A,doc:z,id:N,model:s||null,app:p,refreshLocal:x,markDirty:Q,saveDoc:P,persistAtt:se,attachAreaRef:gt,reviewBarRef:vt,reviewSumRef:He,taskRow:I,ackOpen:ze,setAckOpen:Be,ackOverflow:Ve,ackLong:Ue,ackHtml:Ct,isChainTip:ke,latestChild:je,openFeedback:Gt,openLatestRound:Y,attachments:Z.length?Z:z.attachments}),(0,J.jsx)(rt,{dockOpen:V,dockTab:H,showDockTab:U,setDockOpen:ce,canShowGoalLog:Se,goalLog:ye,openGoalLog:Jt,isDraft:j,taskRow:I,mdCount:(Z.length?Z:z.attachments).filter(e=>e.kind===`mdfile`).length})]}),(0,J.jsx)(Oe,{nodes:wt,scrollRoot:Tt}),(0,J.jsx)(Ae,{at:X,onFormat:e=>{yt.current?.format?.(e),Re()},onCompose:()=>{let t=s||p.model;if(!t)return;let r=String(X?.text||Fe.current||``);L(t,{mode:`comment`,quote:r,taskLabel:n==null?``:`#`+n,taskTitle:String(z?.title||``).replace(/^#+\s*/,``),src:{dirKey:A||e||``,task:String(n),name:`原文 #${n}`},onSubmit:e=>Kt({...e,quote:r})}),Re()},onCopy:()=>{let e=X?.blockRange,t=``;if(e&&z){let n=k(z.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
|
|
12
|
-
|
|
13
|
-
`))}navigator.clipboard?.writeText(t||Fe.current||X?.text||``),h(`已复制`),Re()},onDelete:X?.blockRange?()=>{let e=X.blockRange;e&&(yt.current?.deleteBlockRange?.(e[0],e[1])?h(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):h(`选区已失效`),Re())}:void 0}),(0,J.jsx)(`input`,{ref:ht,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&zt(t)}}),(0,J.jsx)(`input`,{ref:mt,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Mt(t)}}),et&&(0,J.jsx)(Me,{onClose:()=>tt(!1)})]}):p.localReady===!1||j?(0,J.jsx)(`div`,{className:`mdw`,children:(0,J.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,J.jsx)(ct,{task:n,app:p,groupAnchored:D,groupId:t,dirKey:e}):(0,J.jsx)(ot,{historyId:l,historyNode:De,closeBesideSelf:an})}export{dt as default};
|