@tt-a1i/hive 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{c as M,j as e,u as L,a6 as le,a8 as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,a9 as pe,aa as he,T as S,X as xe,E as me,ab as Q,C as W,b as ee,ac as H,d as ke,ad as fe,x as ge,y as be,ae as je,t as ye}from"./index-BcwN8cCw.js";const we=[["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"}]],I=M("at-sign",we);const ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ne=M("circle",ve);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=M("corner-down-right",_e);const Te=[["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"}]],Ce=M("file-code",Te);const $e=[["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"}]],ze=M("save",$e),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},Se=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=L(),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(ze,{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]},Ee=[{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","产物"]),De=/^(.*?)\s*\(([^()]+)\)\s*$/,Re=/\s*[·,,;;]\s*/,Me=/^([^::]+)[::]\s*(.+)$/,Le=s=>{for(const{pattern:n,tone:l}of Ee)if(n.test(s))return l;return"neutral"},Ae=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),Pe=s=>{const n=s.match(De);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(Re).filter(Boolean),r=[];for(const i of c){const o=i.match(Me);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:Le(u)}):X.has(d)||X.has(t)||Ae(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Ie=({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(I,{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(I,{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}=L(),c=s.checked?ke:Ne,{title:r,meta:i}=Pe(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[g,E]=f.useState(!1),[y,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:w,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:b=!1}=n,C=!!w&&!b,N=!!_&&!b,A=!!D&&!b,$=!!T,R=!o&&!u&&(C||N||A||$),z=s.children.length,x=fe(s),P=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),w?.(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(Ie,{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(I,{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(I,{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(y?"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(y?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:y?e.jsx(ge,{size:12}):e.jsx(be,{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(je,{size:12})})}):null,A?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${P?" 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}=L(),[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")})]})},Ke=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}},Oe=({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:y,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=L(),[w,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const P=s.split(/\r?\n/)[x];typeof P=="string"&&navigator.clipboard?.writeText(P).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,y?{knownWorkerNames:y}:{}),[s,y]),{completedTasks:b,completionPercent:C,doneRoots:N,openRoots:A,totalTasks:$}=f.useMemo(()=>Ke(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(w?"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(w?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Ce,{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]})]}),!w&&$>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:w?e.jsx(Se,{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:[A.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]})})]})},Ve=({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:y,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:w}=L(),_=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":w("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(Oe,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:y,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...g?{onDeleteTask:g}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Oe as TaskGraphContent,Ve as TaskGraphDrawer};
1
+ import{c as M,j as e,u as L,a6 as le,a8 as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,a9 as pe,aa as he,T as S,X as xe,E as me,ab as Q,C as W,b as ee,ac as H,d as ke,ad as fe,x as ge,y as be,ae as je,t as ye}from"./index-D9zUE0W6.js";const we=[["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"}]],I=M("at-sign",we);const ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ne=M("circle",ve);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=M("corner-down-right",_e);const Te=[["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"}]],Ce=M("file-code",Te);const $e=[["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"}]],ze=M("save",$e),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},Se=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=L(),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(ze,{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]},Ee=[{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","产物"]),De=/^(.*?)\s*\(([^()]+)\)\s*$/,Re=/\s*[·,,;;]\s*/,Me=/^([^::]+)[::]\s*(.+)$/,Le=s=>{for(const{pattern:n,tone:l}of Ee)if(n.test(s))return l;return"neutral"},Ae=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),Pe=s=>{const n=s.match(De);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(Re).filter(Boolean),r=[];for(const i of c){const o=i.match(Me);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:Le(u)}):X.has(d)||X.has(t)||Ae(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Ie=({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(I,{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(I,{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}=L(),c=s.checked?ke:Ne,{title:r,meta:i}=Pe(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[g,E]=f.useState(!1),[y,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:w,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:b=!1}=n,C=!!w&&!b,N=!!_&&!b,A=!!D&&!b,$=!!T,R=!o&&!u&&(C||N||A||$),z=s.children.length,x=fe(s),P=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),w?.(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(Ie,{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(I,{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(I,{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(y?"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(y?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:y?e.jsx(ge,{size:12}):e.jsx(be,{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(je,{size:12})})}):null,A?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${P?" 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}=L(),[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")})]})},Ke=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}},Oe=({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:y,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=L(),[w,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const P=s.split(/\r?\n/)[x];typeof P=="string"&&navigator.clipboard?.writeText(P).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,y?{knownWorkerNames:y}:{}),[s,y]),{completedTasks:b,completionPercent:C,doneRoots:N,openRoots:A,totalTasks:$}=f.useMemo(()=>Ke(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(w?"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(w?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Ce,{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]})]}),!w&&$>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:w?e.jsx(Se,{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:[A.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]})})]})},Ve=({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:y,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:w}=L(),_=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":w("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(Oe,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:y,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...g?{onDeleteTask:g}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Oe as TaskGraphContent,Ve 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,a0 as f}from"./index-BcwN8cCw.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
+ 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,a0 as f}from"./index-D9zUE0W6.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 z,i as k,ai as f,j as e,R,P as N,O as C,k as M,m as E,a0 as S,a6 as L,T as D,z as I,X as O,aj as W,q as A,ak as T,al as P}from"./index-BcwN8cCw.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,j=s==="left"?h-2*w:h+2*w;o(x(j))},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}=z(),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
+ import{r as d,u as z,i as k,ai as f,j as e,R,P as N,O as C,k as M,m as E,a0 as S,a6 as L,T as D,z as I,X as O,aj as W,q as A,ak as T,al as P}from"./index-D9zUE0W6.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,j=s==="left"?h-2*w:h+2*w;o(x(j))},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}=z(),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-BcwN8cCw.js";import{S as Z}from"./square-terminal-B7E57In1.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-D9zUE0W6.js";import{S as Z}from"./square-terminal-Co4pmGzn.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 +1 @@
1
- import{c as j,i as te,u as W,r as d,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as de,m as ce,T as g,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as Q,Z as fe}from"./index-BcwN8cCw.js";import{S as ge}from"./search-BZw4T67h.js";const je=[["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"}]],ye=j("archive",je);const ve=[["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"}]],Ne=j("eye-off",ve);const we=[["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"}]],ke=j("pin-off",we);const Se=[["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"}]],Ce=j("pin",Se);const $e=[["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"}]],Me=j("settings-2",$e),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},_e=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},Ee=r=>r==="dreams"?null:r,De=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,c]=d.useState(!1),{t:o}=W();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:()=>c(m=>!m),"aria-expanded":i,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:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:_e(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx(Ce,{size:13})})}),e.jsx(g,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(g,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},U=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),Re=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=d.useState(!1),{t:i}=W();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:()=>n(c=>!c),"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:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:Re(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(g,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{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"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(c=>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--${c.kind} scale-90 origin-left inline-block mr-1`,children:i(G[c.kind])}),c.body]})]},c.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]"}),i("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(c=>c.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"}),i("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(c=>c.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"}),i("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(c=>c.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,c]=d.useState("active"),[o,m]=d.useState(""),[y,C]=d.useState([]),[v,$]=d.useState([]),[M,N]=d.useState(null),[q,T]=d.useState(!1),[L,x]=d.useState(null),[J,B]=d.useState(null),[_,w]=d.useState(null),[E,D]=d.useState(null),[R,z]=d.useState(null),[A,F]=d.useState(!1),b=d.useRef(0),X=d.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=Ee(i),f=d.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){C([]),$([]),N(null),T(!1);return}T(!0),x(null),C([]),$([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),C(h),$(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);d.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=d.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"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(de,{"data-testid":"memory-drawer","aria-label":n("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(ce,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(g,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{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:X.map(t=>e.jsx("button",{type:"button",onClick:()=>c(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===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:n("memory.searchPlaceholder")}),e.jsx(ge,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("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:[L?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:L}):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(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:_!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[_==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(U,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(U,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:_===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(De,{memory:t,busy:J===t.id,onArchive:D,onToggleDisabled:l=>P(l,h=>Q(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>Q(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:E!==null,onOpenChange:t=>{t||D(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!E)return;const t=E;D(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:R!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!R)return;const t=R;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
1
+ import{c as j,i as te,u as W,r as d,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as de,m as ce,T as g,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as Q,Z as fe}from"./index-D9zUE0W6.js";import{S as ge}from"./search-BRQbevR2.js";const je=[["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"}]],ye=j("archive",je);const ve=[["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"}]],Ne=j("eye-off",ve);const we=[["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"}]],ke=j("pin-off",we);const Se=[["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"}]],Ce=j("pin",Se);const $e=[["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"}]],Me=j("settings-2",$e),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},_e=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},Ee=r=>r==="dreams"?null:r,De=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,c]=d.useState(!1),{t:o}=W();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:()=>c(m=>!m),"aria-expanded":i,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:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:_e(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx(Ce,{size:13})})}),e.jsx(g,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(g,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},U=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),Re=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=d.useState(!1),{t:i}=W();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:()=>n(c=>!c),"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:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:Re(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(g,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{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"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(c=>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--${c.kind} scale-90 origin-left inline-block mr-1`,children:i(G[c.kind])}),c.body]})]},c.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]"}),i("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(c=>c.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"}),i("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(c=>c.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"}),i("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(c=>c.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,c]=d.useState("active"),[o,m]=d.useState(""),[y,C]=d.useState([]),[v,$]=d.useState([]),[M,N]=d.useState(null),[q,T]=d.useState(!1),[L,x]=d.useState(null),[J,B]=d.useState(null),[_,w]=d.useState(null),[E,D]=d.useState(null),[R,z]=d.useState(null),[A,F]=d.useState(!1),b=d.useRef(0),X=d.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=Ee(i),f=d.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){C([]),$([]),N(null),T(!1);return}T(!0),x(null),C([]),$([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),C(h),$(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);d.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=d.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"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(de,{"data-testid":"memory-drawer","aria-label":n("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(ce,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(g,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{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:X.map(t=>e.jsx("button",{type:"button",onClick:()=>c(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===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:n("memory.searchPlaceholder")}),e.jsx(ge,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("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:[L?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:L}):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(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:_!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[_==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(U,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(U,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:_===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(De,{memory:t,busy:J===t.id,onArchive:D,onToggleDisabled:l=>P(l,h=>Q(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>Q(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:E!==null,onOpenChange:t=>{t||D(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!E)return;const t=E;D(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:R!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!R)return;const t=R;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
@@ -1 +1 @@
1
- import{r as k,j as h,_ as e}from"./index-BcwN8cCw.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-C2JufcPs.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};
1
+ import{r as k,j as h,_ as e}from"./index-D9zUE0W6.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-Beh95yUu.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};