@kabmo-labs/kabmo 0.39.0 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +270 -270
- package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-7synegzg.js} +1 -1
- package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-v5d9n5yw.js} +1 -1
- package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-ww7y98tt.js} +1 -1
- package/dist/client/static/js/{ImageView-nreh25s0.js → ImageView-t3rkypzs.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-0x1q1q5z.js → LayoutWrapper-th2pd4yt.js} +1 -1
- package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-qj39shgb.js} +1 -1
- package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-t9v4datp.js} +1 -1
- package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-yqy0a1xg.js} +1 -1
- package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-6zkxbjd4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-7rt2p1y1.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-b04e26rb.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-32ph2m52.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-hwnaa333.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-5v3rzdxd.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-7er2jwy1.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-yf61ftn0.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-cn3rs9xn.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-7kvtsj6c.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-g3zg3r5e.js} +1 -1
- package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-f9j396wm.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-227xs61z.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-4671gdym.js} +1 -1
- package/dist/client/static/js/{index-a7qccdq2.js → index-28a5kf88.js} +1 -1
- package/dist/client/static/js/{index-ymp2wqtc.js → index-35mh9kbs.js} +1 -1
- package/dist/client/static/js/{index-3fw3sd10.js → index-4c2zcvem.js} +7 -7
- package/dist/client/static/js/{index-jkph8wqq.js → index-4ry8kz8h.js} +1 -1
- package/dist/client/static/js/{index-v8vjh5jj.js → index-668chrpq.js} +1 -1
- package/dist/client/static/js/{index-8qgwj6m8.js → index-6rs8e8ng.js} +1 -1
- package/dist/client/static/js/{index-56w8m083.js → index-7qc2avfy.js} +1 -1
- package/dist/client/static/js/{index-5kvvb0zm.js → index-87qandgr.js} +1 -1
- package/dist/client/static/js/{index-ntx3bbmb.js → index-8xasfxf3.js} +1 -1
- package/dist/client/static/js/{index-gvkc9e32.js → index-d3prrt2q.js} +1 -1
- package/dist/client/static/js/{index-4pehdq5h.js → index-f1nqk6z6.js} +1 -1
- package/dist/client/static/js/{index-pzqsp5jw.js → index-f73v86a3.js} +1 -1
- package/dist/client/static/js/{index-270y5r9k.js → index-fjqp03xe.js} +1 -1
- package/dist/client/static/js/{index-mmsszqvn.js → index-fs3pbqwn.js} +1 -1
- package/dist/client/static/js/{index-xdqsqhnn.js → index-h8rr48px.js} +1 -1
- package/dist/client/static/js/{index-dmd26a1y.js → index-hdd8nqz8.js} +1 -1
- package/dist/client/static/js/{index-me7m3516.js → index-j2g39xq7.js} +1 -1
- package/dist/client/static/js/{index-dt22v9ns.js → index-jze0zg3z.js} +1 -1
- package/dist/client/static/js/{index-m3r0j562.js → index-kkfbd1db.js} +1 -1
- package/dist/client/static/js/{index-7h5n5rz4.js → index-m847wafq.js} +1 -1
- package/dist/client/static/js/{index-y2prm0xm.js → index-mtadrbxt.js} +1 -1
- package/dist/client/static/js/{index-7z63xr1s.js → index-phm1zb8m.js} +1 -1
- package/dist/client/static/js/{index-p89z1qmj.js → index-qbnd827h.js} +1 -1
- package/dist/client/static/js/{index-8w2tx2k9.js → index-s80x8d58.js} +1 -1
- package/dist/client/static/js/{index-ywpdhntc.js → index-tmnnafht.js} +1 -1
- package/dist/client/static/js/{index-hh05xd1d.js → index-vb3srfyc.js} +1 -1
- package/dist/client/static/js/{index-k61tdd4a.js → index-w0rbyw47.js} +1 -1
- package/dist/client/static/js/{index-5a4w58r2.js → index-w0xvdda9.js} +1 -1
- package/dist/client/static/js/{index-878d61js.js → index-wfcgqjzr.js} +1 -1
- package/dist/client/static/js/{index-pr7gk5eq.js → index-wgvysmnr.js} +1 -1
- package/dist/client/static/js/{index-mdxnhndy.js → index-xfr6r539.js} +1 -1
- package/dist/client/static/js/{index-k3c3n69j.js → index-xnk1500f.js} +2 -2
- package/dist/client/static/js/{index-61qjr1k0.js → index-y5ymgp20.js} +2 -2
- package/dist/client/static/js/{index-k5a6r25s.js → index-y91j4t1q.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +1 -1
- package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-0gafsqrm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +1 -1
- package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
- package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-66mn2qnt.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +1 -1
- package/dist/client/static/js/{rust-jatm47v6.js → rust-jvkbr060.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zk37paj9.js → swimlanesDiagram-TC7HE7FX-d48g5gjf.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/terminal/attach-replay.test.ts +80 -17
- package/src/server/plugins/static.test.ts +23 -1
- package/src/server/plugins/static.ts +24 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
- package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
- package/dist/client/static/js/one-light-czk9dzya.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d,n,o,W,i,u,a,le,e,w,Uf,we,Gr,Bp,s,E,ne,De,Be,ur,m,L,_,Xe,wt,f,B,ie,et,Nn,tt,Nt,on,nt,ge,xr,Ue,yo,Fn,xa,Y,D,O,Yn,b,rt,pe,J,st,he,Ht,Wt,It,ht,_t,fn,Wa,ea,Ks,GA,He,es,pm,Hu,hc,Ia,mm,To,Do,Qo,yt,fm,ts,ns,bc,jA,qA,gm,rs,No,Ro,Am,Fo,hm,HA,bm,WA,ym,vm,km,KA,xm,Ys,cn,yc,Js,wm,Ku,VA,vc,Vu,Cm}from"./index-3fw3sd10.js";import{ml,Ta,xd,ws}from"./index-7h5n5rz4.js";var Un={name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]},us=s(Un);var Gn={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]},Sa=s(Gn);var jn={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]},dt=s(jn);var Kn={name:"list-checks",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]},Qr=s(Kn);function ut({value:t,onInput:r,onSubmit:l,onRefresh:c,onNewFolder:p,loading:g,creating:h,resolved:x}){return e("div",{children:[e("div",{className:"flex items-center space-x-2",children:[e("form",{onSubmit:(v)=>{v.preventDefault(),l()},className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[e("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:e(ur,{size:14})}),e("input",{type:"text",value:t,onChange:(v)=>r(v.currentTarget.value),placeholder:"~/projects/my-project",spellcheck:!1,"aria-label":"Project path",className:"w-full px-3 py-2 outline-none text-sm bg-transparent font-mono"})]}),e("button",{type:"button",onClick:c,disabled:g,title:"Refresh folders","aria-label":"Refresh folders","aria-busy":g,className:"px-2.5 py-2 bg-ink/5 border border-ink/10 rounded text-ink/70 hover:bg-ink/10 hover:text-ink disabled:opacity-40 transition-colors flex-shrink-0",children:e(D,{size:13,className:g?"animate-spin":void 0})}),e("button",{type:"button",onClick:p,disabled:h||g||!x,title:"New folder here","aria-label":"New folder here","aria-busy":h,className:"px-2.5 py-2 bg-ink/5 border border-ink/10 rounded text-ink/70 hover:bg-ink/10 hover:text-ink disabled:opacity-40 transition-colors flex-shrink-0",children:h?e(m,{size:13,className:"animate-spin"}):e(on,{size:13})})]}),x&&x!==t.trim()&&e("p",{className:"mt-1 text-[10px] text-ink/40 font-mono truncate",children:["Listing: ",x]})]})}function pt({directories:t,loading:r,error:l,onOpen:c,onRetry:p,creating:g,name:h,onNameChange:x,onCreate:k,onCancelCreate:v,createError:y,creatingBusy:N}){return e("div",{className:"border border-ink/15 rounded overflow-hidden",children:[g&&e("form",{onSubmit:(T)=>{if(T.preventDefault(),h.trim())k(h.trim())},className:"flex items-center space-x-1.5 px-2 py-1.5 border-b border-ink/10 bg-ink/5",children:[e(nt,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:h,onChange:(T)=>x(T.currentTarget.value),placeholder:"new-folder-name","aria-label":"New folder name",spellcheck:!1,className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 outline-none focus:border-ink/50 text-xs"}),e("button",{type:"submit",disabled:N||!h.trim(),className:"px-2 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:bg-ink/90 disabled:opacity-40 transition-colors",children:N?"Creating…":"Create"}),e("button",{type:"button",onClick:v,"aria-label":"Cancel new folder",className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors",children:e(b,{size:12})})]}),g&&y&&e("p",{className:"px-2.5 py-1.5 text-[11px] text-error border-b border-ink/10",children:y}),e("div",{className:"max-h-52 overflow-y-auto scrollbar-overlay-container",children:r?e("div",{className:"flex items-center justify-center py-8 text-ink/40",children:e(m,{size:16,className:"animate-spin"})}):l?e("div",{className:"flex flex-col items-center justify-center py-6 px-3 text-xs text-error space-y-2",children:[e("span",{className:"text-center",children:l}),e("button",{type:"button",onClick:p,className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[e(D,{size:11})," ",e("span",{children:"Retry"})]})]}):t.length===0?e("div",{className:"text-center py-8 text-xs text-ink/40",children:"No subfolders"}):t.map((T)=>e("button",{type:"button",onClick:()=>c(T),title:T.path,className:"w-full flex items-center space-x-2 px-2.5 py-1.5 text-left hover:bg-ink/5 transition-colors group",children:[e(nt,{size:14,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-xs truncate text-ink/85 flex-1",children:T.name}),e(tt,{size:11,className:"text-ink/20 group-hover:text-ink/50 flex-shrink-0 transition-colors"})]},T.path))})]})}function mt(t){let r=t.trim();if(!r||/\s/.test(r))return!1;if(/^https?:\/\/\S+$/i.test(r))return!0;if(/^ssh:\/\/\S+$/i.test(r))return!0;if(/^git@[^:/\s]+:\S+$/.test(r))return!0;if(/^file:\/\/\S+$/i.test(r))return!0;if(r.startsWith("/")||r.startsWith("~"))return!0;if(/^[a-z]:[\\/]/i.test(r))return!0;if(/^\\\\[^\\]+\\/.test(r))return!0;return!1}function ft(t){let c=t.replace(/^[a-z]:/i,"").replace(/\\/g,"/").replace(/\/+$/,"").split(/[/:]/).filter(Boolean),p=c.length===0?"":c[c.length-1];if(p===""||/^[a-z]+:$/i.test(p)||/^https?:?$/i.test(p))return"";return p.replace(/\.git$/i,"").replace(/[^a-z0-9._-]/gi,"-")}function bt({parent:t,busy:r,onClone:l}){let[c,p]=n(""),g=c.trim(),h=mt(g),x=h?ft(g):"",k=()=>{if(h&&!r)l(g)};return e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Clone Git Repository"," ",e("span",{className:"text-ink/40 font-normal",children:"(optional: clones into the path above)"})]}),e("div",{className:"flex items-center space-x-2",children:[e("input",{type:"text",value:c,onChange:(v)=>p(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")v.preventDefault(),k()},disabled:r,placeholder:"https://github.com/org/repo.git",spellcheck:!1,"aria-label":"Git repository URL",className:"flex-1 bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm font-mono disabled:opacity-60"}),e("button",{type:"button",onClick:k,disabled:!h||r,title:h?`Clone into ${t}/${x}`:"Enter an https, ssh, git@ or local path","aria-label":"Clone repository",className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[r?e(m,{size:13,className:"animate-spin"}):e(xr,{size:13}),e("span",{children:r?"Cloning…":"Clone"})]})]}),h&&x&&!r&&e("p",{className:"mt-1 text-[10px] text-ink/40 font-mono truncate",children:["Creates workspace “",x.toLowerCase(),"” at ",t,"/",x]})]})}function gt(t){let[r,l]=n(t??""),[c,p]=n([]),[g,h]=n(null),[x,k]=n(!1),[v,y]=n(null),N=i(0),C=a(async(S)=>{let I=++N.current;k(!0),y(null);try{let P=await xd(S);if(I!==N.current)return;l(P.path??S??""),h(P.parentPath??null),p(P.directories??[])}catch(P){if(I!==N.current)return;y(P instanceof Error?P.message:String(P)),p([])}finally{if(I===N.current)k(!1)}},[]);o(()=>{C(t||void 0)},[C]);let T=a(()=>C(r||void 0),[C,r]);return{current:r,directories:c,parentPath:g,loading:x,error:v,navigate:C,refresh:T}}function pl({isOpen:t,onClose:r,onCreate:l,onClone:c}){if(!t)return null;return e(Xn,{onClose:r,onCreate:l,onClone:c})}function Xn({onClose:t,onCreate:r,onClone:l}){let[c,p]=n("create"),[g,h]=n(""),[x,k]=n(""),[v,y]=n(!1),[N,C]=n(null),[T,S]=n(!1),[I,P]=n(!1),[A,F]=n(""),[R,z]=n(null),[Q,te]=n(!1),G=gt(),oe=async(H)=>{te(!0),z(null);try{let K=await fetch("/api/folders/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:G.current,name:H})}),M=await K.json().catch(()=>({}));if(!K.ok||!M.success)throw Error(M.error||`HTTP ${K.status}`);P(!1),await G.refresh()}catch(K){z(K instanceof Error?K.message:String(K))}finally{te(!1)}},re=async()=>{if(!r)return t();if(!g.trim()&&!x.trim()){C("Enter a name or a project path.");return}y(!0),C(null);try{await r({name:g.trim(),path:x.trim()||void 0}),t()}catch(H){C(H instanceof Error?H.message:String(H)),y(!1)}},V=async(H)=>{if(!l)return t();if(!G.current){C("Enter the folder the repository should be cloned into.");return}y(!0),C(null);try{await l({url:H,parent:G.current,name:g.trim()||void 0}),t()}catch(K){C(K instanceof Error?K.message:String(K)),y(!1)}};return e("div",{className:"fixed inset-0 modal-scrim z-50 flex items-center justify-center p-4",children:[e("div",{className:"glass-overlay bg-paper border border-ink/10 rounded-lg shadow-xl w-[30rem] max-w-full max-h-full overflow-y-auto flex flex-col",children:[e("div",{className:"flex justify-between items-center px-4 pt-4 pb-2 border-b border-ink/10",children:[e("h3",{className:"font-semibold text-sm",children:"New Workspace"}),e("button",{type:"button",onClick:t,"aria-label":"Close",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/10 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex px-4 pt-2 space-x-1",children:["create","clone"].map((H)=>e("button",{type:"button",onClick:()=>{p(H),C(null)},"aria-pressed":c===H,className:`px-3 py-1.5 text-xs font-medium rounded-t transition-colors ${c===H?"text-ink border-b-2 border-ink":"text-ink/50 hover:text-ink"}`,children:H==="create"?"Create":"Clone"},H))}),e("div",{className:"px-4 py-3 space-y-3 text-sm text-ink/80",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Workspace Name"," ",e("span",{className:"text-ink/40 font-normal",children:c==="clone"?"(optional: defaults to the repository name)":""})]}),e("input",{type:"text",value:g,onChange:(H)=>h(H.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:[c==="clone"?"Clone Into":"Project Path"," ",e("span",{className:"text-ink/40 font-normal",children:c==="create"?"(optional: binds omp sessions)":""})]}),e(ut,{value:x,onInput:k,onSubmit:()=>void G.navigate(x.trim()||void 0),onRefresh:()=>void G.refresh(),onNewFolder:()=>{F(""),P(!0),z(null)},loading:G.loading,creating:Q,resolved:G.current})]}),e(pt,{directories:G.directories,loading:G.loading,error:G.error,onOpen:(H)=>{k(H.path),G.navigate(H.path)},onRetry:()=>void G.refresh(),creating:I,name:A,onNameChange:F,onCreate:(H)=>void oe(H),onCancelCreate:()=>{P(!1),F(""),z(null)},createError:R,creatingBusy:Q}),e("div",{className:"flex items-center justify-between",children:[e("button",{type:"button",onClick:()=>S(!0),className:"px-3 py-1.5 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5",children:[e(Nt,{size:13}),e("span",{children:"Browse…"})]}),G.parentPath&&e("button",{type:"button",onClick:()=>void G.navigate(G.parentPath??void 0),className:"text-[11px] text-ink/50 hover:text-ink transition-colors",children:"↑ Up one level"})]}),c==="clone"&&e(bt,{parent:G.current,busy:v,onClone:(H)=>void V(H)}),N&&e("div",{className:"text-xs text-error",children:N})]}),e("div",{className:"px-4 py-3 border-t border-ink/10 flex justify-end space-x-2",children:[e("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:t,disabled:v,children:"Cancel"}),c==="create"&&e("button",{type:"button",className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:()=>void re(),disabled:v,children:v?"Creating…":"Create Workspace"})]})]}),T&&e(ws,{initialPath:x||void 0,onSelect:(H)=>{if(k(H),S(!1),!g.trim()){let K=H.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";if(K)h(K)}G.navigate(H)},onClose:()=>S(!1)})]})}async function Zn(t){let r=await t.json().catch(()=>null);if(!t.ok||!r||r.error)return null;return{tasks:r.tasks??[],serverTimeZone:r.serverTimeZone??""}}function xt(t){let[r,l]=n([]),[c,p]=n(""),[g,h]=n(!1),[x,k]=n(null),v=a(async()=>{h(!0);try{let A=await Zn(await fetch("/api/schedule"));if(A){if(l(A.tasks),A.serverTimeZone)p(A.serverTimeZone);k(null)}else k("Could not load scheduled tasks.")}catch(A){k(A instanceof Error?A.message:String(A))}finally{h(!1)}},[]),y=we(Uf,{enabled:t});o(()=>{if(!y.data)return;if(l(y.data.tasks),y.data.serverTimeZone)p(y.data.serverTimeZone);h(!1),k(null)},[y.data]);let N=a(async(A,F)=>{try{let R=await fetch(A,F),z=await R.json().catch(()=>null);if(!R.ok||!z||z.error){let Q=z?.error??`HTTP ${R.status}`;return k(Q),Q}if(z.tasks)l(z.tasks);return k(null),null}catch(R){let z=R instanceof Error?R.message:String(R);return k(z),z}},[]),C=a(async(A)=>await N("/api/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),[N]),T=a(async(A,F)=>N(`/api/schedule?id=${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),[N]),S=a(async(A)=>N(`/api/schedule?id=${encodeURIComponent(A)}`,{method:"DELETE"}),[N]),I=a(async(A)=>await N(`/api/schedule?id=${encodeURIComponent(A)}&run=now`,{method:"POST"}),[N]),P=a(async(A)=>{try{let F=await fetch(`/api/schedule/${encodeURIComponent(A)}/runs`),R=await F.json().catch(()=>null);return F.ok?R?.runs??[]:[]}catch{return[]}},[]);return{tasks:r,serverTimeZone:c,loading:g,error:x,refresh:v,create:C,patch:T,remove:S,runNow:I,loadRuns:P}}function Xc(){let t=we(Uf);return u(()=>(t.data?.tasks??[]).filter((r)=>r.enabled).length,[t.data])}var kt=new Map;function vt(t){let r=kt.get(t);if(!r)r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),kt.set(t,r);return r}function Tt(t){if(!t)return!1;try{return vt(t),!0}catch{return!1}}function Ct(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function Ae(t,r){let l=vt(r).formatToParts(new Date(t)),c=(p)=>{let g=l.find((h)=>h.type===p);return g?Number(g.value):0};return{year:c("year"),month:c("month"),day:c("day"),hour:c("hour"),minute:c("minute"),second:c("second")}}function St(t,r){let l=Ae(t,r);return Date.UTC(l.year,l.month-1,l.day,l.hour,l.minute,l.second)-Math.floor(t/1000)*1000}function Ye(t,r,l,c,p,g){let h=Date.UTC(t,r-1,l,c,p),x=St(h,g),k=h-x,v=St(k,g);if(v!==x)k=h-v;let y=Ae(k,g);if(y.year!==t||y.month!==r||y.day!==l||y.hour!==c||y.minute!==p)return null;return k}var qn=60000,Vn={s:1000,sec:1000,secs:1000,second:1000,seconds:1000,m:60000,min:60000,mins:60000,minute:60000,minutes:60000,h:3600000,hr:3600000,hrs:3600000,hour:3600000,hours:3600000,d:86400000,day:86400000,days:86400000,w:604800000,week:604800000,weeks:604800000};function Ot(t){let r=t.trim().toLowerCase();if(!r)return null;if(/^\d+(\.\d+)?$/.test(r)){let g=Number(r);return g>0?Math.round(g*60000):null}let l=r.match(/(\d+(?:\.\d+)?)\s*([a-z]+)/g);if(!l)return null;if(l.join("").replace(/\s+/g,"").length!==r.replace(/\s+/g,"").length)return null;let p=0;for(let g of l){let h=g.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)$/);if(!h)return null;let x=Vn[h[2]];if(!x)return null;p+=Number(h[1])*x}return p>0?Math.round(p):null}var Jn=[[0,59],[0,23],[1,31],[1,12],[0,7]];function Qn(t,r,l){let c=new Set;for(let p of t.split(",")){let[g,h]=p.split("/"),x=h===void 0?1:Number(h);if(!Number.isInteger(x)||x<1)return null;let k,v;if(g==="*")k=r,v=l;else if(g.includes("-")){let[y,N]=g.split("-");k=Number(y),v=Number(N)}else k=Number(g),v=h===void 0?k:l;if(!Number.isInteger(k)||!Number.isInteger(v))return null;if(k<r||v>l||k>v)return null;for(let y=k;y<=v;y+=x)c.add(y)}return c.size?[...c].sort((p,g)=>p-g):null}function eo(t){let r=t.trim().split(/\s+/);if(r.length!==5)return null;let l=r.map((k,v)=>{let[y,N]=Jn[v];return Qn(k,y,N)});if(l.some((k)=>k===null))return null;let[c,p,g,h,x]=l;return{minutes:c,hours:p,daysOfMonth:g,months:h,daysOfWeek:[...new Set(x.map((k)=>k===7?0:k))].sort((k,v)=>k-v),domRestricted:r[2].trim()!=="*",dowRestricted:r[4].trim()!=="*"}}function to(t,r,l,c){let p=new Date(Date.UTC(r,l-1,c)).getUTCDay(),g=t.daysOfMonth.includes(c),h=t.daysOfWeek.includes(p);if(t.domRestricted&&t.dowRestricted)return g||h;if(t.domRestricted)return g;if(t.dowRestricted)return h;return!0}function no(t,r,l){let c=l&&Tt(l)?l:Ct(),p=Ae(r.getTime(),c),g=Date.UTC(p.year+8,p.month-1,p.day);for(let h=Date.UTC(p.year,p.month-1,p.day);h<=g;){let x=new Date(h),k=x.getUTCFullYear(),v=x.getUTCMonth()+1,y=x.getUTCDate();if(!t.months.includes(v)){h=Date.UTC(k,v,1);continue}if(to(t,k,v,y))for(let N of t.hours)for(let C of t.minutes){let T=Ye(k,v,y,N,C,c);if(T!==null&&T>r.getTime())return T}h=Date.UTC(k,v-1,y+1)}return null}var oo=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function Pt(t,r){let l=t.trim();if(!l)return null;if(/^\d+$/.test(l)){let p=Number(l);return p>0?p:null}if(r){let p=l.match(oo);if(p){let[,g,h,x,k,v,y,N]=p,C=Ye(Number(g),Number(h),Number(x),Number(k),Number(v),r);if(C===null)return null;let T=(y?Number(y)*1000:0)+(N?Number(N.padEnd(3,"0")):0);return C+T}}let c=Date.parse(l);return Number.isNaN(c)?null:c}function Rt(t,r,l=Date.now(),c){if(!r.trim())return{ok:!1,error:"Enter a schedule."};if(t==="once"){let h=Pt(r,c);if(h===null)return{ok:!1,error:"Use an ISO timestamp, e.g. 2026-10-01T09:00."};if(h<=l)return{ok:!1,error:"That time is already in the past."};return{ok:!0,nextRunAt:h}}if(t==="every"){let h=Ot(r);if(h===null)return{ok:!1,error:"Use a duration, e.g. 30m, 1h30m, 2 days."};if(h<qn)return{ok:!1,error:"The shortest interval is 1 minute."};return{ok:!0,nextRunAt:l+h}}let p=eo(r);if(!p)return{ok:!1,error:"Use 5 fields: minute hour day-of-month month day-of-week."};let g=no(p,new Date(l),c);if(g===null)return{ok:!1,error:"That expression never matches a date."};return{ok:!0,nextRunAt:g}}function At(t,r,l){let c=r.trim();if(t==="once"){let p=Pt(c,l);return p===null?c:`Once at ${new Date(p).toLocaleString(void 0,l?{timeZone:l}:void 0)}`}if(t==="every"){let p=Ot(c);return p===null?c:`Every ${qe(p)}`}return`Cron ${c}`}function qe(t){let r=Math.round(t/1000),l=Math.floor(r/86400),c=Math.floor(r%86400/3600),p=Math.floor(r%3600/60),g=r%60,h=[];if(l)h.push(`${l}d`);if(c)h.push(`${c}h`);if(p)h.push(`${p}m`);if(g&&!l)h.push(`${g}s`);return h.length?h.join(" "):"0s"}var ro={"always-ask":"Ask before writes",write:"Auto-write, ask before exec",yolo:"Auto-run everything"};function Ve(t){return`${t.provider}/${t.id}`}function so(t){if(!Array.isArray(t))return[];let r=[];for(let l of t){if(!l||typeof l!=="object")continue;if(!("id"in l)||typeof l.id!=="string")continue;if(!("name"in l)||typeof l.name!=="string")continue;if(!("provider"in l)||typeof l.provider!=="string")continue;let c="thinkingLevels"in l&&Array.isArray(l.thinkingLevels)?l.thinkingLevels.filter((p)=>typeof p==="string"):void 0;r.push({id:l.id,name:l.name,provider:l.provider,...c?{thinkingLevels:c}:{}})}return r}function Dt({harness:t,model:r,onHarnessChange:l,onModelChange:c}){let{harnesses:p}=fn(),g=Wa((S)=>{let I=Array.isArray(S.modelList)&&S.modelList.length>0?S.modelList:S.models;return so(I)}),h=es(p,t,g??[]),x=h.models,k=r?x.find((S)=>S.provider===r.provider&&S.id===r.modelId):void 0,v=hc(k?.thinkingLevels),y=pm(p,t),N=(S)=>{if(!S){c(null);return}let I=x.find((P)=>Ve(P)===S);if(!I)return;c({provider:I.provider,modelId:I.id,thinkingLevel:"auto",accessMode:r?.accessMode??"always-ask"})},C=(S)=>{if(!r)return;c({...r,thinkingLevel:S})},T=(S)=>{if(!r)return;c({...r,accessMode:S})};return e("div",{className:"space-y-2",children:[e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Harness"}),e("select",{value:t,onChange:(S)=>l(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[!y.some((S)=>S.id===t)&&e("option",{value:t,children:t}),y.map((S)=>e("option",{value:S.id,children:S.label},S.id))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Model"}),e("select",{value:r?`${r.provider}/${r.modelId}`:"",onChange:(S)=>N(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:t==="omp-rpc"?"Default (composer selection)":"Harness default"}),r&&!x.some((S)=>S.provider===r.provider&&S.id===r.modelId)&&e("option",{value:`${r.provider}/${r.modelId}`,children:[r.provider,"/",r.modelId]}),x.map((S)=>e("option",{value:Ve(S),children:[S.name," · ",S.provider]},Ve(S)))]})]})]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Thinking"}),e("select",{value:r?.thinkingLevel??"auto",disabled:!r||v.length===0,onChange:(S)=>C(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:[e("option",{value:"auto",children:"Auto"}),r&&r.thinkingLevel!=="auto"&&!v.includes(r.thinkingLevel)&&e("option",{value:r.thinkingLevel,children:r.thinkingLevel}),v.map((S)=>e("option",{value:S,children:S},S))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Access"}),e("select",{value:r?.accessMode??"always-ask",disabled:!r,onChange:(S)=>T(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:Hu.map((S)=>e("option",{value:S,children:ro[S]},S))})]})]}),h.blocked&&e("p",{className:"text-[11px] text-error",children:h.blocked}),h.unprobed&&e("p",{className:"text-[11px] text-ink/40",children:"This harness has not been probed yet; its models appear after a status check."})]})}var Et={once:"Once",every:"Every",cron:"Cron"},io={once:"An ISO timestamp, e.g. 2026-10-01T09:00",every:"A duration, e.g. 30m, 1h30m, 2 days",cron:"5 fields: minute hour day-of-month month day-of-week"},ao={once:"2026-10-01T09:00",every:"1h30m",cron:"0 9 * * 1-5"};function lo(t){let r=t-Date.now();if(r<=0)return"due now";let l=Math.round(r/60000);if(l<60)return`in ${l}m`;let c=Math.round(l/60);if(c<24)return`in ${c}h`;return`in ${Math.round(c/24)}d`}var Ee=null;function co(){if(Ee)return Ee;let t=Intl,r=[];try{r=t.supportedValuesOf?.("timeZone")??[]}catch{r=[]}return Ee=r.length?r:["UTC"],Ee}function uo(t){let r=co();return t&&!r.includes(t)?[t,...r]:r}function Bt({folders:t,initial:r,activeSessionId:l,serverTimeZone:c,busy:p,onSubmit:g,onCancel:h}){let[x,k]=n(""),[v,y]=n(""),[N,C]=n("every"),[T,S]=n("1h"),[I,P]=n("omp-rpc"),[A,F]=n(null),R=c||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",[z,Q]=n(R),[te,G]=n(null),[oe,re]=n(!1);o(()=>{k(r?.name??""),y(r?.prompt??""),C(r?.kind??"every"),S(r?.spec??"1h"),P(r?.harness??"omp-rpc"),F(r?.model??null),Q(r?.timezone??R),G(r?.folderId??null),re(Boolean(r?.sessionId))},[r?.id,R]);let V=Rt(N,T,Date.now(),z),H=Boolean(v.trim())&&V.ok&&!p,K=()=>{if(!H||!V.ok)return;g({name:x.trim(),prompt:v.trim(),kind:N,spec:T.trim(),harness:I,timezone:z,folderId:te,sessionId:oe?r?.sessionId??l:null,model:A})};return e("div",{className:"space-y-3 text-xs",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:["Name ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("input",{type:"text",value:x,onInput:(M)=>k(M.currentTarget.value),placeholder:"Morning standup digest",className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs"})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Prompt"}),e("textarea",{value:v,onInput:(M)=>y(M.currentTarget.value),placeholder:"Describe the task, ask a question, or paste commands…",rows:4,className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs resize-y min-h-[80px]"})]}),e("div",{className:"flex items-end gap-2",children:[e("div",{className:"w-28 flex-shrink-0",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Schedule"}),e("select",{value:N,onChange:(M)=>C(M.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:Object.keys(Et).map((M)=>e("option",{value:M,children:Et[M]},M))})]}),e("div",{className:"flex-1",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"When"}),e("input",{type:"text",value:T,onInput:(M)=>S(M.currentTarget.value),placeholder:ao[N],className:`w-full bg-paper border rounded px-2.5 py-1.5 outline-none text-xs font-mono ${V.ok?"border-ink/20 focus:border-ink/50":"border-error/50 focus:border-error"}`})]})]}),e("p",{className:`text-[11px] ${V.ok?"text-ink/50":"text-error"}`,children:V.ok?`Next run ${lo(V.nextRunAt)} · ${new Date(V.nextRunAt).toLocaleString(void 0,{timeZone:z})} · ${z}`:V.error}),e("p",{className:"text-[11px] text-ink/40",children:io[N]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Timezone"}),e("select",{value:z,onChange:(M)=>Q(M.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:uo(z).map((M)=>e("option",{value:M,children:M},M))})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Run in"}),e("select",{value:te===null?"":String(te),onChange:(M)=>G(M.currentTarget.value?Number(M.currentTarget.value):null),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:"Server default directory"}),t.map((M)=>e("option",{value:M.id,children:M.name},M.id))]})]})]}),e(Dt,{harness:I,model:A,onHarnessChange:(M)=>{P(M),F(null)},onModelChange:F}),e("label",{className:`flex items-center gap-2 text-[11px] ${l?"text-ink/70":"text-ink/35"}`,children:[e("input",{type:"checkbox",checked:oe,disabled:!l,onChange:(M)=>re(M.currentTarget.checked),className:`${he} accent-ink`}),e("span",{children:"Resume the open session each run"})]}),e("div",{className:"flex justify-end gap-2 pt-1",children:[e("button",{type:"button",onClick:h,disabled:p,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),e("button",{type:"button",onClick:K,disabled:!H,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-40",children:[p&&e(m,{size:12,className:"animate-spin"}),r?"Save changes":"Schedule task"]})]})]})}function po(t){return t===null?"–":new Date(t).toLocaleString()}function mo(t){if(t.name)return t.name;let r=t.prompt.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,57)}…`:r||"(empty prompt)"}function Ft({tasks:t,loading:r,pending:l,onRunNow:c,onToggleEnabled:p,onEdit:g,onDelete:h,loadRuns:x}){let[k,v]=n(null),[y,N]=n([]),[C,T]=n(!1);if(o(()=>{if(!k)return;let S=!0;return T(!0),x(k).then((I)=>{if(!S)return;N(I),T(!1)}),()=>{S=!1}},[k,x]),t.length===0)return e("div",{className:"px-3 py-8 text-center text-[11px] text-ink/50 border border-dashed border-ink/15 rounded-lg",children:r?"Loading…":"No scheduled tasks yet. Create one above."});return e("ul",{className:"space-y-2",children:t.map((S)=>{let I=l===S.id,P=k===S.id;return e("li",{className:"border border-ink/10 rounded-lg bg-paper",children:[e("div",{className:"flex items-start gap-2 p-2.5",children:[e("span",{className:"mt-0.5 shrink-0","aria-hidden":"true",children:!S.enabled?e(yo,{size:14,className:"text-ink/40"}):S.lastStatus==="error"?e(E,{size:14,className:"text-error"}):S.lastStatus==="success"?e(ne,{size:14,className:"text-ink/60"}):e(Nn,{size:14,className:"text-ink/60"})}),e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"text-xs font-medium text-ink truncate",children:mo(S)}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:[At(S.kind,S.spec,S.timezone),S.kind!=="every"&&e(d,{children:[e("span",{className:"text-ink/30",children:" · "}),S.timezone]}),e("span",{className:"text-ink/30",children:" · "}),!S.enabled?S.kind==="once"&&S.lastRunAt!==null?"Ran once, with no next run":"Paused":`Next ${po(S.nextRunAt)}`]}),S.cwd&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:S.cwd}),e("p",{className:"text-[10.5px] text-ink/40 truncate mt-0.5",children:[S.harness,S.model&&` · ${S.model.provider}/${S.model.modelId}`]}),S.sessionId&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:["resumes ",S.sessionId.slice(0,8)]}),S.lastStatus==="error"&&S.lastError&&e("p",{className:"text-[10.5px] text-error mt-0.5 break-words",children:S.lastError}),S.runCount>0&&e("p",{className:"text-[10.5px] text-ink/40 mt-0.5",children:["Fired ",S.runCount,"×"]})]}),e("div",{className:"flex items-center gap-1 shrink-0",children:[e("button",{type:"button",title:"Run now","aria-label":"Run now",disabled:I,onClick:()=>c(S.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:I?e(m,{size:13,className:"animate-spin"}):e(xa,{size:13})}),e("button",{type:"button",title:S.enabled?"Pause":"Resume","aria-label":S.enabled?"Pause":"Resume","aria-pressed":S.enabled,disabled:I,onClick:()=>p(S),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:S.enabled?e(yo,{size:13}):e(xa,{size:13})}),e("button",{type:"button",title:"Edit","aria-label":"Edit",disabled:I,onClick:()=>g(S),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:e(Fn,{size:13})}),e("button",{type:"button",title:"Delete","aria-label":"Delete",disabled:I,onClick:()=>h(S.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-error transition-colors disabled:opacity-40",children:e(L,{size:13})})]})]}),e("button",{type:"button",onClick:()=>v(P?null:S.id),"aria-expanded":P,className:"w-full text-left px-2.5 py-1.5 border-t border-ink/5 text-[10.5px] text-ink/50 hover:text-ink transition-colors",children:P?"Hide run history":"Run history"}),P&&e("div",{className:"px-2.5 pb-2.5 space-y-1",children:[C&&e("p",{className:"text-[10.5px] text-ink/40",children:"Loading…"}),!C&&y.length===0&&e("p",{className:"text-[10.5px] text-ink/40",children:"This task has not run yet."}),!C&&y.map((A)=>e("div",{className:"flex items-start gap-2 text-[10.5px]",children:[e("span",{className:"w-16 shrink-0 text-ink/50",children:new Date(A.startedAt).toLocaleTimeString()}),e("span",{className:`w-14 shrink-0 font-medium ${A.status==="error"?"text-error":A.status==="running"?"text-ink/60":"text-ink/70"}`,children:A.status}),e("span",{className:"w-12 shrink-0 text-ink/40",children:A.finishedAt===null?"…":qe(A.finishedAt-A.startedAt)}),e("span",{className:"min-w-0 flex-1 text-ink/60 break-words",children:[A.detail||"–",A.sessionId&&e("span",{className:"block font-mono text-[10px] text-ink/40",children:["session ",A.sessionId.slice(0,8)]})]})]},A.id))]})]},S.id)})})}function Lt(){let[t,r]=n([]);return o(()=>{let l=!0;return fetch("/api/settings/projects").then((c)=>c.json()).then((c)=>{if(!l)return;r((c.projects??[]).filter((p)=>typeof p.folderId==="number").map((p)=>({id:p.folderId,name:p.name})))}).catch((c)=>console.error("Failed to load workspace folders:",c)),()=>{l=!1}},[]),t}function eu({isOpen:t,onClose:r,activeSessionId:l=null,onToast:c}){let p=xt(t),g=Lt(),[h,x]=n(null),[k,v]=n(!1),[y,N]=n(!1),[C,T]=n(null);if(o(()=>{if(t)return;x(null),v(!1),N(!1),T(null)},[t]),o(()=>{let R=(z)=>{if(z.key!=="Escape"||y)return;if(z.preventDefault(),h||k){x(null),v(!1);return}r()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,y,h,k]),!t)return null;let S=async(R)=>{N(!0);let z=h?await p.patch(h.id,R):await p.create(R);if(N(!1),z){c?.(z,"error");return}c?.(h?"Scheduled task updated.":"Scheduled task created.","success"),x(null),v(!1)},I=async(R)=>{T(R.id);let z=await p.patch(R.id,{enabled:!R.enabled});if(T(null),z)c?.(z,"error")},P=async(R)=>{T(R);let z=await p.runNow(R);if(T(null),z){c?.(z,"error");return}c?.("Task dispatched. Open the session to watch it run.","success")},A=async(R)=>{T(R);let z=await p.remove(R);if(T(null),z){c?.(z,"error");return}if(h?.id===R)x(null)},F=h!==null||k;return e("div",{className:"fixed inset-0 modal-scrim backdrop-blur-[2px] z-50 flex items-center justify-center p-4",onClick:y?void 0:r,role:"dialog","aria-modal":"true","aria-label":"Scheduled tasks",children:e("div",{className:"glass-overlay bg-paper border border-ink/15 rounded-xl shadow-2xl w-[min(94vw,640px)] max-h-[88vh] flex flex-col overflow-hidden text-ink",onClick:(R)=>R.stopPropagation(),children:[e("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[e("div",{className:"flex items-center gap-2",children:[e(Sa,{size:15}),e("h3",{className:"font-semibold text-sm",children:"Scheduled Tasks"})]}),e("button",{type:"button",onClick:r,"aria-label":"Close",className:"p-1.5 -m-1.5 rounded text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors",children:e(b,{size:16})})]}),e("div",{className:"p-4 overflow-y-auto space-y-4",children:[p.error&&!F&&e("p",{className:"text-[11px] text-error border border-error/30 bg-error/5 rounded px-2.5 py-1.5",children:p.error}),F?e(Bt,{folders:g,initial:h,activeSessionId:l,serverTimeZone:p.serverTimeZone,busy:y,onSubmit:S,onCancel:()=>{x(null),v(!1)}}):e("button",{type:"button",onClick:()=>v(!0),className:"w-full py-2 rounded-lg border border-dashed border-ink/20 text-xs font-medium text-ink/70 hover:text-ink hover:border-ink/40 transition-colors",children:"+ New scheduled task"}),!F&&e(Ft,{tasks:p.tasks,loading:p.loading,pending:C,onRunNow:P,onToggleEnabled:I,onEdit:(R)=>x({id:R.id,name:R.name,prompt:R.prompt,kind:R.kind,spec:R.spec,harness:R.harness,timezone:R.timezone,folderId:R.folderId,sessionId:R.sessionId,model:R.model}),onDelete:A,loadRuns:p.loadRuns})]})]})})}var Je=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],Mt={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function $o({variant:t,sortOption:r,onSortChange:l}){if(t==="mobile")return e(d,{children:[e("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),Je.map((c)=>e("button",{type:"button",onClick:()=>l(c),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${r===c?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[e("span",{children:c.replace("_"," ")}),r===c&&e(f,{size:13,className:"text-ink"})]},c))]});return e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),Je.map((c)=>e("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${r===c?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(c),children:[e("span",{children:Mt[c]}),r===c&&e("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},c))]})}function tu({actions:t,sortHidden:r,sortOption:l,onSortChange:c,layout:p="desktop"}){let g=p==="mobile",[h,x]=n(!1),k=i(null);pe(k,()=>x(!1)),o(()=>{if(!h)return;let y=(N)=>{if(N.key==="Escape")x(!1)};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[h]);let v=(y)=>{x(!1),y.onSelect()};return e("div",{className:"relative shrink-0",ref:k,children:[e("button",{type:"button",title:"More sidebar actions","aria-label":"More sidebar actions","aria-haspopup":"menu","aria-expanded":h,onClick:()=>x(!h),className:`inline-flex items-center justify-center transition-colors cursor-pointer ${g?"w-9.5 h-9.5 rounded-xl border active:scale-95 shadow-xs":"w-7 h-7 rounded border"} ${h?"border-ink/30 bg-ink/10 text-ink":"border-ink/15 bg-paper text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e(Be,{size:g?16:14})}),h&&e("div",{role:"menu",className:`glass-popover absolute right-0 top-full mt-2 w-52 bg-paper border border-ink/15 shadow-lg z-50 py-1 text-xs ${g?"rounded-xl p-2":"rounded-lg"}`,children:[t.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>v(y),"aria-pressed":y.active,className:`w-full text-left flex items-center gap-2 transition-colors ${g?"px-2.5 py-1.5 rounded-lg":"px-3 py-1.5"} ${y.active?"bg-ink/5 text-ink font-medium":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e(y.icon,{size:13}),e("span",{children:y.label})]},y.id)),r&&e("div",{className:"mt-1 border-t border-ink/10 pt-1",children:e($o,{variant:p,sortOption:l,onSortChange:c})})]})]})}function ds(t){let r=i(null),[l,c]=n(0);return W(()=>{let p=r.current;if(!p)return;let g=()=>c(Math.max(0,p.clientWidth-t));if(g(),typeof ResizeObserver>"u")return;let h=new ResizeObserver(g);return h.observe(p),()=>h.disconnect()},[t]),{ref:r,width:l}}var yd=["new-workspace","refresh","search","select","archive","scheduler","sort"];var mg=8;function fg(t){let r=yd.length;if(!(t>0))return r;let l=t-112-6-8;if(r*28+(r-1)*6<=l)return r;let p=Math.floor((l-28-8)/34);return Math.max(2,Math.min(r,p))}var fo=38,ho=8,bo=126,go=1,vd=["new-workspace","refresh","archive","sort","scheduler","select"];function gg(t){let r=vd.length;if(!(t>0))return r;let l=fo+ho,c=Math.floor((t-bo)/l);if(c>=r)return r;return Math.max(go,Math.min(r,c-1))}function ps(t=5,r=7){let[l,c]=n(t),p=a(()=>c((h)=>h+r),[r]),g=a(()=>c(t),[t]);return{visibleCount:l,showMore:p,showLess:g,canShowLess:l>t}}function ms(t,r,l){let[c,p]=n(!1),g=st(),h=st(),{handleArchive:x,handleRename:k,handleRenameWithAi:v}=mm(r,l),y=()=>{if(typeof t.id!=="number")return;g.submit({isPinned:String(!t.isPinned)},{method:"POST",action:`/api/folders/${t.id}/pin`}),r()},N=()=>{if(typeof t.id!=="number")return;h.submit({},{method:"POST",action:`/api/folders/${t.id}/delete`}),p(!1),r()},C=t.project_path?()=>{(async()=>{try{let T=await fetch(`/api/folders/${encodeURIComponent(String(t.id))}/open`,{method:"POST"}),S=await T.json().catch(()=>({}));if(!T.ok)l?.(S.error||`Could not open the folder (HTTP ${T.status})`)}catch(T){l?.(T instanceof Error?T.message:String(T))}})()}:void 0;return{confirmDelete:c,requestDelete:()=>p(!0),cancelDelete:()=>p(!1),handlePin:y,handleOpenFolder:C,handleDelete:N,handleArchive:x,handleRename:k,handleRenameWithAi:v}}function Nr({checked:t,indeterminate:r=!1,label:l,onChange:c,size:p="sm"}){let g=i(null);return o(()=>{if(g.current)g.current.indeterminate=r},[r]),e("input",{ref:g,type:"checkbox",checked:t,"aria-label":l,onChange:c,onClick:(h)=>h.stopPropagation(),className:`${he} shrink-0 accent-ink cursor-pointer ${p==="md"?"w-3.5 h-3.5":"w-3 h-3"}`})}function xo(t){let r=t.branch||(t.detached?"detached":"worktree");return t.status==="missing"?`${r} · ${"missing"}`:r}function ko(t){if(t.status==="missing")return`Worktree folder is missing: ${t.path}`;return t.detached?`Detached HEAD in worktree ${t.path}`:`Runs in worktree ${t.path}`}function fs({worktree:t}){let r=t.status==="missing";return e("span",{className:`flex min-w-0 items-center gap-1 truncate text-[10px] font-normal ${r?"text-warning":"text-ink/45"}`,title:ko(t),"data-worktree-status":t.status,children:[e("span",{"aria-hidden":"true",className:"shrink-0 font-mono",children:"⑂"}),e("span",{className:"truncate",children:xo(t)})]})}var So=1000,Fe=new Set,Oe=null;function vo(){let t=Date.now();for(let r of Fe)r(t)}function wo(t){if(Fe.add(t),Oe===null)Oe=setInterval(vo,So);return()=>{if(Fe.delete(t),Fe.size===0&&Oe!==null)clearInterval(Oe),Oe=null}}function $t(t=!0){let[r,l]=n(()=>Date.now());return o(()=>{if(!t)return;return wo(l)},[t]),r}function gs(t,r=Date.now()){if(t===null||t===void 0||t==="")return null;let l=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(l))return null;let c=Math.round((r-l)/1000);if(c<45)return"now";let p=Math.round(c/60);if(p<60)return`${p}m`;let g=Math.round(p/60);if(g<24)return`${g}h`;let h=Math.round(g/24);if(h<7)return`${h}d`;let x=Math.round(h/7);if(x<5)return`${x}w`;let k=new Date(l),v=k.getFullYear()===new Date(r).getFullYear(),y=k.getDate(),N=k.toLocaleString("en-US",{month:"short"});return v?`${y} ${N}`:`${y} ${N} ${k.getFullYear()}`}function zo(t){if(t===null||t===void 0||t==="")return null;let r=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(r))return null;return new Date(r).toLocaleString("en-US",{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function zt(t){if(!Number.isFinite(t)||t<1000)return"0s";return Am(t)??"0s"}function Ut({startedAt:t,className:r}){let l=$t(),c=zt(Math.max(0,l-t)),p=u(()=>zo(t),[t]);return e("span",{role:"timer",className:`tabular-nums ${r??""}`,title:p?`Started ${p}`:void 0,"aria-label":`Running for ${c}`,children:c})}var Co="text-ink/40",Io="text-ink/80";function As({timeAgo:t,timeTitle:r,runStartedAt:l,className:c,restingClassName:p=Co}){if(l!==void 0)return e(Ut,{startedAt:l,className:`${c} ${Io}`});if(!t)return null;return e("span",{className:`${c} ${p}`,title:r??void 0,children:t})}var hs="bg-ink/10 text-ink ring-1 ring-inset ring-ink/20";function bs({variant:t,isPinned:r=!1,onOpenFolder:l,onSelectSessions:c,onNewWorktree:p,confirmDelete:g,onPin:h,onDelete:x,onRequestDelete:k,onCancelDelete:v}){if(t==="mobile")return g?e(d,{children:[e("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:x,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(L,{size:13}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(Nt,{size:13}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:h,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[r?e(ml,{size:13}):e(Ta,{size:13}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(Qr,{size:13}),e("span",{children:"Select sessions"})]}),p&&e("button",{type:"button",onClick:p,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(ge,{size:13}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(L,{size:13}),e("span",{children:"Delete Workspace"})]})]});return g?e(d,{children:[e("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:x,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(L,{size:12}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",children:e("span",{children:"Cancel"})})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(Nt,{size:12}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:h,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[r?e(ml,{size:12}):e(Ta,{size:12}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(Qr,{size:12}),e("span",{children:"Select sessions"})]}),p&&e("button",{type:"button",onClick:p,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(ge,{size:12}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(L,{size:12}),e("span",{children:"Delete Workspace"})]})]})}function _e({ancestors:t,isLast:r,first:l,style:c}){let p=c.insetPx+c.slotWidth/2,g=c.slotWidth/2+c.markGap+c.glyph/2,h=g+c.insetPx-p,x=2,k=p-1,v=l?r?{left:k,top:-6,height:"calc(50% + 6px)"}:{left:k,top:-6,bottom:-2}:r?{left:k,top:0,height:"50%"}:{left:k,top:0,bottom:-2};return e(d,{children:[t.map((y,N)=>e("span",{"data-guide":"ancestor","data-continues":y?void 0:"true","aria-hidden":"true",className:"relative shrink-0",style:{width:g},children:!y&&e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:0,bottom:-2,width:2}})},N)),e("span",{"data-guide":"connector","data-last":r?"true":void 0,"data-first":l?"true":void 0,"aria-hidden":"true",className:"relative shrink-0",style:{width:g},children:[e("span",{className:"absolute z-10 bg-ink/40",style:{width:2,...v}}),e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:"calc(50% - 1px)",width:h+1,height:2}})]})]})}function Gt({subagent:t,sessionId:r,style:l,running:c}){let[p]=le(),g=t.id===p.get("subagent"),h=HA(t),x=t.task??t.assignment??t.description??h;return e("div",{className:"group/subagent-row flex items-center",children:[e("button",{type:"button",title:x,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:r,subagent:t}})),className:`flex-1 min-w-0 flex items-center text-left text-xs rounded-md ${l.inset} ${l.padding} cursor-pointer transition-colors select-none ${g?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[e("span",{"data-testid":"subagent-status-slot",className:"w-4 h-4 flex items-center justify-center shrink-0",children:e(hm,{status:t.status,live:c,size:11})}),e("span",{className:"w-2 shrink-0"}),e("span",{"data-testid":"subagent-mark",className:"mr-1.5 flex shrink-0 items-center text-ink/55",children:e(wt,{size:l.glyph,"aria-hidden":"true"})}),e("span",{className:"flex-1 min-w-0 truncate leading-snug",children:h})]}),c&&e("button",{type:"button",title:"Stop this subagent","aria-label":"Stop this subagent",onClick:()=>void bm(r,t.id),className:"touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer",children:e(Yn,{size:10})})]})}var Oo={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function Po(t,r){return t.map((l)=>{if(r.id!==void 0){if(l.id!==r.id)return l}else if(r.index===void 0||r.index<0||l.index!==r.index)return l;let c=r.status&&l.status==="started"?Oo[r.status]??l.status:l.status;return{...l,status:c,progress:{...l.progress,...r},lastUpdate:Date.now()}})}function jt(t,r,l){let[c,p]=n([]),[g,h]=n(!1);return o(()=>{if(!l)return;let x=!1;return p([]),h(!0),WA(t).then((k)=>{if(x||!k)return;let v=k.map(ym);p((y)=>xm(y,v))}).finally(()=>{if(!x)h(!1)}),()=>{x=!0}},[t,l]),o(()=>{if(!l||!r)return;let x=!1,k=Date.now(),v=(C)=>C.sessionId===t?C.payload:null,y=Ys("subagent_lifecycle",(C)=>{let T=vm(v(C));if(T)p((S)=>xm(S,[T]))}),N=Ys("subagent_progress",(C)=>{let T=km(v(C));if(T)p((S)=>Po(S,T))});return fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then((C)=>C.ok?C.json():null).then((C)=>{if(x||!w(C))return;let T="data"in C?C.data:C;p((S)=>xm(S,KA(T),k))}).catch(()=>{}),()=>{x=!0,y(),N()}},[l,r,t]),{subagents:c,isLoading:g}}function ys(t,r,l,c,p=!1){let g=String(t.id);return{expandable:(r.get(g)?.length??0)>0||Boolean(t.hasSubagents),isExpanded:l.has(g),onToggleExpand:()=>c(g),isChild:p}}function gi({parentId:t,hasSubagents:r,childrenOf:l,expandedIds:c,onToggle:p,activeSessionId:g,renderSession:h,style:x,ancestors:k=[]}){let v=l.get(t)??[],{subagents:y,isLoading:N}=jt(t,g===t,r),C=[...v.map((T)=>({kind:"session",session:T})),...y.map((T)=>({kind:"subagent",subagent:T}))];if(C.length===0){if(!N)return null;return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:!0,first:!0,style:x}),e("div",{className:`flex min-w-0 flex-1 items-center text-xs italic text-ink/40 ${x.inset} ${x.padding}`,children:"Loading subagents…"})]})})}return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:C.map((T,S)=>{let I=S===C.length-1;if(T.kind==="subagent")return e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:I,first:S===0,style:x}),e("div",{className:"min-w-0 flex-1",children:e(Gt,{subagent:T.subagent,sessionId:t,style:x,running:g===t&&T.subagent.status==="started"})})]},`subagent:${T.subagent.id}`);let P=String(T.session.id),F={expandable:(l.get(P)?.length??0)>0||Boolean(T.session.hasSubagents),isExpanded:c.has(P),onToggleExpand:()=>p(P),isChild:!0};return e(d,{children:[e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:I,first:S===0,style:x}),e("div",{className:"min-w-0 flex-1",children:h(T.session,F)})]}),F.isExpanded&&e(gi,{parentId:P,hasSubagents:Boolean(T.session.hasSubagents),childrenOf:l,expandedIds:c,onToggle:p,activeSessionId:g,renderSession:h,style:x,ancestors:[...k,I]})]},P)})})}function vs(t){let r=new Set(t.map((p)=>String(p.id))),l=new Map,c=[];for(let p of t){let g=p.parentSessionId;if(!g||!r.has(g)||g===String(p.id)){c.push(p);continue}let h=l.get(g);if(h)h.push(p);else l.set(g,[p])}return{roots:c,childrenOf:l}}function Kt(t,r){return t.includes(r)?t.filter((l)=>l!==r):[...t,r]}function Xt(t,r){let l=new Set(t),c=r.filter((p)=>l.has(p)).length;return{count:c,all:r.length>0&&c===r.length,some:c>0&&c<r.length}}function Le(t,r){return t.filter((l)=>r?l.is_archived===1:l.is_archived!==1).map((l)=>String(l.id))}function Zt(t,r){let l=new Set(r);return t.filter((c)=>l.has(c))}function Yt(t,r,{activeSessionId:l,sessionStatus:c={}}){if(t.length<=r)return{rendered:t,hiddenCount:0};let p=[],g=0;for(let h=0;h<t.length;h+=1){let x=t[h],k=String(x.id),y=(l!==null?String(l)===k:x.is_active===1)||c[k]==="stream"||Boolean(x.awaitingInput);if(h<r||y)p.push(x);else g+=1}return{rendered:p,hiddenCount:g}}function qt(t,r){return t.mode==="workspace"||t.mode==="session"&&t.scopeFolderId===r}function Vt(t,r){return t.mode==="session"&&t.scopeFolderId===r}function ks({batch:t,folder:r,sessions:l,showArchived:c,visibleCount:p,activeSessionId:g,sessionStatus:h}){let x=t?qt(t,r.id):!1,k=t?Vt(t,r.id):!1,v=k?Le(l,c):x?[String(r.id)]:[],y=t&&x?t.summaryOf(v):null,N=Yt(l,p,{activeSessionId:g,sessionStatus:h});return{folderCheckbox:x,sessionCheckboxes:k,folderSummary:y,selectableIds:v,toggleFolderSelection:()=>{if(!t)return;if(x&&!k){t.toggle(String(r.id));return}if(!k)return;if(y?.all)t.unselectAllOf(v);else t.selectAllOf(v)},rendered:k?l:N.rendered,hiddenCount:k?0:N.hiddenCount}}function xs({touch:t=!1,onRetry:r,refreshing:l=!1}){return e("div",{role:"alert",className:`flex flex-col items-center justify-center gap-2 px-4 text-center ${t?"py-10":"py-8"}`,children:[e("span",{className:"flex h-8 w-8 items-center justify-center rounded-md border border-ink/10 bg-ink/5 text-muted",children:e(_,{size:15,"aria-hidden":"true"})}),e("p",{className:"text-xs font-semibold text-ink",children:"The session list could not be loaded."}),e("p",{className:`text-muted leading-relaxed ${t?"text-xs":"text-[11px]"}`,children:"The live connection closed before the first reply arrived. Your sessions are still on disk; they are not shown here because this tab never received them."}),e("button",{type:"button",onClick:r,disabled:l,"aria-busy":l,className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-ink/20 bg-paper px-2.5 font-medium text-ink transition-colors hover:bg-ink/5 disabled:opacity-60 ${t?"h-11 text-sm":"h-7 text-xs"}`,children:[e(D,{size:13,className:l?"animate-spin":void 0,"aria-hidden":"true"}),"Try again"]})]})}function Jt({value:t,onChange:r,touch:l=!1}){return e("div",{className:l?"px-3 pt-3 pb-2":"px-3 pt-2 pb-2",children:e("div",{className:`flex items-center gap-1.5 rounded-lg border border-ink/10 bg-ink/[0.04] px-2 transition-colors focus-within:border-ink/30 focus-within:bg-paper ${l?"h-9":"h-7"}`,children:[e(O,{size:l?15:13,"aria-hidden":"true",className:"shrink-0 text-ink/35"}),e("input",{type:"search",value:t,onChange:(c)=>r(c.currentTarget.value),placeholder:"Search workspaces & sessions","aria-label":"Search workspaces and sessions",className:`min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink/40 ${l?"text-[13px]":"text-xs"}`}),t.length>0&&e("button",{type:"button",onClick:()=>r(""),title:"Clear search","aria-label":"Clear search",className:"-mr-0.5 shrink-0 rounded p-0.5 text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink",children:e(b,{size:l?14:12})})]})})}var Pe={all:32,running:72,runningCount:14,archived:79,select:66};function Ao(t,r){let l=[Pe.all,Pe.running+(t>0?Pe.runningCount:0),Pe.archived,...r?[Pe.select]:[]];return l.reduce((c,p)=>c+p,0)+(l.length-1)*4}function Qt(t,r){if(!(t>0))return"button";return Ao(r,!0)<=t?"chip":"button"}var Me="inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors cursor-pointer",Qe="border-ink bg-ink text-paper",$e="border-ink/15 text-ink/60 hover:border-ink/30 hover:text-ink",Eo=(t)=>t?"Cancel":"Select";function en({focus:t,onFocusChange:r,runningCount:l,showArchived:c,onToggleArchived:p,selecting:g,onToggleSelect:h}){let{ref:x,width:k}=ds(0),v=Qt(k,l),y=g?e(b,{size:10}):e(Qr,{size:10});return e("div",{className:"px-3 pb-2",children:e("div",{ref:x,className:"flex flex-nowrap items-center gap-1",children:[e("div",{className:"flex shrink-0 items-center gap-1",role:"group","aria-label":"Session filters",children:[e("button",{type:"button",onClick:()=>r("all"),"aria-pressed":t==="all",className:`${Me} ${t==="all"?Qe:$e}`,children:"All"}),e("button",{type:"button",onClick:()=>r("running"),"aria-pressed":t==="running",title:l>0?`${l} running or waiting`:"Nothing running",className:`${Me} ${t==="running"?Qe:$e}`,children:[e("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${l>0?"bg-current":"bg-current opacity-30"}`}),"Running",l>0&&e("span",{className:"font-mono tabular-nums opacity-70",children:l})]}),e("button",{type:"button",onClick:p,"aria-pressed":c,title:c?"Hide archived sessions":"Show archived sessions",className:`${Me} ${c?"border-warning/40 bg-warning/10 text-warning hover:bg-warning/15":$e}`,children:[e(Xe,{size:10}),"Archived"]})]}),v==="chip"?e("button",{type:"button",onClick:h,"aria-pressed":g,title:g?"Cancel selection":"Select workspaces",className:`${Me} ml-auto ${g?Qe:$e}`,children:[y,Eo(g)]}):e("button",{type:"button",onClick:h,title:g?"Cancel selection":"Select workspaces","aria-label":g?"Cancel selection":"Select workspaces","aria-pressed":g,className:`ml-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors cursor-pointer ${g?"bg-ink/10 text-ink":"text-ink/55 hover:bg-ink/[0.06] hover:text-ink"}`,children:g?e(b,{size:14}):e(Qr,{size:14})})]})})}var Bo="shrink-0 inline-flex items-center justify-center rounded-md text-ink/55 transition-colors cursor-pointer hover:bg-ink/[0.06] hover:text-ink",_o="bg-ink/10 text-ink",tn={"A-Z":"A–Z","Z-A":"Z–A",LATEST_SESSION:"Latest chat",LATEST_ADDED:"Latest added"};function nn({onNewSession:t,onNewWorkspace:r,onScheduler:l,scheduledCount:c,onRefresh:p,refreshing:g,sortOption:h,optionsOpen:x,onToggleOptions:k,onCloseOptions:v,onSortChange:y,touch:N=!1}){let C=`${Bo} ${N?cn.mobile:cn.desktop}`,T=c>0?`Scheduled tasks (${c} armed)`:"Scheduled tasks";return e("div",{className:`flex items-center ${Js} px-3 pb-2`,children:[e("button",{type:"button",onClick:t,title:"New Session","aria-label":"New Session",className:`flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md bg-ink px-2 font-semibold text-canvas transition-colors cursor-pointer hover:bg-ink/90 ${N?"h-9 text-[13px]":"h-7 text-xs"}`,children:[e(Y,{size:N?16:14,className:"shrink-0"}),e("span",{className:"truncate",children:"New Session"})]}),e("div",{className:`flex shrink-0 items-center ${yc}`,children:[e("button",{type:"button",onClick:r,title:"New Workspace","aria-label":"New Workspace",className:C,children:e(on,{size:N?16:14})}),e("button",{type:"button",onClick:l,title:T,"aria-label":c>0?`Scheduled tasks, ${c} armed`:"Scheduled tasks",className:`relative ${C}`,children:[e(Sa,{size:N?16:14}),c>0&&e("span",{className:"absolute right-0.5 top-0.5 min-w-[10px] rounded-full bg-ink px-[2px] text-center text-[7px] font-semibold leading-[10px] text-canvas",children:c>9?"9+":c})]}),e("button",{type:"button",onClick:p,title:"Refresh sessions","aria-label":"Refresh sessions","aria-busy":g,className:C,children:e(D,{size:N?16:14,className:g?"animate-spin":""})}),e("div",{className:"relative",children:[e("button",{type:"button",onClick:k,title:`Sort: ${tn[h]}`,"aria-label":`Sort workspaces, currently ${tn[h]}`,"aria-haspopup":"menu","aria-expanded":x,className:`${C} ${x||h!=="A-Z"?_o:""}`,children:e(us,{size:N?16:14})}),x&&e("div",{className:"glass-popover absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-ink/15 bg-paper py-1 shadow-lg",onMouseLeave:v,children:e($o,{variant:"desktop",sortOption:h,onSortChange:y})})]})]})]})}function rn({title:t,status:r,awaitingInput:l=!1,renaming:c=!1,waitingFor:p,expandable:g=!1,isExpanded:h=!1,onToggleExpand:x,child:k=!1,selectable:v=!1,selected:y=!1,onToggleSelect:N,touch:C=!1}){if(v)return e("span",{className:"flex shrink-0 items-center",children:[e(Nr,{checked:y,label:`Select ${t}`,onChange:()=>N?.()}),e("span",{className:"w-2 shrink-0"})]});let T=C?14:13,S=Boolean(p),I=l||r==="stream"||S,P=Boolean(g&&x)&&!I&&!c,A=Boolean(c||l||S||r)&&!P;return e(d,{children:[e("span",{className:`relative shrink-0 ${C?"w-[18px] h-5":"w-4 h-4"}`,children:[g&&x&&e("button",{type:"button",onClick:(F)=>{F.stopPropagation(),x(F)},title:h?"Collapse sessions and subagents":"Expand sessions and subagents","aria-expanded":h,"aria-label":h?"Collapse sessions and subagents":"Expand sessions and subagents",className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${P?"text-ink/55 hover:text-ink":"text-ink/40 opacity-0 hover:text-ink group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:h?e(B,{size:T}):e(ie,{size:T})}),A&&e("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${g?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:c?e("span",{role:"status","aria-label":"Generating a name…",children:e(m,{size:T-1,className:"animate-spin"})}):l?e(De,{size:T-1,className:"animate-pulse text-warning"}):S?e("span",{role:"status","aria-label":`Waiting for ${p?.title??"another session"}`,children:e(Ue,{size:T-1,className:"animate-pulse"})}):r==="stream"?e("span",{role:"status","aria-label":"Running",children:e(m,{size:T-1,className:"animate-spin"})}):e(f,{size:T-1})}),k&&!(g&&x)&&!A&&e("span",{"data-testid":"child-indicator","aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex items-center justify-center text-ink/35",children:e(ge,{size:T-1,"aria-hidden":"true"})})]}),e("span",{className:"w-2 shrink-0"})]})}function sn({timeAgo:t,timeTitle:r,runStartedAt:l,onOpenMenu:c,menuOpen:p=!1,touch:g=!1}){let h=(k)=>e(As,{timeAgo:t,timeTitle:r,runStartedAt:l,className:k});if(!c)return h("ml-2 shrink-0 font-mono text-[10px]");let x=e("button",{type:"button",onClick:c,title:"Session actions","aria-label":"Session actions","aria-haspopup":"menu","aria-expanded":p,className:`shrink-0 rounded text-ink/40 hover:bg-ink/10 hover:text-ink cursor-pointer ${g?"p-1.5":"p-1"} ${g?"":"opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 focus-visible:opacity-100"}`,children:e(Be,{size:g?16:14})});if(g)return e("span",{className:"ml-1 flex shrink-0 items-center gap-0.5",children:[h("font-mono text-[10px]"),x]});return e("span",{className:"relative ml-2 flex h-4 min-w-8 shrink-0 items-center justify-end pr-1",children:[h("whitespace-nowrap font-mono text-[10px] leading-none transition-opacity group-hover/item:opacity-0 group-focus-within/item:opacity-0"),e("span",{className:"absolute right-0 -my-1 flex",children:x})]})}function an(t){return{inset:"pl-1 pr-1",insetPx:4,slotWidth:t?18:16,markGap:8,padding:t?"py-0.5":"py-[7px]",glyph:t?_t.touch:_t.compact}}function ln({sessionId:t,title:r,harness:l,isActive:c=!1,isArchived:p=!1,status:g,awaitingInput:h=!1,timeAgo:x,timeTitle:k,runStartedAt:v,worktree:y,waitingFor:N,expandable:C=!1,isExpanded:T=!1,onToggleExpand:S,isChild:I=!1,folderId:P,onClick:A,onRename:F,onRenameWithAi:R,onArchive:z,onDelete:Q,onCancelWait:te,selectable:G=!1,selected:oe=!1,onToggleSelect:re,density:V="compact"}){let H=V==="touch",K=Ia(t),M=No(),{isEditing:de,draft:ae,setDraft:Se,inputRef:me,startRename:se,handleKeyDown:ee,handleBlur:Te}=Qo(r,F),ve=Boolean(F||z||Q||te),fe=M.anchor!==null,xe=Boolean(N),ue=r.charAt(0).toUpperCase()+r.slice(1);if(de)return e("div",{className:`flex w-full items-center rounded-lg bg-ink/10 ${H?"px-2 py-1.5":"px-2 py-1"}`,children:e("input",{ref:me,autoFocus:!0,value:ae,onChange:(ye)=>Se(ye.currentTarget.value),onClick:(ye)=>ye.stopPropagation(),onKeyDown:ee,onBlur:Te,"aria-label":"Session name",className:"min-w-0 flex-1 rounded border border-ink/25 bg-paper px-2 py-0.5 text-xs text-ink outline-none focus:border-ink/50"})});return e(d,{children:[e("div",{"data-testid":"session-item","data-session-id":String(t),"data-selected":G&&oe?"true":void 0,"data-menu-open":fe?"true":void 0,onClick:G?re:A,onContextMenu:ve&&!G?M.openAtCursor:void 0,className:`group/item relative flex w-full items-center rounded-lg text-xs transition-colors select-none cursor-pointer ${H?"py-0.5 pl-1 pr-1":"py-[7px] pl-1 pr-1"} ${G&&oe||fe?hs:c?"bg-ink/[0.08] font-medium text-ink":"text-ink/75 hover:bg-ink/[0.04] hover:text-ink"}`,children:[c&&!G&&e("span",{"aria-hidden":"true",className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-ink"}),e(rn,{title:r,status:g,awaitingInput:h,renaming:K,waitingFor:N,expandable:C,isExpanded:T,onToggleExpand:S,child:I,selectable:G,selected:oe,onToggleSelect:re,touch:H}),l&&e("span",{className:"mr-1.5 flex shrink-0 items-center",children:e(ht,{harness:l,size:H?_t.touch:_t.compact})}),e("span",{className:`flex min-w-0 flex-1 flex-col leading-snug ${p?"text-ink/45":""}`,children:[e("span",{className:"min-w-0 truncate",children:ue}),xe&&e("span",{className:"truncate text-[10px] font-normal text-ink/40",children:["waiting for ",N?.title??"another session"]}),y&&e(fs,{worktree:y})]}),e(sn,{timeAgo:x,timeTitle:k,runStartedAt:v,touch:H,menuOpen:fe,onOpenMenu:ve&&!G?M.openBelow:void 0})]}),M.anchor&&e(Ro,{anchor:M.anchor,sessionId:t,...l?{harness:l}:{},...P!==void 0?{folderId:P}:{},isArchived:p,onRename:F?se:void 0,onRenameWithAi:R,onArchive:z,onDelete:Q,onCancelWait:te,onClose:M.close})]})}function Lo(t){let r=t.parentElement;while(r){let l=getComputedStyle(r);if(/(auto|scroll|overlay)/.test(l.overflowY))return r;r=r.parentElement}return null}function dn(t){let[r,l]=n(!1);return o(()=>{let c=t.current;if(!c)return;let p=Lo(c),g=!1,h=()=>{g=!1;let v=p?p.getBoundingClientRect():{top:0},y=p?p.scrollTop>0:window.scrollY>0,N=c.getBoundingClientRect();l(y&&N.top<=v.top+0.5&&N.bottom>v.top)},x=()=>{if(g)return;g=!0,requestAnimationFrame(h)};h();let k=typeof ResizeObserver>"u"?null:new ResizeObserver(x);if(k?.observe(c),p)k?.observe(p);return(p??window).addEventListener("scroll",x,{passive:!0}),window.addEventListener("resize",x),()=>{g=!1,k?.disconnect(),(p??window).removeEventListener("scroll",x),window.removeEventListener("resize",x)}},[t]),r}function un({folder:t,isOpen:r,onToggleFolder:l,sessionCount:c,checkbox:p,batchActive:g,showMenu:h,onToggleMenu:x,onCloseMenu:k,onNewSession:v,menu:y,touch:N=!1}){let C=ea(t.icon),T=t.accentColor||void 0,S=i(null),[I,P]=n(null),A=i(null),F=dn(A);return e("div",{ref:A,"data-stuck":F?"":void 0,className:`group/ws sticky top-0 z-10 -mx-1 flex items-center gap-1 rounded-md px-1 text-xs font-semibold text-ink ${N?"h-8 bg-canvas glass-sticky":"h-[26px] bg-paper glass-sticky"}`,children:[e("button",{type:"button",onClick:g?void 0:l,"aria-expanded":r,"aria-label":`${t.name}${r?", collapse":", expand"}`,className:"flex h-full min-w-0 flex-1 items-center gap-2 rounded-md px-1 text-left cursor-pointer hover:bg-ink/[0.04]",children:[p?e(Nr,{size:"md",checked:p.checked,indeterminate:p.indeterminate,label:p.label,onChange:p.onChange}):e("span",{className:`relative flex shrink-0 items-center justify-center ${N?"h-[18px] w-[18px]":"h-4 w-4"}`,children:t.customIconUrl?e("img",{src:t.customIconUrl,alt:"",className:"h-[15px] w-[15px] shrink-0 rounded-xs object-contain",referrerPolicy:"no-referrer"}):e(C,{size:15,className:"project-accent-mark text-ink/70",style:Ks(T)})}),e("span",{className:"glass-sticky-label truncate text-[13px] font-semibold tracking-tight",children:t.name}),t.isPinned&&e(Ta,{size:10,className:"shrink-0 text-ink/45"}),T&&!p&&e("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:T}}),e("span",{className:"glass-sticky-label shrink-0 font-mono text-[10px] font-normal tabular-nums text-ink/35",children:c}),e("span",{className:"ml-auto shrink-0 text-ink/40",children:r?e(B,{size:N?14:12}):e(ie,{size:N?14:12})})]}),!g&&e("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:[e("button",{type:"button",title:"New Session","aria-label":`New session in ${t.name}`,onClick:(R)=>{R.stopPropagation(),v()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${N?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(Y,{size:N?15:12})}),e("div",{className:"relative flex items-center",children:[e("button",{ref:S,type:"button",title:`Options for ${t.name}`,"aria-label":`Options for ${t.name}`,"aria-haspopup":"menu","aria-expanded":h,onClick:(R)=>{if(R.stopPropagation(),S.current)P(Ht(S.current));x()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${N?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(Be,{size:N?15:12})}),e(Wt,{anchor:h&&y?I:null,align:"end",ariaLabel:`Options for ${t.name}`,className:"glass-popover w-44 rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",onClose:k,children:y})]})]})]})}function pn({hiddenCount:t,canShowLess:r,onShowMore:l,onShowLess:c}){if(t<=0&&!r)return null;return e("div",{className:"flex items-center gap-1 pl-6",children:[t>0&&e("button",{type:"button",onClick:l,className:"min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(B,{size:11,className:"mr-1 inline align-[-2px]"}),t," more"]}),r&&e("button",{type:"button",onClick:c,className:"ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(et,{size:11,className:"mr-1 inline align-[-2px]"}),"Less"]})]})}function mn({folder:t,activeSessionId:r,sessionStatus:l,showArchived:c,forceExpanded:p=!1,density:g="compact",batch:h,onSelectSession:x,onNewSessionForFolder:k,onNewWorktreeSession:v,onToast:y,onStartSessionSelection:N,onCancelWait:C}){let[T,S]=n(t.isExpanded||!1),[I,P]=n(!1),[A,F]=n(!1),{visibleCount:R,showMore:z,showLess:Q,canShowLess:te}=ps(),[G]=le(),oe=G.get("subagent"),re=G.get("sessionId"),{expandedSessionIds:V,toggleSession:H}=rs(),{refresh:K,runStartedAtMap:M}=He(),de=st(),{confirmDelete:ae,requestDelete:Se,cancelDelete:me,handlePin:se,handleDelete:ee,handleArchive:Te,handleRename:ve,handleRenameWithAi:fe,handleOpenFolder:xe}=ms(t,K,y),ue=To();o(()=>{if(typeof t.isExpanded==="boolean")S(t.isExpanded)},[t.isExpanded]);let ye=()=>{P(!1),me()},Re=()=>{let U=!T;if(S(U),typeof t.id!=="number")return;de.submit({isExpanded:String(U)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},Ie=t.sessions.filter((U)=>c?U.is_archived===1:U.is_archived!==1),{folderCheckbox:Ke,sessionCheckboxes:j,folderSummary:Z,toggleFolderSelection:X,rendered:q,hiddenCount:Ne}=ks({batch:h,folder:t,sessions:Ie,showArchived:c,visibleCount:R,activeSessionId:r,sessionStatus:l}),be=vs(q),it=p||T||j,at=(U,Ce)=>{let ce=String(U.id),ct=r===null?U.is_active===1:String(r)===ce,zn=ct&&re===ce&&Boolean(oe),Ze=yt(ce);return e(ln,{sessionId:U.id,title:U.title,harness:U.harness,folderId:U.folder_id,density:g,isActive:ct&&!zn,isArchived:U.is_archived===1,status:l[ce],awaitingInput:Boolean(U.awaitingInput),timeAgo:gs(U.updated_at??U.created_at),timeTitle:zo(U.updated_at??U.created_at),runStartedAt:l[ce]==="stream"?M[ce]:void 0,worktree:U.worktree,waitingFor:U.waitingFor?{title:U.waitingFor.title}:void 0,expandable:Ce.expandable,isChild:Ce.isChild,isExpanded:Ce.isExpanded,onToggleExpand:Ce.onToggleExpand,onClick:()=>x(U.id),onArchive:()=>Te(U),onDelete:Ze?void 0:()=>ue.requestDelete(U),onRename:Ze?void 0:(Hn)=>void ve(U,Hn),onRenameWithAi:Ze?void 0:()=>void fe(U),onCancelWait:U.waitingFor?()=>C?.(U.waitingFor.waitId):void 0,selectable:j,selected:Boolean(h?.selected.includes(ce)),onToggleSelect:h?()=>h.toggle(ce):void 0})},Wn=(U)=>ys(U,be.childrenOf,V,H),lt=Boolean(v&&t.project_path);return e("div",{className:"space-y-0.5",children:[e(un,{folder:t,isOpen:it,onToggleFolder:Re,sessionCount:Ie.length,checkbox:Ke&&Z?{checked:Z.all,indeterminate:Z.some,label:`Select ${t.name}`,onChange:X}:null,batchActive:Boolean(h),showMenu:I,onToggleMenu:()=>P((U)=>!U),onCloseMenu:ye,onNewSession:()=>k(t.id),touch:g==="touch",menu:e(bs,{variant:"desktop",isPinned:t.isPinned,onOpenFolder:xe?()=>{xe(),P(!1)}:void 0,onSelectSessions:N?()=>{P(!1),N(t.id)}:void 0,onNewWorktree:lt?()=>{P(!1),F(!0)}:void 0,confirmDelete:ae,onPin:()=>{se(),P(!1)},onDelete:()=>{ee(),P(!1)},onRequestDelete:Se,onCancelDelete:me})}),it&&e("div",{className:"space-y-0.5",children:[be.roots.map((U)=>{let Ce=String(U.id),ce=Wn(U);return e("div",{className:"space-y-0.5",children:[at(U,ce),ce.isExpanded&&e(gi,{parentId:Ce,hasSubagents:Boolean(U.hasSubagents),childrenOf:be.childrenOf,expandedIds:V,onToggle:H,activeSessionId:r===null?null:String(r),renderSession:at,style:an(g==="touch")})]},U.id)}),!j&&e(pn,{hiddenCount:Ne,canShowLess:te,onShowMore:z,onShowLess:Q}),Ie.length===0&&e("div",{className:"px-1 py-1 pl-6 text-[11px] italic text-ink/40",children:c?"No archived sessions.":"No sessions."})]}),e(Do,{session:ue.pending,isDeleting:ue.isDeleting,error:ue.error,onClose:ue.cancelDelete,onConfirm:()=>void ue.confirmDelete()}),lt&&e(Fo,{isOpen:A,onClose:()=>F(!1),root:t.project_path??null,folderId:t.id,folderName:t.name,onCreated:(U)=>{F(!1),v?.(t.id,U.path)}})]})}var Mo=[3,2];function hn({touch:t=!1}){return e("div",{className:"space-y-3","aria-hidden":"true",children:Mo.map((r,l)=>e("div",{className:"space-y-0.5",children:[e("div",{className:`flex items-center gap-2 px-1 ${t?"h-8":"h-[26px]"}`,children:[e("span",{className:`animate-pulse rounded-sm bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 w-24 animate-pulse rounded bg-ink/10"})]}),Array.from({length:r},(c,p)=>e("div",{className:`flex items-center gap-2 pl-1 pr-2 ${t?"h-8":"h-[31px]"}`,children:[e("span",{className:`shrink-0 animate-pulse rounded-full bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 animate-pulse rounded bg-ink/10",style:{width:`${58-p%3*12}%`}})]},p))]},l))})}function bn(t,r){if(t.awaitingInput)return!0;if(t.waitingFor)return!0;return r==="stream"}function gn(t,{focus:r,statusOf:l}){if(r==="all")return t;return t.map((c)=>({...c,sessions:c.sessions.filter((p)=>bn(p,l(String(p.id))))})).filter((c)=>c.sessions.length>0)}function xn(t,r){let l=0;for(let c of t)for(let p of c.sessions)if(bn(p,r(String(p.id))))l+=1;return l}function nu({className:t="",folders:r,initializing:l,failed:c,activeSessionId:p,sessionStatus:g,searchQuery:h,onSearchChange:x,showArchived:k,onToggleArchived:v,sortOption:y,optionsOpen:N,onToggleOptions:C,onCloseOptions:T,onSortChange:S,onRefresh:I,refreshing:P,scheduledCount:A,onNewSession:F,onNewWorkspace:R,onScheduler:z,onSelectSession:Q,onNewSessionForFolder:te,onNewWorktreeSession:G,onToast:oe,onCancelWait:re,batch:V,onSelectWorkspaces:H,onStartSessionSelection:K,touch:M=!1}){let[de,ae]=n("all"),Se=u(()=>xn(r,(ee)=>g[ee]),[r,g]),me=u(()=>gn(r,{focus:de,statusOf:(ee)=>g[ee]}),[r,de,g]),se=Boolean(V);return e("div",{className:`flex flex-col ${t}`,children:[e(Jt,{value:h,onChange:x,touch:M}),e(en,{focus:de,onFocusChange:ae,runningCount:Se,showArchived:k,onToggleArchived:v,selecting:se,onToggleSelect:H}),e(nn,{onNewSession:F,onNewWorkspace:R,onScheduler:z,scheduledCount:A,onRefresh:I,refreshing:P,sortOption:y,optionsOpen:N,onToggleOptions:C,onCloseOptions:T,onSortChange:S,touch:M}),e("div",{className:"mt-1 flex-1 scrollbar-overlay-container px-2 pb-3",children:c?e(xs,{touch:M,onRetry:I,refreshing:P}):l?e(hn,{touch:M}):me.length===0?e("div",{className:"px-1 py-8 text-center text-[11px] leading-relaxed text-muted",children:de==="running"?"Nothing is running right now.":h?"No workspace or chat matches that search.":"No workspaces yet."}):e("div",{className:"space-y-3",children:me.map((ee)=>e(mn,{folder:ee,activeSessionId:p,sessionStatus:g,showArchived:k,forceExpanded:h.trim().length>0,density:M?"touch":"compact",batch:V,onSelectSession:Q,onNewSessionForFolder:te,onNewWorktreeSession:G,onToast:oe,onStartSessionSelection:K,onCancelWait:re},ee.id))})})]})}function Wo(t){if(!t)return Number.NaN;let r=Date.parse(t);return Number.isFinite(r)?r:Number.NaN}function kn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Wo(l.updated_at??l.created_at);if(c>r)r=c}return r}function Sn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Number(l.id);if(Number.isFinite(c)&&c>r)r=c}return r}function ke(t){let r=Number(t.id);return Number.isFinite(r)?r:Number.NEGATIVE_INFINITY}function We(t,r){if(t===r)return 0;return t>r?-1:1}function vn(t,r){if(t===r)return 0;return t>r?1:-1}function Ho(t,r,l){let c=Boolean(t.isPinned),p=Boolean(r.isPinned);if(c!==p)return c?-1:1;switch(l){case"Z-A":{let g=r.name.localeCompare(t.name);return g!==0?g:vn(ke(t),ke(r))}case"LATEST_SESSION":{let g=We(kn(t),kn(r));if(g!==0)return g;let h=We(Sn(t),Sn(r));if(h!==0)return h;let x=We(ke(t),ke(r));return x!==0?x:t.name.localeCompare(r.name)}case"LATEST_ADDED":{let g=We(ke(t),ke(r));return g!==0?g:t.name.localeCompare(r.name)}case"A-Z":default:{let g=t.name.localeCompare(r.name);return g!==0?g:vn(ke(t),ke(r))}}}function yn(t,r){return[...t].sort((l,c)=>Ho(l,c,r))}var Uo=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],wn="LATEST_SESSION";function Tn(t){return typeof t==="string"&&Uo.includes(t)}function Cn(t,r,l){if(r.length===0||t.length===0)return t;let c=new Set;for(let h of t)for(let x of h.sessions??[])c.add(String(x.id));let p=r.filter((h)=>!c.has(String(h.id)));if(p.length===0)return t;let g=t;for(let h of p){let x=On(g,h,l);if(!x)continue;let k=new Date(h.createdAt).toISOString(),v={id:h.id,folder_id:x.id,title:h.title??l.titleFor?.(String(h.id))??fm(h.id),created_at:k,updated_at:k,...h.parentSessionId?{parentSessionId:h.parentSessionId}:{},...h.harness?{harness:h.harness}:{},...h.waiting?{waitingFor:{waitId:h.waiting.waitId,sessionId:h.waiting.dependsOn,title:h.waiting.dependsOnTitle}}:{}};g=g.map((y)=>y.id===x.id?{...y,isExpanded:!0,sessions:[v,...y.sessions??[]]}:y)}return g}function In(t,r,l){if(r.length===0||t.length===0)return[];let c=new Set;for(let p of r){let g=On(t,p,l);if(g)c.add(String(g.id))}return[...c]}function On(t,r,l){if(r.folderId!==null&&r.folderId!==void 0){let c=t.find((p)=>String(p.id)===String(r.folderId));if(c)return c}if(l.activeId){let c=t.find((p)=>(p.sessions??[]).some((g)=>String(g.id)===String(l.activeId)));if(c)return c}if(l.urlFolderId){let c=t.find((p)=>String(p.id)===String(l.urlFolderId));if(c)return c}return t[0]}async function kd(t,r){try{return(await fetch(`/api/folders/${encodeURIComponent(String(t))}/toggle`,{method:"POST",body:new URLSearchParams({isExpanded:String(r)})})).ok}catch(l){return console.error("Failed to save workspace expansion:",l),!1}}function Pn(t,r){return t.find((l)=>(l.sessions??[]).some((c)=>String(c.id)===r))}function Rn(t){let{folders:r,initializing:l,runningIds:c,pendingEntries:p,activeId:g,urlFolderId:h}=t,x=u(()=>{let v=new Set;for(let y of c){let N=Pn(r,y);if(N)v.add(String(N.id))}return v},[r,c]),k=i({running:new Set,pending:new Set});return o(()=>{if(l||r.length===0)return;let v=k.current,y=new Set,N=new Set,C=new Set;for(let S of c){if(v.running.has(S)){y.add(S);continue}let I=Pn(r,S);if(!I)continue;y.add(S),C.add(String(I.id))}let T={activeId:g,urlFolderId:h};for(let S of p){let I=String(S.id);if(v.pending.has(I)){N.add(I);continue}N.add(I);for(let P of In(r,[S],T))C.add(P)}v.running=y,v.pending=N;for(let S of C){let I=r.find((P)=>String(P.id)===S);if(!I||I.isExpanded)continue;kd(S,!0)}},[l,r,c,p,g,h]),x}var Go=200;function ru(t={},r={}){let{expandSearchMatches:l=!1,onSelectSession:c,onAfterSelect:p}=r,{folders:g,initializing:h,failed:x,refresh:k,refreshNow:v,refreshing:y,isRefreshing:N,markSeen:C,hasSeen:T,streamStatusMap:S,titleHint:I}=He(),[P,A]=le(),F=P.get("sessionId"),R=P.get("folderId"),z=F?Number.isNaN(Number(F))?F:Number(F):null,Q=i(k);Q.current=k;let te=a(()=>Q.current(),[]),[G,oe]=n(""),[re,V]=n(!1),[H,K]=n(!1),[M,de]=n(()=>Tn(t.omp_sidebar_sort)?t.omp_sidebar_sort:wn),ae=i(null),Se=a((j)=>{if(ae.current)clearTimeout(ae.current);ae.current=setTimeout(()=>{rt("omp_sidebar_sort",j)},Go)},[]);o(()=>()=>{if(ae.current)clearTimeout(ae.current)},[]);let me=(j)=>{de(j),K(!1),Se(j)},se=S;GA(se,z,te,T);let ee=gm(),{prompts:Te,loaded:ve}=vc(),fe=u(()=>new Set(Object.entries(se).filter(([,j])=>j==="stream").map(([j])=>j)),[se]),xe=Rn({folders:g,initializing:h,runningIds:fe,pendingEntries:ee,activeId:F,urlFolderId:R});o(()=>{if(!F||h)return;if(g.some((j)=>(j.sessions??[]).some((Z)=>String(Z.id)===F)))return;jA(F,R,se[F]==="stream")},[F,g,h,R,se]),o(()=>{if(h||!ve)return;for(let j of ee){let Z=String(j.id),X=Te.find((q)=>q.pendingId===Z&&q.status==="waiting");if(!X||j.waiting?.waitId===X.id)continue;wm(Z,{waitId:X.id,dependsOn:X.dependsOn,dependsOnTitle:X.dependsOnTitle})}},[ee,Te,ve,h]);let[ue,ye]=n(0),Re=ee.map((j)=>String(j.id)).join(`
|
|
1
|
+
import{d,n,o,W,i,u,a,le,e,w,Uf,we,Gr,Bp,s,E,ne,De,Be,ur,m,L,_,Xe,wt,f,B,ie,et,Nn,tt,Nt,on,nt,ge,xr,Ue,yo,Fn,xa,Y,D,O,Yn,b,rt,pe,J,st,he,Ht,Wt,It,ht,_t,fn,Wa,ea,Ks,GA,He,es,pm,Hu,hc,Ia,mm,To,Do,Qo,yt,fm,ts,ns,bc,jA,qA,gm,rs,No,Ro,Am,Fo,hm,HA,bm,WA,ym,vm,km,KA,xm,Ys,cn,yc,Js,wm,Ku,VA,vc,Vu,Cm}from"./index-4c2zcvem.js";import{ml,Ta,xd,ws}from"./index-m847wafq.js";var Un={name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]},us=s(Un);var Gn={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]},Sa=s(Gn);var jn={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]},dt=s(jn);var Kn={name:"list-checks",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]},Qr=s(Kn);function ut({value:t,onInput:r,onSubmit:l,onRefresh:c,onNewFolder:p,loading:g,creating:h,resolved:x}){return e("div",{children:[e("div",{className:"flex items-center space-x-2",children:[e("form",{onSubmit:(v)=>{v.preventDefault(),l()},className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[e("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:e(ur,{size:14})}),e("input",{type:"text",value:t,onChange:(v)=>r(v.currentTarget.value),placeholder:"~/projects/my-project",spellcheck:!1,"aria-label":"Project path",className:"w-full px-3 py-2 outline-none text-sm bg-transparent font-mono"})]}),e("button",{type:"button",onClick:c,disabled:g,title:"Refresh folders","aria-label":"Refresh folders","aria-busy":g,className:"px-2.5 py-2 bg-ink/5 border border-ink/10 rounded text-ink/70 hover:bg-ink/10 hover:text-ink disabled:opacity-40 transition-colors flex-shrink-0",children:e(D,{size:13,className:g?"animate-spin":void 0})}),e("button",{type:"button",onClick:p,disabled:h||g||!x,title:"New folder here","aria-label":"New folder here","aria-busy":h,className:"px-2.5 py-2 bg-ink/5 border border-ink/10 rounded text-ink/70 hover:bg-ink/10 hover:text-ink disabled:opacity-40 transition-colors flex-shrink-0",children:h?e(m,{size:13,className:"animate-spin"}):e(on,{size:13})})]}),x&&x!==t.trim()&&e("p",{className:"mt-1 text-[10px] text-ink/40 font-mono truncate",children:["Listing: ",x]})]})}function pt({directories:t,loading:r,error:l,onOpen:c,onRetry:p,creating:g,name:h,onNameChange:x,onCreate:k,onCancelCreate:v,createError:y,creatingBusy:N}){return e("div",{className:"border border-ink/15 rounded overflow-hidden",children:[g&&e("form",{onSubmit:(T)=>{if(T.preventDefault(),h.trim())k(h.trim())},className:"flex items-center space-x-1.5 px-2 py-1.5 border-b border-ink/10 bg-ink/5",children:[e(nt,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:h,onChange:(T)=>x(T.currentTarget.value),placeholder:"new-folder-name","aria-label":"New folder name",spellcheck:!1,className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 outline-none focus:border-ink/50 text-xs"}),e("button",{type:"submit",disabled:N||!h.trim(),className:"px-2 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:bg-ink/90 disabled:opacity-40 transition-colors",children:N?"Creating…":"Create"}),e("button",{type:"button",onClick:v,"aria-label":"Cancel new folder",className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors",children:e(b,{size:12})})]}),g&&y&&e("p",{className:"px-2.5 py-1.5 text-[11px] text-error border-b border-ink/10",children:y}),e("div",{className:"max-h-52 overflow-y-auto scrollbar-overlay-container",children:r?e("div",{className:"flex items-center justify-center py-8 text-ink/40",children:e(m,{size:16,className:"animate-spin"})}):l?e("div",{className:"flex flex-col items-center justify-center py-6 px-3 text-xs text-error space-y-2",children:[e("span",{className:"text-center",children:l}),e("button",{type:"button",onClick:p,className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[e(D,{size:11})," ",e("span",{children:"Retry"})]})]}):t.length===0?e("div",{className:"text-center py-8 text-xs text-ink/40",children:"No subfolders"}):t.map((T)=>e("button",{type:"button",onClick:()=>c(T),title:T.path,className:"w-full flex items-center space-x-2 px-2.5 py-1.5 text-left hover:bg-ink/5 transition-colors group",children:[e(nt,{size:14,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-xs truncate text-ink/85 flex-1",children:T.name}),e(tt,{size:11,className:"text-ink/20 group-hover:text-ink/50 flex-shrink-0 transition-colors"})]},T.path))})]})}function mt(t){let r=t.trim();if(!r||/\s/.test(r))return!1;if(/^https?:\/\/\S+$/i.test(r))return!0;if(/^ssh:\/\/\S+$/i.test(r))return!0;if(/^git@[^:/\s]+:\S+$/.test(r))return!0;if(/^file:\/\/\S+$/i.test(r))return!0;if(r.startsWith("/")||r.startsWith("~"))return!0;if(/^[a-z]:[\\/]/i.test(r))return!0;if(/^\\\\[^\\]+\\/.test(r))return!0;return!1}function ft(t){let c=t.replace(/^[a-z]:/i,"").replace(/\\/g,"/").replace(/\/+$/,"").split(/[/:]/).filter(Boolean),p=c.length===0?"":c[c.length-1];if(p===""||/^[a-z]+:$/i.test(p)||/^https?:?$/i.test(p))return"";return p.replace(/\.git$/i,"").replace(/[^a-z0-9._-]/gi,"-")}function bt({parent:t,busy:r,onClone:l}){let[c,p]=n(""),g=c.trim(),h=mt(g),x=h?ft(g):"",k=()=>{if(h&&!r)l(g)};return e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Clone Git Repository"," ",e("span",{className:"text-ink/40 font-normal",children:"(optional: clones into the path above)"})]}),e("div",{className:"flex items-center space-x-2",children:[e("input",{type:"text",value:c,onChange:(v)=>p(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")v.preventDefault(),k()},disabled:r,placeholder:"https://github.com/org/repo.git",spellcheck:!1,"aria-label":"Git repository URL",className:"flex-1 bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm font-mono disabled:opacity-60"}),e("button",{type:"button",onClick:k,disabled:!h||r,title:h?`Clone into ${t}/${x}`:"Enter an https, ssh, git@ or local path","aria-label":"Clone repository",className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[r?e(m,{size:13,className:"animate-spin"}):e(xr,{size:13}),e("span",{children:r?"Cloning…":"Clone"})]})]}),h&&x&&!r&&e("p",{className:"mt-1 text-[10px] text-ink/40 font-mono truncate",children:["Creates workspace “",x.toLowerCase(),"” at ",t,"/",x]})]})}function gt(t){let[r,l]=n(t??""),[c,p]=n([]),[g,h]=n(null),[x,k]=n(!1),[v,y]=n(null),N=i(0),C=a(async(S)=>{let I=++N.current;k(!0),y(null);try{let P=await xd(S);if(I!==N.current)return;l(P.path??S??""),h(P.parentPath??null),p(P.directories??[])}catch(P){if(I!==N.current)return;y(P instanceof Error?P.message:String(P)),p([])}finally{if(I===N.current)k(!1)}},[]);o(()=>{C(t||void 0)},[C]);let T=a(()=>C(r||void 0),[C,r]);return{current:r,directories:c,parentPath:g,loading:x,error:v,navigate:C,refresh:T}}function pl({isOpen:t,onClose:r,onCreate:l,onClone:c}){if(!t)return null;return e(Xn,{onClose:r,onCreate:l,onClone:c})}function Xn({onClose:t,onCreate:r,onClone:l}){let[c,p]=n("create"),[g,h]=n(""),[x,k]=n(""),[v,y]=n(!1),[N,C]=n(null),[T,S]=n(!1),[I,P]=n(!1),[A,F]=n(""),[R,z]=n(null),[Q,te]=n(!1),G=gt(),oe=async(H)=>{te(!0),z(null);try{let K=await fetch("/api/folders/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent:G.current,name:H})}),M=await K.json().catch(()=>({}));if(!K.ok||!M.success)throw Error(M.error||`HTTP ${K.status}`);P(!1),await G.refresh()}catch(K){z(K instanceof Error?K.message:String(K))}finally{te(!1)}},re=async()=>{if(!r)return t();if(!g.trim()&&!x.trim()){C("Enter a name or a project path.");return}y(!0),C(null);try{await r({name:g.trim(),path:x.trim()||void 0}),t()}catch(H){C(H instanceof Error?H.message:String(H)),y(!1)}},V=async(H)=>{if(!l)return t();if(!G.current){C("Enter the folder the repository should be cloned into.");return}y(!0),C(null);try{await l({url:H,parent:G.current,name:g.trim()||void 0}),t()}catch(K){C(K instanceof Error?K.message:String(K)),y(!1)}};return e("div",{className:"fixed inset-0 modal-scrim z-50 flex items-center justify-center p-4",children:[e("div",{className:"glass-overlay bg-paper border border-ink/10 rounded-lg shadow-xl w-[30rem] max-w-full max-h-full overflow-y-auto flex flex-col",children:[e("div",{className:"flex justify-between items-center px-4 pt-4 pb-2 border-b border-ink/10",children:[e("h3",{className:"font-semibold text-sm",children:"New Workspace"}),e("button",{type:"button",onClick:t,"aria-label":"Close",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/10 transition-colors",children:e(b,{size:14})})]}),e("div",{className:"flex px-4 pt-2 space-x-1",children:["create","clone"].map((H)=>e("button",{type:"button",onClick:()=>{p(H),C(null)},"aria-pressed":c===H,className:`px-3 py-1.5 text-xs font-medium rounded-t transition-colors ${c===H?"text-ink border-b-2 border-ink":"text-ink/50 hover:text-ink"}`,children:H==="create"?"Create":"Clone"},H))}),e("div",{className:"px-4 py-3 space-y-3 text-sm text-ink/80",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Workspace Name"," ",e("span",{className:"text-ink/40 font-normal",children:c==="clone"?"(optional: defaults to the repository name)":""})]}),e("input",{type:"text",value:g,onChange:(H)=>h(H.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold mb-1 text-ink",children:[c==="clone"?"Clone Into":"Project Path"," ",e("span",{className:"text-ink/40 font-normal",children:c==="create"?"(optional: binds omp sessions)":""})]}),e(ut,{value:x,onInput:k,onSubmit:()=>void G.navigate(x.trim()||void 0),onRefresh:()=>void G.refresh(),onNewFolder:()=>{F(""),P(!0),z(null)},loading:G.loading,creating:Q,resolved:G.current})]}),e(pt,{directories:G.directories,loading:G.loading,error:G.error,onOpen:(H)=>{k(H.path),G.navigate(H.path)},onRetry:()=>void G.refresh(),creating:I,name:A,onNameChange:F,onCreate:(H)=>void oe(H),onCancelCreate:()=>{P(!1),F(""),z(null)},createError:R,creatingBusy:Q}),e("div",{className:"flex items-center justify-between",children:[e("button",{type:"button",onClick:()=>S(!0),className:"px-3 py-1.5 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5",children:[e(Nt,{size:13}),e("span",{children:"Browse…"})]}),G.parentPath&&e("button",{type:"button",onClick:()=>void G.navigate(G.parentPath??void 0),className:"text-[11px] text-ink/50 hover:text-ink transition-colors",children:"↑ Up one level"})]}),c==="clone"&&e(bt,{parent:G.current,busy:v,onClone:(H)=>void V(H)}),N&&e("div",{className:"text-xs text-error",children:N})]}),e("div",{className:"px-4 py-3 border-t border-ink/10 flex justify-end space-x-2",children:[e("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:t,disabled:v,children:"Cancel"}),c==="create"&&e("button",{type:"button",className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:()=>void re(),disabled:v,children:v?"Creating…":"Create Workspace"})]})]}),T&&e(ws,{initialPath:x||void 0,onSelect:(H)=>{if(k(H),S(!1),!g.trim()){let K=H.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";if(K)h(K)}G.navigate(H)},onClose:()=>S(!1)})]})}async function Zn(t){let r=await t.json().catch(()=>null);if(!t.ok||!r||r.error)return null;return{tasks:r.tasks??[],serverTimeZone:r.serverTimeZone??""}}function xt(t){let[r,l]=n([]),[c,p]=n(""),[g,h]=n(!1),[x,k]=n(null),v=a(async()=>{h(!0);try{let A=await Zn(await fetch("/api/schedule"));if(A){if(l(A.tasks),A.serverTimeZone)p(A.serverTimeZone);k(null)}else k("Could not load scheduled tasks.")}catch(A){k(A instanceof Error?A.message:String(A))}finally{h(!1)}},[]),y=we(Uf,{enabled:t});o(()=>{if(!y.data)return;if(l(y.data.tasks),y.data.serverTimeZone)p(y.data.serverTimeZone);h(!1),k(null)},[y.data]);let N=a(async(A,F)=>{try{let R=await fetch(A,F),z=await R.json().catch(()=>null);if(!R.ok||!z||z.error){let Q=z?.error??`HTTP ${R.status}`;return k(Q),Q}if(z.tasks)l(z.tasks);return k(null),null}catch(R){let z=R instanceof Error?R.message:String(R);return k(z),z}},[]),C=a(async(A)=>await N("/api/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),[N]),T=a(async(A,F)=>N(`/api/schedule?id=${encodeURIComponent(A)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),[N]),S=a(async(A)=>N(`/api/schedule?id=${encodeURIComponent(A)}`,{method:"DELETE"}),[N]),I=a(async(A)=>await N(`/api/schedule?id=${encodeURIComponent(A)}&run=now`,{method:"POST"}),[N]),P=a(async(A)=>{try{let F=await fetch(`/api/schedule/${encodeURIComponent(A)}/runs`),R=await F.json().catch(()=>null);return F.ok?R?.runs??[]:[]}catch{return[]}},[]);return{tasks:r,serverTimeZone:c,loading:g,error:x,refresh:v,create:C,patch:T,remove:S,runNow:I,loadRuns:P}}function Xc(){let t=we(Uf);return u(()=>(t.data?.tasks??[]).filter((r)=>r.enabled).length,[t.data])}var kt=new Map;function vt(t){let r=kt.get(t);if(!r)r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),kt.set(t,r);return r}function Tt(t){if(!t)return!1;try{return vt(t),!0}catch{return!1}}function Ct(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function Ae(t,r){let l=vt(r).formatToParts(new Date(t)),c=(p)=>{let g=l.find((h)=>h.type===p);return g?Number(g.value):0};return{year:c("year"),month:c("month"),day:c("day"),hour:c("hour"),minute:c("minute"),second:c("second")}}function St(t,r){let l=Ae(t,r);return Date.UTC(l.year,l.month-1,l.day,l.hour,l.minute,l.second)-Math.floor(t/1000)*1000}function Ye(t,r,l,c,p,g){let h=Date.UTC(t,r-1,l,c,p),x=St(h,g),k=h-x,v=St(k,g);if(v!==x)k=h-v;let y=Ae(k,g);if(y.year!==t||y.month!==r||y.day!==l||y.hour!==c||y.minute!==p)return null;return k}var qn=60000,Vn={s:1000,sec:1000,secs:1000,second:1000,seconds:1000,m:60000,min:60000,mins:60000,minute:60000,minutes:60000,h:3600000,hr:3600000,hrs:3600000,hour:3600000,hours:3600000,d:86400000,day:86400000,days:86400000,w:604800000,week:604800000,weeks:604800000};function Ot(t){let r=t.trim().toLowerCase();if(!r)return null;if(/^\d+(\.\d+)?$/.test(r)){let g=Number(r);return g>0?Math.round(g*60000):null}let l=r.match(/(\d+(?:\.\d+)?)\s*([a-z]+)/g);if(!l)return null;if(l.join("").replace(/\s+/g,"").length!==r.replace(/\s+/g,"").length)return null;let p=0;for(let g of l){let h=g.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)$/);if(!h)return null;let x=Vn[h[2]];if(!x)return null;p+=Number(h[1])*x}return p>0?Math.round(p):null}var Jn=[[0,59],[0,23],[1,31],[1,12],[0,7]];function Qn(t,r,l){let c=new Set;for(let p of t.split(",")){let[g,h]=p.split("/"),x=h===void 0?1:Number(h);if(!Number.isInteger(x)||x<1)return null;let k,v;if(g==="*")k=r,v=l;else if(g.includes("-")){let[y,N]=g.split("-");k=Number(y),v=Number(N)}else k=Number(g),v=h===void 0?k:l;if(!Number.isInteger(k)||!Number.isInteger(v))return null;if(k<r||v>l||k>v)return null;for(let y=k;y<=v;y+=x)c.add(y)}return c.size?[...c].sort((p,g)=>p-g):null}function eo(t){let r=t.trim().split(/\s+/);if(r.length!==5)return null;let l=r.map((k,v)=>{let[y,N]=Jn[v];return Qn(k,y,N)});if(l.some((k)=>k===null))return null;let[c,p,g,h,x]=l;return{minutes:c,hours:p,daysOfMonth:g,months:h,daysOfWeek:[...new Set(x.map((k)=>k===7?0:k))].sort((k,v)=>k-v),domRestricted:r[2].trim()!=="*",dowRestricted:r[4].trim()!=="*"}}function to(t,r,l,c){let p=new Date(Date.UTC(r,l-1,c)).getUTCDay(),g=t.daysOfMonth.includes(c),h=t.daysOfWeek.includes(p);if(t.domRestricted&&t.dowRestricted)return g||h;if(t.domRestricted)return g;if(t.dowRestricted)return h;return!0}function no(t,r,l){let c=l&&Tt(l)?l:Ct(),p=Ae(r.getTime(),c),g=Date.UTC(p.year+8,p.month-1,p.day);for(let h=Date.UTC(p.year,p.month-1,p.day);h<=g;){let x=new Date(h),k=x.getUTCFullYear(),v=x.getUTCMonth()+1,y=x.getUTCDate();if(!t.months.includes(v)){h=Date.UTC(k,v,1);continue}if(to(t,k,v,y))for(let N of t.hours)for(let C of t.minutes){let T=Ye(k,v,y,N,C,c);if(T!==null&&T>r.getTime())return T}h=Date.UTC(k,v-1,y+1)}return null}var oo=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function Pt(t,r){let l=t.trim();if(!l)return null;if(/^\d+$/.test(l)){let p=Number(l);return p>0?p:null}if(r){let p=l.match(oo);if(p){let[,g,h,x,k,v,y,N]=p,C=Ye(Number(g),Number(h),Number(x),Number(k),Number(v),r);if(C===null)return null;let T=(y?Number(y)*1000:0)+(N?Number(N.padEnd(3,"0")):0);return C+T}}let c=Date.parse(l);return Number.isNaN(c)?null:c}function Rt(t,r,l=Date.now(),c){if(!r.trim())return{ok:!1,error:"Enter a schedule."};if(t==="once"){let h=Pt(r,c);if(h===null)return{ok:!1,error:"Use an ISO timestamp, e.g. 2026-10-01T09:00."};if(h<=l)return{ok:!1,error:"That time is already in the past."};return{ok:!0,nextRunAt:h}}if(t==="every"){let h=Ot(r);if(h===null)return{ok:!1,error:"Use a duration, e.g. 30m, 1h30m, 2 days."};if(h<qn)return{ok:!1,error:"The shortest interval is 1 minute."};return{ok:!0,nextRunAt:l+h}}let p=eo(r);if(!p)return{ok:!1,error:"Use 5 fields: minute hour day-of-month month day-of-week."};let g=no(p,new Date(l),c);if(g===null)return{ok:!1,error:"That expression never matches a date."};return{ok:!0,nextRunAt:g}}function At(t,r,l){let c=r.trim();if(t==="once"){let p=Pt(c,l);return p===null?c:`Once at ${new Date(p).toLocaleString(void 0,l?{timeZone:l}:void 0)}`}if(t==="every"){let p=Ot(c);return p===null?c:`Every ${qe(p)}`}return`Cron ${c}`}function qe(t){let r=Math.round(t/1000),l=Math.floor(r/86400),c=Math.floor(r%86400/3600),p=Math.floor(r%3600/60),g=r%60,h=[];if(l)h.push(`${l}d`);if(c)h.push(`${c}h`);if(p)h.push(`${p}m`);if(g&&!l)h.push(`${g}s`);return h.length?h.join(" "):"0s"}var ro={"always-ask":"Ask before writes",write:"Auto-write, ask before exec",yolo:"Auto-run everything"};function Ve(t){return`${t.provider}/${t.id}`}function so(t){if(!Array.isArray(t))return[];let r=[];for(let l of t){if(!l||typeof l!=="object")continue;if(!("id"in l)||typeof l.id!=="string")continue;if(!("name"in l)||typeof l.name!=="string")continue;if(!("provider"in l)||typeof l.provider!=="string")continue;let c="thinkingLevels"in l&&Array.isArray(l.thinkingLevels)?l.thinkingLevels.filter((p)=>typeof p==="string"):void 0;r.push({id:l.id,name:l.name,provider:l.provider,...c?{thinkingLevels:c}:{}})}return r}function Dt({harness:t,model:r,onHarnessChange:l,onModelChange:c}){let{harnesses:p}=fn(),g=Wa((S)=>{let I=Array.isArray(S.modelList)&&S.modelList.length>0?S.modelList:S.models;return so(I)}),h=es(p,t,g??[]),x=h.models,k=r?x.find((S)=>S.provider===r.provider&&S.id===r.modelId):void 0,v=hc(k?.thinkingLevels),y=pm(p,t),N=(S)=>{if(!S){c(null);return}let I=x.find((P)=>Ve(P)===S);if(!I)return;c({provider:I.provider,modelId:I.id,thinkingLevel:"auto",accessMode:r?.accessMode??"always-ask"})},C=(S)=>{if(!r)return;c({...r,thinkingLevel:S})},T=(S)=>{if(!r)return;c({...r,accessMode:S})};return e("div",{className:"space-y-2",children:[e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Harness"}),e("select",{value:t,onChange:(S)=>l(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[!y.some((S)=>S.id===t)&&e("option",{value:t,children:t}),y.map((S)=>e("option",{value:S.id,children:S.label},S.id))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Model"}),e("select",{value:r?`${r.provider}/${r.modelId}`:"",onChange:(S)=>N(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:t==="omp-rpc"?"Default (composer selection)":"Harness default"}),r&&!x.some((S)=>S.provider===r.provider&&S.id===r.modelId)&&e("option",{value:`${r.provider}/${r.modelId}`,children:[r.provider,"/",r.modelId]}),x.map((S)=>e("option",{value:Ve(S),children:[S.name," · ",S.provider]},Ve(S)))]})]})]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Thinking"}),e("select",{value:r?.thinkingLevel??"auto",disabled:!r||v.length===0,onChange:(S)=>C(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:[e("option",{value:"auto",children:"Auto"}),r&&r.thinkingLevel!=="auto"&&!v.includes(r.thinkingLevel)&&e("option",{value:r.thinkingLevel,children:r.thinkingLevel}),v.map((S)=>e("option",{value:S,children:S},S))]})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Access"}),e("select",{value:r?.accessMode??"always-ask",disabled:!r,onChange:(S)=>T(S.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs disabled:opacity-40",children:Hu.map((S)=>e("option",{value:S,children:ro[S]},S))})]})]}),h.blocked&&e("p",{className:"text-[11px] text-error",children:h.blocked}),h.unprobed&&e("p",{className:"text-[11px] text-ink/40",children:"This harness has not been probed yet; its models appear after a status check."})]})}var Et={once:"Once",every:"Every",cron:"Cron"},io={once:"An ISO timestamp, e.g. 2026-10-01T09:00",every:"A duration, e.g. 30m, 1h30m, 2 days",cron:"5 fields: minute hour day-of-month month day-of-week"},ao={once:"2026-10-01T09:00",every:"1h30m",cron:"0 9 * * 1-5"};function lo(t){let r=t-Date.now();if(r<=0)return"due now";let l=Math.round(r/60000);if(l<60)return`in ${l}m`;let c=Math.round(l/60);if(c<24)return`in ${c}h`;return`in ${Math.round(c/24)}d`}var Ee=null;function co(){if(Ee)return Ee;let t=Intl,r=[];try{r=t.supportedValuesOf?.("timeZone")??[]}catch{r=[]}return Ee=r.length?r:["UTC"],Ee}function uo(t){let r=co();return t&&!r.includes(t)?[t,...r]:r}function Bt({folders:t,initial:r,activeSessionId:l,serverTimeZone:c,busy:p,onSubmit:g,onCancel:h}){let[x,k]=n(""),[v,y]=n(""),[N,C]=n("every"),[T,S]=n("1h"),[I,P]=n("omp-rpc"),[A,F]=n(null),R=c||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",[z,Q]=n(R),[te,G]=n(null),[oe,re]=n(!1);o(()=>{k(r?.name??""),y(r?.prompt??""),C(r?.kind??"every"),S(r?.spec??"1h"),P(r?.harness??"omp-rpc"),F(r?.model??null),Q(r?.timezone??R),G(r?.folderId??null),re(Boolean(r?.sessionId))},[r?.id,R]);let V=Rt(N,T,Date.now(),z),H=Boolean(v.trim())&&V.ok&&!p,K=()=>{if(!H||!V.ok)return;g({name:x.trim(),prompt:v.trim(),kind:N,spec:T.trim(),harness:I,timezone:z,folderId:te,sessionId:oe?r?.sessionId??l:null,model:A})};return e("div",{className:"space-y-3 text-xs",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:["Name ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("input",{type:"text",value:x,onInput:(M)=>k(M.currentTarget.value),placeholder:"Morning standup digest",className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs"})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Prompt"}),e("textarea",{value:v,onInput:(M)=>y(M.currentTarget.value),placeholder:"Describe the task, ask a question, or paste commands…",rows:4,className:"w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 outline-none focus:border-ink/50 text-xs resize-y min-h-[80px]"})]}),e("div",{className:"flex items-end gap-2",children:[e("div",{className:"w-28 flex-shrink-0",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Schedule"}),e("select",{value:N,onChange:(M)=>C(M.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:Object.keys(Et).map((M)=>e("option",{value:M,children:Et[M]},M))})]}),e("div",{className:"flex-1",children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"When"}),e("input",{type:"text",value:T,onInput:(M)=>S(M.currentTarget.value),placeholder:ao[N],className:`w-full bg-paper border rounded px-2.5 py-1.5 outline-none text-xs font-mono ${V.ok?"border-ink/20 focus:border-ink/50":"border-error/50 focus:border-error"}`})]})]}),e("p",{className:`text-[11px] ${V.ok?"text-ink/50":"text-error"}`,children:V.ok?`Next run ${lo(V.nextRunAt)} · ${new Date(V.nextRunAt).toLocaleString(void 0,{timeZone:z})} · ${z}`:V.error}),e("p",{className:"text-[11px] text-ink/40",children:io[N]}),e("div",{className:"grid grid-cols-2 gap-2",children:[e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Timezone"}),e("select",{value:z,onChange:(M)=>Q(M.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:uo(z).map((M)=>e("option",{value:M,children:M},M))})]}),e("div",{children:[e("label",{className:"block font-semibold mb-1 text-ink",children:"Run in"}),e("select",{value:te===null?"":String(te),onChange:(M)=>G(M.currentTarget.value?Number(M.currentTarget.value):null),className:"w-full bg-paper border border-ink/20 rounded px-2 py-1.5 outline-none focus:border-ink/50 text-xs",children:[e("option",{value:"",children:"Server default directory"}),t.map((M)=>e("option",{value:M.id,children:M.name},M.id))]})]})]}),e(Dt,{harness:I,model:A,onHarnessChange:(M)=>{P(M),F(null)},onModelChange:F}),e("label",{className:`flex items-center gap-2 text-[11px] ${l?"text-ink/70":"text-ink/35"}`,children:[e("input",{type:"checkbox",checked:oe,disabled:!l,onChange:(M)=>re(M.currentTarget.checked),className:`${he} accent-ink`}),e("span",{children:"Resume the open session each run"})]}),e("div",{className:"flex justify-end gap-2 pt-1",children:[e("button",{type:"button",onClick:h,disabled:p,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),e("button",{type:"button",onClick:K,disabled:!H,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-40",children:[p&&e(m,{size:12,className:"animate-spin"}),r?"Save changes":"Schedule task"]})]})]})}function po(t){return t===null?"–":new Date(t).toLocaleString()}function mo(t){if(t.name)return t.name;let r=t.prompt.replace(/\s+/g," ").trim();return r.length>60?`${r.slice(0,57)}…`:r||"(empty prompt)"}function Ft({tasks:t,loading:r,pending:l,onRunNow:c,onToggleEnabled:p,onEdit:g,onDelete:h,loadRuns:x}){let[k,v]=n(null),[y,N]=n([]),[C,T]=n(!1);if(o(()=>{if(!k)return;let S=!0;return T(!0),x(k).then((I)=>{if(!S)return;N(I),T(!1)}),()=>{S=!1}},[k,x]),t.length===0)return e("div",{className:"px-3 py-8 text-center text-[11px] text-ink/50 border border-dashed border-ink/15 rounded-lg",children:r?"Loading…":"No scheduled tasks yet. Create one above."});return e("ul",{className:"space-y-2",children:t.map((S)=>{let I=l===S.id,P=k===S.id;return e("li",{className:"border border-ink/10 rounded-lg bg-paper",children:[e("div",{className:"flex items-start gap-2 p-2.5",children:[e("span",{className:"mt-0.5 shrink-0","aria-hidden":"true",children:!S.enabled?e(yo,{size:14,className:"text-ink/40"}):S.lastStatus==="error"?e(E,{size:14,className:"text-error"}):S.lastStatus==="success"?e(ne,{size:14,className:"text-ink/60"}):e(Nn,{size:14,className:"text-ink/60"})}),e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"text-xs font-medium text-ink truncate",children:mo(S)}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:[At(S.kind,S.spec,S.timezone),S.kind!=="every"&&e(d,{children:[e("span",{className:"text-ink/30",children:" · "}),S.timezone]}),e("span",{className:"text-ink/30",children:" · "}),!S.enabled?S.kind==="once"&&S.lastRunAt!==null?"Ran once, with no next run":"Paused":`Next ${po(S.nextRunAt)}`]}),S.cwd&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:S.cwd}),e("p",{className:"text-[10.5px] text-ink/40 truncate mt-0.5",children:[S.harness,S.model&&` · ${S.model.provider}/${S.model.modelId}`]}),S.sessionId&&e("p",{className:"text-[10.5px] text-ink/40 font-mono truncate mt-0.5",children:["resumes ",S.sessionId.slice(0,8)]}),S.lastStatus==="error"&&S.lastError&&e("p",{className:"text-[10.5px] text-error mt-0.5 break-words",children:S.lastError}),S.runCount>0&&e("p",{className:"text-[10.5px] text-ink/40 mt-0.5",children:["Fired ",S.runCount,"×"]})]}),e("div",{className:"flex items-center gap-1 shrink-0",children:[e("button",{type:"button",title:"Run now","aria-label":"Run now",disabled:I,onClick:()=>c(S.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:I?e(m,{size:13,className:"animate-spin"}):e(xa,{size:13})}),e("button",{type:"button",title:S.enabled?"Pause":"Resume","aria-label":S.enabled?"Pause":"Resume","aria-pressed":S.enabled,disabled:I,onClick:()=>p(S),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:S.enabled?e(yo,{size:13}):e(xa,{size:13})}),e("button",{type:"button",title:"Edit","aria-label":"Edit",disabled:I,onClick:()=>g(S),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors disabled:opacity-40",children:e(Fn,{size:13})}),e("button",{type:"button",title:"Delete","aria-label":"Delete",disabled:I,onClick:()=>h(S.id),className:"p-1.5 rounded hover:bg-ink/5 text-ink/60 hover:text-error transition-colors disabled:opacity-40",children:e(L,{size:13})})]})]}),e("button",{type:"button",onClick:()=>v(P?null:S.id),"aria-expanded":P,className:"w-full text-left px-2.5 py-1.5 border-t border-ink/5 text-[10.5px] text-ink/50 hover:text-ink transition-colors",children:P?"Hide run history":"Run history"}),P&&e("div",{className:"px-2.5 pb-2.5 space-y-1",children:[C&&e("p",{className:"text-[10.5px] text-ink/40",children:"Loading…"}),!C&&y.length===0&&e("p",{className:"text-[10.5px] text-ink/40",children:"This task has not run yet."}),!C&&y.map((A)=>e("div",{className:"flex items-start gap-2 text-[10.5px]",children:[e("span",{className:"w-16 shrink-0 text-ink/50",children:new Date(A.startedAt).toLocaleTimeString()}),e("span",{className:`w-14 shrink-0 font-medium ${A.status==="error"?"text-error":A.status==="running"?"text-ink/60":"text-ink/70"}`,children:A.status}),e("span",{className:"w-12 shrink-0 text-ink/40",children:A.finishedAt===null?"…":qe(A.finishedAt-A.startedAt)}),e("span",{className:"min-w-0 flex-1 text-ink/60 break-words",children:[A.detail||"–",A.sessionId&&e("span",{className:"block font-mono text-[10px] text-ink/40",children:["session ",A.sessionId.slice(0,8)]})]})]},A.id))]})]},S.id)})})}function Lt(){let[t,r]=n([]);return o(()=>{let l=!0;return fetch("/api/settings/projects").then((c)=>c.json()).then((c)=>{if(!l)return;r((c.projects??[]).filter((p)=>typeof p.folderId==="number").map((p)=>({id:p.folderId,name:p.name})))}).catch((c)=>console.error("Failed to load workspace folders:",c)),()=>{l=!1}},[]),t}function eu({isOpen:t,onClose:r,activeSessionId:l=null,onToast:c}){let p=xt(t),g=Lt(),[h,x]=n(null),[k,v]=n(!1),[y,N]=n(!1),[C,T]=n(null);if(o(()=>{if(t)return;x(null),v(!1),N(!1),T(null)},[t]),o(()=>{let R=(z)=>{if(z.key!=="Escape"||y)return;if(z.preventDefault(),h||k){x(null),v(!1);return}r()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,y,h,k]),!t)return null;let S=async(R)=>{N(!0);let z=h?await p.patch(h.id,R):await p.create(R);if(N(!1),z){c?.(z,"error");return}c?.(h?"Scheduled task updated.":"Scheduled task created.","success"),x(null),v(!1)},I=async(R)=>{T(R.id);let z=await p.patch(R.id,{enabled:!R.enabled});if(T(null),z)c?.(z,"error")},P=async(R)=>{T(R);let z=await p.runNow(R);if(T(null),z){c?.(z,"error");return}c?.("Task dispatched. Open the session to watch it run.","success")},A=async(R)=>{T(R);let z=await p.remove(R);if(T(null),z){c?.(z,"error");return}if(h?.id===R)x(null)},F=h!==null||k;return e("div",{className:"fixed inset-0 modal-scrim backdrop-blur-[2px] z-50 flex items-center justify-center p-4",onClick:y?void 0:r,role:"dialog","aria-modal":"true","aria-label":"Scheduled tasks",children:e("div",{className:"glass-overlay bg-paper border border-ink/15 rounded-xl shadow-2xl w-[min(94vw,640px)] max-h-[88vh] flex flex-col overflow-hidden text-ink",onClick:(R)=>R.stopPropagation(),children:[e("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[e("div",{className:"flex items-center gap-2",children:[e(Sa,{size:15}),e("h3",{className:"font-semibold text-sm",children:"Scheduled Tasks"})]}),e("button",{type:"button",onClick:r,"aria-label":"Close",className:"p-1.5 -m-1.5 rounded text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors",children:e(b,{size:16})})]}),e("div",{className:"p-4 overflow-y-auto space-y-4",children:[p.error&&!F&&e("p",{className:"text-[11px] text-error border border-error/30 bg-error/5 rounded px-2.5 py-1.5",children:p.error}),F?e(Bt,{folders:g,initial:h,activeSessionId:l,serverTimeZone:p.serverTimeZone,busy:y,onSubmit:S,onCancel:()=>{x(null),v(!1)}}):e("button",{type:"button",onClick:()=>v(!0),className:"w-full py-2 rounded-lg border border-dashed border-ink/20 text-xs font-medium text-ink/70 hover:text-ink hover:border-ink/40 transition-colors",children:"+ New scheduled task"}),!F&&e(Ft,{tasks:p.tasks,loading:p.loading,pending:C,onRunNow:P,onToggleEnabled:I,onEdit:(R)=>x({id:R.id,name:R.name,prompt:R.prompt,kind:R.kind,spec:R.spec,harness:R.harness,timezone:R.timezone,folderId:R.folderId,sessionId:R.sessionId,model:R.model}),onDelete:A,loadRuns:p.loadRuns})]})]})})}var Je=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],Mt={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function $o({variant:t,sortOption:r,onSortChange:l}){if(t==="mobile")return e(d,{children:[e("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),Je.map((c)=>e("button",{type:"button",onClick:()=>l(c),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${r===c?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[e("span",{children:c.replace("_"," ")}),r===c&&e(f,{size:13,className:"text-ink"})]},c))]});return e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),Je.map((c)=>e("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${r===c?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(c),children:[e("span",{children:Mt[c]}),r===c&&e("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},c))]})}function tu({actions:t,sortHidden:r,sortOption:l,onSortChange:c,layout:p="desktop"}){let g=p==="mobile",[h,x]=n(!1),k=i(null);pe(k,()=>x(!1)),o(()=>{if(!h)return;let y=(N)=>{if(N.key==="Escape")x(!1)};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[h]);let v=(y)=>{x(!1),y.onSelect()};return e("div",{className:"relative shrink-0",ref:k,children:[e("button",{type:"button",title:"More sidebar actions","aria-label":"More sidebar actions","aria-haspopup":"menu","aria-expanded":h,onClick:()=>x(!h),className:`inline-flex items-center justify-center transition-colors cursor-pointer ${g?"w-9.5 h-9.5 rounded-xl border active:scale-95 shadow-xs":"w-7 h-7 rounded border"} ${h?"border-ink/30 bg-ink/10 text-ink":"border-ink/15 bg-paper text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e(Be,{size:g?16:14})}),h&&e("div",{role:"menu",className:`glass-popover absolute right-0 top-full mt-2 w-52 bg-paper border border-ink/15 shadow-lg z-50 py-1 text-xs ${g?"rounded-xl p-2":"rounded-lg"}`,children:[t.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>v(y),"aria-pressed":y.active,className:`w-full text-left flex items-center gap-2 transition-colors ${g?"px-2.5 py-1.5 rounded-lg":"px-3 py-1.5"} ${y.active?"bg-ink/5 text-ink font-medium":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e(y.icon,{size:13}),e("span",{children:y.label})]},y.id)),r&&e("div",{className:"mt-1 border-t border-ink/10 pt-1",children:e($o,{variant:p,sortOption:l,onSortChange:c})})]})]})}function ds(t){let r=i(null),[l,c]=n(0);return W(()=>{let p=r.current;if(!p)return;let g=()=>c(Math.max(0,p.clientWidth-t));if(g(),typeof ResizeObserver>"u")return;let h=new ResizeObserver(g);return h.observe(p),()=>h.disconnect()},[t]),{ref:r,width:l}}var yd=["new-workspace","refresh","search","select","archive","scheduler","sort"];var mg=8;function fg(t){let r=yd.length;if(!(t>0))return r;let l=t-112-6-8;if(r*28+(r-1)*6<=l)return r;let p=Math.floor((l-28-8)/34);return Math.max(2,Math.min(r,p))}var fo=38,ho=8,bo=126,go=1,vd=["new-workspace","refresh","archive","sort","scheduler","select"];function gg(t){let r=vd.length;if(!(t>0))return r;let l=fo+ho,c=Math.floor((t-bo)/l);if(c>=r)return r;return Math.max(go,Math.min(r,c-1))}function ps(t=5,r=7){let[l,c]=n(t),p=a(()=>c((h)=>h+r),[r]),g=a(()=>c(t),[t]);return{visibleCount:l,showMore:p,showLess:g,canShowLess:l>t}}function ms(t,r,l){let[c,p]=n(!1),g=st(),h=st(),{handleArchive:x,handleRename:k,handleRenameWithAi:v}=mm(r,l),y=()=>{if(typeof t.id!=="number")return;g.submit({isPinned:String(!t.isPinned)},{method:"POST",action:`/api/folders/${t.id}/pin`}),r()},N=()=>{if(typeof t.id!=="number")return;h.submit({},{method:"POST",action:`/api/folders/${t.id}/delete`}),p(!1),r()},C=t.project_path?()=>{(async()=>{try{let T=await fetch(`/api/folders/${encodeURIComponent(String(t.id))}/open`,{method:"POST"}),S=await T.json().catch(()=>({}));if(!T.ok)l?.(S.error||`Could not open the folder (HTTP ${T.status})`)}catch(T){l?.(T instanceof Error?T.message:String(T))}})()}:void 0;return{confirmDelete:c,requestDelete:()=>p(!0),cancelDelete:()=>p(!1),handlePin:y,handleOpenFolder:C,handleDelete:N,handleArchive:x,handleRename:k,handleRenameWithAi:v}}function Nr({checked:t,indeterminate:r=!1,label:l,onChange:c,size:p="sm"}){let g=i(null);return o(()=>{if(g.current)g.current.indeterminate=r},[r]),e("input",{ref:g,type:"checkbox",checked:t,"aria-label":l,onChange:c,onClick:(h)=>h.stopPropagation(),className:`${he} shrink-0 accent-ink cursor-pointer ${p==="md"?"w-3.5 h-3.5":"w-3 h-3"}`})}function xo(t){let r=t.branch||(t.detached?"detached":"worktree");return t.status==="missing"?`${r} · ${"missing"}`:r}function ko(t){if(t.status==="missing")return`Worktree folder is missing: ${t.path}`;return t.detached?`Detached HEAD in worktree ${t.path}`:`Runs in worktree ${t.path}`}function fs({worktree:t}){let r=t.status==="missing";return e("span",{className:`flex min-w-0 items-center gap-1 truncate text-[10px] font-normal ${r?"text-warning":"text-ink/45"}`,title:ko(t),"data-worktree-status":t.status,children:[e("span",{"aria-hidden":"true",className:"shrink-0 font-mono",children:"⑂"}),e("span",{className:"truncate",children:xo(t)})]})}var So=1000,Fe=new Set,Oe=null;function vo(){let t=Date.now();for(let r of Fe)r(t)}function wo(t){if(Fe.add(t),Oe===null)Oe=setInterval(vo,So);return()=>{if(Fe.delete(t),Fe.size===0&&Oe!==null)clearInterval(Oe),Oe=null}}function $t(t=!0){let[r,l]=n(()=>Date.now());return o(()=>{if(!t)return;return wo(l)},[t]),r}function gs(t,r=Date.now()){if(t===null||t===void 0||t==="")return null;let l=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(l))return null;let c=Math.round((r-l)/1000);if(c<45)return"now";let p=Math.round(c/60);if(p<60)return`${p}m`;let g=Math.round(p/60);if(g<24)return`${g}h`;let h=Math.round(g/24);if(h<7)return`${h}d`;let x=Math.round(h/7);if(x<5)return`${x}w`;let k=new Date(l),v=k.getFullYear()===new Date(r).getFullYear(),y=k.getDate(),N=k.toLocaleString("en-US",{month:"short"});return v?`${y} ${N}`:`${y} ${N} ${k.getFullYear()}`}function zo(t){if(t===null||t===void 0||t==="")return null;let r=typeof t==="number"?t:Date.parse(t);if(Number.isNaN(r))return null;return new Date(r).toLocaleString("en-US",{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function zt(t){if(!Number.isFinite(t)||t<1000)return"0s";return Am(t)??"0s"}function Ut({startedAt:t,className:r}){let l=$t(),c=zt(Math.max(0,l-t)),p=u(()=>zo(t),[t]);return e("span",{role:"timer",className:`tabular-nums ${r??""}`,title:p?`Started ${p}`:void 0,"aria-label":`Running for ${c}`,children:c})}var Co="text-ink/40",Io="text-ink/80";function As({timeAgo:t,timeTitle:r,runStartedAt:l,className:c,restingClassName:p=Co}){if(l!==void 0)return e(Ut,{startedAt:l,className:`${c} ${Io}`});if(!t)return null;return e("span",{className:`${c} ${p}`,title:r??void 0,children:t})}var hs="bg-ink/10 text-ink ring-1 ring-inset ring-ink/20";function bs({variant:t,isPinned:r=!1,onOpenFolder:l,onSelectSessions:c,onNewWorktree:p,confirmDelete:g,onPin:h,onDelete:x,onRequestDelete:k,onCancelDelete:v}){if(t==="mobile")return g?e(d,{children:[e("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:x,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(L,{size:13}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(Nt,{size:13}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:h,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[r?e(ml,{size:13}):e(Ta,{size:13}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(Qr,{size:13}),e("span",{children:"Select sessions"})]}),p&&e("button",{type:"button",onClick:p,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[e(ge,{size:13}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[e(L,{size:13}),e("span",{children:"Delete Workspace"})]})]});return g?e(d,{children:[e("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),e("button",{type:"button",onClick:x,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(L,{size:12}),e("span",{children:"Yes, delete"})]}),e("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",children:e("span",{children:"Cancel"})})]}):e(d,{children:[l&&e("button",{type:"button",onClick:l,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(Nt,{size:12}),e("span",{children:"Go to Explorer"})]}),e("button",{type:"button",onClick:h,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[r?e(ml,{size:12}):e(Ta,{size:12}),e("span",{children:r?"Unpin Workspace":"Pin Workspace"})]}),c&&e("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(Qr,{size:12}),e("span",{children:"Select sessions"})]}),p&&e("button",{type:"button",onClick:p,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",children:[e(ge,{size:12}),e("span",{children:"New worktree…"})]}),e("button",{type:"button",onClick:k,className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",children:[e(L,{size:12}),e("span",{children:"Delete Workspace"})]})]})}function _e({ancestors:t,isLast:r,first:l,style:c}){let p=c.insetPx+c.slotWidth/2,g=c.slotWidth/2+c.markGap+c.glyph/2,h=g+c.insetPx-p,x=2,k=p-1,v=l?r?{left:k,top:-6,height:"calc(50% + 6px)"}:{left:k,top:-6,bottom:-2}:r?{left:k,top:0,height:"50%"}:{left:k,top:0,bottom:-2};return e(d,{children:[t.map((y,N)=>e("span",{"data-guide":"ancestor","data-continues":y?void 0:"true","aria-hidden":"true",className:"relative shrink-0",style:{width:g},children:!y&&e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:0,bottom:-2,width:2}})},N)),e("span",{"data-guide":"connector","data-last":r?"true":void 0,"data-first":l?"true":void 0,"aria-hidden":"true",className:"relative shrink-0",style:{width:g},children:[e("span",{className:"absolute z-10 bg-ink/40",style:{width:2,...v}}),e("span",{className:"absolute z-10 bg-ink/40",style:{left:k,top:"calc(50% - 1px)",width:h+1,height:2}})]})]})}function Gt({subagent:t,sessionId:r,style:l,running:c}){let[p]=le(),g=t.id===p.get("subagent"),h=HA(t),x=t.task??t.assignment??t.description??h;return e("div",{className:"group/subagent-row flex items-center",children:[e("button",{type:"button",title:x,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:r,subagent:t}})),className:`flex-1 min-w-0 flex items-center text-left text-xs rounded-md ${l.inset} ${l.padding} cursor-pointer transition-colors select-none ${g?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[e("span",{"data-testid":"subagent-status-slot",className:"w-4 h-4 flex items-center justify-center shrink-0",children:e(hm,{status:t.status,live:c,size:11})}),e("span",{className:"w-2 shrink-0"}),e("span",{"data-testid":"subagent-mark",className:"mr-1.5 flex shrink-0 items-center text-ink/55",children:e(wt,{size:l.glyph,"aria-hidden":"true"})}),e("span",{className:"flex-1 min-w-0 truncate leading-snug",children:h})]}),c&&e("button",{type:"button",title:"Stop this subagent","aria-label":"Stop this subagent",onClick:()=>void bm(r,t.id),className:"touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer",children:e(Yn,{size:10})})]})}var Oo={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function Po(t,r){return t.map((l)=>{if(r.id!==void 0){if(l.id!==r.id)return l}else if(r.index===void 0||r.index<0||l.index!==r.index)return l;let c=r.status&&l.status==="started"?Oo[r.status]??l.status:l.status;return{...l,status:c,progress:{...l.progress,...r},lastUpdate:Date.now()}})}function jt(t,r,l){let[c,p]=n([]),[g,h]=n(!1);return o(()=>{if(!l)return;let x=!1;return p([]),h(!0),WA(t).then((k)=>{if(x||!k)return;let v=k.map(ym);p((y)=>xm(y,v))}).finally(()=>{if(!x)h(!1)}),()=>{x=!0}},[t,l]),o(()=>{if(!l||!r)return;let x=!1,k=Date.now(),v=(C)=>C.sessionId===t?C.payload:null,y=Ys("subagent_lifecycle",(C)=>{let T=vm(v(C));if(T)p((S)=>xm(S,[T]))}),N=Ys("subagent_progress",(C)=>{let T=km(v(C));if(T)p((S)=>Po(S,T))});return fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then((C)=>C.ok?C.json():null).then((C)=>{if(x||!w(C))return;let T="data"in C?C.data:C;p((S)=>xm(S,KA(T),k))}).catch(()=>{}),()=>{x=!0,y(),N()}},[l,r,t]),{subagents:c,isLoading:g}}function ys(t,r,l,c,p=!1){let g=String(t.id);return{expandable:(r.get(g)?.length??0)>0||Boolean(t.hasSubagents),isExpanded:l.has(g),onToggleExpand:()=>c(g),isChild:p}}function gi({parentId:t,hasSubagents:r,childrenOf:l,expandedIds:c,onToggle:p,activeSessionId:g,renderSession:h,style:x,ancestors:k=[]}){let v=l.get(t)??[],{subagents:y,isLoading:N}=jt(t,g===t,r),C=[...v.map((T)=>({kind:"session",session:T})),...y.map((T)=>({kind:"subagent",subagent:T}))];if(C.length===0){if(!N)return null;return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:!0,first:!0,style:x}),e("div",{className:`flex min-w-0 flex-1 items-center text-xs italic text-ink/40 ${x.inset} ${x.padding}`,children:"Loading subagents…"})]})})}return e("div",{"data-testid":"session-branch",className:"space-y-0.5",children:C.map((T,S)=>{let I=S===C.length-1;if(T.kind==="subagent")return e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:I,first:S===0,style:x}),e("div",{className:"min-w-0 flex-1",children:e(Gt,{subagent:T.subagent,sessionId:t,style:x,running:g===t&&T.subagent.status==="started"})})]},`subagent:${T.subagent.id}`);let P=String(T.session.id),F={expandable:(l.get(P)?.length??0)>0||Boolean(T.session.hasSubagents),isExpanded:c.has(P),onToggleExpand:()=>p(P),isChild:!0};return e(d,{children:[e("div",{className:"flex items-stretch",children:[e(_e,{ancestors:k,isLast:I,first:S===0,style:x}),e("div",{className:"min-w-0 flex-1",children:h(T.session,F)})]}),F.isExpanded&&e(gi,{parentId:P,hasSubagents:Boolean(T.session.hasSubagents),childrenOf:l,expandedIds:c,onToggle:p,activeSessionId:g,renderSession:h,style:x,ancestors:[...k,I]})]},P)})})}function vs(t){let r=new Set(t.map((p)=>String(p.id))),l=new Map,c=[];for(let p of t){let g=p.parentSessionId;if(!g||!r.has(g)||g===String(p.id)){c.push(p);continue}let h=l.get(g);if(h)h.push(p);else l.set(g,[p])}return{roots:c,childrenOf:l}}function Kt(t,r){return t.includes(r)?t.filter((l)=>l!==r):[...t,r]}function Xt(t,r){let l=new Set(t),c=r.filter((p)=>l.has(p)).length;return{count:c,all:r.length>0&&c===r.length,some:c>0&&c<r.length}}function Le(t,r){return t.filter((l)=>r?l.is_archived===1:l.is_archived!==1).map((l)=>String(l.id))}function Zt(t,r){let l=new Set(r);return t.filter((c)=>l.has(c))}function Yt(t,r,{activeSessionId:l,sessionStatus:c={}}){if(t.length<=r)return{rendered:t,hiddenCount:0};let p=[],g=0;for(let h=0;h<t.length;h+=1){let x=t[h],k=String(x.id),y=(l!==null?String(l)===k:x.is_active===1)||c[k]==="stream"||Boolean(x.awaitingInput);if(h<r||y)p.push(x);else g+=1}return{rendered:p,hiddenCount:g}}function qt(t,r){return t.mode==="workspace"||t.mode==="session"&&t.scopeFolderId===r}function Vt(t,r){return t.mode==="session"&&t.scopeFolderId===r}function ks({batch:t,folder:r,sessions:l,showArchived:c,visibleCount:p,activeSessionId:g,sessionStatus:h}){let x=t?qt(t,r.id):!1,k=t?Vt(t,r.id):!1,v=k?Le(l,c):x?[String(r.id)]:[],y=t&&x?t.summaryOf(v):null,N=Yt(l,p,{activeSessionId:g,sessionStatus:h});return{folderCheckbox:x,sessionCheckboxes:k,folderSummary:y,selectableIds:v,toggleFolderSelection:()=>{if(!t)return;if(x&&!k){t.toggle(String(r.id));return}if(!k)return;if(y?.all)t.unselectAllOf(v);else t.selectAllOf(v)},rendered:k?l:N.rendered,hiddenCount:k?0:N.hiddenCount}}function xs({touch:t=!1,onRetry:r,refreshing:l=!1}){return e("div",{role:"alert",className:`flex flex-col items-center justify-center gap-2 px-4 text-center ${t?"py-10":"py-8"}`,children:[e("span",{className:"flex h-8 w-8 items-center justify-center rounded-md border border-ink/10 bg-ink/5 text-muted",children:e(_,{size:15,"aria-hidden":"true"})}),e("p",{className:"text-xs font-semibold text-ink",children:"The session list could not be loaded."}),e("p",{className:`text-muted leading-relaxed ${t?"text-xs":"text-[11px]"}`,children:"The live connection closed before the first reply arrived. Your sessions are still on disk; they are not shown here because this tab never received them."}),e("button",{type:"button",onClick:r,disabled:l,"aria-busy":l,className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-ink/20 bg-paper px-2.5 font-medium text-ink transition-colors hover:bg-ink/5 disabled:opacity-60 ${t?"h-11 text-sm":"h-7 text-xs"}`,children:[e(D,{size:13,className:l?"animate-spin":void 0,"aria-hidden":"true"}),"Try again"]})]})}function Jt({value:t,onChange:r,touch:l=!1}){return e("div",{className:l?"px-3 pt-3 pb-2":"px-3 pt-2 pb-2",children:e("div",{className:`flex items-center gap-1.5 rounded-lg border border-ink/10 bg-ink/[0.04] px-2 transition-colors focus-within:border-ink/30 focus-within:bg-paper ${l?"h-9":"h-7"}`,children:[e(O,{size:l?15:13,"aria-hidden":"true",className:"shrink-0 text-ink/35"}),e("input",{type:"search",value:t,onChange:(c)=>r(c.currentTarget.value),placeholder:"Search workspaces & sessions","aria-label":"Search workspaces and sessions",className:`min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink/40 ${l?"text-[13px]":"text-xs"}`}),t.length>0&&e("button",{type:"button",onClick:()=>r(""),title:"Clear search","aria-label":"Clear search",className:"-mr-0.5 shrink-0 rounded p-0.5 text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink",children:e(b,{size:l?14:12})})]})})}var Pe={all:32,running:72,runningCount:14,archived:79,select:66};function Ao(t,r){let l=[Pe.all,Pe.running+(t>0?Pe.runningCount:0),Pe.archived,...r?[Pe.select]:[]];return l.reduce((c,p)=>c+p,0)+(l.length-1)*4}function Qt(t,r){if(!(t>0))return"button";return Ao(r,!0)<=t?"chip":"button"}var Me="inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors cursor-pointer",Qe="border-ink bg-ink text-paper",$e="border-ink/15 text-ink/60 hover:border-ink/30 hover:text-ink",Eo=(t)=>t?"Cancel":"Select";function en({focus:t,onFocusChange:r,runningCount:l,showArchived:c,onToggleArchived:p,selecting:g,onToggleSelect:h}){let{ref:x,width:k}=ds(0),v=Qt(k,l),y=g?e(b,{size:10}):e(Qr,{size:10});return e("div",{className:"px-3 pb-2",children:e("div",{ref:x,className:"flex flex-nowrap items-center gap-1",children:[e("div",{className:"flex shrink-0 items-center gap-1",role:"group","aria-label":"Session filters",children:[e("button",{type:"button",onClick:()=>r("all"),"aria-pressed":t==="all",className:`${Me} ${t==="all"?Qe:$e}`,children:"All"}),e("button",{type:"button",onClick:()=>r("running"),"aria-pressed":t==="running",title:l>0?`${l} running or waiting`:"Nothing running",className:`${Me} ${t==="running"?Qe:$e}`,children:[e("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${l>0?"bg-current":"bg-current opacity-30"}`}),"Running",l>0&&e("span",{className:"font-mono tabular-nums opacity-70",children:l})]}),e("button",{type:"button",onClick:p,"aria-pressed":c,title:c?"Hide archived sessions":"Show archived sessions",className:`${Me} ${c?"border-warning/40 bg-warning/10 text-warning hover:bg-warning/15":$e}`,children:[e(Xe,{size:10}),"Archived"]})]}),v==="chip"?e("button",{type:"button",onClick:h,"aria-pressed":g,title:g?"Cancel selection":"Select workspaces",className:`${Me} ml-auto ${g?Qe:$e}`,children:[y,Eo(g)]}):e("button",{type:"button",onClick:h,title:g?"Cancel selection":"Select workspaces","aria-label":g?"Cancel selection":"Select workspaces","aria-pressed":g,className:`ml-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors cursor-pointer ${g?"bg-ink/10 text-ink":"text-ink/55 hover:bg-ink/[0.06] hover:text-ink"}`,children:g?e(b,{size:14}):e(Qr,{size:14})})]})})}var Bo="shrink-0 inline-flex items-center justify-center rounded-md text-ink/55 transition-colors cursor-pointer hover:bg-ink/[0.06] hover:text-ink",_o="bg-ink/10 text-ink",tn={"A-Z":"A–Z","Z-A":"Z–A",LATEST_SESSION:"Latest chat",LATEST_ADDED:"Latest added"};function nn({onNewSession:t,onNewWorkspace:r,onScheduler:l,scheduledCount:c,onRefresh:p,refreshing:g,sortOption:h,optionsOpen:x,onToggleOptions:k,onCloseOptions:v,onSortChange:y,touch:N=!1}){let C=`${Bo} ${N?cn.mobile:cn.desktop}`,T=c>0?`Scheduled tasks (${c} armed)`:"Scheduled tasks";return e("div",{className:`flex items-center ${Js} px-3 pb-2`,children:[e("button",{type:"button",onClick:t,title:"New Session","aria-label":"New Session",className:`flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md bg-ink px-2 font-semibold text-canvas transition-colors cursor-pointer hover:bg-ink/90 ${N?"h-9 text-[13px]":"h-7 text-xs"}`,children:[e(Y,{size:N?16:14,className:"shrink-0"}),e("span",{className:"truncate",children:"New Session"})]}),e("div",{className:`flex shrink-0 items-center ${yc}`,children:[e("button",{type:"button",onClick:r,title:"New Workspace","aria-label":"New Workspace",className:C,children:e(on,{size:N?16:14})}),e("button",{type:"button",onClick:l,title:T,"aria-label":c>0?`Scheduled tasks, ${c} armed`:"Scheduled tasks",className:`relative ${C}`,children:[e(Sa,{size:N?16:14}),c>0&&e("span",{className:"absolute right-0.5 top-0.5 min-w-[10px] rounded-full bg-ink px-[2px] text-center text-[7px] font-semibold leading-[10px] text-canvas",children:c>9?"9+":c})]}),e("button",{type:"button",onClick:p,title:"Refresh sessions","aria-label":"Refresh sessions","aria-busy":g,className:C,children:e(D,{size:N?16:14,className:g?"animate-spin":""})}),e("div",{className:"relative",children:[e("button",{type:"button",onClick:k,title:`Sort: ${tn[h]}`,"aria-label":`Sort workspaces, currently ${tn[h]}`,"aria-haspopup":"menu","aria-expanded":x,className:`${C} ${x||h!=="A-Z"?_o:""}`,children:e(us,{size:N?16:14})}),x&&e("div",{className:"glass-popover absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-ink/15 bg-paper py-1 shadow-lg",onMouseLeave:v,children:e($o,{variant:"desktop",sortOption:h,onSortChange:y})})]})]})]})}function rn({title:t,status:r,awaitingInput:l=!1,renaming:c=!1,waitingFor:p,expandable:g=!1,isExpanded:h=!1,onToggleExpand:x,child:k=!1,selectable:v=!1,selected:y=!1,onToggleSelect:N,touch:C=!1}){if(v)return e("span",{className:"flex shrink-0 items-center",children:[e(Nr,{checked:y,label:`Select ${t}`,onChange:()=>N?.()}),e("span",{className:"w-2 shrink-0"})]});let T=C?14:13,S=Boolean(p),I=l||r==="stream"||S,P=Boolean(g&&x)&&!I&&!c,A=Boolean(c||l||S||r)&&!P;return e(d,{children:[e("span",{className:`relative shrink-0 ${C?"w-[18px] h-5":"w-4 h-4"}`,children:[g&&x&&e("button",{type:"button",onClick:(F)=>{F.stopPropagation(),x(F)},title:h?"Collapse sessions and subagents":"Expand sessions and subagents","aria-expanded":h,"aria-label":h?"Collapse sessions and subagents":"Expand sessions and subagents",className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${P?"text-ink/55 hover:text-ink":"text-ink/40 opacity-0 hover:text-ink group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:h?e(B,{size:T}):e(ie,{size:T})}),A&&e("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${g?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:c?e("span",{role:"status","aria-label":"Generating a name…",children:e(m,{size:T-1,className:"animate-spin"})}):l?e(De,{size:T-1,className:"animate-pulse text-warning"}):S?e("span",{role:"status","aria-label":`Waiting for ${p?.title??"another session"}`,children:e(Ue,{size:T-1,className:"animate-pulse"})}):r==="stream"?e("span",{role:"status","aria-label":"Running",children:e(m,{size:T-1,className:"animate-spin"})}):e(f,{size:T-1})}),k&&!(g&&x)&&!A&&e("span",{"data-testid":"child-indicator","aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex items-center justify-center text-ink/35",children:e(ge,{size:T-1,"aria-hidden":"true"})})]}),e("span",{className:"w-2 shrink-0"})]})}function sn({timeAgo:t,timeTitle:r,runStartedAt:l,onOpenMenu:c,menuOpen:p=!1,touch:g=!1}){let h=(k)=>e(As,{timeAgo:t,timeTitle:r,runStartedAt:l,className:k});if(!c)return h("ml-2 shrink-0 font-mono text-[10px]");let x=e("button",{type:"button",onClick:c,title:"Session actions","aria-label":"Session actions","aria-haspopup":"menu","aria-expanded":p,className:`shrink-0 rounded text-ink/40 hover:bg-ink/10 hover:text-ink cursor-pointer ${g?"p-1.5":"p-1"} ${g?"":"opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 focus-visible:opacity-100"}`,children:e(Be,{size:g?16:14})});if(g)return e("span",{className:"ml-1 flex shrink-0 items-center gap-0.5",children:[h("font-mono text-[10px]"),x]});return e("span",{className:"relative ml-2 flex h-4 min-w-8 shrink-0 items-center justify-end pr-1",children:[h("whitespace-nowrap font-mono text-[10px] leading-none transition-opacity group-hover/item:opacity-0 group-focus-within/item:opacity-0"),e("span",{className:"absolute right-0 -my-1 flex",children:x})]})}function an(t){return{inset:"pl-1 pr-1",insetPx:4,slotWidth:t?18:16,markGap:8,padding:t?"py-0.5":"py-[7px]",glyph:t?_t.touch:_t.compact}}function ln({sessionId:t,title:r,harness:l,isActive:c=!1,isArchived:p=!1,status:g,awaitingInput:h=!1,timeAgo:x,timeTitle:k,runStartedAt:v,worktree:y,waitingFor:N,expandable:C=!1,isExpanded:T=!1,onToggleExpand:S,isChild:I=!1,folderId:P,onClick:A,onRename:F,onRenameWithAi:R,onArchive:z,onDelete:Q,onCancelWait:te,selectable:G=!1,selected:oe=!1,onToggleSelect:re,density:V="compact"}){let H=V==="touch",K=Ia(t),M=No(),{isEditing:de,draft:ae,setDraft:Se,inputRef:me,startRename:se,handleKeyDown:ee,handleBlur:Te}=Qo(r,F),ve=Boolean(F||z||Q||te),fe=M.anchor!==null,xe=Boolean(N),ue=r.charAt(0).toUpperCase()+r.slice(1);if(de)return e("div",{className:`flex w-full items-center rounded-lg bg-ink/10 ${H?"px-2 py-1.5":"px-2 py-1"}`,children:e("input",{ref:me,autoFocus:!0,value:ae,onChange:(ye)=>Se(ye.currentTarget.value),onClick:(ye)=>ye.stopPropagation(),onKeyDown:ee,onBlur:Te,"aria-label":"Session name",className:"min-w-0 flex-1 rounded border border-ink/25 bg-paper px-2 py-0.5 text-xs text-ink outline-none focus:border-ink/50"})});return e(d,{children:[e("div",{"data-testid":"session-item","data-session-id":String(t),"data-selected":G&&oe?"true":void 0,"data-menu-open":fe?"true":void 0,onClick:G?re:A,onContextMenu:ve&&!G?M.openAtCursor:void 0,className:`group/item relative flex w-full items-center rounded-lg text-xs transition-colors select-none cursor-pointer ${H?"py-0.5 pl-1 pr-1":"py-[7px] pl-1 pr-1"} ${G&&oe||fe?hs:c?"bg-ink/[0.08] font-medium text-ink":"text-ink/75 hover:bg-ink/[0.04] hover:text-ink"}`,children:[c&&!G&&e("span",{"aria-hidden":"true",className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-ink"}),e(rn,{title:r,status:g,awaitingInput:h,renaming:K,waitingFor:N,expandable:C,isExpanded:T,onToggleExpand:S,child:I,selectable:G,selected:oe,onToggleSelect:re,touch:H}),l&&e("span",{className:"mr-1.5 flex shrink-0 items-center",children:e(ht,{harness:l,size:H?_t.touch:_t.compact})}),e("span",{className:`flex min-w-0 flex-1 flex-col leading-snug ${p?"text-ink/45":""}`,children:[e("span",{className:"min-w-0 truncate",children:ue}),xe&&e("span",{className:"truncate text-[10px] font-normal text-ink/40",children:["waiting for ",N?.title??"another session"]}),y&&e(fs,{worktree:y})]}),e(sn,{timeAgo:x,timeTitle:k,runStartedAt:v,touch:H,menuOpen:fe,onOpenMenu:ve&&!G?M.openBelow:void 0})]}),M.anchor&&e(Ro,{anchor:M.anchor,sessionId:t,...l?{harness:l}:{},...P!==void 0?{folderId:P}:{},isArchived:p,onRename:F?se:void 0,onRenameWithAi:R,onArchive:z,onDelete:Q,onCancelWait:te,onClose:M.close})]})}function Lo(t){let r=t.parentElement;while(r){let l=getComputedStyle(r);if(/(auto|scroll|overlay)/.test(l.overflowY))return r;r=r.parentElement}return null}function dn(t){let[r,l]=n(!1);return o(()=>{let c=t.current;if(!c)return;let p=Lo(c),g=!1,h=()=>{g=!1;let v=p?p.getBoundingClientRect():{top:0},y=p?p.scrollTop>0:window.scrollY>0,N=c.getBoundingClientRect();l(y&&N.top<=v.top+0.5&&N.bottom>v.top)},x=()=>{if(g)return;g=!0,requestAnimationFrame(h)};h();let k=typeof ResizeObserver>"u"?null:new ResizeObserver(x);if(k?.observe(c),p)k?.observe(p);return(p??window).addEventListener("scroll",x,{passive:!0}),window.addEventListener("resize",x),()=>{g=!1,k?.disconnect(),(p??window).removeEventListener("scroll",x),window.removeEventListener("resize",x)}},[t]),r}function un({folder:t,isOpen:r,onToggleFolder:l,sessionCount:c,checkbox:p,batchActive:g,showMenu:h,onToggleMenu:x,onCloseMenu:k,onNewSession:v,menu:y,touch:N=!1}){let C=ea(t.icon),T=t.accentColor||void 0,S=i(null),[I,P]=n(null),A=i(null),F=dn(A);return e("div",{ref:A,"data-stuck":F?"":void 0,className:`group/ws sticky top-0 z-10 -mx-1 flex items-center gap-1 rounded-md px-1 text-xs font-semibold text-ink ${N?"h-8 bg-canvas glass-sticky":"h-[26px] bg-paper glass-sticky"}`,children:[e("button",{type:"button",onClick:g?void 0:l,"aria-expanded":r,"aria-label":`${t.name}${r?", collapse":", expand"}`,className:"flex h-full min-w-0 flex-1 items-center gap-2 rounded-md px-1 text-left cursor-pointer hover:bg-ink/[0.04]",children:[p?e(Nr,{size:"md",checked:p.checked,indeterminate:p.indeterminate,label:p.label,onChange:p.onChange}):e("span",{className:`relative flex shrink-0 items-center justify-center ${N?"h-[18px] w-[18px]":"h-4 w-4"}`,children:t.customIconUrl?e("img",{src:t.customIconUrl,alt:"",className:"h-[15px] w-[15px] shrink-0 rounded-xs object-contain",referrerPolicy:"no-referrer"}):e(C,{size:15,className:"project-accent-mark text-ink/70",style:Ks(T)})}),e("span",{className:"glass-sticky-label truncate text-[13px] font-semibold tracking-tight",children:t.name}),t.isPinned&&e(Ta,{size:10,className:"shrink-0 text-ink/45"}),T&&!p&&e("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:T}}),e("span",{className:"glass-sticky-label shrink-0 font-mono text-[10px] font-normal tabular-nums text-ink/35",children:c}),e("span",{className:"ml-auto shrink-0 text-ink/40",children:r?e(B,{size:N?14:12}):e(ie,{size:N?14:12})})]}),!g&&e("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:[e("button",{type:"button",title:"New Session","aria-label":`New session in ${t.name}`,onClick:(R)=>{R.stopPropagation(),v()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${N?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(Y,{size:N?15:12})}),e("div",{className:"relative flex items-center",children:[e("button",{ref:S,type:"button",title:`Options for ${t.name}`,"aria-label":`Options for ${t.name}`,"aria-haspopup":"menu","aria-expanded":h,onClick:(R)=>{if(R.stopPropagation(),S.current)P(Ht(S.current));x()},className:`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${N?"h-7 w-7":"h-[22px] w-[22px]"}`,children:e(Be,{size:N?15:12})}),e(Wt,{anchor:h&&y?I:null,align:"end",ariaLabel:`Options for ${t.name}`,className:"glass-popover w-44 rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",onClose:k,children:y})]})]})]})}function pn({hiddenCount:t,canShowLess:r,onShowMore:l,onShowLess:c}){if(t<=0&&!r)return null;return e("div",{className:"flex items-center gap-1 pl-6",children:[t>0&&e("button",{type:"button",onClick:l,className:"min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(B,{size:11,className:"mr-1 inline align-[-2px]"}),t," more"]}),r&&e("button",{type:"button",onClick:c,className:"ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80",children:[e(et,{size:11,className:"mr-1 inline align-[-2px]"}),"Less"]})]})}function mn({folder:t,activeSessionId:r,sessionStatus:l,showArchived:c,forceExpanded:p=!1,density:g="compact",batch:h,onSelectSession:x,onNewSessionForFolder:k,onNewWorktreeSession:v,onToast:y,onStartSessionSelection:N,onCancelWait:C}){let[T,S]=n(t.isExpanded||!1),[I,P]=n(!1),[A,F]=n(!1),{visibleCount:R,showMore:z,showLess:Q,canShowLess:te}=ps(),[G]=le(),oe=G.get("subagent"),re=G.get("sessionId"),{expandedSessionIds:V,toggleSession:H}=rs(),{refresh:K,runStartedAtMap:M}=He(),de=st(),{confirmDelete:ae,requestDelete:Se,cancelDelete:me,handlePin:se,handleDelete:ee,handleArchive:Te,handleRename:ve,handleRenameWithAi:fe,handleOpenFolder:xe}=ms(t,K,y),ue=To();o(()=>{if(typeof t.isExpanded==="boolean")S(t.isExpanded)},[t.isExpanded]);let ye=()=>{P(!1),me()},Re=()=>{let U=!T;if(S(U),typeof t.id!=="number")return;de.submit({isExpanded:String(U)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},Ie=t.sessions.filter((U)=>c?U.is_archived===1:U.is_archived!==1),{folderCheckbox:Ke,sessionCheckboxes:j,folderSummary:Z,toggleFolderSelection:X,rendered:q,hiddenCount:Ne}=ks({batch:h,folder:t,sessions:Ie,showArchived:c,visibleCount:R,activeSessionId:r,sessionStatus:l}),be=vs(q),it=p||T||j,at=(U,Ce)=>{let ce=String(U.id),ct=r===null?U.is_active===1:String(r)===ce,zn=ct&&re===ce&&Boolean(oe),Ze=yt(ce);return e(ln,{sessionId:U.id,title:U.title,harness:U.harness,folderId:U.folder_id,density:g,isActive:ct&&!zn,isArchived:U.is_archived===1,status:l[ce],awaitingInput:Boolean(U.awaitingInput),timeAgo:gs(U.updated_at??U.created_at),timeTitle:zo(U.updated_at??U.created_at),runStartedAt:l[ce]==="stream"?M[ce]:void 0,worktree:U.worktree,waitingFor:U.waitingFor?{title:U.waitingFor.title}:void 0,expandable:Ce.expandable,isChild:Ce.isChild,isExpanded:Ce.isExpanded,onToggleExpand:Ce.onToggleExpand,onClick:()=>x(U.id),onArchive:()=>Te(U),onDelete:Ze?void 0:()=>ue.requestDelete(U),onRename:Ze?void 0:(Hn)=>void ve(U,Hn),onRenameWithAi:Ze?void 0:()=>void fe(U),onCancelWait:U.waitingFor?()=>C?.(U.waitingFor.waitId):void 0,selectable:j,selected:Boolean(h?.selected.includes(ce)),onToggleSelect:h?()=>h.toggle(ce):void 0})},Wn=(U)=>ys(U,be.childrenOf,V,H),lt=Boolean(v&&t.project_path);return e("div",{className:"space-y-0.5",children:[e(un,{folder:t,isOpen:it,onToggleFolder:Re,sessionCount:Ie.length,checkbox:Ke&&Z?{checked:Z.all,indeterminate:Z.some,label:`Select ${t.name}`,onChange:X}:null,batchActive:Boolean(h),showMenu:I,onToggleMenu:()=>P((U)=>!U),onCloseMenu:ye,onNewSession:()=>k(t.id),touch:g==="touch",menu:e(bs,{variant:"desktop",isPinned:t.isPinned,onOpenFolder:xe?()=>{xe(),P(!1)}:void 0,onSelectSessions:N?()=>{P(!1),N(t.id)}:void 0,onNewWorktree:lt?()=>{P(!1),F(!0)}:void 0,confirmDelete:ae,onPin:()=>{se(),P(!1)},onDelete:()=>{ee(),P(!1)},onRequestDelete:Se,onCancelDelete:me})}),it&&e("div",{className:"space-y-0.5",children:[be.roots.map((U)=>{let Ce=String(U.id),ce=Wn(U);return e("div",{className:"space-y-0.5",children:[at(U,ce),ce.isExpanded&&e(gi,{parentId:Ce,hasSubagents:Boolean(U.hasSubagents),childrenOf:be.childrenOf,expandedIds:V,onToggle:H,activeSessionId:r===null?null:String(r),renderSession:at,style:an(g==="touch")})]},U.id)}),!j&&e(pn,{hiddenCount:Ne,canShowLess:te,onShowMore:z,onShowLess:Q}),Ie.length===0&&e("div",{className:"px-1 py-1 pl-6 text-[11px] italic text-ink/40",children:c?"No archived sessions.":"No sessions."})]}),e(Do,{session:ue.pending,isDeleting:ue.isDeleting,error:ue.error,onClose:ue.cancelDelete,onConfirm:()=>void ue.confirmDelete()}),lt&&e(Fo,{isOpen:A,onClose:()=>F(!1),root:t.project_path??null,folderId:t.id,folderName:t.name,onCreated:(U)=>{F(!1),v?.(t.id,U.path)}})]})}var Mo=[3,2];function hn({touch:t=!1}){return e("div",{className:"space-y-3","aria-hidden":"true",children:Mo.map((r,l)=>e("div",{className:"space-y-0.5",children:[e("div",{className:`flex items-center gap-2 px-1 ${t?"h-8":"h-[26px]"}`,children:[e("span",{className:`animate-pulse rounded-sm bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 w-24 animate-pulse rounded bg-ink/10"})]}),Array.from({length:r},(c,p)=>e("div",{className:`flex items-center gap-2 pl-1 pr-2 ${t?"h-8":"h-[31px]"}`,children:[e("span",{className:`shrink-0 animate-pulse rounded-full bg-ink/10 ${t?"h-[18px] w-[18px]":"h-4 w-4"}`}),e("span",{className:"h-3 animate-pulse rounded bg-ink/10",style:{width:`${58-p%3*12}%`}})]},p))]},l))})}function bn(t,r){if(t.awaitingInput)return!0;if(t.waitingFor)return!0;return r==="stream"}function gn(t,{focus:r,statusOf:l}){if(r==="all")return t;return t.map((c)=>({...c,sessions:c.sessions.filter((p)=>bn(p,l(String(p.id))))})).filter((c)=>c.sessions.length>0)}function xn(t,r){let l=0;for(let c of t)for(let p of c.sessions)if(bn(p,r(String(p.id))))l+=1;return l}function nu({className:t="",folders:r,initializing:l,failed:c,activeSessionId:p,sessionStatus:g,searchQuery:h,onSearchChange:x,showArchived:k,onToggleArchived:v,sortOption:y,optionsOpen:N,onToggleOptions:C,onCloseOptions:T,onSortChange:S,onRefresh:I,refreshing:P,scheduledCount:A,onNewSession:F,onNewWorkspace:R,onScheduler:z,onSelectSession:Q,onNewSessionForFolder:te,onNewWorktreeSession:G,onToast:oe,onCancelWait:re,batch:V,onSelectWorkspaces:H,onStartSessionSelection:K,touch:M=!1}){let[de,ae]=n("all"),Se=u(()=>xn(r,(ee)=>g[ee]),[r,g]),me=u(()=>gn(r,{focus:de,statusOf:(ee)=>g[ee]}),[r,de,g]),se=Boolean(V);return e("div",{className:`flex flex-col ${t}`,children:[e(Jt,{value:h,onChange:x,touch:M}),e(en,{focus:de,onFocusChange:ae,runningCount:Se,showArchived:k,onToggleArchived:v,selecting:se,onToggleSelect:H}),e(nn,{onNewSession:F,onNewWorkspace:R,onScheduler:z,scheduledCount:A,onRefresh:I,refreshing:P,sortOption:y,optionsOpen:N,onToggleOptions:C,onCloseOptions:T,onSortChange:S,touch:M}),e("div",{className:"mt-1 flex-1 scrollbar-overlay-container px-2 pb-3",children:c?e(xs,{touch:M,onRetry:I,refreshing:P}):l?e(hn,{touch:M}):me.length===0?e("div",{className:"px-1 py-8 text-center text-[11px] leading-relaxed text-muted",children:de==="running"?"Nothing is running right now.":h?"No workspace or chat matches that search.":"No workspaces yet."}):e("div",{className:"space-y-3",children:me.map((ee)=>e(mn,{folder:ee,activeSessionId:p,sessionStatus:g,showArchived:k,forceExpanded:h.trim().length>0,density:M?"touch":"compact",batch:V,onSelectSession:Q,onNewSessionForFolder:te,onNewWorktreeSession:G,onToast:oe,onStartSessionSelection:K,onCancelWait:re},ee.id))})})]})}function Wo(t){if(!t)return Number.NaN;let r=Date.parse(t);return Number.isFinite(r)?r:Number.NaN}function kn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Wo(l.updated_at??l.created_at);if(c>r)r=c}return r}function Sn(t){let r=Number.NEGATIVE_INFINITY;for(let l of t.sessions??[]){let c=Number(l.id);if(Number.isFinite(c)&&c>r)r=c}return r}function ke(t){let r=Number(t.id);return Number.isFinite(r)?r:Number.NEGATIVE_INFINITY}function We(t,r){if(t===r)return 0;return t>r?-1:1}function vn(t,r){if(t===r)return 0;return t>r?1:-1}function Ho(t,r,l){let c=Boolean(t.isPinned),p=Boolean(r.isPinned);if(c!==p)return c?-1:1;switch(l){case"Z-A":{let g=r.name.localeCompare(t.name);return g!==0?g:vn(ke(t),ke(r))}case"LATEST_SESSION":{let g=We(kn(t),kn(r));if(g!==0)return g;let h=We(Sn(t),Sn(r));if(h!==0)return h;let x=We(ke(t),ke(r));return x!==0?x:t.name.localeCompare(r.name)}case"LATEST_ADDED":{let g=We(ke(t),ke(r));return g!==0?g:t.name.localeCompare(r.name)}case"A-Z":default:{let g=t.name.localeCompare(r.name);return g!==0?g:vn(ke(t),ke(r))}}}function yn(t,r){return[...t].sort((l,c)=>Ho(l,c,r))}var Uo=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],wn="LATEST_SESSION";function Tn(t){return typeof t==="string"&&Uo.includes(t)}function Cn(t,r,l){if(r.length===0||t.length===0)return t;let c=new Set;for(let h of t)for(let x of h.sessions??[])c.add(String(x.id));let p=r.filter((h)=>!c.has(String(h.id)));if(p.length===0)return t;let g=t;for(let h of p){let x=On(g,h,l);if(!x)continue;let k=new Date(h.createdAt).toISOString(),v={id:h.id,folder_id:x.id,title:h.title??l.titleFor?.(String(h.id))??fm(h.id),created_at:k,updated_at:k,...h.parentSessionId?{parentSessionId:h.parentSessionId}:{},...h.harness?{harness:h.harness}:{},...h.waiting?{waitingFor:{waitId:h.waiting.waitId,sessionId:h.waiting.dependsOn,title:h.waiting.dependsOnTitle}}:{}};g=g.map((y)=>y.id===x.id?{...y,isExpanded:!0,sessions:[v,...y.sessions??[]]}:y)}return g}function In(t,r,l){if(r.length===0||t.length===0)return[];let c=new Set;for(let p of r){let g=On(t,p,l);if(g)c.add(String(g.id))}return[...c]}function On(t,r,l){if(r.folderId!==null&&r.folderId!==void 0){let c=t.find((p)=>String(p.id)===String(r.folderId));if(c)return c}if(l.activeId){let c=t.find((p)=>(p.sessions??[]).some((g)=>String(g.id)===String(l.activeId)));if(c)return c}if(l.urlFolderId){let c=t.find((p)=>String(p.id)===String(l.urlFolderId));if(c)return c}return t[0]}async function kd(t,r){try{return(await fetch(`/api/folders/${encodeURIComponent(String(t))}/toggle`,{method:"POST",body:new URLSearchParams({isExpanded:String(r)})})).ok}catch(l){return console.error("Failed to save workspace expansion:",l),!1}}function Pn(t,r){return t.find((l)=>(l.sessions??[]).some((c)=>String(c.id)===r))}function Rn(t){let{folders:r,initializing:l,runningIds:c,pendingEntries:p,activeId:g,urlFolderId:h}=t,x=u(()=>{let v=new Set;for(let y of c){let N=Pn(r,y);if(N)v.add(String(N.id))}return v},[r,c]),k=i({running:new Set,pending:new Set});return o(()=>{if(l||r.length===0)return;let v=k.current,y=new Set,N=new Set,C=new Set;for(let S of c){if(v.running.has(S)){y.add(S);continue}let I=Pn(r,S);if(!I)continue;y.add(S),C.add(String(I.id))}let T={activeId:g,urlFolderId:h};for(let S of p){let I=String(S.id);if(v.pending.has(I)){N.add(I);continue}N.add(I);for(let P of In(r,[S],T))C.add(P)}v.running=y,v.pending=N;for(let S of C){let I=r.find((P)=>String(P.id)===S);if(!I||I.isExpanded)continue;kd(S,!0)}},[l,r,c,p,g,h]),x}var Go=200;function ru(t={},r={}){let{expandSearchMatches:l=!1,onSelectSession:c,onAfterSelect:p}=r,{folders:g,initializing:h,failed:x,refresh:k,refreshNow:v,refreshing:y,isRefreshing:N,markSeen:C,hasSeen:T,streamStatusMap:S,titleHint:I}=He(),[P,A]=le(),F=P.get("sessionId"),R=P.get("folderId"),z=F?Number.isNaN(Number(F))?F:Number(F):null,Q=i(k);Q.current=k;let te=a(()=>Q.current(),[]),[G,oe]=n(""),[re,V]=n(!1),[H,K]=n(!1),[M,de]=n(()=>Tn(t.omp_sidebar_sort)?t.omp_sidebar_sort:wn),ae=i(null),Se=a((j)=>{if(ae.current)clearTimeout(ae.current);ae.current=setTimeout(()=>{rt("omp_sidebar_sort",j)},Go)},[]);o(()=>()=>{if(ae.current)clearTimeout(ae.current)},[]);let me=(j)=>{de(j),K(!1),Se(j)},se=S;GA(se,z,te,T);let ee=gm(),{prompts:Te,loaded:ve}=vc(),fe=u(()=>new Set(Object.entries(se).filter(([,j])=>j==="stream").map(([j])=>j)),[se]),xe=Rn({folders:g,initializing:h,runningIds:fe,pendingEntries:ee,activeId:F,urlFolderId:R});o(()=>{if(!F||h)return;if(g.some((j)=>(j.sessions??[]).some((Z)=>String(Z.id)===F)))return;jA(F,R,se[F]==="stream")},[F,g,h,R,se]),o(()=>{if(h||!ve)return;for(let j of ee){let Z=String(j.id),X=Te.find((q)=>q.pendingId===Z&&q.status==="waiting");if(!X||j.waiting?.waitId===X.id)continue;wm(Z,{waitId:X.id,dependsOn:X.dependsOn,dependsOnTitle:X.dependsOnTitle})}},[ee,Te,ve,h]);let[ue,ye]=n(0),Re=ee.map((j)=>String(j.id)).join(`
|
|
2
2
|
`);o(()=>{let j=()=>ye((X)=>X+1),Z=Re.split(`
|
|
3
3
|
`).filter(Boolean).flatMap((X)=>[Gr(X,ts,j),Gr(X,ns,j)]);return()=>{for(let X of Z)X()}},[Re]),o(()=>{if(h)return;let j=new Set;for(let Z of g)for(let X of Z.sessions??[])j.add(String(X.id));qA({listed:j,running:fe,activeId:F})},[g,h,fe,F,ue]);let Ie=(j)=>{if(C(j),c)c(j);else A((Z)=>{let X=It(Z);if(X.set("sessionId",j.toString()),X.has("subagent"))X.delete("subagent");return X},{replace:!0});p?.()},Ke=u(()=>{let j=Cn(g,ee,{activeId:F,urlFolderId:R,titleFor:I});if(G.trim()){let Z=G.toLowerCase(),X=(q)=>q.title.toLowerCase().includes(Z)||String(q.id).toLowerCase().includes(Z);if(l)j=j.filter((q)=>{let Ne=q.name.toLowerCase().includes(Z),be=q.sessions?.some(X);return Ne||be}).map((q)=>{let Ne=q.sessions?.filter((be)=>q.name.toLowerCase().includes(Z)||X(be));return{...q,sessions:Ne,isExpanded:!0}});else j=j.map((q)=>{let Ne=q.name.toLowerCase().includes(Z),be=(q.sessions||[]).filter(X);if(Ne)return q;return{...q,sessions:be}}).filter((q)=>q.sessions&&q.sessions.length>0)}if(xe.size>0)j=j.map((Z)=>xe.has(String(Z.id))?{...Z,isExpanded:!0}:Z);return j=yn(j,M),j},[g,ee,G,M,F,R,l,I,xe]);return{folders:g,initializing:h,failed:x,refresh:te,refreshNow:v,refreshing:y,isRefreshing:N,activeSessionId:z,sessionParam:F,searchQuery:G,setSearchQuery:oe,showArchived:re,setShowArchived:V,optionsOpen:H,setOptionsOpen:K,sortOption:M,handleSortChange:me,processedFolders:Ke,sessionStatus:se,handleSelectSession:Ie}}function au({onNotice:t}={}){let{prompts:r}=vc(),[,l]=le(),c=i(t);c.current=t;let p=i(new Set);o(()=>{let g=new URLSearchParams(window.location.search).get("sessionId");for(let h of r){let{pendingId:x,targetSessionId:k}=h,v=x?VA(x):null,y=Boolean(x)&&(Boolean(v)||g===x),N=Boolean(k)&&g===k;if(!x&&!k)continue;let C=`${h.id}:${h.status}`;if(p.current.has(C))continue;if(h.status==="dispatched"&&h.sessionId){if(p.current.add(C),x&&y)bc(x,h.sessionId,h.folderId),l((T)=>{if(T.get("sessionId")!==x)return T;let S=It(T);return S.set("sessionId",h.sessionId),S},{replace:!0}),c.current?.("Waiting finished — your prompt is now running in a new session.","success");else if(k&&N)c.current?.("Waiting finished — your prompt is now running in this chat.","success");continue}if(h.status==="error"){if(p.current.add(C),!y&&!N)continue;if(Vu(h),x)Ku(x);c.current?.(`The prompt you held was not sent: ${h.error??"the dispatch failed."} Your draft is back in the composer.`,"error");continue}if(h.status==="cancelled"){if(p.current.add(C),!y&&!N)continue;if(Vu(h),x)Ku(x)}}},[r,l])}async function ou(t){let r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json().catch(()=>({}));if(!r.ok||!l.success)throw Error(l.error||`HTTP ${r.status}`);window.location.reload()}async function iu(t){let r=await fetch("/api/folders/clone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json().catch(()=>({}));if(!r.ok||!l.success)throw Error(l.error||`HTTP ${r.status}`);window.location.reload()}function An(){let[t,r]=n(null),[l,c]=n(null),[p,g]=n([]),h=a((C,T)=>{r(C),c(C==="session"?T??null:null),g([])},[]),x=a(()=>{r(null),c(null),g([])},[]),k=a((C)=>{g((T)=>Kt(T,C))},[]),v=a((C)=>{g((T)=>[...new Set([...T,...C])])},[]),y=a((C)=>{g((T)=>{let S=new Set(C);return T.filter((I)=>!S.has(I))})},[]),N=a((C)=>Xt(p,C),[p]);return u(()=>({mode:t,scopeFolderId:l,selected:p,begin:h,end:x,toggle:k,selectAllOf:v,unselectAllOf:y,summaryOf:N}),[t,l,p,h,x,k,v,y,N])}var ze=500,Dn=200;function Ge(t,r){if(!Number.isSafeInteger(r)||r<1)throw Error(`chunkIds needs a positive integer limit, got ${r}`);let l=[];for(let c=0;c<t.length;c+=r)l.push(t.slice(c,c+r));return l}var je={removed:[],refused:[]};async function jo(t,r){try{let l=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:r})}),c=await l.json().catch(()=>null);if(!l.ok)return{...je,error:c?.error||`Could not delete (HTTP ${l.status}).`};return{removed:Array.isArray(c?.removed)?c.removed:[],refused:Array.isArray(c?.refused)?c.refused:[]}}catch(l){return{...je,error:l instanceof Error?l.message:"Could not reach the server."}}}async function En(t,r,l,c){let p=[],g=[],h,x=0;for(let k of Ge(r,l)){let v=await jo(t,k);p.push(...v.removed),g.push(...v.refused),h??=v.error,x+=k.length,c?.({done:x,total:r.length})}return{removed:p,refused:g,...h?{error:h}:{}}}function Bn(t,r){if(t.length===0)return Promise.resolve({...je});return En("/api/sessions/batch-delete",t,ze,r)}function _n(t,r){if(t.length===0)return Promise.resolve({...je});return En("/api/folders/batch-delete",t,Dn,r)}function Ln(t){let[r,l]=n([]),[c,p]=n(!1),[g,h]=n(null),[x,k]=n(null),[v,y]=le(),N=a((S)=>{h(null),k(null),l([...S])},[]),C=a(()=>{h(null),k(null),l([])},[]),T=a(async(S)=>{if(r.length===0||c)return null;p(!0),h(null);let I=r;k({done:0,total:I.length});let P=(F)=>k(F),A=S==="workspace"?await _n(I,P):await Bn(I,P);if(S==="session"&&A.removed.length>0){for(let R of A.removed)Bp(R);let F=v.get("sessionId");if(F&&A.removed.includes(F))y((R)=>{let z=It(R);return z.delete("sessionId"),z.delete("subagent"),z},{replace:!0})}if(A.removed.length>0)t();if(h(A),k(null),p(!1),A.removed.length===I.length)l([]);return A},[r,c,v,y,t]);return{pending:r,isDeleting:c,outcome:g,progress:x,request:N,cancel:C,confirm:T}}var ot={archived:[],refused:[]};async function Ko(t,r){try{let l=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:r})}),c=await l.json().catch(()=>null);if(!l.ok)return{...ot,error:c?.error||`Could not archive (HTTP ${l.status}).`};return{archived:Array.isArray(c?.archived)?c.archived:[],refused:Array.isArray(c?.refused)?c.refused:[]}}catch(l){return{...ot,error:l instanceof Error?l.message:"Could not reach the server."}}}async function Mn(t){if(t.length===0)return{...ot};let r=[],l=[],c;for(let p of Ge(t,ze)){let g=await Ko("/api/sessions/batch-archive",p);r.push(...g.archived),l.push(...g.refused),c??=g.error}return{archived:r,refused:l,...c?{error:c}:{}}}function su(t){if(t.error)return{message:t.error,tone:"error"};let r=t.archived.length,l=t.refused.length;if(r===0&&l===0)return null;if(l===0)return{message:`Archived ${r} ${r===1?"session":"sessions"}.`,tone:"success"};if(r===0)return{message:`${l} ${l===1?"session":"sessions"} could not be archived.`,tone:"error"};return{message:`Archived ${r} ${r===1?"session":"sessions"}; ${l} refused.`,tone:"warning"}}function $n(t){let[r,l]=n(!1),c=a(async(p)=>{if(p.length===0||r)return null;l(!0);let g=await Mn(p);if(g.archived.length>0)t();return l(!1),g},[r,t]);return{isArchiving:r,archive:c}}function lu(t,r,l){let c=An(),p=Ln(l),g=$n(l),h=c.scopeFolderId===null?null:t.find((N)=>N.id===c.scopeFolderId)??null,x=c.mode==="workspace"?t.map((N)=>String(N.id)):c.mode==="session"?Le(h?.sessions??[],r):[],k=Zt(c.selected,x),v=c.mode?{mode:c.mode,scopeFolderId:c.scopeFolderId,selected:c.selected,toggle:c.toggle,selectAllOf:c.selectAllOf,unselectAllOf:c.unselectAllOf,summaryOf:c.summaryOf}:void 0,y=a(()=>{if(c.mode==="workspace")c.end();else c.begin("workspace")},[c]);return{selection:c,deleteRun:p,archiveRun:g,binding:v,scopeFolder:h,available:x,selected:k,toggleWorkspaceSelection:y}}function cu({mode:t,count:r,total:l,busy:c,archiving:p=!1,scopeLabel:g,onSelectAll:h,onUnselectAll:x,onDelete:k,onArchive:v,onCancel:y,drawer:N=!1}){let C=t==="workspace"?"workspace":"session",T=r===1?C:`${C}s`,S=t==="session"&&g?` in ${g}`:"",I=c||p,P=I||r===0,A=t==="session"&&Boolean(v),F="min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40",R="border-ink/20 text-ink hover:bg-ink/5";return e("div",{"data-testid":"batch-action-bar",className:`border-t border-ink/15 bg-paper ${N?"px-3":"px-2.5"} py-2 flex flex-col gap-1.5 flex-shrink-0`,children:[e("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[e("span",{className:"min-w-0 truncate text-ink/70",children:[e("span",{className:"font-semibold text-ink",children:r})," ","of ",l," ",l===1?C:`${C}s`," selected",S]}),e("button",{type:"button",onClick:y,disabled:I,title:"Cancel selection","aria-label":"Cancel selection",className:"shrink-0 w-5 h-5 flex items-center justify-center rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:13})})]}),e("div",{className:`grid gap-1.5 ${A?"grid-cols-2":"grid-cols-3"}`,children:[e("button",{type:"button",onClick:h,disabled:I||l===0||r===l,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:[e(dt,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:"Select all"})]}),e("button",{type:"button",onClick:x,disabled:I||r===0,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:e("span",{className:"truncate",children:"Unselect all"})}),A&&e("button",{type:"button",onClick:v,disabled:P,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded border text-[11px] font-medium transition-colors cursor-pointer disabled:opacity-40 border-ink/20 text-ink hover:bg-ink/5",children:p?e(d,{children:[e(m,{size:12,className:"animate-spin shrink-0"}),e("span",{className:"truncate",children:"Archiving…"})]}):e(d,{children:[e(Xe,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:["Archive ",r>0?`${r} ${T}`:T]})]})}),e("button",{type:"button",onClick:k,disabled:P,className:"min-w-0 w-full h-7 flex items-center justify-center gap-1 px-2 rounded bg-error text-canvas text-[11px] font-semibold hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40",children:c?e(d,{children:[e(m,{size:12,className:"animate-spin shrink-0"}),e("span",{className:"truncate",children:"Deleting…"})]}):e(d,{children:[e(L,{size:12,className:"shrink-0"}),e("span",{className:"truncate",children:["Delete ",r>0?`${r} ${T}`:T]})]})})]})]})}function uu({mode:t,count:r,scopeLabel:l,isDeleting:c,progress:p=null,outcome:g,onClose:h,onConfirm:x}){if(o(()=>{let I=(P)=>{if(P.key!=="Escape"||c)return;P.preventDefault(),h()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[h,c]),r===0)return null;let k=t==="session",v=k?"session":"workspace",y=r===1?v:`${v}s`,N=k&&l?` in ${l}`:"",C=!c&&g!==null,T=g?.removed.length??0,S=g?.refused??[];return e(J,{onClose:c?()=>{}:h,zClass:"z-[70]",maxWidthClass:"max-w-[460px]",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(L,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:["Delete ",r," ",y,"?"]}),e("p",{className:"text-[11px] text-ink/50 truncate",children:N?N.trim():"Selected rows"})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:h,disabled:c,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:C?"Close":"Cancel"}),e("button",{type:"button",onClick:x,disabled:c||C,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:c?e(d,{children:[e(m,{size:13,className:"animate-spin"}),e("span",{children:"Deleting…"})]}):e(d,{children:[e(L,{size:13}),e("span",{children:["Delete ",r," ",y]})]})})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[c&&e("div",{className:"space-y-1.5","data-testid":"batch-delete-progress",children:[e("div",{className:"flex items-center justify-between text-[11px] text-ink/60",children:[e("span",{children:["Deleting ",p?.done??0," of ",r,"…"]}),e("span",{children:[Math.round((p?.done??0)/Math.max(1,r)*100),"%"]})]}),e(Cm,{percent:(p?.done??0)/Math.max(1,r)*100,label:`Deleting ${r} ${y}`,tone:"error"})]}),k?e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:["Each transcript is removed from"," ",e("span",{className:"font-mono text-ink",children:"~/.omp/agent/sessions"})," — the conversations are gone from the sidebar and from oh-my-pi."]}),e("li",{children:"Chats that ran on another agent (opencode, dsh, …) are removed from that agent's own history too; one the agent cannot delete is refused, not silently forgotten."}),e("li",{children:"Their subagent transcripts, side questions, queued messages and saved layout go too."}),e("li",{children:"A session that is mid-run is refused rather than interrupted; stop it and delete again."})]}):e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspaces are removed from this sidebar."}),e("li",{children:["Their directories and every transcript on disk are left alone — re-add a workspace with"," ",e("span",{className:"font-mono text-ink",children:"New Workspace"})," when you want it back."]})]}),g?.error?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:g.error})]}):C?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-ink/15 bg-ink/5 text-[11px] text-ink/75",children:e("span",{children:["Removed ",T," ",T===1?v:`${v}s`,S.length>0?`, ${S.length} refused:`:"."]})}):e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:k?"This cannot be undone from the UI. Archive a session instead to keep its transcript.":"This removes the sidebar entry only. The folder itself is not deleted."})]}),S.length>0&&e("ul",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container space-y-1 text-[11px] text-ink/70",children:S.map((I)=>e("li",{className:"flex items-start gap-1.5",children:[e("span",{className:"font-mono text-ink/50 shrink-0 max-w-[7rem] truncate",title:I.id,children:I.id}),e("span",{className:"min-w-0",children:I.error})]},I.id))})]})})}
|
|
4
4
|
export{us,Sa,Qr,pl,Xc,eu,$o,tu,ds,yd,mg,fg,vd,gg,ps,ms,Nr,fs,gs,zo,As,hs,bs,ys,gi,vs,ks,xs,nu,kd,ru,au,ou,iu,su,lu,cu,uu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,e,fo,s,m,_,jr,Fi,f,re,Nt,ge,D,O,Qp,J,jt,Wl,Np,Pu}from"./index-3fw3sd10.js";var Y={name:"clipboard-paste",size:24,node:[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]},Ns=s(Y);var K={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},kp=s(K);function H({row:t,active:r,name:p,loading:c,onSelect:l,onCopyPath:g,onReveal:C}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:l,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(ge,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:p})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:c,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:C,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Nt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(X,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function X({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${fo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),fo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Fi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(jr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function q(t){let{open:r,rootPath:p,scanning:c}=t,[l,g]=n([]),[C,y]=n(!1),[M,G]=n(!1),[k,v]=n(null),[S,T]=n(0),A=t.repos.join("\x00"),w=i(!0),b=i(null);o(()=>(w.current=!0,()=>{w.current=!1,b.current?.abort(),b.current=null}),[]);let z=a(async()=>{b.current?.abort();let R=new AbortController;b.current=R,G(!0),y(!0);try{let N=new URLSearchParams({repoDetails:"1"});if(p)N.set("root",p);let E=await fetch(`/api/fs/git?${N.toString()}`,{signal:R.signal}),L=await E.json();if(!w.current||b.current!==R)return;if(!E.ok||!Array.isArray(L.details)){v(L.error||`Failed to read repositories (HTTP ${E.status})`);return}g(L.details),v(null)}catch(N){if(!w.current||b.current!==R)return;if(N instanceof Error&&N.name==="AbortError")return;v(N instanceof Error?N.message:"Failed to read repositories")}finally{if(w.current&&b.current===R)b.current=null,G(!1),y(!1)}},[p]);o(()=>{if(!r){g([]),v(null),y(!1);return}z()},[r,z,A,c,S]);let j=a(()=>T((R)=>R+1),[]);return{details:l,loading:C,reading:M,error:k,refresh:j}}function I(t){let r=new Map;for(let p of t){if(!p||p==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let c=p.indexOf("/"),l=c===-1?"":p.slice(0,c),g=r.get(l);if(!g)g={key:l,label:l===""?null:l,paths:[]},r.set(l,g);g.paths.push(p)}for(let p of r.values())p.paths.sort((c,l)=>c==="."?-1:l==="."?1:c.localeCompare(l));return[...r.values()].sort((p,c)=>{if(p.key==="")return-1;if(c.key==="")return 1;return p.key.localeCompare(c.key)})}function B(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function U({isOpen:t,rootPath:r,activeRepo:p,repos:c,scanning:l,onSelectRepo:g,onRefreshRepos:C,onClose:y}){let[M,G]=n(""),[k,v]=n(null),{details:S,loading:T,reading:A,error:w,refresh:b}=q({open:t,rootPath:r,repos:c,scanning:l});o(()=>{if(!t)G(""),v(null)},[t]);let z=u(()=>{let x=M.trim().toLowerCase();if(!x)return S;return S.filter((h)=>h.path.toLowerCase().includes(x))},[S,M]),j=u(()=>I(z.map((x)=>x.path)),[z]),R=u(()=>{let x=new Map;for(let h of S)x.set(h.path,h);return x},[S]),N=a(()=>{C(),b()},[C,b]),E=a(async(x)=>{let h=r?Pu(r,x==="."?"":x):x,P=await jt(h);v(P?{text:`Copied ${h}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),L=a(async(x)=>{let h=new FormData;if(h.append("actionType","open_explorer"),h.append("path","."),h.append("repo",x),r)h.append("root",r);try{let P=await fetch("/api/fs/action",{method:"POST",body:h}),F=await P.json();if(!P.ok||F.error)v({text:F.error||"Could not open the file manager",kind:"error"})}catch{v({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(J,{onClose:y,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(kp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[c.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:M,onChange:(x)=>G(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:N,disabled:A||l,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:A||l?"animate-spin":""})})]}),l&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),k&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${k.kind==="error"?"text-error":"text-ink/60"}`,title:k.text,role:"status",children:k.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:T&&S.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):w?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:w}):z.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:M.trim()?"No matching repositories.":"No repositories in this workspace."}):j.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??Wl(".",r)}),x.paths.map((h)=>{let P=R.get(h);if(!P)return null;return e(H,{row:P,active:h===p,name:B(h,x.key),loading:A,onSelect:()=>{g(h),y()},onCopyPath:()=>void E(h),onReveal:()=>void L(h)},h)})]},x.key))})]})}function hr({rootPath:t,activeRepo:r,onSelectRepo:p,repos:c,scanning:l,onRefreshRepos:g}){let[C,y]=n(!1),M=u(()=>({root:t??null,repo:r,rows:c.map((k)=>({repo:k,label:Wl(k,t),short:Np(k,t)})),scanning:l,ready:!0,setRepo:p,refresh:g}),[t,r,c,l,p,g]),G=a(()=>y(!0),[]);return e("div",{className:"relative",children:[e(Qp,{scope:M,onManage:G}),e(U,{isOpen:C,rootPath:t,activeRepo:r,repos:c,scanning:l,onSelectRepo:p,onRefreshRepos:g,onClose:()=>y(!1)})]})}var W="(pointer: coarse)",V="(hover: none)";function Q(){if(typeof window>"u")return!1;if(window.matchMedia(W).matches)return!0;return navigator.maxTouchPoints>0&&window.matchMedia(V).matches}function Ru(){let[t,r]=n(Q);return o(()=>{let p=[W,V].map((l)=>window.matchMedia(l)),c=()=>r(Q());for(let l of p)l.addEventListener("change",c);return()=>{for(let l of p)l.removeEventListener("change",c)}},[]),t}
|
|
1
|
+
import{d,n,o,i,u,a,e,fo,s,m,_,jr,Fi,f,re,Nt,ge,D,O,Qp,J,jt,Wl,Np,Pu}from"./index-4c2zcvem.js";var Y={name:"clipboard-paste",size:24,node:[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]},Ns=s(Y);var K={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},kp=s(K);function H({row:t,active:r,name:p,loading:c,onSelect:l,onCopyPath:g,onReveal:C}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:l,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(ge,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:p})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:c,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:C,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Nt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(X,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function X({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${fo[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),fo[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Fi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(jr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function q(t){let{open:r,rootPath:p,scanning:c}=t,[l,g]=n([]),[C,y]=n(!1),[M,G]=n(!1),[k,v]=n(null),[S,T]=n(0),A=t.repos.join("\x00"),w=i(!0),b=i(null);o(()=>(w.current=!0,()=>{w.current=!1,b.current?.abort(),b.current=null}),[]);let z=a(async()=>{b.current?.abort();let R=new AbortController;b.current=R,G(!0),y(!0);try{let N=new URLSearchParams({repoDetails:"1"});if(p)N.set("root",p);let E=await fetch(`/api/fs/git?${N.toString()}`,{signal:R.signal}),L=await E.json();if(!w.current||b.current!==R)return;if(!E.ok||!Array.isArray(L.details)){v(L.error||`Failed to read repositories (HTTP ${E.status})`);return}g(L.details),v(null)}catch(N){if(!w.current||b.current!==R)return;if(N instanceof Error&&N.name==="AbortError")return;v(N instanceof Error?N.message:"Failed to read repositories")}finally{if(w.current&&b.current===R)b.current=null,G(!1),y(!1)}},[p]);o(()=>{if(!r){g([]),v(null),y(!1);return}z()},[r,z,A,c,S]);let j=a(()=>T((R)=>R+1),[]);return{details:l,loading:C,reading:M,error:k,refresh:j}}function I(t){let r=new Map;for(let p of t){if(!p||p==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let c=p.indexOf("/"),l=c===-1?"":p.slice(0,c),g=r.get(l);if(!g)g={key:l,label:l===""?null:l,paths:[]},r.set(l,g);g.paths.push(p)}for(let p of r.values())p.paths.sort((c,l)=>c==="."?-1:l==="."?1:c.localeCompare(l));return[...r.values()].sort((p,c)=>{if(p.key==="")return-1;if(c.key==="")return 1;return p.key.localeCompare(c.key)})}function B(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function U({isOpen:t,rootPath:r,activeRepo:p,repos:c,scanning:l,onSelectRepo:g,onRefreshRepos:C,onClose:y}){let[M,G]=n(""),[k,v]=n(null),{details:S,loading:T,reading:A,error:w,refresh:b}=q({open:t,rootPath:r,repos:c,scanning:l});o(()=>{if(!t)G(""),v(null)},[t]);let z=u(()=>{let x=M.trim().toLowerCase();if(!x)return S;return S.filter((h)=>h.path.toLowerCase().includes(x))},[S,M]),j=u(()=>I(z.map((x)=>x.path)),[z]),R=u(()=>{let x=new Map;for(let h of S)x.set(h.path,h);return x},[S]),N=a(()=>{C(),b()},[C,b]),E=a(async(x)=>{let h=r?Pu(r,x==="."?"":x):x,P=await jt(h);v(P?{text:`Copied ${h}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),L=a(async(x)=>{let h=new FormData;if(h.append("actionType","open_explorer"),h.append("path","."),h.append("repo",x),r)h.append("root",r);try{let P=await fetch("/api/fs/action",{method:"POST",body:h}),F=await P.json();if(!P.ok||F.error)v({text:F.error||"Could not open the file manager",kind:"error"})}catch{v({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(J,{onClose:y,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(kp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[c.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:M,onChange:(x)=>G(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:N,disabled:A||l,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:A||l?"animate-spin":""})})]}),l&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),k&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${k.kind==="error"?"text-error":"text-ink/60"}`,title:k.text,role:"status",children:k.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:T&&S.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Reading repositories…"]}):w?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:w}):z.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:M.trim()?"No matching repositories.":"No repositories in this workspace."}):j.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??Wl(".",r)}),x.paths.map((h)=>{let P=R.get(h);if(!P)return null;return e(H,{row:P,active:h===p,name:B(h,x.key),loading:A,onSelect:()=>{g(h),y()},onCopyPath:()=>void E(h),onReveal:()=>void L(h)},h)})]},x.key))})]})}function hr({rootPath:t,activeRepo:r,onSelectRepo:p,repos:c,scanning:l,onRefreshRepos:g}){let[C,y]=n(!1),M=u(()=>({root:t??null,repo:r,rows:c.map((k)=>({repo:k,label:Wl(k,t),short:Np(k,t)})),scanning:l,ready:!0,setRepo:p,refresh:g}),[t,r,c,l,p,g]),G=a(()=>y(!0),[]);return e("div",{className:"relative",children:[e(Qp,{scope:M,onManage:G}),e(U,{isOpen:C,rootPath:t,activeRepo:r,repos:c,scanning:l,onSelectRepo:p,onRefreshRepos:g,onClose:()=>y(!1)})]})}var W="(pointer: coarse)",V="(hover: none)";function Q(){if(typeof window>"u")return!1;if(window.matchMedia(W).matches)return!0;return navigator.maxTouchPoints>0&&window.matchMedia(V).matches}function Ru(){let[t,r]=n(Q);return o(()=>{let p=[W,V].map((l)=>window.matchMedia(l)),c=()=>r(Q());for(let l of p)l.addEventListener("change",c);return()=>{for(let l of p)l.removeEventListener("change",c)}},[]),t}
|
|
2
2
|
export{Ns,kp,hr,Ru};
|