@tt-a1i/hive 1.4.2 → 1.4.3

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 z,j as e,u as O,T as oe,R as ie,r as k,p as re,a as ce,P as de,O as ue,C as pe,b as he,D as xe,d as S,X as ke,E as me,e as te,f as Y,g as fe,h as ge,i as je,k as be,l as we,m as ye,n as D}from"./index-CWW5vUjQ.js";import{C as se}from"./chevron-right-Bmg7DcUj.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],K=z("at-sign",ve);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Te=z("circle",Ne);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],G=z("corner-down-right",_e);const Ce=[["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"}]],$e=z("file-code",Ce);const Se=[["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 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ae=z("file-text",Se);const ze=[["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"}]],Ee=z("save",ze),U=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let o=0;for(;o<t.length;){const i=t.slice(o),r=i.match(/^\*\*([^*]+?)\*\*/);if(r?.[1]){c(),n.push(e.jsx("strong",{children:U(r[1])},a++)),o+=r[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),o+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:U(u[1])},a++)),o+=u[0].length;continue}l+=t[o],o+=1}return c(),n},De=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:o})=>{const{t:i}=O(),r=s=>{s.preventDefault(),o()};return e.jsxs("form",{onSubmit:r,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:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.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(oe,{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(ie,{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(Ee,{size:14}),i("tasks.raw.save")]})})]})},B=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],ne=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return B[n%B.length]??B[0]},Me=[{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"}],W=new Set(["owner","assignee","负责","负责人","执行人"]),Z=new Set(["status","状态"]),J=new Set(["报告","report","文件","file","path","日志","log","产物"]),Re=/^(.*?)\s*\(([^()]+)\)\s*$/,Ae=/\s*[·,,;;]\s*/,Le=/^([^::]+)[::]\s*(.+)$/,Pe=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Ke=t=>t.includes("/")?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Oe=t=>{const n=t.match(Re);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Ae).filter(Boolean),o=[];for(const i of c){const r=i.match(Le);if(!r){o.push({kind:"note",value:i.trim()});continue}const s=(r[1]??"").trim(),u=(r[2]??"").trim(),h=s.toLowerCase();W.has(h)||W.has(s)?o.push({kind:"owner",value:u}):Z.has(h)||Z.has(s)?o.push({kind:"status",value:u,tone:Pe(u)}):J.has(h)||J.has(s)||Ke(u)?o.push({kind:"path",label:s,value:u}):o.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:o}},Q=3,Ie=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":ne(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ae,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},F=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,o]=k.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},r=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>o(s.target.value),onKeyDown:r,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},q=({task:t,handlers:n,depth:l})=>{const{t:a}=O(),c=t.checked?fe:Te,{title:o,meta:i}=Oe(t.text),[r,s]=k.useState(!1),[u,h]=k.useState(!1),[b,M]=k.useState(!1),[_,C]=k.useState(!1),g=k.useRef(null);k.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const{onToggle:f,onUpdateText:x,onDelete:y,onAppendSubtask:R,onCopyLine:I,onSelectOwner:v,writeDisabled:j=!1}=n,A=!!x&&!j,$=!!y&&!j,N=!!R&&!j,L=!!I,E=!r&&!u&&(A||$||N||L),w=t.children.length,T=ge(t),P=l+1>=Q,H=w>0,V=b?a("tasks.aria.expandSubtasks",{count:w}):a("tasks.aria.collapseSubtasks",{count:w}),p=v?{onSelectOwner:v}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Q?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:t.checked,disabled:j,onChange:()=>{j||f(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.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:r?e.jsx(F,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:d=>{s(!1),x?.(t.line,d)},onCancel:()=>s(!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 ${t.checked?"text-ter line-through":"text-pri"}`,children:U(o)}),H?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:d=>{d.stopPropagation(),M(m=>!m)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!b,"aria-label":V,children:b?e.jsx(se,{size:12,"aria-hidden":!0}):e.jsx(te,{size:12,"aria-hidden":!0})}):null,T?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:T.done,total:T.total}),children:[T.done,"/",T.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(d=>e.jsx(Ie,{item:d,handlers:p},`${t.line}-meta-${d.kind}-${"label"in d?d.label:""}-${d.value}`)),t.mentions.map(d=>{const m=d.replace(/^@/,""),X={"--owner-tone":ne(m)};return v?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${m}`,"data-owner":m,onClick:le=>{le.stopPropagation(),v(m)},style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${m}`,"data-owner":m,style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`)})]}):null]})}),E?e.jsxs("div",{className:"task-row__actions",children:[L?e.jsx(S,{label:a(_?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{I?.(t.line),C(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1),g.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(_?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:_?e.jsx(je,{size:12}):e.jsx(be,{size:12})})}):null,A?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{M(!1),h(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(G,{size:12})})}):null,$?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger",onClick:()=>y?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),w>0&&!b||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[b?null:t.children.map(d=>e.jsx(q,{depth:l+1,handlers:n,task:d},d.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(G,{size:12})}),e.jsx(F,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:d=>{h(!1),R?.(t.line,d)},onCancel:()=>h(!1)})]})}):null]}):null]})},ee=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=O(),[c,o]=k.useState(!1),[i,r]=k.useState(""),s=()=>{const h=i.trim();if(!h){o(!1);return}t(h),r("")},u=h=>{h.key==="Enter"?(h.preventDefault(),s()):h.key==="Escape"&&(h.preventDefault(),r(""),o(!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(Y,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:h=>r(h.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>o(!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(Y,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},He=t=>{let n=0,l=0;const a=[],c=[],o=r=>{n+=1,r.checked&&(l+=1);for(const s of r.children)o(s)};for(const r of t)r.checked?c.push(r):a.push(r),o(r);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ve=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i,onToggleTaskLine:r,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:h,onDeleteTask:b,open:M,workspacePath:_,knownWorkerNames:C,onSelectOwner:g,connectionStale:f=!1})=>{const{t:x}=O(),[y,R]=k.useState(!1),v={onToggle:r,onCopyLine:p=>{const d=t.split(/\r?\n/)[p];typeof d=="string"&&navigator.clipboard?.writeText(d).catch(m=>{console.error("[hive] swallowed:tasks.copyLine",m)})},...h&&!f?{onUpdateText:h}:{},...b&&!f?{onDelete:b}:{},...u&&!f?{onAppendSubtask:u}:{},...g?{onSelectOwner:g}:{},...f?{writeDisabled:!0}:{}},j=k.useMemo(()=>re(t,C?{knownWorkerNames:C}:{}),[t,C]),{completedTasks:A,completionPercent:$,doneRoots:N,openRoots:L,totalTasks:E}=k.useMemo(()=>He(j),[j]),[w,T]=k.useState(N.length<=3),P=_?`${_}/.hive/tasks.md`:".hive/tasks.md",H=p=>{if(p.key!=="Escape")return;const d=p.target?.tagName;d==="INPUT"||d==="TEXTAREA"||(p.preventDefault(),l())},V=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${f?" task-dialog--stale":""}`;return e.jsx(ce,{open:M,onOpenChange:p=>!p&&l(),children:e.jsxs(de,{children:[e.jsx(ue,{"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.jsxs(pe,{"aria-label":x("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":f||void 0,onEscapeKeyDown:p=>p.preventDefault(),onKeyDown:H,className:V,style:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(780px, calc(100vh - 48px))",width:"min(1040px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx(he,{className:"font-semibold text-pri leading-tight",children:x("tasks.title.todo")}),e.jsx(xe,{className:"mono truncate text-xs text-ter",title:P,children:P})]}),E>0?e.jsxs("span",{className:"text-xs text-ter tabular-nums","data-testid":"task-graph-summary",children:[e.jsxs("span",{"data-testid":"task-progress-text",children:[A," / ",E]})," ","· ",$,"%"]}):null,e.jsx(S,{label:x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>R(p=>!p),"data-testid":"task-raw-toggle",className:"icon-btn","aria-label":x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx($e,{size:14})})}),e.jsx(S,{label:x("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":x("tasks.action.closeTodo"),className:"icon-btn",children:e.jsx(ke,{size:14})})})]}),!y&&E>0?e.jsx("div",{"aria-label":x("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":$,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${$}%`}})}):null,e.jsx("div",{className:"flex-1 scroll-y px-3 py-3 text-sm",children:y?e.jsx(De,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i}):j.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ae,{size:20}),title:x("tasks.empty.title"),description:x("tasks.empty.description"),...s?{action:e.jsx(ee,{variant:"primary",disabled:f,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line)),s?e.jsx("li",{children:e.jsx(ee,{disabled:f,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>T(p=>!p),"aria-expanded":w,"data-testid":"task-completed-toggle",className:"task-completed-toggle",children:[w?e.jsx(te,{size:12,"aria-hidden":!0}):e.jsx(se,{size:12,"aria-hidden":!0}),e.jsx("span",{children:x("tasks.completed.toggle",{count:N.length})})]}),w?e.jsx("ul",{className:"task-list","data-testid":"task-completed-list",children:N.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line))}):null]}):null]})})]})})]})})},qe=({tasksFile:t,workspacePath:n,open:l,onClose:a,workers:c,onSelectOwner:o,connectionStale:i})=>{const r=k.useMemo(()=>c?.length?c.map(s=>s.name):void 0,[c]);return e.jsx(Ve,{content:t.content,hasConflict:t.hasConflict,onClose:a,onContentChange:t.onChange,onKeepLocal:t.onKeepLocal,onReload:t.onReload,onSave:t.onSave,onToggleTaskLine:s=>{t.toggleTaskAtLine(s).catch(D("tasks.toggleTaskAtLine"))},onAppendTask:s=>{t.appendTask(s).catch(D("tasks.appendTask"))},onAppendSubtask:(s,u)=>{t.appendSubtask(s,u).catch(D("tasks.appendSubtask"))},onUpdateTaskText:(s,u)=>{t.updateTaskText(s,u).catch(D("tasks.updateTaskText"))},onDeleteTask:s=>{t.deleteTask(s).catch(D("tasks.deleteTask"))},open:l,workspacePath:n,...r?{knownWorkerNames:r}:{},...o?{onSelectOwner:o}:{},...i!==void 0?{connectionStale:i}:{}})};export{qe as WorkspaceTaskDrawer};
1
+ import{c as z,j as e,u as O,T as oe,R as ie,r as k,p as re,a as ce,P as de,O as ue,C as pe,b as he,D as xe,d as S,X as ke,E as me,e as te,f as Y,g as fe,h as ge,i as je,k as be,l as we,m as ye,n as D}from"./index-Cn8X3get.js";import{C as se}from"./chevron-right-CtLjVEl7.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],K=z("at-sign",ve);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Te=z("circle",Ne);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],G=z("corner-down-right",_e);const Ce=[["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"}]],$e=z("file-code",Ce);const Se=[["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 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ae=z("file-text",Se);const ze=[["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"}]],Ee=z("save",ze),U=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let o=0;for(;o<t.length;){const i=t.slice(o),r=i.match(/^\*\*([^*]+?)\*\*/);if(r?.[1]){c(),n.push(e.jsx("strong",{children:U(r[1])},a++)),o+=r[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),o+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:U(u[1])},a++)),o+=u[0].length;continue}l+=t[o],o+=1}return c(),n},De=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:o})=>{const{t:i}=O(),r=s=>{s.preventDefault(),o()};return e.jsxs("form",{onSubmit:r,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:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.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(oe,{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(ie,{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(Ee,{size:14}),i("tasks.raw.save")]})})]})},B=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],ne=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return B[n%B.length]??B[0]},Me=[{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"}],W=new Set(["owner","assignee","负责","负责人","执行人"]),Z=new Set(["status","状态"]),J=new Set(["报告","report","文件","file","path","日志","log","产物"]),Re=/^(.*?)\s*\(([^()]+)\)\s*$/,Ae=/\s*[·,,;;]\s*/,Le=/^([^::]+)[::]\s*(.+)$/,Pe=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Ke=t=>t.includes("/")?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Oe=t=>{const n=t.match(Re);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Ae).filter(Boolean),o=[];for(const i of c){const r=i.match(Le);if(!r){o.push({kind:"note",value:i.trim()});continue}const s=(r[1]??"").trim(),u=(r[2]??"").trim(),h=s.toLowerCase();W.has(h)||W.has(s)?o.push({kind:"owner",value:u}):Z.has(h)||Z.has(s)?o.push({kind:"status",value:u,tone:Pe(u)}):J.has(h)||J.has(s)||Ke(u)?o.push({kind:"path",label:s,value:u}):o.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:o}},Q=3,Ie=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":ne(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ae,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},F=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,o]=k.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},r=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>o(s.target.value),onKeyDown:r,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},q=({task:t,handlers:n,depth:l})=>{const{t:a}=O(),c=t.checked?fe:Te,{title:o,meta:i}=Oe(t.text),[r,s]=k.useState(!1),[u,h]=k.useState(!1),[b,M]=k.useState(!1),[_,C]=k.useState(!1),g=k.useRef(null);k.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const{onToggle:f,onUpdateText:x,onDelete:y,onAppendSubtask:R,onCopyLine:I,onSelectOwner:v,writeDisabled:j=!1}=n,A=!!x&&!j,$=!!y&&!j,N=!!R&&!j,L=!!I,E=!r&&!u&&(A||$||N||L),w=t.children.length,T=ge(t),P=l+1>=Q,H=w>0,V=b?a("tasks.aria.expandSubtasks",{count:w}):a("tasks.aria.collapseSubtasks",{count:w}),p=v?{onSelectOwner:v}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Q?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:t.checked,disabled:j,onChange:()=>{j||f(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.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:r?e.jsx(F,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:d=>{s(!1),x?.(t.line,d)},onCancel:()=>s(!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 ${t.checked?"text-ter line-through":"text-pri"}`,children:U(o)}),H?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:d=>{d.stopPropagation(),M(m=>!m)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!b,"aria-label":V,children:b?e.jsx(se,{size:12,"aria-hidden":!0}):e.jsx(te,{size:12,"aria-hidden":!0})}):null,T?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:T.done,total:T.total}),children:[T.done,"/",T.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(d=>e.jsx(Ie,{item:d,handlers:p},`${t.line}-meta-${d.kind}-${"label"in d?d.label:""}-${d.value}`)),t.mentions.map(d=>{const m=d.replace(/^@/,""),X={"--owner-tone":ne(m)};return v?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${m}`,"data-owner":m,onClick:le=>{le.stopPropagation(),v(m)},style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${m}`,"data-owner":m,style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`)})]}):null]})}),E?e.jsxs("div",{className:"task-row__actions",children:[L?e.jsx(S,{label:a(_?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{I?.(t.line),C(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1),g.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(_?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:_?e.jsx(je,{size:12}):e.jsx(be,{size:12})})}):null,A?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{M(!1),h(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(G,{size:12})})}):null,$?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger",onClick:()=>y?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),w>0&&!b||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[b?null:t.children.map(d=>e.jsx(q,{depth:l+1,handlers:n,task:d},d.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(G,{size:12})}),e.jsx(F,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:d=>{h(!1),R?.(t.line,d)},onCancel:()=>h(!1)})]})}):null]}):null]})},ee=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=O(),[c,o]=k.useState(!1),[i,r]=k.useState(""),s=()=>{const h=i.trim();if(!h){o(!1);return}t(h),r("")},u=h=>{h.key==="Enter"?(h.preventDefault(),s()):h.key==="Escape"&&(h.preventDefault(),r(""),o(!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(Y,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:h=>r(h.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>o(!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(Y,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},He=t=>{let n=0,l=0;const a=[],c=[],o=r=>{n+=1,r.checked&&(l+=1);for(const s of r.children)o(s)};for(const r of t)r.checked?c.push(r):a.push(r),o(r);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ve=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i,onToggleTaskLine:r,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:h,onDeleteTask:b,open:M,workspacePath:_,knownWorkerNames:C,onSelectOwner:g,connectionStale:f=!1})=>{const{t:x}=O(),[y,R]=k.useState(!1),v={onToggle:r,onCopyLine:p=>{const d=t.split(/\r?\n/)[p];typeof d=="string"&&navigator.clipboard?.writeText(d).catch(m=>{console.error("[hive] swallowed:tasks.copyLine",m)})},...h&&!f?{onUpdateText:h}:{},...b&&!f?{onDelete:b}:{},...u&&!f?{onAppendSubtask:u}:{},...g?{onSelectOwner:g}:{},...f?{writeDisabled:!0}:{}},j=k.useMemo(()=>re(t,C?{knownWorkerNames:C}:{}),[t,C]),{completedTasks:A,completionPercent:$,doneRoots:N,openRoots:L,totalTasks:E}=k.useMemo(()=>He(j),[j]),[w,T]=k.useState(N.length<=3),P=_?`${_}/.hive/tasks.md`:".hive/tasks.md",H=p=>{if(p.key!=="Escape")return;const d=p.target?.tagName;d==="INPUT"||d==="TEXTAREA"||(p.preventDefault(),l())},V=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${f?" task-dialog--stale":""}`;return e.jsx(ce,{open:M,onOpenChange:p=>!p&&l(),children:e.jsxs(de,{children:[e.jsx(ue,{"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.jsxs(pe,{"aria-label":x("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":f||void 0,onEscapeKeyDown:p=>p.preventDefault(),onKeyDown:H,className:V,style:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(780px, calc(100vh - 48px))",width:"min(1040px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx(he,{className:"font-semibold text-pri leading-tight",children:x("tasks.title.todo")}),e.jsx(xe,{className:"mono truncate text-xs text-ter",title:P,children:P})]}),E>0?e.jsxs("span",{className:"text-xs text-ter tabular-nums","data-testid":"task-graph-summary",children:[e.jsxs("span",{"data-testid":"task-progress-text",children:[A," / ",E]})," ","· ",$,"%"]}):null,e.jsx(S,{label:x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>R(p=>!p),"data-testid":"task-raw-toggle",className:"icon-btn","aria-label":x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx($e,{size:14})})}),e.jsx(S,{label:x("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":x("tasks.action.closeTodo"),className:"icon-btn",children:e.jsx(ke,{size:14})})})]}),!y&&E>0?e.jsx("div",{"aria-label":x("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":$,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${$}%`}})}):null,e.jsx("div",{className:"flex-1 scroll-y px-3 py-3 text-sm",children:y?e.jsx(De,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i}):j.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ae,{size:20}),title:x("tasks.empty.title"),description:x("tasks.empty.description"),...s?{action:e.jsx(ee,{variant:"primary",disabled:f,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line)),s?e.jsx("li",{children:e.jsx(ee,{disabled:f,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>T(p=>!p),"aria-expanded":w,"data-testid":"task-completed-toggle",className:"task-completed-toggle",children:[w?e.jsx(te,{size:12,"aria-hidden":!0}):e.jsx(se,{size:12,"aria-hidden":!0}),e.jsx("span",{children:x("tasks.completed.toggle",{count:N.length})})]}),w?e.jsx("ul",{className:"task-list","data-testid":"task-completed-list",children:N.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line))}):null]}):null]})})]})})]})})},qe=({tasksFile:t,workspacePath:n,open:l,onClose:a,workers:c,onSelectOwner:o,connectionStale:i})=>{const r=k.useMemo(()=>c?.length?c.map(s=>s.name):void 0,[c]);return e.jsx(Ve,{content:t.content,hasConflict:t.hasConflict,onClose:a,onContentChange:t.onChange,onKeepLocal:t.onKeepLocal,onReload:t.onReload,onSave:t.onSave,onToggleTaskLine:s=>{t.toggleTaskAtLine(s).catch(D("tasks.toggleTaskAtLine"))},onAppendTask:s=>{t.appendTask(s).catch(D("tasks.appendTask"))},onAppendSubtask:(s,u)=>{t.appendSubtask(s,u).catch(D("tasks.appendSubtask"))},onUpdateTaskText:(s,u)=>{t.updateTaskText(s,u).catch(D("tasks.updateTaskText"))},onDeleteTask:s=>{t.deleteTask(s).catch(D("tasks.deleteTask"))},open:l,workspacePath:n,...r?{knownWorkerNames:r}:{},...o?{onSelectOwner:o}:{},...i!==void 0?{connectionStale:i}:{}})};export{qe as WorkspaceTaskDrawer};
@@ -1 +1 @@
1
- import{r as E,_ as R,x as X,j as _,u as F,y as Z}from"./index-CWW5vUjQ.js";const z="hive:terminal-visible-resize",Q=e=>new CustomEvent(z,{detail:{runId:e}}),ee=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),S={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},te=(e,n={})=>{const t=n.isMac??ee();if(e.key==="Enter"&&e.shiftKey)return e.type==="keypress"?{kind:"send",bytes:S.shiftEnter}:{kind:"block"};if(!t||e.type!=="keydown")return{kind:"passthrough"};const o=e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey,r=e.altKey&&!e.metaKey&&!e.ctrlKey;if(o)switch(e.key){case"Backspace":return{kind:"send",bytes:S.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:S.lineStart};case"ArrowRight":return{kind:"send",bytes:S.lineEnd};case"k":case"K":return{kind:"clear"}}if(r)switch(e.key){case"Backspace":return{kind:"send",bytes:S.killWordBack};case"ArrowLeft":return{kind:"send",bytes:S.wordBack};case"ArrowRight":return{kind:"send",bytes:S.wordForward}}return{kind:"passthrough"}},K=(e,n={})=>{const t=new URL(e,window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:";for(const[o,r]of Object.entries(n))r!==void 0&&t.searchParams.set(o,String(r));return t.toString()},ne=({initialSize:e,onError:n,onExit:t,onOutput:o,onRestore:r,runId:l})=>{const s=crypto.randomUUID(),a={...e,clientId:s},d=new WebSocket(K(`/ws/terminal/${l}/io`,a)),c=new WebSocket(K(`/ws/terminal/${l}/control`,a));let g=!1;const u=[];let h=null;const b=()=>{!h||c.readyState!==c.OPEN||(c.send(JSON.stringify({type:"resize",...h})),h=null)};return d.onmessage=p=>{const w=typeof p.data=="string"?p.data:"",m=v=>{c.readyState===c.OPEN&&c.send(JSON.stringify({type:"output_ack",bytes:v}))};if(!g){u.push({chunk:w,acknowledge:m});return}o(w,m)},c.onopen=()=>{b()},c.onmessage=p=>{const w=JSON.parse(String(p.data));if(w.type==="exit"&&t(w.code),w.type==="error"&&n(w.message),w.type==="restore"){r(w.snapshot),g=!0,c.readyState===c.OPEN&&c.send(JSON.stringify({type:"restore_complete"}));for(const m of u.splice(0))o(m.chunk,m.acknowledge)}},{dispose(){d.close(),c.close()},resize(p,w,m,v){h={cols:p,rows:w},m!==void 0&&(h.pixelWidth=m),v!==void 0&&(h.pixelHeight=v),b()},sendBinaryInput(p){if(d.readyState!==d.OPEN)return;const w=new Uint8Array(p.length);for(let m=0;m<p.length;m++)w[m]=p.charCodeAt(m)&255;d.send(w)},sendInput(p){d.readyState===d.OPEN&&d.send(p)}}},re=16,oe=.3,se=(e,n)=>{const t=n==="up"?"A":"B";return e?`\x1BO${t}`:`\x1B[${t}`},ie=(e,n,t)=>n==="opencode"?t==="up"?"\x1B[5~":"\x1B[6~":se(e.modes?.applicationCursorKeysMode,t),ae=(e,n="default")=>{let t=0;return o=>{if(e.buffer?.active?.type!=="alternate")return t=0,{handled:!1,input:null};if(n!=="opencode"&&e.modes?.mouseTrackingMode&&e.modes.mouseTrackingMode!=="none")return t=0,{handled:!1,input:null};if(o.deltaY===0||o.shiftKey)return{handled:!1,input:null};let r=o.deltaY;return o.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=re,Math.abs(o.deltaY)<50&&(r*=oe),t+=r,r=Math.trunc(t),t%=1):t=0,r===0?{handled:!0,input:null}:{handled:!0,input:ie(e,n,r<0?"up":"down")}}},le=({element:e,profile:n="default",sendInput:t,terminal:o})=>{const r=ae(o,n),l=a=>{const{handled:d,input:c}=r(a);return d?(a.preventDefault(),a.stopPropagation(),c&&t(c),!1):!0};if(typeof o.attachCustomWheelEventHandler=="function")return o.attachCustomWheelEventHandler(l),()=>{};const s=a=>{l(a)||a.stopImmediatePropagation()};return e.addEventListener("wheel",s,{capture:!0,passive:!1}),()=>e.removeEventListener("wheel",s,{capture:!0})},ce=new RegExp("\x1B\\[M([\\s\\S])([\\s\\S])([\\s\\S])","g"),de=(e,n,t,o)=>{const r=n.charCodeAt(0)-32,l=t.charCodeAt(0)-32,s=o.charCodeAt(0)-32;if(r<0||l<1||s<1)return e;const d=(r&3)===3&&(r&32)===0&&(r&64)===0?"m":"M";return`\x1B[<${r};${l};${s}${d}`},ue=(e,n)=>{if(n!=="opencode")return{binary:!0,chunk:e};const t=e.replace(ce,de);return{binary:t===e,chunk:t}},fe=(e,n="default")=>{const t=E.useRef(null),[o,r]=E.useState(null),[l,s]=E.useState("connecting");return E.useEffect(()=>{if(!t.current)return;let a=!1,d,c,g,u,h,b,p,w,m,v,T=null,P,L;const O={current:!1};return Promise.all([R(()=>import("./xterm-B-qIQCd3.js"),[]),R(()=>import("./addon-fit-DX4qG4td.js"),[]),R(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),R(()=>import("./addon-clipboard-wHJhZAA4.js"),[])]).then(([$,j,U,Y])=>{if(a||!t.current)return;const W=typeof window<"u"?getComputedStyle(document.documentElement):null,q=W?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",J=W?.getPropertyValue("--text-primary").trim()||"#ebebeb",f=new $.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:q,foreground:J}}),M=new j.FitAddon;if(f.loadAddon(M),f.loadAddon(new U.Unicode11Addon),f.unicode.activeVersion="11",f.loadAddon(new Y.ClipboardAddon),f.open(t.current),M.fit(),b=f,p=M,v=le({element:t.current,profile:n,sendInput:i=>h?.sendInput(i),terminal:f}),T=t.current.querySelector(".xterm-helper-textarea"),T){const i=T;P=()=>{O.current=!0},L=y=>{const k=y.data;k&&h?.sendInput(k),i.value="",setTimeout(()=>{O.current=!1},0)},T.addEventListener("compositionstart",P,{capture:!0}),T.addEventListener("compositionend",L,{capture:!0})}typeof f.attachCustomKeyEventHandler=="function"&&f.attachCustomKeyEventHandler(i=>{const y=te(i);switch(y.kind){case"send":return i.preventDefault(),h?.sendInput(y.bytes),!1;case"clear":return i.preventDefault(),f.clear(),!1;case"block":return!1;case"passthrough":return!0}});const G=()=>{const i=t.current;return i?.isConnected?!i.closest('[data-terminal-host-parked="true"]'):!1},N=()=>{if(!t.current)return{};const i=t.current.clientWidth,y=t.current.clientHeight,k={};return y>0&&(k.pixelHeight=y),i>0&&(k.pixelWidth=i),k},I=()=>{if(!t.current||!G())return;p?.fit();const{pixelHeight:i,pixelWidth:y}=N();h?.resize(b?.cols??80,b?.rows??24,y,i)},H=()=>{m&&window.clearTimeout(m),m=window.setTimeout(()=>{m=void 0,I()},50)};R(()=>import("./addon-web-links-DIbG5aQx.js"),[]).then(i=>{a||b!==f||f.loadAddon(new i.WebLinksAddon)}).catch(()=>{}),R(()=>import("./addon-webgl-DCtw1yLn.js"),[]).then(i=>{if(!(a||b!==f))try{const y=new i.WebglAddon;y.onContextLoss(()=>y.dispose()),f.loadAddon(y),H()}catch{}}).catch(()=>{}),h=ne({initialSize:{cols:f.cols,rows:f.rows,...N()},onError(i){r(i)},onExit(){s("stopped")},onOutput(i,y){f.write(i,()=>y(new TextEncoder().encode(i).byteLength))},onRestore(i){f.write(i)},runId:e}),u=f.onData(i=>{O.current||h?.sendInput(i)}),typeof f.onBinary=="function"&&(g=f.onBinary(i=>{const y=ue(i,n);y.binary?h?.sendBinaryInput(y.chunk):h?.sendInput(y.chunk)})),s("running"),I(),typeof ResizeObserver<"u"&&t.current&&(w=new ResizeObserver(H),w.observe(t.current)),d=i=>{i.detail?.runId===e&&I()},c=()=>I(),window.addEventListener(z,d),window.addEventListener("resize",c)}),()=>{a=!0,d&&window.removeEventListener(z,d),c&&window.removeEventListener("resize",c),w?.disconnect(),m&&window.clearTimeout(m),v?.(),T&&P&&T.removeEventListener("compositionstart",P,{capture:!0}),T&&L&&T.removeEventListener("compositionend",L,{capture:!0}),g?.dispose(),u?.dispose(),h?.dispose(),b?.dispose(),p?.dispose()}},[e,n]),{containerRef:t,error:o,status:l}},pe={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},D="hive-terminal-parking-lot",me=500,he=e=>[`worker-pty-${e}`,`orch-pty-${e}`,`shell-pty-${e}`],ye=e=>{const n=Array.from(document.querySelectorAll("[data-pty-slot]")).filter(t=>t.id===e);return n[n.length-1]??null},we=()=>{let e=document.getElementById(D);return e||(e=document.createElement("div"),e.id=D,e.hidden=!0,e.style.display="none",(document.body??document.documentElement).appendChild(e)),e},B=()=>{const e=document.getElementById(D);e&&e.childElementCount===0&&e.remove()},C=new Set;let x,A;const V=()=>{for(const e of C)e()},Ee=()=>{x?.disconnect(),x=void 0,A!==void 0&&(window.clearInterval(A),A=void 0)},ge=()=>{if(x||A!==void 0)return;const e=document.body??document.documentElement;if(typeof MutationObserver<"u"&&e){x=new MutationObserver(V),x.observe(e,{attributeFilter:["data-pty-slot","id"],attributes:!0,childList:!0,subtree:!0});return}A=window.setInterval(V,100)},be=e=>(C.add(e),ge(),()=>{C.delete(e),C.size===0&&Ee()}),Te=[50,150,300],ve=e=>{const n=[],t=[],o=()=>window.dispatchEvent(Q(e)),r=(l,s)=>{const a=window.setTimeout(()=>{const d=t.indexOf(a);d>=0&&t.splice(d,1),s()},l);t.push(a)};if(typeof window.requestAnimationFrame=="function"){const l=window.requestAnimationFrame(()=>{o();const s=window.requestAnimationFrame(o);n.push(s)});n.push(l)}else r(0,o);for(const l of Te)r(l,o);return()=>{for(const l of n)window.cancelAnimationFrame?.(l);for(const l of t)window.clearTimeout(l);n.length=0,t.length=0}},Se=e=>{const[n,t]=E.useState(null);return E.useEffect(()=>{const o=he(e),r=()=>{for(const s of o){const a=ye(s);if(a)return a}return null},l=()=>{const s=r();t(a=>a===s?a:s)};return l(),be(l)},[e]),n},_e=(e,n)=>{const[t,o]=E.useState(!1),[r,l]=E.useState(null),s=E.useRef(void 0),a=E.useRef(null),d=E.useRef(void 0),c=E.useCallback(()=>{s.current!==void 0&&(window.clearTimeout(s.current),s.current=void 0)},[]),g=E.useCallback(()=>{d.current?.(),d.current=void 0},[]);return E.useLayoutEffect(()=>{const u=document.createElement("div");return u.dataset.terminalHostRunId=e,u.dataset.terminalHostParked="false",u.className="h-full min-h-0 w-full min-w-0",a.current=u,l(u),()=>{c(),g(),u.remove(),a.current=null,B()}},[c,g,e]),E.useLayoutEffect(()=>{if(n){c(),o(!0);return}if(!(!t||s.current!==void 0))return s.current=window.setTimeout(()=>{s.current=void 0,o(!1)},me),c},[t,c,n]),E.useLayoutEffect(()=>{const u=a.current;if(!u)return;if(!t){g(),u.remove(),u.dataset.terminalHostParked="false",B();return}const h=n??we();if(u.parentElement===h)return;const b=u.parentElement!==null,p=document.activeElement;n||g(),!n&&p instanceof HTMLElement&&u.contains(p)&&p.blur(),u.dataset.terminalHostParked=n?"false":"true",h.appendChild(u),B(),n&&b&&(g(),d.current=ve(e))},[t,g,e,n]),t?r:null},ke=({inputProfile:e="default",runId:n,title:t})=>{const o=Se(n),r=_e(n,o);return r?X.createPortal(_.jsx(Re,{inputProfile:e,runId:n,title:t}),r):null},Re=({inputProfile:e,runId:n,title:t})=>{const{t:o}=F(),{containerRef:r,error:l,status:s}=fe(n,e),a=pe[s];return _.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[_.jsx("p",{className:"sr-only",children:a?o(a):s}),l?_.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:l}):null,_.jsx("div",{"data-testid":`terminal-${n}`,ref:r,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},Ae=({hidden:e=!1,optimisticRuns:n=[],terminalRuns:t,workspaceId:o})=>{const{t:r}=F(),l=Z(t,n,o);return _.jsx("section",{hidden:e,"aria-hidden":e||void 0,"aria-label":r("terminalPanels.aria"),children:l.map(s=>_.jsx(ke,{inputProfile:s.terminal_input_profile??"default",runId:s.run_id,title:`${s.agent_name} (${s.status})`},s.run_id))})};export{Ae as WorkspaceTerminalPanels};
1
+ import{r as E,_ as R,x as X,j as _,u as F,y as Z}from"./index-Cn8X3get.js";const z="hive:terminal-visible-resize",Q=e=>new CustomEvent(z,{detail:{runId:e}}),ee=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),S={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},te=(e,n={})=>{const t=n.isMac??ee();if(e.key==="Enter"&&e.shiftKey)return e.type==="keypress"?{kind:"send",bytes:S.shiftEnter}:{kind:"block"};if(!t||e.type!=="keydown")return{kind:"passthrough"};const o=e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey,r=e.altKey&&!e.metaKey&&!e.ctrlKey;if(o)switch(e.key){case"Backspace":return{kind:"send",bytes:S.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:S.lineStart};case"ArrowRight":return{kind:"send",bytes:S.lineEnd};case"k":case"K":return{kind:"clear"}}if(r)switch(e.key){case"Backspace":return{kind:"send",bytes:S.killWordBack};case"ArrowLeft":return{kind:"send",bytes:S.wordBack};case"ArrowRight":return{kind:"send",bytes:S.wordForward}}return{kind:"passthrough"}},K=(e,n={})=>{const t=new URL(e,window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:";for(const[o,r]of Object.entries(n))r!==void 0&&t.searchParams.set(o,String(r));return t.toString()},ne=({initialSize:e,onError:n,onExit:t,onOutput:o,onRestore:r,runId:l})=>{const s=crypto.randomUUID(),a={...e,clientId:s},d=new WebSocket(K(`/ws/terminal/${l}/io`,a)),c=new WebSocket(K(`/ws/terminal/${l}/control`,a));let g=!1;const u=[];let h=null;const b=()=>{!h||c.readyState!==c.OPEN||(c.send(JSON.stringify({type:"resize",...h})),h=null)};return d.onmessage=p=>{const w=typeof p.data=="string"?p.data:"",m=v=>{c.readyState===c.OPEN&&c.send(JSON.stringify({type:"output_ack",bytes:v}))};if(!g){u.push({chunk:w,acknowledge:m});return}o(w,m)},c.onopen=()=>{b()},c.onmessage=p=>{const w=JSON.parse(String(p.data));if(w.type==="exit"&&t(w.code),w.type==="error"&&n(w.message),w.type==="restore"){r(w.snapshot),g=!0,c.readyState===c.OPEN&&c.send(JSON.stringify({type:"restore_complete"}));for(const m of u.splice(0))o(m.chunk,m.acknowledge)}},{dispose(){d.close(),c.close()},resize(p,w,m,v){h={cols:p,rows:w},m!==void 0&&(h.pixelWidth=m),v!==void 0&&(h.pixelHeight=v),b()},sendBinaryInput(p){if(d.readyState!==d.OPEN)return;const w=new Uint8Array(p.length);for(let m=0;m<p.length;m++)w[m]=p.charCodeAt(m)&255;d.send(w)},sendInput(p){d.readyState===d.OPEN&&d.send(p)}}},re=16,oe=.3,se=(e,n)=>{const t=n==="up"?"A":"B";return e?`\x1BO${t}`:`\x1B[${t}`},ie=(e,n,t)=>n==="opencode"?t==="up"?"\x1B[5~":"\x1B[6~":se(e.modes?.applicationCursorKeysMode,t),ae=(e,n="default")=>{let t=0;return o=>{if(e.buffer?.active?.type!=="alternate")return t=0,{handled:!1,input:null};if(n!=="opencode"&&e.modes?.mouseTrackingMode&&e.modes.mouseTrackingMode!=="none")return t=0,{handled:!1,input:null};if(o.deltaY===0||o.shiftKey)return{handled:!1,input:null};let r=o.deltaY;return o.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=re,Math.abs(o.deltaY)<50&&(r*=oe),t+=r,r=Math.trunc(t),t%=1):t=0,r===0?{handled:!0,input:null}:{handled:!0,input:ie(e,n,r<0?"up":"down")}}},le=({element:e,profile:n="default",sendInput:t,terminal:o})=>{const r=ae(o,n),l=a=>{const{handled:d,input:c}=r(a);return d?(a.preventDefault(),a.stopPropagation(),c&&t(c),!1):!0};if(typeof o.attachCustomWheelEventHandler=="function")return o.attachCustomWheelEventHandler(l),()=>{};const s=a=>{l(a)||a.stopImmediatePropagation()};return e.addEventListener("wheel",s,{capture:!0,passive:!1}),()=>e.removeEventListener("wheel",s,{capture:!0})},ce=new RegExp("\x1B\\[M([\\s\\S])([\\s\\S])([\\s\\S])","g"),de=(e,n,t,o)=>{const r=n.charCodeAt(0)-32,l=t.charCodeAt(0)-32,s=o.charCodeAt(0)-32;if(r<0||l<1||s<1)return e;const d=(r&3)===3&&(r&32)===0&&(r&64)===0?"m":"M";return`\x1B[<${r};${l};${s}${d}`},ue=(e,n)=>{if(n!=="opencode")return{binary:!0,chunk:e};const t=e.replace(ce,de);return{binary:t===e,chunk:t}},fe=(e,n="default")=>{const t=E.useRef(null),[o,r]=E.useState(null),[l,s]=E.useState("connecting");return E.useEffect(()=>{if(!t.current)return;let a=!1,d,c,g,u,h,b,p,w,m,v,T=null,P,L;const O={current:!1};return Promise.all([R(()=>import("./xterm-B-qIQCd3.js"),[]),R(()=>import("./addon-fit-DX4qG4td.js"),[]),R(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),R(()=>import("./addon-clipboard-wHJhZAA4.js"),[])]).then(([$,j,U,Y])=>{if(a||!t.current)return;const W=typeof window<"u"?getComputedStyle(document.documentElement):null,q=W?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",J=W?.getPropertyValue("--text-primary").trim()||"#ebebeb",f=new $.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:q,foreground:J}}),M=new j.FitAddon;if(f.loadAddon(M),f.loadAddon(new U.Unicode11Addon),f.unicode.activeVersion="11",f.loadAddon(new Y.ClipboardAddon),f.open(t.current),M.fit(),b=f,p=M,v=le({element:t.current,profile:n,sendInput:i=>h?.sendInput(i),terminal:f}),T=t.current.querySelector(".xterm-helper-textarea"),T){const i=T;P=()=>{O.current=!0},L=y=>{const k=y.data;k&&h?.sendInput(k),i.value="",setTimeout(()=>{O.current=!1},0)},T.addEventListener("compositionstart",P,{capture:!0}),T.addEventListener("compositionend",L,{capture:!0})}typeof f.attachCustomKeyEventHandler=="function"&&f.attachCustomKeyEventHandler(i=>{const y=te(i);switch(y.kind){case"send":return i.preventDefault(),h?.sendInput(y.bytes),!1;case"clear":return i.preventDefault(),f.clear(),!1;case"block":return!1;case"passthrough":return!0}});const G=()=>{const i=t.current;return i?.isConnected?!i.closest('[data-terminal-host-parked="true"]'):!1},N=()=>{if(!t.current)return{};const i=t.current.clientWidth,y=t.current.clientHeight,k={};return y>0&&(k.pixelHeight=y),i>0&&(k.pixelWidth=i),k},I=()=>{if(!t.current||!G())return;p?.fit();const{pixelHeight:i,pixelWidth:y}=N();h?.resize(b?.cols??80,b?.rows??24,y,i)},H=()=>{m&&window.clearTimeout(m),m=window.setTimeout(()=>{m=void 0,I()},50)};R(()=>import("./addon-web-links-DIbG5aQx.js"),[]).then(i=>{a||b!==f||f.loadAddon(new i.WebLinksAddon)}).catch(()=>{}),R(()=>import("./addon-webgl-DCtw1yLn.js"),[]).then(i=>{if(!(a||b!==f))try{const y=new i.WebglAddon;y.onContextLoss(()=>y.dispose()),f.loadAddon(y),H()}catch{}}).catch(()=>{}),h=ne({initialSize:{cols:f.cols,rows:f.rows,...N()},onError(i){r(i)},onExit(){s("stopped")},onOutput(i,y){f.write(i,()=>y(new TextEncoder().encode(i).byteLength))},onRestore(i){f.write(i)},runId:e}),u=f.onData(i=>{O.current||h?.sendInput(i)}),typeof f.onBinary=="function"&&(g=f.onBinary(i=>{const y=ue(i,n);y.binary?h?.sendBinaryInput(y.chunk):h?.sendInput(y.chunk)})),s("running"),I(),typeof ResizeObserver<"u"&&t.current&&(w=new ResizeObserver(H),w.observe(t.current)),d=i=>{i.detail?.runId===e&&I()},c=()=>I(),window.addEventListener(z,d),window.addEventListener("resize",c)}),()=>{a=!0,d&&window.removeEventListener(z,d),c&&window.removeEventListener("resize",c),w?.disconnect(),m&&window.clearTimeout(m),v?.(),T&&P&&T.removeEventListener("compositionstart",P,{capture:!0}),T&&L&&T.removeEventListener("compositionend",L,{capture:!0}),g?.dispose(),u?.dispose(),h?.dispose(),b?.dispose(),p?.dispose()}},[e,n]),{containerRef:t,error:o,status:l}},pe={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},D="hive-terminal-parking-lot",me=500,he=e=>[`worker-pty-${e}`,`orch-pty-${e}`,`shell-pty-${e}`],ye=e=>{const n=Array.from(document.querySelectorAll("[data-pty-slot]")).filter(t=>t.id===e);return n[n.length-1]??null},we=()=>{let e=document.getElementById(D);return e||(e=document.createElement("div"),e.id=D,e.hidden=!0,e.style.display="none",(document.body??document.documentElement).appendChild(e)),e},B=()=>{const e=document.getElementById(D);e&&e.childElementCount===0&&e.remove()},C=new Set;let x,A;const V=()=>{for(const e of C)e()},Ee=()=>{x?.disconnect(),x=void 0,A!==void 0&&(window.clearInterval(A),A=void 0)},ge=()=>{if(x||A!==void 0)return;const e=document.body??document.documentElement;if(typeof MutationObserver<"u"&&e){x=new MutationObserver(V),x.observe(e,{attributeFilter:["data-pty-slot","id"],attributes:!0,childList:!0,subtree:!0});return}A=window.setInterval(V,100)},be=e=>(C.add(e),ge(),()=>{C.delete(e),C.size===0&&Ee()}),Te=[50,150,300],ve=e=>{const n=[],t=[],o=()=>window.dispatchEvent(Q(e)),r=(l,s)=>{const a=window.setTimeout(()=>{const d=t.indexOf(a);d>=0&&t.splice(d,1),s()},l);t.push(a)};if(typeof window.requestAnimationFrame=="function"){const l=window.requestAnimationFrame(()=>{o();const s=window.requestAnimationFrame(o);n.push(s)});n.push(l)}else r(0,o);for(const l of Te)r(l,o);return()=>{for(const l of n)window.cancelAnimationFrame?.(l);for(const l of t)window.clearTimeout(l);n.length=0,t.length=0}},Se=e=>{const[n,t]=E.useState(null);return E.useEffect(()=>{const o=he(e),r=()=>{for(const s of o){const a=ye(s);if(a)return a}return null},l=()=>{const s=r();t(a=>a===s?a:s)};return l(),be(l)},[e]),n},_e=(e,n)=>{const[t,o]=E.useState(!1),[r,l]=E.useState(null),s=E.useRef(void 0),a=E.useRef(null),d=E.useRef(void 0),c=E.useCallback(()=>{s.current!==void 0&&(window.clearTimeout(s.current),s.current=void 0)},[]),g=E.useCallback(()=>{d.current?.(),d.current=void 0},[]);return E.useLayoutEffect(()=>{const u=document.createElement("div");return u.dataset.terminalHostRunId=e,u.dataset.terminalHostParked="false",u.className="h-full min-h-0 w-full min-w-0",a.current=u,l(u),()=>{c(),g(),u.remove(),a.current=null,B()}},[c,g,e]),E.useLayoutEffect(()=>{if(n){c(),o(!0);return}if(!(!t||s.current!==void 0))return s.current=window.setTimeout(()=>{s.current=void 0,o(!1)},me),c},[t,c,n]),E.useLayoutEffect(()=>{const u=a.current;if(!u)return;if(!t){g(),u.remove(),u.dataset.terminalHostParked="false",B();return}const h=n??we();if(u.parentElement===h)return;const b=u.parentElement!==null,p=document.activeElement;n||g(),!n&&p instanceof HTMLElement&&u.contains(p)&&p.blur(),u.dataset.terminalHostParked=n?"false":"true",h.appendChild(u),B(),n&&b&&(g(),d.current=ve(e))},[t,g,e,n]),t?r:null},ke=({inputProfile:e="default",runId:n,title:t})=>{const o=Se(n),r=_e(n,o);return r?X.createPortal(_.jsx(Re,{inputProfile:e,runId:n,title:t}),r):null},Re=({inputProfile:e,runId:n,title:t})=>{const{t:o}=F(),{containerRef:r,error:l,status:s}=fe(n,e),a=pe[s];return _.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[_.jsx("p",{className:"sr-only",children:a?o(a):s}),l?_.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:l}):null,_.jsx("div",{"data-testid":`terminal-${n}`,ref:r,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},Ae=({hidden:e=!1,optimisticRuns:n=[],terminalRuns:t,workspaceId:o})=>{const{t:r}=F(),l=Z(t,n,o);return _.jsx("section",{hidden:e,"aria-hidden":e||void 0,"aria-label":r("terminalPanels.aria"),children:l.map(s=>_.jsx(ke,{inputProfile:s.terminal_input_profile??"default",runId:s.run_id,title:`${s.agent_name} (${s.status})`},s.run_id))})};export{Ae as WorkspaceTerminalPanels};
@@ -1 +1 @@
1
- import{c as o}from"./index-CWW5vUjQ.js";const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=o("chevron-right",t);export{e as C};
1
+ import{c as o}from"./index-Cn8X3get.js";const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=o("chevron-right",t);export{e as C};