@tt-a1i/hive 2.1.3 → 2.1.4
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 +13 -0
- package/package.json +3 -2
- package/web/dist/assets/{AddWorkerDialog-DHwOZ75i.js → AddWorkerDialog-CkCGKa0N.js} +2 -2
- package/web/dist/assets/{AddWorkspaceFlow-qOI1CmqC.js → AddWorkspaceFlow-Cd73iChz.js} +1 -1
- package/web/dist/assets/{FirstRunWizard-D5kGMD_V.js → FirstRunWizard-Db4HWbBQ.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-BuCbtqFk.js → MarketplaceDrawer-DHwl1if1.js} +1 -1
- package/web/dist/assets/{TaskGraphDrawer-e_bg3f5u.js → TaskGraphDrawer-B_OibVQO.js} +1 -1
- package/web/dist/assets/{WhatsNewDialog-BB9ieq3T.js → WhatsNewDialog-9QXlLVfy.js} +1 -1
- package/web/dist/assets/{WorkerModal-CGeWO3Dg.js → WorkerModal-BGdtte3-.js} +1 -1
- package/web/dist/assets/{WorkflowsDrawer-CVvGxxdR.js → WorkflowsDrawer-DRuS0Ao5.js} +1 -1
- package/web/dist/assets/{WorkspaceMemoryDrawer-BamHuJEp.js → WorkspaceMemoryDrawer-C8PuHo0x.js} +1 -1
- package/web/dist/assets/{WorkspaceTaskDrawer-CqntbH9-.js → WorkspaceTaskDrawer-6mbgRoOq.js} +1 -1
- package/web/dist/assets/index-BiGD5NhO.js +84 -0
- package/web/dist/assets/index-CG2TurwT.css +1 -0
- package/web/dist/assets/{search-DKgM9IgX.js → search-BHvXxsdK.js} +1 -1
- package/web/dist/assets/{square-terminal-DMWazpEv.js → square-terminal-CzkQzjCU.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-BOpmn5Ij.js +0 -84
- package/web/dist/assets/index-rPYd0MUk.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as I,j as e,u as M,a8 as le,aa as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,ab as pe,ac as he,T as S,X as xe,E as me,ad as Q,C as W,b as ee,ae as H,d as ke,af as fe,ag as ge,x as be,y as je,ah as we,t as ye}from"./index-BOpmn5Ij.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],P=I("at-sign",ve);const Ne=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=I("corner-down-right",Ne);const _e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Te=I("file-code",_e);const Ce=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$e=I("save",Ce),B=s=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let r=0;for(;r<s.length;){const i=s.slice(r),o=i.match(/^\*\*([^*]+?)\*\*/);if(o?.[1]){c(),n.push(e.jsx("strong",{children:B(o[1])},a++)),r+=o[0].length;continue}const t=i.match(/^`([^`]+?)`/);if(t?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:t[1]},a++)),r+=t[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:B(u[1])},a++)),r+=u[0].length;continue}l+=s[r],r+=1}return c(),n},ze=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=M(),o=t=>{t.preventDefault(),r()};return e.jsxs("form",{onSubmit:o,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:s.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:s,onChange:t=>l(t.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(le,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(re,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx($e,{size:14}),i("tasks.raw.save")]})})]})},O=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],se=s=>{let n=0;for(let l=0;l<s.length;l+=1)n=n*31+s.charCodeAt(l)>>>0;return O[n%O.length]??O[0]},Se=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],q=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),X=new Set(["报告","report","文件","file","path","日志","log","产物"]),Ee=/^(.*?)\s*\(([^()]+)\)\s*$/,De=/\s*[·,,;;]\s*/,Re=/^([^::]+)[::]\s*(.+)$/,Me=s=>{for(const{pattern:n,tone:l}of Se)if(n.test(s))return l;return"neutral"},Le=s=>s.includes("/")||/^[A-Za-z]:\\/.test(s)||(s.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(s),Ae=s=>{const n=s.match(Ee);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(De).filter(Boolean),r=[];for(const i of c){const o=i.match(Re);if(!o){r.push({kind:"note",value:i.trim()});continue}const t=(o[1]??"").trim(),u=(o[2]??"").trim(),d=t.toLowerCase();q.has(d)||q.has(t)?r.push({kind:"owner",value:u}):G.has(d)||G.has(t)?r.push({kind:"status",value:u,tone:Me(u)}):X.has(d)||X.has(t)||Le(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Pe=({item:s,handlers:n})=>{if(s.kind==="status")return e.jsx("span",{className:`pill pill--${s.tone}`,"data-testid":"task-meta-status",children:s.value});if(s.kind==="owner"){const a={"--owner-tone":se(s.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":s.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(s.value)},style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":s.value,style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]})}return s.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${s.label}: ${s.value}`,children:[e.jsx(Q,{size:10,"aria-hidden":!0}),s.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:s.value})},Z=({initial:s,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,r]=f.useState(s),i=()=>{const t=c.trim();if(!t){l();return}n(t)},o=t=>{t.key==="Enter"?(t.preventDefault(),i()):t.key==="Escape"&&(t.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:t=>r(t.target.value),onKeyDown:o,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},V=({task:s,handlers:n,depth:l})=>{const{t:a}=M(),c=s.checked?ke:fe,{title:r,meta:i}=Ae(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[g,E]=f.useState(!1),[w,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:y,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:b=!1}=n,C=!!y&&!b,N=!!_&&!b,L=!!D&&!b,$=!!T,R=!o&&!u&&(C||N||L||$),z=s.children.length,x=ge(s),A=l+1>=Y,K=z>0,te=g?a("tasks.aria.expandSubtasks",{count:z}):a("tasks.aria.collapseSubtasks",{count:z}),ae=k?{onSelectOwner:k}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${s.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Y?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:s.checked,disabled:b,onChange:()=>{b||p(s.line)},className:"sr-only","data-testid":`task-checkbox-${s.line}`,"aria-label":s.text||`task-line-${s.line}`}),e.jsx("span",{className:`task-row__indicator ${s.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:o?e.jsx(Z,{initial:s.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:h=>{t(!1),y?.(s.line,h)},onCancel:()=>t(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${s.checked?"text-ter line-through":"text-pri"}`,children:B(r)}),K?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:h=>{h.stopPropagation(),E(j=>!j)},"data-testid":`task-collapse-${s.line}`,"aria-expanded":!g,"aria-label":te,children:g?e.jsx(ee,{size:12,"aria-hidden":!0}):e.jsx(W,{size:12,"aria-hidden":!0})}):null,x?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${s.line}`,title:a("tasks.progress.subtaskTitle",{done:x.done,total:x.total}),children:[x.done,"/",x.total]}):null]}),i.length>0||s.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(h=>e.jsx(Pe,{item:h,handlers:ae},`${s.line}-meta-${h.kind}-${"label"in h?h.label:""}-${h.value}`)),s.mentions.map(h=>{const j=h.replace(/^@/,""),F={"--owner-tone":se(j)};return k?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${j}`,"data-owner":j,onClick:ne=>{ne.stopPropagation(),k(j)},style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${j}`,"data-owner":j,style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`)})]}):null]})}),R?e.jsxs("div",{className:"task-row__actions pointer-coarse:opacity-100",children:[$?e.jsx(S,{label:a(w?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{T?.(s.line),v(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{v(!1),m.current=null},1500)},"data-testid":`task-copy-${s.line}`,"aria-label":a(w?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:w?e.jsx(be,{size:12}):e.jsx(je,{size:12})})}):null,C?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>t(!0),"data-testid":`task-edit-${s.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,L?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{E(!1),d(!0)},"data-testid":`task-add-subtask-${s.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(U,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>_?.(s.line),"data-testid":`task-delete-${s.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),z>0&&!g||u?e.jsxs("ul",{className:`task-children${A?" task-children--deep":""}`,"data-testid":`task-children-${s.line}`,children:[g?null:s.children.map(h=>e.jsx(V,{depth:l+1,handlers:n,task:h},h.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(U,{size:12})}),e.jsx(Z,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:h=>{d(!1),D?.(s.line,h)},onCancel:()=>d(!1)})]})}):null]}):null]})},J=({onSubmit:s,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=M(),[c,r]=f.useState(!1),[i,o]=f.useState(""),t=()=>{const d=i.trim();if(!d){r(!1);return}s(d),o("")},u=d=>{d.key==="Enter"?(d.preventDefault(),t()):d.key==="Escape"&&(d.preventDefault(),o(""),r(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(H,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:d=>o(d.target.value),onKeyDown:u,onBlur:t,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(H,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ie=s=>{let n=0,l=0;const a=[],c=[],r=o=>{n+=1,o.checked&&(l+=1);for(const t of o.children)r(t)};for(const o of s)o.checked?c.push(o):a.push(o),r(o);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ke=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,workspacePath:E,knownWorkerNames:w,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=M(),[y,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const A=s.split(/\r?\n/)[x];typeof A=="string"&&navigator.clipboard?.writeText(A).catch(K=>{console.error("[hive] swallowed:tasks.copyLine",K)})},...d&&!m?{onUpdateText:d}:{},...g&&!m?{onDelete:g}:{},...u&&!m?{onAppendSubtask:u}:{},...v?{onSelectOwner:v}:{},...m?{writeDisabled:!0}:{}},k=f.useMemo(()=>pe(s,w?{knownWorkerNames:w}:{}),[s,w]),{completedTasks:b,completionPercent:C,doneRoots:N,openRoots:L,totalTasks:$}=f.useMemo(()=>Ie(k),[k]),[R,z]=f.useState(N.length<=3);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"task-graph-content",children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(he,{size:16,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:p("tasks.title.todo")}),$>0?e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{background:C===100?"color-mix(in oklab, var(--status-green) 18%, transparent)":"var(--bg-3)",color:C===100?"var(--status-green)":"var(--text-secondary)"},"data-testid":"task-graph-summary",children:e.jsxs("span",{"data-testid":"task-progress-text",children:[b,"/",$]})}):null]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(S,{label:p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>_(x=>!x),"data-testid":"task-raw-toggle",className:"icon-btn pointer-coarse:min-h-10","aria-label":p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Te,{size:14})})}),l?e.jsx(S,{label:p("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":p("tasks.action.closeTodo"),className:"icon-btn pointer-coarse:min-h-10",children:e.jsx(xe,{size:14})})}):null]})]}),!y&&$>0?e.jsx("div",{"aria-label":p("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":C,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${C}%`}})}):null,e.jsx("div",{className:"scroll-y flex-1 px-3 py-2.5 text-sm",children:y?e.jsx(ze,{content:s,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i}):k.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(Q,{size:20}),title:p("tasks.empty.title"),description:p("tasks.empty.description"),...t?{action:e.jsx(J,{variant:"primary",disabled:m,onSubmit:t})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line)),t?e.jsx("li",{children:e.jsx(J,{disabled:m,onSubmit:t})}):null]}),N.length>0?e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>z(x=>!x),"aria-expanded":R,"data-testid":"task-completed-toggle",className:"task-completed-toggle pointer-coarse:min-h-10",children:[R?e.jsx(W,{size:11,"aria-hidden":!0}):e.jsx(ee,{size:11,"aria-hidden":!0}),e.jsx("span",{children:p("tasks.completed.toggle",{count:N.length})}),e.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[9px] tabular-nums",style:{background:"var(--bg-3)",color:"var(--text-tertiary)"},children:N.length})]}),R?e.jsx("ul",{className:"task-list mt-1","data-testid":"task-completed-list",children:N.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line))}):null]}):null]})})]})},Be=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,open:E,workspacePath:w,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:y}=M(),_=ie(),D=k=>{if(k.key!=="Escape")return;const b=k.target?.tagName;b==="INPUT"||b==="TEXTAREA"||(k.preventDefault(),l())},T=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${p?" task-dialog--stale":""}`;return e.jsx(oe,{open:E,onOpenChange:k=>!k&&l(),children:e.jsxs(ce,{children:[e.jsx(de,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ue,{"aria-label":y("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":p||void 0,"data-mobile":_||void 0,onEscapeKeyDown:k=>k.preventDefault(),onKeyDown:D,className:T,style:_?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 64px))",width:"min(640px, calc(100vw - 48px))"},children:e.jsx(Ke,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:w,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...g?{onDeleteTask:g}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Ke as TaskGraphContent,Be as TaskGraphDrawer};
|
|
1
|
+
import{c as I,j as e,u as M,a8 as le,aa as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,ab as pe,ac as he,T as S,X as xe,E as me,ad as Q,C as W,b as ee,ae as H,d as ke,af as fe,ag as ge,x as be,y as je,ah as we,t as ye}from"./index-BiGD5NhO.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],P=I("at-sign",ve);const Ne=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=I("corner-down-right",Ne);const _e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Te=I("file-code",_e);const Ce=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$e=I("save",Ce),B=s=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let r=0;for(;r<s.length;){const i=s.slice(r),o=i.match(/^\*\*([^*]+?)\*\*/);if(o?.[1]){c(),n.push(e.jsx("strong",{children:B(o[1])},a++)),r+=o[0].length;continue}const t=i.match(/^`([^`]+?)`/);if(t?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:t[1]},a++)),r+=t[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:B(u[1])},a++)),r+=u[0].length;continue}l+=s[r],r+=1}return c(),n},ze=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=M(),o=t=>{t.preventDefault(),r()};return e.jsxs("form",{onSubmit:o,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:s.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:s,onChange:t=>l(t.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(le,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(re,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx($e,{size:14}),i("tasks.raw.save")]})})]})},O=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],se=s=>{let n=0;for(let l=0;l<s.length;l+=1)n=n*31+s.charCodeAt(l)>>>0;return O[n%O.length]??O[0]},Se=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],q=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),X=new Set(["报告","report","文件","file","path","日志","log","产物"]),Ee=/^(.*?)\s*\(([^()]+)\)\s*$/,De=/\s*[·,,;;]\s*/,Re=/^([^::]+)[::]\s*(.+)$/,Me=s=>{for(const{pattern:n,tone:l}of Se)if(n.test(s))return l;return"neutral"},Le=s=>s.includes("/")||/^[A-Za-z]:\\/.test(s)||(s.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(s),Ae=s=>{const n=s.match(Ee);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(De).filter(Boolean),r=[];for(const i of c){const o=i.match(Re);if(!o){r.push({kind:"note",value:i.trim()});continue}const t=(o[1]??"").trim(),u=(o[2]??"").trim(),d=t.toLowerCase();q.has(d)||q.has(t)?r.push({kind:"owner",value:u}):G.has(d)||G.has(t)?r.push({kind:"status",value:u,tone:Me(u)}):X.has(d)||X.has(t)||Le(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Pe=({item:s,handlers:n})=>{if(s.kind==="status")return e.jsx("span",{className:`pill pill--${s.tone}`,"data-testid":"task-meta-status",children:s.value});if(s.kind==="owner"){const a={"--owner-tone":se(s.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":s.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(s.value)},style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":s.value,style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]})}return s.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${s.label}: ${s.value}`,children:[e.jsx(Q,{size:10,"aria-hidden":!0}),s.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:s.value})},Z=({initial:s,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,r]=f.useState(s),i=()=>{const t=c.trim();if(!t){l();return}n(t)},o=t=>{t.key==="Enter"?(t.preventDefault(),i()):t.key==="Escape"&&(t.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:t=>r(t.target.value),onKeyDown:o,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},V=({task:s,handlers:n,depth:l})=>{const{t:a}=M(),c=s.checked?ke:fe,{title:r,meta:i}=Ae(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[g,E]=f.useState(!1),[w,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:y,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:b=!1}=n,C=!!y&&!b,N=!!_&&!b,L=!!D&&!b,$=!!T,R=!o&&!u&&(C||N||L||$),z=s.children.length,x=ge(s),A=l+1>=Y,K=z>0,te=g?a("tasks.aria.expandSubtasks",{count:z}):a("tasks.aria.collapseSubtasks",{count:z}),ae=k?{onSelectOwner:k}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${s.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Y?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:s.checked,disabled:b,onChange:()=>{b||p(s.line)},className:"sr-only","data-testid":`task-checkbox-${s.line}`,"aria-label":s.text||`task-line-${s.line}`}),e.jsx("span",{className:`task-row__indicator ${s.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:o?e.jsx(Z,{initial:s.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:h=>{t(!1),y?.(s.line,h)},onCancel:()=>t(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${s.checked?"text-ter line-through":"text-pri"}`,children:B(r)}),K?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:h=>{h.stopPropagation(),E(j=>!j)},"data-testid":`task-collapse-${s.line}`,"aria-expanded":!g,"aria-label":te,children:g?e.jsx(ee,{size:12,"aria-hidden":!0}):e.jsx(W,{size:12,"aria-hidden":!0})}):null,x?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${s.line}`,title:a("tasks.progress.subtaskTitle",{done:x.done,total:x.total}),children:[x.done,"/",x.total]}):null]}),i.length>0||s.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(h=>e.jsx(Pe,{item:h,handlers:ae},`${s.line}-meta-${h.kind}-${"label"in h?h.label:""}-${h.value}`)),s.mentions.map(h=>{const j=h.replace(/^@/,""),F={"--owner-tone":se(j)};return k?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${j}`,"data-owner":j,onClick:ne=>{ne.stopPropagation(),k(j)},style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${j}`,"data-owner":j,style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`)})]}):null]})}),R?e.jsxs("div",{className:"task-row__actions pointer-coarse:opacity-100",children:[$?e.jsx(S,{label:a(w?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{T?.(s.line),v(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{v(!1),m.current=null},1500)},"data-testid":`task-copy-${s.line}`,"aria-label":a(w?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:w?e.jsx(be,{size:12}):e.jsx(je,{size:12})})}):null,C?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>t(!0),"data-testid":`task-edit-${s.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,L?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{E(!1),d(!0)},"data-testid":`task-add-subtask-${s.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(U,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>_?.(s.line),"data-testid":`task-delete-${s.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),z>0&&!g||u?e.jsxs("ul",{className:`task-children${A?" task-children--deep":""}`,"data-testid":`task-children-${s.line}`,children:[g?null:s.children.map(h=>e.jsx(V,{depth:l+1,handlers:n,task:h},h.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(U,{size:12})}),e.jsx(Z,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:h=>{d(!1),D?.(s.line,h)},onCancel:()=>d(!1)})]})}):null]}):null]})},J=({onSubmit:s,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=M(),[c,r]=f.useState(!1),[i,o]=f.useState(""),t=()=>{const d=i.trim();if(!d){r(!1);return}s(d),o("")},u=d=>{d.key==="Enter"?(d.preventDefault(),t()):d.key==="Escape"&&(d.preventDefault(),o(""),r(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(H,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:d=>o(d.target.value),onKeyDown:u,onBlur:t,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(H,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ie=s=>{let n=0,l=0;const a=[],c=[],r=o=>{n+=1,o.checked&&(l+=1);for(const t of o.children)r(t)};for(const o of s)o.checked?c.push(o):a.push(o),r(o);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ke=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,workspacePath:E,knownWorkerNames:w,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=M(),[y,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const A=s.split(/\r?\n/)[x];typeof A=="string"&&navigator.clipboard?.writeText(A).catch(K=>{console.error("[hive] swallowed:tasks.copyLine",K)})},...d&&!m?{onUpdateText:d}:{},...g&&!m?{onDelete:g}:{},...u&&!m?{onAppendSubtask:u}:{},...v?{onSelectOwner:v}:{},...m?{writeDisabled:!0}:{}},k=f.useMemo(()=>pe(s,w?{knownWorkerNames:w}:{}),[s,w]),{completedTasks:b,completionPercent:C,doneRoots:N,openRoots:L,totalTasks:$}=f.useMemo(()=>Ie(k),[k]),[R,z]=f.useState(N.length<=3);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"task-graph-content",children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(he,{size:16,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:p("tasks.title.todo")}),$>0?e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{background:C===100?"color-mix(in oklab, var(--status-green) 18%, transparent)":"var(--bg-3)",color:C===100?"var(--status-green)":"var(--text-secondary)"},"data-testid":"task-graph-summary",children:e.jsxs("span",{"data-testid":"task-progress-text",children:[b,"/",$]})}):null]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(S,{label:p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>_(x=>!x),"data-testid":"task-raw-toggle",className:"icon-btn pointer-coarse:min-h-10","aria-label":p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Te,{size:14})})}),l?e.jsx(S,{label:p("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":p("tasks.action.closeTodo"),className:"icon-btn pointer-coarse:min-h-10",children:e.jsx(xe,{size:14})})}):null]})]}),!y&&$>0?e.jsx("div",{"aria-label":p("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":C,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${C}%`}})}):null,e.jsx("div",{className:"scroll-y flex-1 px-3 py-2.5 text-sm",children:y?e.jsx(ze,{content:s,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i}):k.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(Q,{size:20}),title:p("tasks.empty.title"),description:p("tasks.empty.description"),...t?{action:e.jsx(J,{variant:"primary",disabled:m,onSubmit:t})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line)),t?e.jsx("li",{children:e.jsx(J,{disabled:m,onSubmit:t})}):null]}),N.length>0?e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>z(x=>!x),"aria-expanded":R,"data-testid":"task-completed-toggle",className:"task-completed-toggle pointer-coarse:min-h-10",children:[R?e.jsx(W,{size:11,"aria-hidden":!0}):e.jsx(ee,{size:11,"aria-hidden":!0}),e.jsx("span",{children:p("tasks.completed.toggle",{count:N.length})}),e.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[9px] tabular-nums",style:{background:"var(--bg-3)",color:"var(--text-tertiary)"},children:N.length})]}),R?e.jsx("ul",{className:"task-list mt-1","data-testid":"task-completed-list",children:N.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line))}):null]}):null]})})]})},Be=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,open:E,workspacePath:w,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:y}=M(),_=ie(),D=k=>{if(k.key!=="Escape")return;const b=k.target?.tagName;b==="INPUT"||b==="TEXTAREA"||(k.preventDefault(),l())},T=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${p?" task-dialog--stale":""}`;return e.jsx(oe,{open:E,onOpenChange:k=>!k&&l(),children:e.jsxs(ce,{children:[e.jsx(de,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ue,{"aria-label":y("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":p||void 0,"data-mobile":_||void 0,onEscapeKeyDown:k=>k.preventDefault(),onKeyDown:D,className:T,style:_?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 64px))",width:"min(640px, calc(100vw - 48px))"},children:e.jsx(Ke,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:w,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...g?{onDeleteTask:g}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Ke as TaskGraphContent,Be as TaskGraphDrawer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a2 as f}from"./index-
|
|
1
|
+
import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a2 as f}from"./index-BiGD5NhO.js";const b=({open:r,entries:n,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:r,onOpenChange:c,children:e.jsxs(h,{children:[e.jsx(m,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(p,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-6 pt-6",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"scroll-y mx-6 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto pr-3",children:n.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"flex shrink-0 justify-end border-t px-6 py-5",style:{borderColor:"var(--border)"},children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{b as WhatsNewDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,u as j,i as k,al as f,j as e,R,P as N,O as C,k as M,m as E,a2 as S,a8 as L,T as D,z as I,X as O,am as W,q as A,an as T,ao as P}from"./index-
|
|
1
|
+
import{r as d,u as j,i as k,al as f,j as e,R,P as N,O as C,k as M,m as E,a2 as S,a8 as L,T as D,z as I,X as O,am as W,q as A,an as T,ao as P}from"./index-BiGD5NhO.js";const _=t=>{switch(t){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"sentinel":return{badgeClass:"role-badge--sentinel",label:"Sentinel"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(t)}}},y="hive.worker-modal.width",u=480,F=.5,x=t=>{const o=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(t,u),Math.max(u,o))},g=()=>typeof window>"u"?u:x(Math.round(window.innerWidth*F)),$=()=>{try{const t=localStorage.getItem(y);if(!t)return g();const o=Number.parseInt(t,10);return Number.isFinite(o)?x(o):g()}catch{return g()}},K=()=>{const[t,o]=d.useState(()=>$()),[m,c]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(y,String(Math.round(t)))}catch{}},[t]),d.useEffect(()=>{const s=()=>{o(a=>x(a))};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);const b=d.useCallback(s=>a=>{a.preventDefault();const r=a.clientX,h=t;c(!0);const p=document.body.style.cursor,v=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const n=i=>{const w=i.clientX-r,z=s==="left"?h-2*w:h+2*w;o(x(z))},l=()=>{c(!1),document.body.style.cursor=p,document.body.style.userSelect=v,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",l),document.removeEventListener("pointercancel",l)};document.addEventListener("pointermove",n),document.addEventListener("pointerup",l),document.addEventListener("pointercancel",l)},[t]);return{width:t,resizing:m,beginResize:b}},U=({onClose:t,onStart:o,runId:m,startError:c,starting:b,worker:s})=>{const{t:a}=j(),r=k(),h=_(s.role),p=!!m,v=T(p),n=K();d.useLayoutEffect(()=>{if(!r)return;const i=P();return f(!0),()=>f(i)},[r]);const l=i=>{i||t()};return e.jsx(R,{open:!0,onOpenChange:l,children:e.jsxs(N,{children:[e.jsx(C,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(M,{"data-testid":"worker-modal","aria-label":a("worker.detail",{name:s.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden","data-mobile":r||void 0,onEscapeKeyDown:i=>i.preventDefault(),style:r?{background:"var(--bg-1)"}:{background:"var(--bg-1)",width:`${n.width}px`},children:[r?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("right")})]}),e.jsx(E,{className:"sr-only",children:s.name}),e.jsxs(S,{className:"sr-only",children:[h.label," agent — status ",v.label]}),c?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(L,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:c})]}):null,e.jsxs("div",{className:`relative flex min-h-0 flex-1 flex-col${r?"":" p-3"}`,"data-testid":"worker-modal-terminal-slot",children:[e.jsx(D,{label:a("common.close"),children:e.jsx(I,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:`float-action absolute z-10 ${r?"top-2 right-2":"top-4 right-4"}`,style:r?{minHeight:44,minWidth:44}:void 0,children:e.jsx(O,{size:r?16:14,"aria-hidden":!0})})})}),e.jsx("div",{className:`flex min-h-0 flex-1${r?"":" rounded-lg border"}`,style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:p?e.jsx("div",{id:`worker-pty-${m}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(W,{commandPresetId:s.commandPresetId,workerRole:s.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:s.name}),e.jsxs("div",{className:"text-xs text-ter",children:[s.status==="stopped"?a("worker.terminalStopped"):a("worker.terminalNotStarted"),a("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>o(s),disabled:b,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",a(b?"common.starting":"common.start")]})]})})]})]})})]})})};export{U as WorkerModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-BOpmn5Ij.js";import{S as Z}from"./square-terminal-DMWazpEv.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
|
|
1
|
+
import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-BiGD5NhO.js";import{S as Z}from"./square-terminal-CzkQzjCU.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
|
package/web/dist/assets/{WorkspaceMemoryDrawer-BamHuJEp.js → WorkspaceMemoryDrawer-C8PuHo0x.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v,i as ne,u as B,r as c,D as ie,F as le,G as oe,j as e,R as ce,P as de,O as me,k as pe,m as xe,T as f,X as J,L as S,H as Q,E as U,J as q,K as he,N as ue,Q as be,U as fe,x as je,V as ye,Y as G,Z as ge,_ as ve,$ as Ne}from"./index-BOpmn5Ij.js";import{S as we}from"./search-DKgM9IgX.js";const ke=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Se=v("archive",ke);const Ce=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Te=v("eye-off",Ce);const Me=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],$e=v("pin-off",Me);const _e=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],De=v("pin",_e);const Ee=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Re=v("settings-2",Ee),X={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},ze=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),C=(n,s)=>n?ze.format(new Date(n)):s("common.never"),Y=(n,s=140)=>{const a=n.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Ae=n=>{const s=n.sources[0];return s?.actorNameSnapshot?`${n.source} · ${s.actorNameSnapshot}`:n.source},We=n=>n==="dreams"?null:n,Le=({busy:n,memory:s,onArchive:a,onApprove:p,onReject:r,onToggleDisabled:o,onTogglePinned:m})=>{const[b,T]=c.useState(!1),{t:l}=B();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>T(d=>!d),"aria-expanded":b,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:l(X[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:l("memory.pinned")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:l("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Ae(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:b?s.body:Y(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(d=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:d},d)),e.jsx("span",{children:l("memory.updated",{time:C(s.updatedAt,l)})}),e.jsx("span",{children:l("memory.injected",{time:C(s.lastInjectedAt,l)})})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:[s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:s.pinned?l("memory.unpinTooltip"):l("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>m(s),"aria-label":s.pinned?l("memory.unpinTooltip"):l("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx($e,{size:13}):e.jsx(De,{size:13})})}),e.jsx(f,{label:s.disabled?l("memory.enableTooltip"):l("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>o(s),"aria-label":s.disabled?l("memory.enableTooltip"):l("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(fe,{size:13}):e.jsx(Te,{size:13})})}),e.jsx(f,{label:l("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>a(s),"aria-label":l("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(Se,{size:13})})})]}):null,s.status==="candidate"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:l("memory.approveTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>p(s),"aria-label":l("memory.approveTooltip"),className:"icon-btn icon-btn--primary pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(je,{size:13})})}),e.jsx(f,{label:l("memory.rejectTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>r(s),"aria-label":l("memory.rejectTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(J,{size:13})})})]}):null]})]}),b?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:l("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:l("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(d=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[d.sourceType,d.actorNameSnapshot?` · ${d.actorNameSnapshot}`:"",d.actorRoleSnapshot?` · ${d.actorRoleSnapshot}`:""]}),d.excerpt?e.jsx("p",{className:"mt-0.5",children:d.excerpt}):null]},d.id))})]}):null]})},I=({label:n,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:n}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:r=>p(r.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),Pe=(n,s)=>n.report?[`${n.report.added.length} ${s("memory.reportAdded")}`,`${n.report.rewritten.length} ${s("memory.reportRewritten")}`,`${n.report.archived.length} ${s("memory.reportArchived")}`,`${n.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):n.error?`${s("common.error")} · ${Y(n.error,90)}`:s("memory.noReport"),qe=(n,s)=>n.inputSeqFrom===null||n.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${n.inputSeqFrom}-${n.inputSeqTo}`,Be=({busy:n,onRevert:s,run:a})=>{const[p,r]=c.useState(!1),{t:o}=B();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:o(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:o(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:qe(a,o)}),e.jsx("span",{className:"text-ter",children:o("memory.started",{time:C(a.startedAt,o)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:Pe(a,o)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:o("memory.finished",{time:C(a.finishedAt,o)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(f,{label:o("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>s(a),"aria-label":o("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:n?e.jsx(S,{size:13,className:"animate-spin"}):e.jsx(be,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),o("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(m=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${m.kind} scale-90 origin-left inline-block mr-1`,children:o(X[m.kind])}),m.body]})]},m.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),o("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(m=>m.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),o("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(m=>m.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),o("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(m=>m.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},Ve=({open:n,onClose:s,workspaceId:a})=>{const p=ne(),{t:r}=B(),[o,m]=c.useState("active"),[b,T]=c.useState(""),[l,d]=c.useState([]),[N,M]=c.useState([]),[$,w]=c.useState(null),[F,_]=c.useState(!1),[O,h]=c.useState(null),[Z,V]=c.useState(null),[D,k]=c.useState(null),[E,R]=c.useState(null),[z,A]=c.useState(null),[W,L]=c.useState(null),[P,K]=c.useState(!1),j=c.useRef(0),ee=c.useMemo(()=>[{id:"active",label:r("memory.tabActive")},{id:"candidate",label:r("memory.tabCandidate")},{id:"archived",label:r("memory.tabArchived")},{id:"dreams",label:r("memory.tabDreams")}],[r]),u=We(o),y=c.useCallback(async()=>{const t=j.current+1;if(j.current=t,!a||!n){d([]),M([]),w(null),_(!1);return}_(!0),h(null),d([]),M([]),w(null);try{const[i,x,re]=await Promise.all([ie(a),u?le(a,{query:b,status:u}):Promise.resolve([]),u?Promise.resolve([]):oe(a,{limit:20})]);if(j.current!==t)return;w(i),d(x),M(re)}catch(i){j.current===t&&h(i instanceof Error?i.message:String(i))}finally{j.current===t&&_(!1)}},[n,b,u,a]);c.useEffect(()=>{y()},[y]);const g=async(t,i)=>{if(a){V(t.id),h(null);try{await i(a),await y()}catch(x){h(x instanceof Error?x.message:String(x))}finally{V(null)}}},se=c.useMemo(()=>({current:u?l.length:N.length}),[N.length,l.length,u]),H=async t=>{if(!(!a||P)){K(!0),h(null);try{w(await ue(a,t))}catch(i){h(i instanceof Error?i.message:String(i))}finally{K(!1)}}},te=async()=>{if(a){k("run-now"),h(null);try{await he(a),await y()}catch(t){h(t instanceof Error?t.message:String(t))}finally{k(null)}}},ae=async t=>{if(a){k(t.id),h(null);try{await ye(a,t.id),await y()}catch(i){h(i instanceof Error?i.message:String(i))}finally{k(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ce,{open:n,onOpenChange:t=>!t&&s(),children:e.jsxs(de,{children:[e.jsx(me,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(pe,{"data-testid":"memory-drawer","aria-label":r("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(xe,{className:"text-base font-semibold text-pri",children:r("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:r("memory.subtitle")})]}),e.jsx(f,{label:r("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":r("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(J,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:ee.map(t=>e.jsx("button",{type:"button",onClick:()=>m(t.id),"aria-pressed":o===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${o===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:r("memory.searchPlaceholder")}),e.jsx(we,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:b,onChange:t=>T(t.currentTarget.value),placeholder:r("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[O?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:O}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[se.current," ",r(u?"memory.entries":"memory.runs")]})]}),o==="dreams"?e.jsxs("button",{type:"button",onClick:te,disabled:D!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[D==="run-now"?e.jsx(S,{size:14,className:"animate-spin"}):e.jsx(Q,{size:14}),r("memory.runNow")]}):null]}),$?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(I,{label:r("memory.injection"),checked:$.enabled,disabled:P,onChange:t=>H({enabled:t})}),e.jsx(I,{label:r("memory.dreamProcessing"),checked:$.dreamEnabled,disabled:P,onChange:t=>H({dreamEnabled:t})})]}):null]}),o==="dreams"?F?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(S,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:r("common.loading")})]}):N.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(U,{icon:e.jsx(Q,{size:20}),title:r("memory.emptyDreams"),description:r("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:N.map(t=>e.jsx(Be,{run:t,busy:D===t.id,onRevert:L},t.id))}):F?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(S,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:r("common.loading")})]}):l.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(U,{title:r(o==="candidate"?"memory.emptyCandidate":"memory.emptyActive"),description:r(o==="candidate"?"memory.emptyCandidateDesc":"memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:l.map(t=>e.jsx(Le,{memory:t,busy:Z===t.id,onArchive:R,onApprove:i=>g(i,x=>ge(x,i.id)),onReject:A,onToggleDisabled:i=>g(i,x=>G(x,i.id,{disabled:!i.disabled})),onTogglePinned:i=>g(i,x=>G(x,i.id,{pinned:!i.pinned}))},t.id))})]})]})})]})}),e.jsx(q,{open:E!==null,onOpenChange:t=>{t||R(null)},title:r("memory.archiveTitle"),description:r("memory.archiveDesc"),confirmLabel:r("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!E)return;const t=E;R(null),g(t,i=>ve(i,t.id))}}),e.jsx(q,{open:z!==null,onOpenChange:t=>{t||A(null)},title:r("memory.rejectTitle"),description:r("memory.rejectDesc"),confirmLabel:r("memory.rejectButton"),confirmKind:"danger",onConfirm:()=>{if(!z)return;const t=z;A(null),g(t,i=>Ne(i,t.id))}}),e.jsx(q,{open:W!==null,onOpenChange:t=>{t||L(null)},title:r("memory.revertTitle"),description:r("memory.revertDesc"),confirmLabel:r("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!W)return;const t=W;L(null),ae(t)}})]})};export{Ve as WorkspaceMemoryDrawer};
|
|
1
|
+
import{c as v,i as ne,u as B,r as c,D as ie,F as le,G as oe,j as e,R as ce,P as de,O as me,k as pe,m as xe,T as f,X as J,L as S,H as Q,E as U,J as q,K as he,N as ue,Q as be,U as fe,x as je,V as ye,Y as G,Z as ge,_ as ve,$ as Ne}from"./index-BiGD5NhO.js";import{S as we}from"./search-BHvXxsdK.js";const ke=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Se=v("archive",ke);const Ce=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Te=v("eye-off",Ce);const Me=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],$e=v("pin-off",Me);const _e=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],De=v("pin",_e);const Ee=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Re=v("settings-2",Ee),X={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},ze=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),C=(n,s)=>n?ze.format(new Date(n)):s("common.never"),Y=(n,s=140)=>{const a=n.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Ae=n=>{const s=n.sources[0];return s?.actorNameSnapshot?`${n.source} · ${s.actorNameSnapshot}`:n.source},We=n=>n==="dreams"?null:n,Le=({busy:n,memory:s,onArchive:a,onApprove:p,onReject:r,onToggleDisabled:o,onTogglePinned:m})=>{const[b,T]=c.useState(!1),{t:l}=B();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>T(d=>!d),"aria-expanded":b,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:l(X[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:l("memory.pinned")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:l("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Ae(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:b?s.body:Y(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(d=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:d},d)),e.jsx("span",{children:l("memory.updated",{time:C(s.updatedAt,l)})}),e.jsx("span",{children:l("memory.injected",{time:C(s.lastInjectedAt,l)})})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:[s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:s.pinned?l("memory.unpinTooltip"):l("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>m(s),"aria-label":s.pinned?l("memory.unpinTooltip"):l("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx($e,{size:13}):e.jsx(De,{size:13})})}),e.jsx(f,{label:s.disabled?l("memory.enableTooltip"):l("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>o(s),"aria-label":s.disabled?l("memory.enableTooltip"):l("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(fe,{size:13}):e.jsx(Te,{size:13})})}),e.jsx(f,{label:l("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>a(s),"aria-label":l("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(Se,{size:13})})})]}):null,s.status==="candidate"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:l("memory.approveTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>p(s),"aria-label":l("memory.approveTooltip"),className:"icon-btn icon-btn--primary pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(je,{size:13})})}),e.jsx(f,{label:l("memory.rejectTooltip"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>r(s),"aria-label":l("memory.rejectTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(J,{size:13})})})]}):null]})]}),b?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:l("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:l("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(d=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[d.sourceType,d.actorNameSnapshot?` · ${d.actorNameSnapshot}`:"",d.actorRoleSnapshot?` · ${d.actorRoleSnapshot}`:""]}),d.excerpt?e.jsx("p",{className:"mt-0.5",children:d.excerpt}):null]},d.id))})]}):null]})},I=({label:n,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:n}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:r=>p(r.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),Pe=(n,s)=>n.report?[`${n.report.added.length} ${s("memory.reportAdded")}`,`${n.report.rewritten.length} ${s("memory.reportRewritten")}`,`${n.report.archived.length} ${s("memory.reportArchived")}`,`${n.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):n.error?`${s("common.error")} · ${Y(n.error,90)}`:s("memory.noReport"),qe=(n,s)=>n.inputSeqFrom===null||n.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${n.inputSeqFrom}-${n.inputSeqTo}`,Be=({busy:n,onRevert:s,run:a})=>{const[p,r]=c.useState(!1),{t:o}=B();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:o(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:o(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:qe(a,o)}),e.jsx("span",{className:"text-ter",children:o("memory.started",{time:C(a.startedAt,o)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:Pe(a,o)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:o("memory.finished",{time:C(a.finishedAt,o)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(f,{label:o("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:n,onClick:()=>s(a),"aria-label":o("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:n?e.jsx(S,{size:13,className:"animate-spin"}):e.jsx(be,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),o("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(m=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${m.kind} scale-90 origin-left inline-block mr-1`,children:o(X[m.kind])}),m.body]})]},m.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),o("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(m=>m.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),o("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(m=>m.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),o("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(m=>m.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},Ve=({open:n,onClose:s,workspaceId:a})=>{const p=ne(),{t:r}=B(),[o,m]=c.useState("active"),[b,T]=c.useState(""),[l,d]=c.useState([]),[N,M]=c.useState([]),[$,w]=c.useState(null),[F,_]=c.useState(!1),[O,h]=c.useState(null),[Z,V]=c.useState(null),[D,k]=c.useState(null),[E,R]=c.useState(null),[z,A]=c.useState(null),[W,L]=c.useState(null),[P,K]=c.useState(!1),j=c.useRef(0),ee=c.useMemo(()=>[{id:"active",label:r("memory.tabActive")},{id:"candidate",label:r("memory.tabCandidate")},{id:"archived",label:r("memory.tabArchived")},{id:"dreams",label:r("memory.tabDreams")}],[r]),u=We(o),y=c.useCallback(async()=>{const t=j.current+1;if(j.current=t,!a||!n){d([]),M([]),w(null),_(!1);return}_(!0),h(null),d([]),M([]),w(null);try{const[i,x,re]=await Promise.all([ie(a),u?le(a,{query:b,status:u}):Promise.resolve([]),u?Promise.resolve([]):oe(a,{limit:20})]);if(j.current!==t)return;w(i),d(x),M(re)}catch(i){j.current===t&&h(i instanceof Error?i.message:String(i))}finally{j.current===t&&_(!1)}},[n,b,u,a]);c.useEffect(()=>{y()},[y]);const g=async(t,i)=>{if(a){V(t.id),h(null);try{await i(a),await y()}catch(x){h(x instanceof Error?x.message:String(x))}finally{V(null)}}},se=c.useMemo(()=>({current:u?l.length:N.length}),[N.length,l.length,u]),H=async t=>{if(!(!a||P)){K(!0),h(null);try{w(await ue(a,t))}catch(i){h(i instanceof Error?i.message:String(i))}finally{K(!1)}}},te=async()=>{if(a){k("run-now"),h(null);try{await he(a),await y()}catch(t){h(t instanceof Error?t.message:String(t))}finally{k(null)}}},ae=async t=>{if(a){k(t.id),h(null);try{await ye(a,t.id),await y()}catch(i){h(i instanceof Error?i.message:String(i))}finally{k(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ce,{open:n,onOpenChange:t=>!t&&s(),children:e.jsxs(de,{children:[e.jsx(me,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(pe,{"data-testid":"memory-drawer","aria-label":r("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(xe,{className:"text-base font-semibold text-pri",children:r("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:r("memory.subtitle")})]}),e.jsx(f,{label:r("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":r("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(J,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:ee.map(t=>e.jsx("button",{type:"button",onClick:()=>m(t.id),"aria-pressed":o===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${o===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:r("memory.searchPlaceholder")}),e.jsx(we,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:b,onChange:t=>T(t.currentTarget.value),placeholder:r("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[O?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:O}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[se.current," ",r(u?"memory.entries":"memory.runs")]})]}),o==="dreams"?e.jsxs("button",{type:"button",onClick:te,disabled:D!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[D==="run-now"?e.jsx(S,{size:14,className:"animate-spin"}):e.jsx(Q,{size:14}),r("memory.runNow")]}):null]}),$?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(I,{label:r("memory.injection"),checked:$.enabled,disabled:P,onChange:t=>H({enabled:t})}),e.jsx(I,{label:r("memory.dreamProcessing"),checked:$.dreamEnabled,disabled:P,onChange:t=>H({dreamEnabled:t})})]}):null]}),o==="dreams"?F?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(S,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:r("common.loading")})]}):N.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(U,{icon:e.jsx(Q,{size:20}),title:r("memory.emptyDreams"),description:r("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:N.map(t=>e.jsx(Be,{run:t,busy:D===t.id,onRevert:L},t.id))}):F?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(S,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:r("common.loading")})]}):l.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(U,{title:r(o==="candidate"?"memory.emptyCandidate":"memory.emptyActive"),description:r(o==="candidate"?"memory.emptyCandidateDesc":"memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:l.map(t=>e.jsx(Le,{memory:t,busy:Z===t.id,onArchive:R,onApprove:i=>g(i,x=>ge(x,i.id)),onReject:A,onToggleDisabled:i=>g(i,x=>G(x,i.id,{disabled:!i.disabled})),onTogglePinned:i=>g(i,x=>G(x,i.id,{pinned:!i.pinned}))},t.id))})]})]})})]})}),e.jsx(q,{open:E!==null,onOpenChange:t=>{t||R(null)},title:r("memory.archiveTitle"),description:r("memory.archiveDesc"),confirmLabel:r("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!E)return;const t=E;R(null),g(t,i=>ve(i,t.id))}}),e.jsx(q,{open:z!==null,onOpenChange:t=>{t||A(null)},title:r("memory.rejectTitle"),description:r("memory.rejectDesc"),confirmLabel:r("memory.rejectButton"),confirmKind:"danger",onConfirm:()=>{if(!z)return;const t=z;A(null),g(t,i=>Ne(i,t.id))}}),e.jsx(q,{open:W!==null,onOpenChange:t=>{t||L(null)},title:r("memory.revertTitle"),description:r("memory.revertDesc"),confirmLabel:r("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!W)return;const t=W;L(null),ae(t)}})]})};export{Ve as WorkspaceMemoryDrawer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as k,j as h,a0 as e}from"./index-
|
|
1
|
+
import{r as k,j as h,a0 as e}from"./index-BiGD5NhO.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-B_OibVQO.js";const u=({tasksFile:a,workspacePath:T,open:c,onClose:r,workers:n,onSelectOwner:p,connectionStale:d})=>{const s=k.useMemo(()=>n?.length?n.map(o=>o.name):void 0,[n]);return h.jsx(g,{content:a.content,hasConflict:a.hasConflict,onClose:r,onContentChange:a.onChange,onKeepLocal:a.onKeepLocal,onReload:a.onReload,onSave:a.onSave,onToggleTaskLine:o=>{a.toggleTaskAtLine(o).catch(e("tasks.toggleTaskAtLine"))},onAppendTask:o=>{a.appendTask(o).catch(e("tasks.appendTask"))},onAppendSubtask:(o,t)=>{a.appendSubtask(o,t).catch(e("tasks.appendSubtask"))},onUpdateTaskText:(o,t)=>{a.updateTaskText(o,t).catch(e("tasks.updateTaskText"))},onDeleteTask:o=>{a.deleteTask(o).catch(e("tasks.deleteTask"))},open:c,workspacePath:T,...s?{knownWorkerNames:s}:{},...p?{onSelectOwner:p}:{},...d!==void 0?{connectionStale:d}:{}})};export{u as WorkspaceTaskDrawer};
|