spexcode 0.5.6 → 0.5.7

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/spec-cli/src/cli.ts +18 -1
  3. package/spec-cli/src/client.ts +21 -0
  4. package/spec-cli/src/git.ts +380 -198
  5. package/spec-cli/src/harness.ts +116 -24
  6. package/spec-cli/src/help.ts +3 -1
  7. package/spec-cli/src/index.ts +41 -7
  8. package/spec-cli/src/layout.ts +2 -0
  9. package/spec-cli/src/mentions.ts +10 -5
  10. package/spec-cli/src/process-identity.ts +20 -0
  11. package/spec-cli/src/session-maintenance.ts +2 -1
  12. package/spec-cli/src/sessions.ts +898 -140
  13. package/spec-cli/src/specs.ts +3 -3
  14. package/spec-dashboard/dist/assets/{App-B72LuS5I.js → App-u2P7KdSg.js} +2 -2
  15. package/spec-dashboard/dist/assets/{Dashboard-C5X4Va3V.js → Dashboard-B8wp5_61.js} +3 -3
  16. package/spec-dashboard/dist/assets/{EvalsPage-BTvJIW8Q.js → EvalsPage-Bq1Tkb8y.js} +1 -1
  17. package/spec-dashboard/dist/assets/{IssuesPage-Bn94h_HQ.js → IssuesPage-BlkPSkmv.js} +1 -1
  18. package/spec-dashboard/dist/assets/{MobileApp-ClbtwZ1e.js → MobileApp-B1GxRZXK.js} +2 -2
  19. package/spec-dashboard/dist/assets/{Modal-6l_QtCKF.js → Modal-bAkq9IIT.js} +1 -1
  20. package/spec-dashboard/dist/assets/{PageScroll-B2kxcqJJ.js → PageScroll-px_rUZVJ.js} +1 -1
  21. package/spec-dashboard/dist/assets/{ProjectsPage-C8IPsMKV.js → ProjectsPage-8uGqYM12.js} +1 -1
  22. package/spec-dashboard/dist/assets/SessionInterface-CswwbewF.js +39 -0
  23. package/spec-dashboard/dist/assets/{SessionWindow-Dag_GiJB.js → SessionWindow-IspcLjFA.js} +1 -1
  24. package/spec-dashboard/dist/assets/{Settings-J3aibcXo.js → Settings-bpAbfnmS.js} +1 -1
  25. package/spec-dashboard/dist/assets/{Thread-Dg35J-Pu.js → Thread-BpL3N3kw.js} +11 -11
  26. package/spec-dashboard/dist/assets/{TimelineChat-f0UF9fXq.js → TimelineChat-Ckmb1Ez2.js} +1 -1
  27. package/spec-dashboard/dist/assets/{data-SNi0AmVT.js → data-CQFbQEMH.js} +1 -1
  28. package/spec-dashboard/dist/assets/index-CixSnz1H.css +1 -0
  29. package/spec-dashboard/dist/assets/{index-BUKLPN_4.js → index-Di1ch5dd.js} +5 -5
  30. package/spec-dashboard/dist/index.html +2 -2
  31. package/spec-dashboard/dist/assets/SessionInterface-B5jf7dW7.js +0 -39
  32. package/spec-dashboard/dist/assets/index-CzutlTDf.css +0 -1
@@ -1,2 +1,2 @@
1
- import{u as U,E as re,c as J,j as s,s as Cs,I as Z,r as c,d as ke,e as be,f as Ts,g as es,n as Fs,q as As,h as Ps}from"./index-BUKLPN_4.js";import{E as ss,R as ds,a as q,L as Os,S as Is,F as ns,s as ts,k as as,e as Ks,r as zs,p as Bs,b as _s,c as Te,d as W,f as G,O as qs,g as Us,D as Fe,m as we,h as Vs,i as ls,u as Hs,j as Xs,l as Ys,n as Qs,o as ye,q as Gs,t as Ae,v as hs,w as Js}from"./Thread-Dg35J-Pu.js";import{b as Zs,c as Ds,d as Ws,e as en}from"./data-SNi0AmVT.js";import"./PageScroll-B2kxcqJJ.js";const rs={video:"vid",image:"img",transcript:"txt",data:"data"},sn=["is","state","verdict","freshness","evidence","node","filer","session","scope"],vs=e=>`eval:${e.node}·${e.scenario}`;function nn({e}){const a=U(),r=e.humanOk&&a("evalsFeed.okdTip",{by:e.humanOk.by,at:new Date(e.humanOk.ts).toLocaleString()});return s.jsx(ds,{state:s.jsx(q,{kind:"eval",state:e.state}),title:e.scenario,meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ef-node",style:{color:`hsl(${e.hue??210} 60% 70%)`},children:e.node}),e.by&&s.jsx("span",{children:a("evalsFeed.filedBy",{by:e.by})}),s.jsx("span",{children:a("evalsFeed.filedAt",{at:tn(e.ts)})})]}),aside:s.jsxs(s.Fragment,{children:[e.inSession&&s.jsx("span",{className:"rl-tag in-session",children:a("evalsFeed.sessionTag")}),as(e).some(i=>rs[i])&&s.jsx("span",{className:"rl-tag",children:as(e).map(i=>rs[i]).filter(Boolean).join("·")}),e.humanOk&&s.jsx("span",{role:"img",className:"ef-okd","data-tip":r,"aria-label":r,children:s.jsx(Z,{name:"check",size:11})})]})})}const tn=e=>{const a=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return a<3600?`${Math.max(1,Math.floor(a/60))}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`},ee=(e,a,r,i=b=>b)=>{var b,v;return(((v=(b=e==null?void 0:e.facets)==null?void 0:b[a])==null?void 0:v.options)??[]).map(x=>({value:x.value,label:x.value===""?r:i(x.value)}))};function an({pageData:e,loading:a=!1,sessions:r=[],queryText:i="",onQueryText:b,hrefFor:v,notice:x=null,leading:m=null,error:j=null,empty:E=null,pagination:R=null}){var M,se,ie;const u=U(),d=String(i??"").trim()||re,p=(o,K)=>b(Cs(d,o,K)),L=Array.isArray(e==null?void 0:e.items)?e.items:[],N=((M=e==null?void 0:e.counts)==null?void 0:M.fail)||{},S=((se=e==null?void 0:e.counts)==null?void 0:se.pass)||{},P=((ie=e==null?void 0:e.counts)==null?void 0:ie.unmeasured)||0,y=o=>o>0?{text:`+${o} ${u("reviewList.freshness.stale")}`,compact:`+${o}`}:null,C=J(d,"verdict"),O=L.flatMap(o=>o.filterKind===ss.BLIND?[{key:`blind:${o.node}·${o.scenario}`,cls:"se-blind",content:s.jsx(ds,{state:s.jsx(q,{kind:"eval",state:"missing"}),title:o.scenario,meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ef-node",style:{color:`hsl(${o.hue??210} 60% 70%)`},children:o.node}),s.jsx("span",{children:u("sessionEval.unmeasured")})]})})}]:o.filterKind===ss.RESULT?[{key:vs(o),href:v(o),content:s.jsx(nn,{e:o})}]:[]),I={label:u("reviewList.facetReview"),value:J(d,"state"),options:ee(e,"review",u("reviewList.all"),o=>u(o==="reviewed"?"reviewList.reviewed":"reviewList.needsReview"))},f={label:u("reviewList.facetFreshness"),value:J(d,"freshness"),options:ee(e,"freshness",u("reviewList.all"),o=>u(`reviewList.freshness.${o}`))},T={label:u("reviewList.facetKind"),value:J(d,"evidence")||"all",options:ee(e,"kind",u("evalsFeed.kind.all"),o=>u(`evalsFeed.kind.${o}`))},B={label:u("reviewList.facetSession"),value:J(d,"session"),options:ee(e,"session",u("reviewList.all"),o=>u(o==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))},_=J(d,"evidence");return s.jsx(Os,{notice:x,leading:m,error:j,loading:a,title:u("evalsFeed.title"),search:{value:String(i??"").trim()?i:re,onSubmit:b,placeholder:u("reviewList.searchEvals"),label:u("reviewList.search"),keys:sn,suggest:{node:ee(e,"node",u("reviewList.all")).filter(o=>o.value),filer:ee(e,"filer",u("reviewList.all")).filter(o=>o.value).map(({value:o})=>{const K=r.find(V=>V.id===o);return{value:o,label:K?ts(K):null}}),scope:r.map(o=>({value:o.id,label:ts(o)}))}},sections:[{key:"fail",label:s.jsx(q,{kind:"eval",state:"fail",title:u("reviewList.verdict.fail"),showLabel:!0}),count:N.fresh||0,countSuffix:y(N.stale||0),active:C==="fail",onSelect:()=>p("verdict",C==="fail"?"":"fail")},{key:"pass",label:s.jsx(q,{kind:"eval",state:"pass",title:u("reviewList.verdict.pass"),showLabel:!0}),count:S.fresh||0,countSuffix:y(S.stale||0),active:C==="pass",onSelect:()=>p("verdict",C==="pass"?"":"pass")},{key:"unmeasured",label:s.jsx(q,{kind:"eval",state:"missing",title:u("reviewList.verdict.unmeasured"),showLabel:!0}),count:P,active:C==="unmeasured",onSelect:()=>p("verdict",C==="unmeasured"?"":"unmeasured")}],sectionMode:"filters",facets:s.jsxs(s.Fragment,{children:[s.jsx(ns,{label:f.label,value:f.value,options:f.options,clearLabel:u("reviewList.all"),onChange:o=>p("freshness",o)}),s.jsx(ns,{label:T.label,value:T.value,options:T.options,onChange:o=>p("evidence",o==="all"?"":o)})]}),secondaryFilters:s.jsx(Is,{label:u("reviewList.filters"),clearLabel:u("reviewList.all"),groups:[{label:I.label,value:I.value,active:!!I.value,options:I.options,onChange:o=>p("state",o)},{label:B.label,value:B.value,active:!!B.value,options:B.options,onChange:o=>p("session",o)},{label:f.label,value:f.value,active:!!f.value,options:f.options,onChange:o=>p("freshness",o),mobileOnly:!0},{label:T.label,value:T.value,active:!!_,options:T.options,clearLabel:null,onChange:o=>p("evidence",o==="all"?"":o),mobileOnly:!0}]}),rows:O,pagination:R,empty:E||{hasData:((e==null?void 0:e.sourceTotal)??0)>0,dataset:u("evalsFeed.datasetEmpty"),filtered:u("evalsFeed.noMatches")}})}const ln=[{name:"ok",color:"green",when:e=>!e.okd&&e.isLatest,descKey:"annotator.cmd.okDesc"}];function rn(e,a){return ln.filter(r=>r.when(e)).map(r=>({...r,run:a[r.name]}))}function on(e,a){return(e||"").replace(/\{(\w+)\}/g,(r,i)=>a[i]!=null?String(a[i]):r)}const is=(e,a)=>{let r=null;for(const i of e)if(i.at<=a)r=i;else break;return r},cn=e=>{if(!e||!Array.isArray(e.events))return null;const a=e.v===1?"time":typeof e.axis=="string"?e.axis:"time",r=e.v===1?i=>i.tMs:i=>i.at;return{axis:a,events:e.events.map(i=>({at:r(i),step:i.step,...i.node?{node:i.node}:{}}))}},un=(e,a,r)=>e==="time"?we(a):e==="frame"?`#${a}`:e==="line"?`L${a}`:e==="index"?r?`${a}/${r}`:`${a}`:String(a);function os({events:e,axis:a,extent:r,activeStepIdx:i,onSeek:b}){return s.jsx("div",{className:"an-ruler",children:e.map((v,x)=>s.jsxs("button",{className:`an-step ${i===x?"on":""}`,onClick:()=>b(v.at),"data-tip":v.node?`→ ${v.node}`:void 0,children:[un(a,v.at,r)," ",v.step]},x))})}const xe=8;function dn({hidden:e,total:a,histIdx:r,onPick:i}){const b=U(),v=Hs(),x=b("annotator.abMore",{n:e.length});return s.jsxs("div",{className:"an-ab-more",ref:v.ref,children:[s.jsx(be,{icon:"ellipsis",size:14,className:"an-ab-morebtn",label:x,"aria-haspopup":"menu","aria-expanded":v.open,onClick:m=>v.toggle(m.currentTarget),onKeyDown:v.onTriggerKeyDown}),v.open&&s.jsx("div",{className:"rl-menu an-ab-menu",role:"menu","aria-label":x,ref:v.menuRef,onKeyDown:v.onMenuKeyDown,children:e.map(m=>{const j=Te(m);return s.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m.idx===r,tabIndex:-1,className:"rl-menu-item an-ab-menuitem",onFocus:v.onItemFocus,onClick:()=>{v.close(!0),i(m.idx)},children:[s.jsx(q,{kind:"eval",state:j,size:13}),s.jsxs("span",{className:"an-ab-menupos",children:[a-m.idx,"/",a]}),s.jsx("span",{className:"an-ab-menudate",children:new Date(m.ts).toLocaleString()})]},`${m.ts}-${m.idx}`)})})]})}function hn({entry:e,history:a,sourceKey:r="project",specs:i=[],sessions:b=[],onWrite:v,onOpenSession:x,onFocusNode:m=null,listHref:j=null,backHref:E=null,backLabel:R=null,queue:u={prev:[],next:[]}}){var Qe,Ge,Je,Ze,De,We;const d=U(),p=c.useRef(null),L=c.useRef(null),N=c.useRef(null),S=c.useRef(null),P=c.useRef(0),[y,C]=c.useState([]),[O,I]=c.useState("time"),[f,T]=c.useState(null),[B,_]=c.useState(""),[M,se]=c.useState(!1),[ie,o]=c.useState(null),K=c.useRef(null),V=c.useRef(null),ne=c.useRef(null),ge=c.useRef(0),[fs,Pe]=c.useState(0),[je,Oe]=c.useState(-1),[Ie,Ke]=c.useState(null),[oe,Ee]=c.useState(!1),[ze,Le]=c.useState(!1),[Se,Me]=c.useState(null),[ce,$e]=c.useState(null),[F,Be]=c.useState(null),[A,te]=c.useState(0),w=F&&F[A]||e,ms=`${A}:${w.ts||w.codeSha||w.blob||"reading"}`,xs=`${r}·${e.node}·${e.scenario}·${ms}`,[ps,bs]=c.useState([]);c.useEffect(()=>{let n=!0;return Zs().then(t=>{n&&Array.isArray(t)&&bs(t)}).catch(()=>{}),()=>{n=!1}},[]),c.useEffect(()=>{T(null),_(""),C([]),o(null),te(0),Be(null),Be(Array.isArray(a)?a:[e])},[e.node,e.scenario,e.ts,e.blob,(Qe=e.humanOk)==null?void 0:Qe.ts,a]),c.useEffect(()=>{T(null),o(null)},[A]);const ae=Ks(w),H=ae.find(n=>n.kind==="video"&&n.state==="present"),ue=ae.filter(n=>n.kind==="image"),ws=ae.filter(n=>n.kind!=="video"&&n.kind!=="image"),X=!!H,de=e.thread??null,Ne=c.useMemo(()=>((de==null?void 0:de.replies)??[]).filter(n=>n.rid!==void 0),[de]),_e=F&&((Ge=F[0])==null?void 0:Ge.by)||e.by||null,z=c.useMemo(()=>Ne.map((n,t)=>{const l=zs(Bs(n.body),y);return l&&l.seekable?{i:t,tMs:l.tMs,step:l.step,label:l.label}:null}).filter(Boolean).sort((n,t)=>n.tMs-t.tMs),[Ne,y]),qe=c.useRef(y);qe.current=y;const Ue=c.useRef(z);Ue.current=z;const he=c.useCallback(()=>{const n=ge.current,t=qe.current;let l=-1;for(let g=0;g<t.length&&t[g].at<=n;g++)l=g;Oe(g=>g===l?g:l);let h=null;for(const g of Ue.current)if(g.tMs<=n)h=g.i;else break;Ke(g=>g===h?g:h)},[]);c.useEffect(()=>{he()},[z,y,he]),c.useEffect(()=>{ge.current=0,K.current&&(K.current.style.width="0%"),V.current&&(V.current.style.left="0%"),ne.current&&(ne.current.textContent=""),Oe(-1),Ke(null),Pe(0),Ee(!1),Le(!1),Me(null),$e(null)},[e.blob,e.scenario,e.node]),c.useEffect(()=>{if(C([]),I("time"),!w.timelineBlob)return;let n=!0;return fetch(ke(`/api/evidence/${w.timelineBlob}`)).then(t=>t.ok?t.json():null).then(t=>{const l=n&&cn(t);l&&(C(l.events),I(l.axis))}).catch(()=>{}),()=>{n=!1}},[w.timelineBlob]),c.useEffect(()=>{const n=p.current;if(!n)return;const t=()=>{const k=Math.round((n.currentTime||0)*1e3),$=Math.round((n.duration||0)*1e3);ge.current=k;const Q=$?k/$*100:0;K.current&&(K.current.style.width=`${Q}%`),V.current&&(V.current.style.left=`${Q}%`),ne.current&&(ne.current.textContent=`${we(k)} / ${we($)}`),he()},l=()=>{Pe(n.duration||0),t()},h=()=>Ee(!0),g=()=>Ee(!1);return n.addEventListener("timeupdate",t),n.addEventListener("seeked",t),n.addEventListener("loadedmetadata",l),n.addEventListener("durationchange",l),n.addEventListener("play",h),n.addEventListener("pause",g),l(),()=>{n.removeEventListener("timeupdate",t),n.removeEventListener("seeked",t),n.removeEventListener("loadedmetadata",l),n.removeEventListener("durationchange",l),n.removeEventListener("play",h),n.removeEventListener("pause",g)}},[H==null?void 0:H.hash,e.node,e.scenario,A,he]);const Y=Math.round(fs*1e3),ve=y[je]||null,Ve=O==="time"?Y:O==="frame"?ue.length:O==="index"?y.length:0,D=c.useCallback(n=>{const t=p.current;t&&(t.currentTime=n/1e3)},[]),fe=c.useCallback(()=>{const n=p.current;n&&(n.paused?n.play():n.pause())},[]),He=(n,t)=>{$e(n),t!=null&&D(t)},me=c.useCallback(async n=>{const t=p.current;if(!(t!=null&&t.videoWidth))return null;se(!0),_(d("annotator.capturing"));try{t.seeking&&await new Promise($=>t.addEventListener("seeked",$,{once:!0}));const l=document.createElement("canvas");l.width=t.videoWidth,l.height=t.videoHeight;const h=l.getContext("2d");h.drawImage(t,0,0,l.width,l.height),n&&(h.strokeStyle="#ff9a3c",h.lineWidth=Math.max(2,l.width/300),h.strokeRect(n.x/100*l.width,n.y/100*l.height,n.w/100*l.width,n.h/100*l.height));const g=await new Promise($=>l.toBlob($,"image/png")),{hash:k}=await Ds(g);if(!k)throw new Error("no hash");return _(""),k}catch{return _(d("annotator.failed")),null}finally{se(!1)}},[d]),ks=c.useCallback(async()=>{var l;const n=p.current;if(!n)return null;n.pause();const t=Math.round((n.currentTime??0)*1e3);return{tMs:t,step:((l=is(y,t))==null?void 0:l.step)??null,frame:await me(null)}},[y,me]),Re=c.useCallback(async n=>{const t=p.current;if(!t)return;t.pause();const l=Math.round((t.currentTime||0)*1e3),h=is(y,l),g=await me(n),k=[_s(l,h==null?void 0:h.step)];g&&k.push(`![frame](/api/evidence/${g})`),h!=null&&h.node&&h.node!==e.node&&k.push(`re: [[${h.node}]]`),k.push(""),o({seq:++P.current,body:k.join(`
1
+ import{u as U,E as re,c as J,j as s,s as Cs,I as Z,r as c,d as ke,e as be,f as Ts,g as es,n as Fs,q as As,h as Ps}from"./index-Di1ch5dd.js";import{E as ss,R as ds,a as q,L as Os,S as Is,F as ns,s as ts,k as as,e as Ks,r as zs,p as Bs,b as _s,c as Te,d as W,f as G,O as qs,g as Us,D as Fe,m as we,h as Vs,i as ls,u as Hs,j as Xs,l as Ys,n as Qs,o as ye,q as Gs,t as Ae,v as hs,w as Js}from"./Thread-BpL3N3kw.js";import{b as Zs,c as Ds,d as Ws,e as en}from"./data-CQFbQEMH.js";import"./PageScroll-px_rUZVJ.js";const rs={video:"vid",image:"img",transcript:"txt",data:"data"},sn=["is","state","verdict","freshness","evidence","node","filer","session","scope"],vs=e=>`eval:${e.node}·${e.scenario}`;function nn({e}){const a=U(),r=e.humanOk&&a("evalsFeed.okdTip",{by:e.humanOk.by,at:new Date(e.humanOk.ts).toLocaleString()});return s.jsx(ds,{state:s.jsx(q,{kind:"eval",state:e.state}),title:e.scenario,meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ef-node",style:{color:`hsl(${e.hue??210} 60% 70%)`},children:e.node}),e.by&&s.jsx("span",{children:a("evalsFeed.filedBy",{by:e.by})}),s.jsx("span",{children:a("evalsFeed.filedAt",{at:tn(e.ts)})})]}),aside:s.jsxs(s.Fragment,{children:[e.inSession&&s.jsx("span",{className:"rl-tag in-session",children:a("evalsFeed.sessionTag")}),as(e).some(i=>rs[i])&&s.jsx("span",{className:"rl-tag",children:as(e).map(i=>rs[i]).filter(Boolean).join("·")}),e.humanOk&&s.jsx("span",{role:"img",className:"ef-okd","data-tip":r,"aria-label":r,children:s.jsx(Z,{name:"check",size:11})})]})})}const tn=e=>{const a=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return a<3600?`${Math.max(1,Math.floor(a/60))}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`},ee=(e,a,r,i=b=>b)=>{var b,v;return(((v=(b=e==null?void 0:e.facets)==null?void 0:b[a])==null?void 0:v.options)??[]).map(x=>({value:x.value,label:x.value===""?r:i(x.value)}))};function an({pageData:e,loading:a=!1,sessions:r=[],queryText:i="",onQueryText:b,hrefFor:v,notice:x=null,leading:m=null,error:j=null,empty:E=null,pagination:R=null}){var M,se,ie;const u=U(),d=String(i??"").trim()||re,p=(o,K)=>b(Cs(d,o,K)),L=Array.isArray(e==null?void 0:e.items)?e.items:[],N=((M=e==null?void 0:e.counts)==null?void 0:M.fail)||{},S=((se=e==null?void 0:e.counts)==null?void 0:se.pass)||{},P=((ie=e==null?void 0:e.counts)==null?void 0:ie.unmeasured)||0,y=o=>o>0?{text:`+${o} ${u("reviewList.freshness.stale")}`,compact:`+${o}`}:null,C=J(d,"verdict"),O=L.flatMap(o=>o.filterKind===ss.BLIND?[{key:`blind:${o.node}·${o.scenario}`,cls:"se-blind",content:s.jsx(ds,{state:s.jsx(q,{kind:"eval",state:"missing"}),title:o.scenario,meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ef-node",style:{color:`hsl(${o.hue??210} 60% 70%)`},children:o.node}),s.jsx("span",{children:u("sessionEval.unmeasured")})]})})}]:o.filterKind===ss.RESULT?[{key:vs(o),href:v(o),content:s.jsx(nn,{e:o})}]:[]),I={label:u("reviewList.facetReview"),value:J(d,"state"),options:ee(e,"review",u("reviewList.all"),o=>u(o==="reviewed"?"reviewList.reviewed":"reviewList.needsReview"))},f={label:u("reviewList.facetFreshness"),value:J(d,"freshness"),options:ee(e,"freshness",u("reviewList.all"),o=>u(`reviewList.freshness.${o}`))},T={label:u("reviewList.facetKind"),value:J(d,"evidence")||"all",options:ee(e,"kind",u("evalsFeed.kind.all"),o=>u(`evalsFeed.kind.${o}`))},B={label:u("reviewList.facetSession"),value:J(d,"session"),options:ee(e,"session",u("reviewList.all"),o=>u(o==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))},_=J(d,"evidence");return s.jsx(Os,{notice:x,leading:m,error:j,loading:a,title:u("evalsFeed.title"),search:{value:String(i??"").trim()?i:re,onSubmit:b,placeholder:u("reviewList.searchEvals"),label:u("reviewList.search"),keys:sn,suggest:{node:ee(e,"node",u("reviewList.all")).filter(o=>o.value),filer:ee(e,"filer",u("reviewList.all")).filter(o=>o.value).map(({value:o})=>{const K=r.find(V=>V.id===o);return{value:o,label:K?ts(K):null}}),scope:r.map(o=>({value:o.id,label:ts(o)}))}},sections:[{key:"fail",label:s.jsx(q,{kind:"eval",state:"fail",title:u("reviewList.verdict.fail"),showLabel:!0}),count:N.fresh||0,countSuffix:y(N.stale||0),active:C==="fail",onSelect:()=>p("verdict",C==="fail"?"":"fail")},{key:"pass",label:s.jsx(q,{kind:"eval",state:"pass",title:u("reviewList.verdict.pass"),showLabel:!0}),count:S.fresh||0,countSuffix:y(S.stale||0),active:C==="pass",onSelect:()=>p("verdict",C==="pass"?"":"pass")},{key:"unmeasured",label:s.jsx(q,{kind:"eval",state:"missing",title:u("reviewList.verdict.unmeasured"),showLabel:!0}),count:P,active:C==="unmeasured",onSelect:()=>p("verdict",C==="unmeasured"?"":"unmeasured")}],sectionMode:"filters",facets:s.jsxs(s.Fragment,{children:[s.jsx(ns,{label:f.label,value:f.value,options:f.options,clearLabel:u("reviewList.all"),onChange:o=>p("freshness",o)}),s.jsx(ns,{label:T.label,value:T.value,options:T.options,onChange:o=>p("evidence",o==="all"?"":o)})]}),secondaryFilters:s.jsx(Is,{label:u("reviewList.filters"),clearLabel:u("reviewList.all"),groups:[{label:I.label,value:I.value,active:!!I.value,options:I.options,onChange:o=>p("state",o)},{label:B.label,value:B.value,active:!!B.value,options:B.options,onChange:o=>p("session",o)},{label:f.label,value:f.value,active:!!f.value,options:f.options,onChange:o=>p("freshness",o),mobileOnly:!0},{label:T.label,value:T.value,active:!!_,options:T.options,clearLabel:null,onChange:o=>p("evidence",o==="all"?"":o),mobileOnly:!0}]}),rows:O,pagination:R,empty:E||{hasData:((e==null?void 0:e.sourceTotal)??0)>0,dataset:u("evalsFeed.datasetEmpty"),filtered:u("evalsFeed.noMatches")}})}const ln=[{name:"ok",color:"green",when:e=>!e.okd&&e.isLatest,descKey:"annotator.cmd.okDesc"}];function rn(e,a){return ln.filter(r=>r.when(e)).map(r=>({...r,run:a[r.name]}))}function on(e,a){return(e||"").replace(/\{(\w+)\}/g,(r,i)=>a[i]!=null?String(a[i]):r)}const is=(e,a)=>{let r=null;for(const i of e)if(i.at<=a)r=i;else break;return r},cn=e=>{if(!e||!Array.isArray(e.events))return null;const a=e.v===1?"time":typeof e.axis=="string"?e.axis:"time",r=e.v===1?i=>i.tMs:i=>i.at;return{axis:a,events:e.events.map(i=>({at:r(i),step:i.step,...i.node?{node:i.node}:{}}))}},un=(e,a,r)=>e==="time"?we(a):e==="frame"?`#${a}`:e==="line"?`L${a}`:e==="index"?r?`${a}/${r}`:`${a}`:String(a);function os({events:e,axis:a,extent:r,activeStepIdx:i,onSeek:b}){return s.jsx("div",{className:"an-ruler",children:e.map((v,x)=>s.jsxs("button",{className:`an-step ${i===x?"on":""}`,onClick:()=>b(v.at),"data-tip":v.node?`→ ${v.node}`:void 0,children:[un(a,v.at,r)," ",v.step]},x))})}const xe=8;function dn({hidden:e,total:a,histIdx:r,onPick:i}){const b=U(),v=Hs(),x=b("annotator.abMore",{n:e.length});return s.jsxs("div",{className:"an-ab-more",ref:v.ref,children:[s.jsx(be,{icon:"ellipsis",size:14,className:"an-ab-morebtn",label:x,"aria-haspopup":"menu","aria-expanded":v.open,onClick:m=>v.toggle(m.currentTarget),onKeyDown:v.onTriggerKeyDown}),v.open&&s.jsx("div",{className:"rl-menu an-ab-menu",role:"menu","aria-label":x,ref:v.menuRef,onKeyDown:v.onMenuKeyDown,children:e.map(m=>{const j=Te(m);return s.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m.idx===r,tabIndex:-1,className:"rl-menu-item an-ab-menuitem",onFocus:v.onItemFocus,onClick:()=>{v.close(!0),i(m.idx)},children:[s.jsx(q,{kind:"eval",state:j,size:13}),s.jsxs("span",{className:"an-ab-menupos",children:[a-m.idx,"/",a]}),s.jsx("span",{className:"an-ab-menudate",children:new Date(m.ts).toLocaleString()})]},`${m.ts}-${m.idx}`)})})]})}function hn({entry:e,history:a,sourceKey:r="project",specs:i=[],sessions:b=[],onWrite:v,onOpenSession:x,onFocusNode:m=null,listHref:j=null,backHref:E=null,backLabel:R=null,queue:u={prev:[],next:[]}}){var Qe,Ge,Je,Ze,De,We;const d=U(),p=c.useRef(null),L=c.useRef(null),N=c.useRef(null),S=c.useRef(null),P=c.useRef(0),[y,C]=c.useState([]),[O,I]=c.useState("time"),[f,T]=c.useState(null),[B,_]=c.useState(""),[M,se]=c.useState(!1),[ie,o]=c.useState(null),K=c.useRef(null),V=c.useRef(null),ne=c.useRef(null),ge=c.useRef(0),[fs,Pe]=c.useState(0),[je,Oe]=c.useState(-1),[Ie,Ke]=c.useState(null),[oe,Ee]=c.useState(!1),[ze,Le]=c.useState(!1),[Se,Me]=c.useState(null),[ce,$e]=c.useState(null),[F,Be]=c.useState(null),[A,te]=c.useState(0),w=F&&F[A]||e,ms=`${A}:${w.ts||w.codeSha||w.blob||"reading"}`,xs=`${r}·${e.node}·${e.scenario}·${ms}`,[ps,bs]=c.useState([]);c.useEffect(()=>{let n=!0;return Zs().then(t=>{n&&Array.isArray(t)&&bs(t)}).catch(()=>{}),()=>{n=!1}},[]),c.useEffect(()=>{T(null),_(""),C([]),o(null),te(0),Be(null),Be(Array.isArray(a)?a:[e])},[e.node,e.scenario,e.ts,e.blob,(Qe=e.humanOk)==null?void 0:Qe.ts,a]),c.useEffect(()=>{T(null),o(null)},[A]);const ae=Ks(w),H=ae.find(n=>n.kind==="video"&&n.state==="present"),ue=ae.filter(n=>n.kind==="image"),ws=ae.filter(n=>n.kind!=="video"&&n.kind!=="image"),X=!!H,de=e.thread??null,Ne=c.useMemo(()=>((de==null?void 0:de.replies)??[]).filter(n=>n.rid!==void 0),[de]),_e=F&&((Ge=F[0])==null?void 0:Ge.by)||e.by||null,z=c.useMemo(()=>Ne.map((n,t)=>{const l=zs(Bs(n.body),y);return l&&l.seekable?{i:t,tMs:l.tMs,step:l.step,label:l.label}:null}).filter(Boolean).sort((n,t)=>n.tMs-t.tMs),[Ne,y]),qe=c.useRef(y);qe.current=y;const Ue=c.useRef(z);Ue.current=z;const he=c.useCallback(()=>{const n=ge.current,t=qe.current;let l=-1;for(let g=0;g<t.length&&t[g].at<=n;g++)l=g;Oe(g=>g===l?g:l);let h=null;for(const g of Ue.current)if(g.tMs<=n)h=g.i;else break;Ke(g=>g===h?g:h)},[]);c.useEffect(()=>{he()},[z,y,he]),c.useEffect(()=>{ge.current=0,K.current&&(K.current.style.width="0%"),V.current&&(V.current.style.left="0%"),ne.current&&(ne.current.textContent=""),Oe(-1),Ke(null),Pe(0),Ee(!1),Le(!1),Me(null),$e(null)},[e.blob,e.scenario,e.node]),c.useEffect(()=>{if(C([]),I("time"),!w.timelineBlob)return;let n=!0;return fetch(ke(`/api/evidence/${w.timelineBlob}`)).then(t=>t.ok?t.json():null).then(t=>{const l=n&&cn(t);l&&(C(l.events),I(l.axis))}).catch(()=>{}),()=>{n=!1}},[w.timelineBlob]),c.useEffect(()=>{const n=p.current;if(!n)return;const t=()=>{const k=Math.round((n.currentTime||0)*1e3),$=Math.round((n.duration||0)*1e3);ge.current=k;const Q=$?k/$*100:0;K.current&&(K.current.style.width=`${Q}%`),V.current&&(V.current.style.left=`${Q}%`),ne.current&&(ne.current.textContent=`${we(k)} / ${we($)}`),he()},l=()=>{Pe(n.duration||0),t()},h=()=>Ee(!0),g=()=>Ee(!1);return n.addEventListener("timeupdate",t),n.addEventListener("seeked",t),n.addEventListener("loadedmetadata",l),n.addEventListener("durationchange",l),n.addEventListener("play",h),n.addEventListener("pause",g),l(),()=>{n.removeEventListener("timeupdate",t),n.removeEventListener("seeked",t),n.removeEventListener("loadedmetadata",l),n.removeEventListener("durationchange",l),n.removeEventListener("play",h),n.removeEventListener("pause",g)}},[H==null?void 0:H.hash,e.node,e.scenario,A,he]);const Y=Math.round(fs*1e3),ve=y[je]||null,Ve=O==="time"?Y:O==="frame"?ue.length:O==="index"?y.length:0,D=c.useCallback(n=>{const t=p.current;t&&(t.currentTime=n/1e3)},[]),fe=c.useCallback(()=>{const n=p.current;n&&(n.paused?n.play():n.pause())},[]),He=(n,t)=>{$e(n),t!=null&&D(t)},me=c.useCallback(async n=>{const t=p.current;if(!(t!=null&&t.videoWidth))return null;se(!0),_(d("annotator.capturing"));try{t.seeking&&await new Promise($=>t.addEventListener("seeked",$,{once:!0}));const l=document.createElement("canvas");l.width=t.videoWidth,l.height=t.videoHeight;const h=l.getContext("2d");h.drawImage(t,0,0,l.width,l.height),n&&(h.strokeStyle="#ff9a3c",h.lineWidth=Math.max(2,l.width/300),h.strokeRect(n.x/100*l.width,n.y/100*l.height,n.w/100*l.width,n.h/100*l.height));const g=await new Promise($=>l.toBlob($,"image/png")),{hash:k}=await Ds(g);if(!k)throw new Error("no hash");return _(""),k}catch{return _(d("annotator.failed")),null}finally{se(!1)}},[d]),ks=c.useCallback(async()=>{var l;const n=p.current;if(!n)return null;n.pause();const t=Math.round((n.currentTime??0)*1e3);return{tMs:t,step:((l=is(y,t))==null?void 0:l.step)??null,frame:await me(null)}},[y,me]),Re=c.useCallback(async n=>{const t=p.current;if(!t)return;t.pause();const l=Math.round((t.currentTime||0)*1e3),h=is(y,l),g=await me(n),k=[_s(l,h==null?void 0:h.step)];g&&k.push(`![frame](/api/evidence/${g})`),h!=null&&h.node&&h.node!==e.node&&k.push(`re: [[${h.node}]]`),k.push(""),o({seq:++P.current,body:k.join(`
2
2
  `)})},[y,e.node,me]),Ce=c.useCallback(n=>{var h;if(!z.length)return;let t=z.findIndex(g=>g.i===ce);if(t<0){const g=Math.round((((h=p.current)==null?void 0:h.currentTime)||0)*1e3);t=z.reduce((k,$,Q)=>$.tMs<=g?Q:k,-1)}t=Math.min(z.length-1,Math.max(0,t+n));const l=z[t];$e(l.i),D(l.tMs)},[z,ce,D]);c.useEffect(()=>{if(!X)return;const n=t=>{const l=document.activeElement;if(l&&(l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.isContentEditable))return;const h=p.current;h&&(t.key===" "?(t.preventDefault(),fe()):t.key==="ArrowRight"?(t.preventDefault(),h.currentTime=Math.min(h.duration||h.currentTime,h.currentTime+(t.shiftKey?1:5))):t.key==="ArrowLeft"?(t.preventDefault(),h.currentTime=Math.max(0,h.currentTime-(t.shiftKey?1:5))):t.key===","?(t.preventDefault(),h.currentTime=Math.max(0,h.currentTime-1/30)):t.key==="."?(t.preventDefault(),h.duration&&(h.currentTime=Math.min(h.duration,h.currentTime+1/30))):t.key==="ArrowDown"?(t.preventDefault(),Ce(1)):t.key==="ArrowUp"?(t.preventDefault(),Ce(-1)):(t.key==="a"||t.key==="A")&&(t.preventDefault(),Re(null)))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[X,fe,Ce,Re]);const Xe=n=>{var h;const t=(h=N.current)==null?void 0:h.getBoundingClientRect(),l=p.current;!t||!t.width||!l||!l.duration||(l.currentTime=Math.min(1,Math.max(0,(n-t.left)/t.width))*l.duration)},ys=n=>{n.preventDefault(),Le(!0),Xe(n.clientX)},gs=n=>{var l;const t=(l=N.current)==null?void 0:l.getBoundingClientRect();t!=null&&t.width&&Me(Math.min(100,Math.max(0,(n.clientX-t.left)/t.width*100)))};c.useEffect(()=>{if(!ze)return;const n=l=>Xe(l.clientX),t=()=>Le(!1);return window.addEventListener("mousemove",n),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",t)}},[ze]);const Ye=n=>{const t=L.current.getBoundingClientRect();return{x:(n.clientX-t.left)/t.width*100,y:(n.clientY-t.top)/t.height*100}},js=n=>{if(n.button!==0||M)return;const t=Ye(n);T({x0:t.x,y0:t.y,x:t.x,y:t.y})},Es=n=>{var l,h;if(!f)return;const t=Ye(n);!((l=p.current)!=null&&l.paused)&&(Math.abs(t.x-f.x0)>1||Math.abs(t.y-f.y0)>1)&&((h=p.current)==null||h.pause()),T({...f,x:t.x,y:t.y})},Ls=()=>{if(!f)return;const n={x:Math.min(f.x0,f.x),y:Math.min(f.y0,f.y),w:Math.abs(f.x-f.x0),h:Math.abs(f.y-f.y0)};if(T(null),n.w<1&&n.h<1){fe();return}Re(n)},le=f&&{x:Math.min(f.x0,f.x),y:Math.min(f.y0,f.y),w:Math.abs(f.x-f.x0),h:Math.abs(f.y-f.y0)},Ss=async()=>{const n=await en(e.node,e.scenario).catch(t=>({error:String(t)}));v==null||v((n==null?void 0:n.error)||"")},Ms=[...rn({okd:!!w.humanOk,isLatest:!F||A===0},{ok:Ss}).map(n=>({name:n.name,description:d(n.descKey),ui:!0,color:n.color,run:n.run})),...ps.map(n=>({name:n.name,description:n.desc||n.title,source:"review",prefill:()=>on(n.body,{node:e.node,scenario:e.scenario,expected:w.expected||""})}))],$s=s.jsxs(s.Fragment,{children:[s.jsx(q,{kind:"eval",state:Te(w),showLabel:!0,className:"an-verdict-badge",size:16}),w.humanOk&&s.jsxs("span",{className:"an-okd","data-tip":d("annotator.okBy",{by:w.humanOk.by,at:new Date(w.humanOk.ts).toLocaleString()}),children:[s.jsx(Z,{name:"circle-check",size:14})," ",d("annotator.okd")]}),F&&F.length>1&&(()=>{const n=F.length,t=Math.min(xe,n),l=A<xe?Array.from({length:t},(k,$)=>t-1-$):[A,...Array.from({length:xe-1},(k,$)=>xe-2-$)],h=new Set(l),g=F.map((k,$)=>({...k,idx:$})).filter(k=>!h.has(k.idx));return s.jsxs("div",{className:"an-ab",children:[s.jsx(be,{icon:"chevron-left",size:13,className:"an-ab-nav",disabled:A>=F.length-1,onClick:()=>te(k=>Math.min(F.length-1,k+1)),label:d("annotator.abOlder")}),g.length>0&&s.jsx(dn,{hidden:g,total:n,histIdx:A,onPick:te}),s.jsx("div",{className:"an-ab-track",children:l.map(k=>{const $=F[k],Q=Te($);return s.jsx("button",{type:"button",className:`an-ab-pip ${k===A?"on":""}`,"aria-current":k===A?"true":void 0,onClick:()=>te(k),"aria-label":`${n-k}/${n} · ${d(`score.${Q}`)} · ${new Date($.ts).toLocaleString()}`,children:s.jsx(q,{kind:"eval",state:Q,size:13})},`${$.ts}-${k}`)})}),s.jsx(be,{icon:"chevron-right",size:13,className:"an-ab-nav",disabled:A<=0,onClick:()=>te(k=>Math.max(0,k-1)),label:d("annotator.abNewer")}),s.jsx("span",{className:"an-ab-pos",children:A===0?d("annotator.abLatest"):d("annotator.abPos",{i:F.length-A,n:F.length})})]})})()]}),Ns=s.jsxs(s.Fragment,{children:[s.jsxs(W,{label:d("detail.sideReading"),children:[w.evaluator&&s.jsx(G,{text:w.evaluator}),s.jsx(G,{text:new Date(w.ts).toLocaleString()})]}),s.jsx(W,{label:d("detail.sideNode"),children:s.jsx(G,{text:e.node,mono:!0,tip:m?d("session.issuesFocusNode"):e.node,onClick:m?()=>m(e.node):null})}),_e&&s.jsx(W,{label:d("detail.sideFiler"),children:s.jsx(qs,{originator:_e,sessions:b,kind:"eval",onOpenSession:x})}),w.humanOk&&s.jsxs(W,{label:d("detail.sideOk"),children:[s.jsx(G,{text:`☑ ${w.humanOk.by}`}),s.jsx(G,{text:new Date(w.humanOk.ts).toLocaleString(),dim:!0})]}),!w.fresh&&(((Je=w.staleAxes)==null?void 0:Je.length)??0)>0&&s.jsxs(W,{label:d("nodeView.eval.staleLabel"),children:[s.jsx(G,{text:w.staleAxes.join(" · "),tip:d("nodeView.eval.staleReadoutTitle")}),(((Ze=w.codeDrift)==null?void 0:Ze.length)??0)>0&&s.jsx(G,{text:w.codeDrift.map(n=>`${n.file.split("/").pop()} +${n.behind}`).join(", "),dim:!0})]}),(u.prev.length>0||u.next.length>0)&&s.jsx(W,{label:d("detail.sideQueue"),children:[["prev",d("detail.queuePrev")],["next",d("detail.queueNext")]].map(([n,t])=>u[n].length>0&&s.jsxs("div",{className:"ds-queue-group",children:[s.jsx("span",{className:"ds-queue-group-label",children:t}),u[n].map(l=>s.jsxs("a",{className:"ds-queue-row",href:l.href,"data-tip":`${l.node} · ${l.scenario}`,children:[s.jsx(q,{kind:"eval",state:l.state,size:13}),s.jsx("span",{className:"ds-queue-scenario",children:l.scenario}),s.jsx("span",{className:"ds-queue-node",children:l.node})]},l.key))]},n))})]}),Rs=s.jsx(Us,{onSend:(n,t)=>Ws({node:e.node,scenario:e.scenario,body:n,codeSha:w.codeSha,evidence:t}),specs:i,sessions:b,focusId:e.node,onDone:v,anchorNow:X?ks:null,draft:ie,commands:Ms},xs);return s.jsxs(Fe,{title:e.scenario,titleMeta:s.jsx("span",{className:"an-node",children:e.node}),status:$s,side:Ns,composer:Rs,listHref:j,backHref:E,backLabel:R,children:[w.expected&&s.jsxs("div",{className:"an-expected",children:[s.jsx("b",{children:d("nodeView.eval.expected")})," ",w.expected]}),ae.length>0&&((De=w.verdict)==null?void 0:De.note)&&s.jsxs("div",{className:"an-expected an-prior-note",children:[s.jsx("b",{children:d("nodeView.eval.noteLabel")})," ",w.verdict.note]}),H&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"an-player",ref:S,children:[s.jsxs("div",{className:`an-stage ${oe?"playing":"paused"}`,ref:L,onMouseDown:js,onMouseMove:Es,onMouseUp:Ls,children:[s.jsx("video",{className:"an-video",ref:p,src:ke(`/api/evidence/${H.hash}`),preload:"metadata",playsInline:!0}),le&&s.jsx("div",{className:"an-rect live",style:{left:`${le.x}%`,top:`${le.y}%`,width:`${le.w}%`,height:`${le.h}%`}}),!oe&&!f&&s.jsx("div",{className:"an-bigplay","aria-hidden":!0,children:s.jsx(Z,{name:"play",size:22})})]}),s.jsxs("div",{className:"an-bar",children:[s.jsx(be,{icon:oe?"pause":"play",size:14,className:"an-play",label:d(oe?"annotator.pause":"annotator.play"),onClick:fe}),s.jsxs("div",{className:"an-seek",ref:N,onMouseDown:ys,onMouseMove:gs,onMouseLeave:()=>Me(null),children:[s.jsx("div",{className:"an-seek-trk"}),Y>0&&O==="time"&&y.map((n,t)=>s.jsx("div",{className:"an-band",style:{left:`${n.at/Y*100}%`},"data-tip":n.step},`band-${t}`)),s.jsx("div",{className:"an-seek-play",ref:K}),Y>0&&z.map(n=>s.jsx("button",{type:"button",className:`an-mk ${ce===n.i?"on":""} ${Ie===n.i?"active":""}`,style:{left:`${n.tMs/Y*100}%`},"data-tip":n.label,onMouseDown:t=>t.stopPropagation(),onClick:t=>{t.stopPropagation(),He(n.i,n.tMs)}},`mk-${n.i}`)),s.jsx("div",{className:"an-knob",ref:V}),Se!=null&&Y>0&&s.jsx("div",{className:"an-seek-hov",style:{left:`${Se}%`},children:we(Se/100*Y)})]}),s.jsx("span",{className:"an-time",ref:ne}),ve&&s.jsx("span",{className:"an-curstep","data-tip":ve.node?`→ ${ve.node}`:void 0,children:ve.step}),s.jsx(Vs,{target:S})]})]}),y.length>0&&s.jsx(os,{events:y,axis:O,extent:Ve,activeStepIdx:je,onSeek:D}),B&&s.jsx("div",{className:"an-flash",children:B})]}),!H&&y.length>0&&s.jsx(os,{events:y,axis:O,extent:Ve,activeStepIdx:je,onSeek:D}),ue.length>0&&s.jsx("div",{className:"an-gallery",children:ue.map((n,t)=>s.jsx(ls,{e:n,alt:e.scenario},`${n.hash}-${t}`))}),ws.map((n,t)=>s.jsx(ls,{e:n,alt:e.scenario,collapsed:X||ue.length>0},`${n.hash}-${t}`)),ae.length===0&&((We=w.verdict)!=null&&We.note?s.jsx("pre",{className:"eval-transcript",children:w.verdict.note}):s.jsx("div",{className:"an-hint",children:d("nodeView.eval.noImage")})),s.jsx(vn,{entry:e,comments:Ne,seekMs:X?D:null,selIdx:ce,activeIdx:Ie,onSelect:X?He:null,events:X?y:null,onWrite:v})]})}function vn({entry:e,comments:a,seekMs:r,selIdx:i,activeIdx:b,onSelect:v,events:x,onWrite:m}){var E;const j=U();return s.jsxs("section",{className:"an-thread",children:[s.jsx("div",{className:"an-comments-head",children:s.jsx("span",{children:j("annotator.comments",{n:a.length})})}),s.jsx(Xs,{replies:a,onSeek:r,selIdx:i,activeIdx:b,onSelect:v,events:x,threadId:((E=e.thread)==null?void 0:E.id)??null,onRemarkChange:()=>m==null?void 0:m("")})]})}const pe=new Map,fn=[];function cs(e,a){if(!(e!=null&&e.evalRevision)||!(a!=null&&a.epoch))return!0;const r=e.evalRevision;return r.epoch!==a.epoch||r.generation<a.generation?!1:r.generation!==a.generation?!0:!(a.revision&&r.content!==a.revision||a.value&&(!e.summary||["measured","total","pass","fail","review","blind","unknown"].some(b=>e.summary[b]!==a.value[b])))}function us(e,a,r){const i=`${r||""}\0${e}\0${a}`;if(pe.has(i))return pe.get(i);const b=new URLSearchParams({node:e,scenario:a});r&&b.set("scope",r);const v=fetch(ke(`/api/evals/detail?${b}`),{cache:"no-store"}).then(x=>x.ok?x.json():x.status===404?!1:Promise.reject(new Error(`HTTP ${x.status}`))).finally(()=>pe.delete(i));return pe.set(i,v),v}function mn(e,a,r,i=!0,b=null){const v=String(e||"").indexOf("/"),x=v>0?e.slice(0,v):e,m=v>0?e.slice(v+1):"",j=`${a||""}\0${x}\0${m}`,[E,R]=c.useState({identity:"",data:null,error:null}),u=c.useRef(0),d=c.useRef(r);d.current=r;const p=c.useCallback(()=>{if(!i||!x||!m)return Promise.resolve();const N=++u.current;return R(S=>S.identity===j?{...S,error:null}:{identity:j,data:null,error:null}),us(x,m,a).then(async S=>{if(N===u.current){if(S&&!cs(S,d.current)){const P=await us(x,m,a);if(N!==u.current)return;if(P&&!cs(P,d.current))throw new Error("stale session eval detail");S=P}R({identity:j,data:S,error:null})}}).catch(S=>{if(N!==u.current)return;const P=S instanceof Error?S.message:String(S);R(y=>({identity:j,data:y.identity===j&&y.data?y.data:!1,error:P}))})},[i,j,x,m,a]);c.useEffect(()=>{i&&p()},[i,x,m,a,b,r==null?void 0:r.epoch,r==null?void 0:r.generation,r==null?void 0:r.revision]);const L=E.identity===j?E:{data:null,error:null};return{data:L.data,error:L.error,reload:p}}function xn({sessionId:e}){const r=U()("sessionEval.scopeDoor");return s.jsx("a",{className:"se-door",href:ye(Js(e)),"data-tip":r,"aria-label":r,children:s.jsx(Z,{name:"arrow-left",size:16})})}function pn({sessionId:e,pageData:a,loading:r,error:i,sessions:b,queryText:v,onQueryText:x,hrefFor:m,hrefForPage:j,notice:E}){const R=U(),u=(a==null?void 0:a.unknown)||0,d=e&&!r&&!i&&((a==null?void 0:a.sourceTotal)??0)===0?R("sessionEval.none"):null,p=e?s.jsxs("div",{className:"se-gates",children:[s.jsx(xn,{sessionId:e}),a&&a.gates.map(L=>s.jsxs("span",{className:`se-gate ${L.ok?"ok":"bad"}`,"data-tip":L.detail,children:[s.jsx(Z,{name:L.ok?"check":"x",size:11})," ",L.label]},L.label)),u>0&&s.jsxs("span",{className:"se-gate bad","data-tip":R("sessionEval.unknownCoverage",{n:u}),children:[s.jsx(Z,{name:"info",size:11})," ",u]}),a&&s.jsx("span",{className:"se-acts",children:s.jsx("a",{className:"se-export",href:ke(`/api/sessions/${encodeURIComponent(e)}/evals?format=html`),target:"_blank",rel:"noreferrer","data-tip":R("sessionEval.exportTitle"),"aria-label":R("sessionEval.export"),children:s.jsx(Z,{name:"download",size:13})})})]}):null;return s.jsx(an,{pageData:a,loading:r,sessions:b,queryText:v,onQueryText:x,hrefFor:m,notice:E,leading:p,error:i?R("sessionEval.loadFailed",{reason:i}):null,empty:d,pagination:a?{page:a.page,pageCount:a.pageCount,prev:a.prev,next:a.next,hrefFor:j}:null})}function bn({param:e,detail:a,sessionId:r,loading:i=!1,error:b,specs:v,sessions:x,listHref:m,backHref:j,backLabel:E,onOpenSession:R,onFocusNode:u,onWrite:d,notice:p}){const L=U(),N=e.indexOf("/"),S=N>0?e.slice(0,N):e,P=N>0?e.slice(N+1):null,y=c.useMemo(()=>{const O=f=>({key:vs(f),node:f.node,scenario:f.scenario,state:f.state,href:ye(r?Ae(r,f.node,f.scenario):hs(f.node,f.scenario))}),I=(a==null?void 0:a.neighbors)||{prev:[],next:[]};return{prev:I.prev.map(O),next:I.next.map(O)}},[a==null?void 0:a.neighbors,r]);if(b)return s.jsx(Fe,{failure:L("sessionEval.loadFailed",{reason:b}),listHref:m,listLabel:L("reviewShell.backToEvals")});if(i)return s.jsx("div",{className:"fv-note",children:L("common.loading")});const C=(a==null?void 0:a.selected)||null;return C?s.jsxs("div",{className:"page-detail-stack",children:[p&&s.jsx("div",{className:"fv-notice",children:p}),s.jsx(hn,{entry:C,history:a.history,sourceKey:r||"project",specs:v,sessions:x,onOpenSession:R,onFocusNode:u,onWrite:d,listHref:m,backHref:j,backLabel:E,queue:y})]}):s.jsx(Fe,{missing:L("reviewShell.evalNotFound",{node:S,scenario:P||""}),listHref:m,listLabel:L("reviewShell.backToEvals")})}function En({specs:e=fn,sessions:a=[],issuesStamp:r=null,reloadBoard:i,onOpenSession:b,onFocusNode:v=null}){var _;const x=U(),{param:m,query:j}=Ts(),E=J(j.q||"","scope")||null,R=((_=a.find(M=>M.id===E))==null?void 0:_.evalSummary)||null,u=mn(m,E,R,!!m,r),d=String(j.q??"").trim()||re,p=Ys(j.page),L=Qs("evals",d,p,{enabled:!m,refreshKey:e}),[N,S]=c.useState(""),P=M=>{M&&(S(M),setTimeout(()=>S(""),6e3))},y=async M=>{P(M),await(i==null?void 0:i()),await u.reload()},C=M=>ye(E?Ae(E,M.node,M.scenario):hs(M.node,M.scenario)),O=E?ye(Ae(E)):es("evals"),I=Gs("evals",E),f=x("detail.backToEvals"),T=M=>Fs("evals",null,{query:As(M,re)}),B=M=>es("evals",null,Ps(d,re,M));return m?s.jsx(bn,{param:m,detail:u.data&&u.data!==!1?u.data:null,sessionId:E,loading:u.data===null,error:u.error,specs:e,sessions:a,listHref:O,backHref:I,backLabel:f,onOpenSession:b,onFocusNode:v,onWrite:y,notice:N}):s.jsx(pn,{sessionId:E,pageData:L.data,loading:L.loading,error:L.error,sessions:a,queryText:j.q||"",onQueryText:T,hrefFor:C,hrefForPage:B,notice:N})}export{bn as EvalDetailPage,xn as EvalScopeDoor,pn as EvalsListPage,En as default,cs as detailMatchesProjection};
@@ -1 +1 @@
1
- import{u as D,f as Y,k as A,r as v,j as e,n as K,g as R,c as F,I as $,h as G,q as Q,s as V}from"./index-BUKLPN_4.js";import{f as J,g as X,h as Z,i as W,j as ee}from"./data-SNi0AmVT.js";import{l as se,n as te,D as P,x as _,j as ne,g as ie,d as C,f as E,O as le,a as U,q as M,R as ae,y as re,L as oe,S as ce,F as ue,z as de,A as fe,M as pe,B as O,C as me,T as q,G as H,H as ve}from"./Thread-Dg35J-Pu.js";import"./PageScroll-B2kxcqJJ.js";const z="new",xe=s=>s.status!=="open",be=s=>{const o=Math.max(0,(Date.now()-new Date(s).getTime())/1e3);return Number.isFinite(o)?o<3600?`${Math.max(1,Math.floor(o/60))}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`:""},je=s=>{const o=String(s||"").split("#"),d=o.length>1?o.at(-1):o[0];return`#${d.length>16?`${d.slice(0,13)}…`:d}`},ge=["is","state","store","author","node","session"],T=(s,o,d,c=l=>l)=>{var l,t;return(((t=(l=s==null?void 0:s.facets)==null?void 0:l[o])==null?void 0:t.options)??[]).map(u=>({value:u.value,label:u.value===""?d:c(u.value)}))};function he({data:s,loading:o,error:d,query:c,notice:l}){var a,y,x,I;const t=D();if(s&&!s.enabled)return e.jsx("div",{className:"fv-note",children:t("session.issuesOff")});const u=Array.isArray(s==null?void 0:s.items)?s.items:[],r=String(c.q??"").trim()||A,b=i=>K("issues",null,{query:Q(i,A)}),m=(i,n)=>b(V(r,i,n)),p=(((y=(a=s==null?void 0:s.facets)==null?void 0:a.store)==null?void 0:y.options)??[]).map(i=>i.value).filter(Boolean),w=u,j=((x=s==null?void 0:s.counts)==null?void 0:x.open)||0,f=((I=s==null?void 0:s.counts)==null?void 0:I.closed)||0,h=F(r,"state"),L=w.map(i=>{var g,B;const n=i.status||"open";return{key:i.id,href:R("issues",i.id),content:e.jsx(e.Fragment,{children:e.jsx(ae,{state:e.jsx(U,{kind:"issue",state:n}),title:i.concern,meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-tip":i.id,children:je(i.id)}),i.by&&e.jsx("span",{"data-tip":i.by,children:t("reviewList.openedBy",{by:re(i.by)})}),i.created&&e.jsx("span",{children:t("reviewList.openedAt",{at:be(i.created)})})]}),aside:e.jsxs(e.Fragment,{children:[(((g=i.replies)==null?void 0:g.length)??0)>0&&e.jsxs("span",{className:"rl-comments","data-tip":t("session.issuesReplies",{n:i.replies.length}),children:[e.jsx($,{name:"message-square",size:14}),i.replies.length]}),p.length>1&&e.jsx("span",{className:`rl-tag fv-store-${i.store==="local"?"local":"forge"}`,children:i.store}),((B=i.nodes)==null?void 0:B[0])&&e.jsx("span",{className:"rl-tag node",children:i.nodes[0]})]})})})}}),k=e.jsxs("a",{className:"rl-new",href:R("issues",z),children:[e.jsx($,{name:"plus",size:14}),t("session.issuesNew")]}),N={label:t("reviewList.facetStore"),value:F(r,"store"),options:T(s,"store",t("reviewList.all"))},S={label:t("reviewList.facetSession"),value:F(r,"session"),options:T(s,"session",t("reviewList.all"),i=>t(i==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))};return e.jsx(oe,{notice:l,loading:o,error:d,title:t("reviewList.issuesTitle"),action:k,search:{value:String(c.q??"").trim()?c.q:A,onSubmit:b,placeholder:t("reviewList.searchIssues"),label:t("reviewList.search"),keys:ge,suggest:{author:T(s,"author",t("reviewList.all")).filter(i=>i.value),node:T(s,"node",t("reviewList.all")).filter(i=>i.value)}},sections:[{key:"open",label:t("reviewList.open"),count:j,active:h===""||h==="open",onSelect:()=>m("state","open")},{key:"closed",label:t("reviewList.closed"),count:f,active:h!==""&&h!=="open",onSelect:()=>m("state","closed")}],facets:e.jsx(ue,{label:N.label,value:N.value,options:N.options,clearLabel:t("reviewList.all"),onChange:i=>m("store",i),mobile:!0}),secondaryFilters:e.jsx(ce,{label:t("reviewList.filters"),clearLabel:t("reviewList.all"),groups:[{label:S.label,value:S.value,active:!!S.value,options:S.options,onChange:i=>m("session",i)}]}),rows:L,pagination:s?{page:s.page,pageCount:s.pageCount,prev:s.prev,next:s.next,hrefFor:i=>R("issues",null,G(r,A,i))}:null,empty:{hasData:((s==null?void 0:s.sourceTotal)??0)>0,dataset:t("session.issuesEmpty"),filtered:t("session.issuesNoMatch")}})}function ye({issue:s,specs:o,sessions:d,onFocusNode:c,onOpenSession:l,onWrite:t,notice:u}){const r=D(),b=s.store==="local",m=xe(s),[p,w]=v.useState(""),[j,f]=v.useState(""),h=Array.isArray(s.nodes)?s.nodes:[],L=Array.isArray(s.replies)?s.replies:[],k=s.status||"open",N=(a,y)=>async()=>{if(!p){w(a);try{const x=await y();x!=null&&x.ok?(f(""),await(t==null?void 0:t(""))):f((x==null?void 0:x.error)||`${a} failed`)}finally{w("")}}},S=(a,y,x,I)=>e.jsx("button",{type:"button",className:`fv-close-issue fv-life-${a}`,disabled:!!p,"data-tip":I,onMouseDown:i=>i.preventDefault(),onClick:N(a,x),children:p===a?r("session.issuesActing"):y});return e.jsxs(P,{title:s.concern,backHref:M("issues"),backLabel:r("detail.backToIssues"),status:e.jsx(U,{kind:"issue",state:k,showLabel:!0,className:"ds-status-pill",size:16}),side:e.jsxs(e.Fragment,{children:[e.jsx(C,{label:r("detail.sideIssue"),children:e.jsx(E,{text:s.id,mono:!0})}),e.jsxs(C,{label:r("detail.sideStore"),children:[e.jsx(E,{text:s.store,className:`fv-store fv-store-${b?"local":"forge"}`}),s.url&&e.jsx(E,{text:r("session.issuesOpenOnStore",{store:Se(s.store)}),href:s.url,external:!0})]}),s.by&&e.jsx(C,{label:r("detail.sideOriginator"),children:b?e.jsx(le,{originator:s.by,sessions:d,kind:"issue",onOpenSession:l}):e.jsx(E,{text:s.by,dim:!0})}),h.length>0&&e.jsx(C,{label:r("detail.sideNodes"),children:h.map(a=>e.jsx(E,{text:a,mono:!0,tip:r("session.issuesFocusNode"),onClick:()=>c==null?void 0:c(a)},a))})]}),composer:e.jsx(ie,{onSend:(a,y)=>Z(s.id,a,y),specs:o,sessions:d,focusId:h[0]||null,onDone:t,actionsEnd:!m&&e.jsxs(e.Fragment,{children:[j&&e.jsx("span",{className:"fv-error",children:j}),b&&S("promote",r("session.issuesPromote"),()=>J(s.id),r("session.issuesPromoteTitle")),S("close",r("session.issuesCloseIssue"),()=>X(s.id),r("session.issuesCloseIssueTitle"))]})},s.id),children:[u&&e.jsx("div",{className:"fv-notice",children:u}),s.body&&e.jsx("div",{className:"fvd-body",children:e.jsx(_,{body:s.body})}),e.jsx(ne,{replies:L,threadId:b?s.id:null,onRemarkChange:()=>t==null?void 0:t("")})]})}function we(s,o){const[d,c]=v.useState(null),[l,t]=v.useState(null),u=v.useRef(0),r=v.useCallback(async()=>{if(!s)return null;const m=++u.current;t(null);try{const p=await W(s);return m===u.current&&c(p),p}catch(p){return m===u.current&&(c(!1),t(p instanceof Error?p.message:String(p))),null}},[s]),b=v.useRef(null);return v.useEffect(()=>{s!==b.current&&(b.current=s,c(null),t(null)),s&&r()},[s,o,r]),{issue:d,error:l,reload:r}}function Ae({onFocusNode:s,onOpenSession:o,specs:d=[],sessions:c=[],issuesStamp:l=null}){var S;const t=D(),{param:u,query:r}=Y(),b=u===z,m=String(r.q??"").trim()||A,p=se(r.page),w=v.useMemo(()=>c.map(a=>a.id).join(","),[c]),j=te("issues",m,p,{enabled:!u||b,refreshKey:`${l??""}|${w}`}),f=we(b?null:u,l),[h,L]=v.useState(""),k=a=>{a&&(L(a),setTimeout(()=>L(""),6e3))},N=async a=>{k(a),await(u?f.reload():j.reload())};if(b){if(j.data&&!j.data.enabled)return e.jsx("div",{className:"fv-note",children:t("session.issuesOff")});const a=Array.isArray((S=j.data)==null?void 0:S.stores)&&j.data.stores.length?j.data.stores:[{id:"local",label:"local",kind:"local"}];return e.jsx(Le,{specs:d,sessions:c,stores:a,onCreated:(y,x)=>{k(x),K("issues",y,{replace:!0})}})}return u?f.issue==null?e.jsx("div",{className:"fv-note",children:t("session.issuesLoading")}):f.error?e.jsx(P,{failure:f.error,listHref:R("issues"),listLabel:t("reviewShell.backToIssues")}):f.issue===!1?e.jsx(P,{missing:t("reviewShell.issueNotFound",{id:u}),listHref:R("issues"),listLabel:t("reviewShell.backToIssues")}):e.jsx(ye,{issue:f.issue,specs:d,sessions:c,onFocusNode:s,onOpenSession:o,onWrite:N,notice:h}):e.jsx(he,{data:j.data,loading:j.loading,error:j.error,query:r,notice:h})}const Ne={github:"GitHub",gitlab:"GitLab"},Se=s=>Ne[s]||s;function Le({specs:s,sessions:o,stores:d,onCreated:c}){var i;const l=D(),[t,u]=v.useState(((i=d[0])==null?void 0:i.id)||"local"),[r,b]=v.useState(""),[m,p]=v.useState(""),[w,j]=v.useState(!1),[f,h]=v.useState(!1),[L,k]=v.useState(""),N=v.useRef(null),{launchers:S}=de(),a=fe({inputRef:N,value:m,setValue:p,specs:s,sessions:o,launchers:S});v.useEffect(()=>{var n;d.some(g=>g.id===t)||u(((n=d[0])==null?void 0:n.id)||"local")},[d,t]);const y=[...new Set([...m.matchAll(pe)].map(n=>n[1]))],x=async()=>{const n=r.trim();if(!(!n||f)){h(!0),k("");try{const g=await ee({concern:n,body:m.trim()||void 0,store:t});g!=null&&g.ok&&g.id?c==null||c(g.id,g.outcomes||""):k((g==null?void 0:g.error)||l("session.issuesPostFailed"))}finally{h(!1)}}},I=(n,g)=>e.jsx("button",{type:"button",role:"tab","aria-selected":w===n,className:`fv-tab ${w===n?"on":""}`,onClick:()=>j(n),children:g});return e.jsx(P,{title:l("session.issuesNewTitle"),backHref:M("issues"),backLabel:l("detail.backToIssues"),side:e.jsxs(e.Fragment,{children:[e.jsx(C,{label:l("session.issuesStoreLabel"),children:e.jsxs("label",{className:"fv-store-pick",children:[e.jsx("span",{className:"sr-only",children:l("session.issuesStoreLabel")}),e.jsx("select",{value:t,disabled:f,onChange:n=>u(n.target.value),children:d.map(n=>e.jsx("option",{value:n.id,children:n.label||n.id},n.id))})]})}),e.jsx(C,{label:l("detail.sideNodes"),children:y.length>0?y.map(n=>e.jsx(E,{text:n,mono:!0},n)):e.jsx(E,{text:l("session.issuesNodesHint"),dim:!0})})]}),children:e.jsxs("div",{className:"fv-new-page",children:[e.jsxs("label",{className:"fv-field",children:[e.jsx("span",{className:"fv-field-label",children:l("session.issuesTitleLabel")}),e.jsx("input",{className:"fv-input fv-new-title",value:r,placeholder:l("session.issuesConcernPlaceholder"),disabled:f,autoFocus:!0,onChange:n=>b(n.target.value),onKeyDown:n=>{O(n)||n.key==="Enter"&&(n.preventDefault(),x())}})]}),e.jsxs("div",{className:"fv-field",children:[e.jsxs("div",{className:"fv-field-head",children:[e.jsx("span",{className:"fv-field-label",children:l("session.issuesBodyLabel")}),e.jsxs("div",{className:"fv-tabs",role:"tablist","aria-label":l("session.issuesBodyLabel"),children:[I(!1,l("session.issuesWrite")),I(!0,l("session.issuesPreview"))]})]}),e.jsx(me,{className:"fv-new-compose",editor:w?e.jsx("div",{className:"fv-new-preview",role:"tabpanel",children:m.trim()?e.jsx(_,{body:m}):e.jsx("span",{className:"fv-new-hint",children:l("session.issuesPreviewEmpty")})}):e.jsxs("div",{className:"fv-tawrap",role:"tabpanel",children:[e.jsx(ve,{ref:N,className:"fv-textarea",rows:1,value:m,placeholder:l("session.issuesBodyPlaceholder"),disabled:f,onChange:n=>{p(n.target.value),a.sync(n.target)},onSelect:n=>a.sync(n.target),onBlur:a.close,onKeyDown:n=>{O(n)||a.onKeyDown(n)||n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),x())}}),a.menuEl]}),footer:e.jsxs("div",{className:"fv-actions",children:[e.jsx(q,{label:l("thread.mentionActor"),disabled:f||w,onClick:()=>H(N.current,"@",p,a.sync),children:"@"}),e.jsx(q,{label:l("thread.mentionNode"),disabled:f||w,onClick:()=>H(N.current,"[[",p,a.sync),children:"[["})]})})]}),e.jsxs("div",{className:"fv-new-actions",children:[L&&e.jsx("span",{className:"fv-error",children:L}),e.jsx("a",{className:"fv-cancel",href:M("issues"),children:l("session.issuesCancel")}),e.jsx("button",{type:"button",className:"fv-post",disabled:f||!r.trim(),onClick:x,children:l(f?"session.issuesSending":"session.issuesPost")})]})]})})}export{ge as ISSUE_QUERY_KEYS,ye as IssueDetailPage,he as IssuesListPage,z as NEW_PARAM,Ae as default};
1
+ import{u as D,f as Y,k as A,r as v,j as e,n as K,g as R,c as F,I as $,h as G,q as Q,s as V}from"./index-Di1ch5dd.js";import{f as J,g as X,h as Z,i as W,j as ee}from"./data-CQFbQEMH.js";import{l as se,n as te,D as P,x as _,j as ne,g as ie,d as C,f as E,O as le,a as U,q as M,R as ae,y as re,L as oe,S as ce,F as ue,z as de,A as fe,M as pe,B as O,C as me,T as q,G as H,H as ve}from"./Thread-BpL3N3kw.js";import"./PageScroll-px_rUZVJ.js";const z="new",xe=s=>s.status!=="open",be=s=>{const o=Math.max(0,(Date.now()-new Date(s).getTime())/1e3);return Number.isFinite(o)?o<3600?`${Math.max(1,Math.floor(o/60))}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`:""},je=s=>{const o=String(s||"").split("#"),d=o.length>1?o.at(-1):o[0];return`#${d.length>16?`${d.slice(0,13)}…`:d}`},ge=["is","state","store","author","node","session"],T=(s,o,d,c=l=>l)=>{var l,t;return(((t=(l=s==null?void 0:s.facets)==null?void 0:l[o])==null?void 0:t.options)??[]).map(u=>({value:u.value,label:u.value===""?d:c(u.value)}))};function he({data:s,loading:o,error:d,query:c,notice:l}){var a,y,x,I;const t=D();if(s&&!s.enabled)return e.jsx("div",{className:"fv-note",children:t("session.issuesOff")});const u=Array.isArray(s==null?void 0:s.items)?s.items:[],r=String(c.q??"").trim()||A,b=i=>K("issues",null,{query:Q(i,A)}),m=(i,n)=>b(V(r,i,n)),p=(((y=(a=s==null?void 0:s.facets)==null?void 0:a.store)==null?void 0:y.options)??[]).map(i=>i.value).filter(Boolean),w=u,j=((x=s==null?void 0:s.counts)==null?void 0:x.open)||0,f=((I=s==null?void 0:s.counts)==null?void 0:I.closed)||0,h=F(r,"state"),L=w.map(i=>{var g,B;const n=i.status||"open";return{key:i.id,href:R("issues",i.id),content:e.jsx(e.Fragment,{children:e.jsx(ae,{state:e.jsx(U,{kind:"issue",state:n}),title:i.concern,meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-tip":i.id,children:je(i.id)}),i.by&&e.jsx("span",{"data-tip":i.by,children:t("reviewList.openedBy",{by:re(i.by)})}),i.created&&e.jsx("span",{children:t("reviewList.openedAt",{at:be(i.created)})})]}),aside:e.jsxs(e.Fragment,{children:[(((g=i.replies)==null?void 0:g.length)??0)>0&&e.jsxs("span",{className:"rl-comments","data-tip":t("session.issuesReplies",{n:i.replies.length}),children:[e.jsx($,{name:"message-square",size:14}),i.replies.length]}),p.length>1&&e.jsx("span",{className:`rl-tag fv-store-${i.store==="local"?"local":"forge"}`,children:i.store}),((B=i.nodes)==null?void 0:B[0])&&e.jsx("span",{className:"rl-tag node",children:i.nodes[0]})]})})})}}),k=e.jsxs("a",{className:"rl-new",href:R("issues",z),children:[e.jsx($,{name:"plus",size:14}),t("session.issuesNew")]}),N={label:t("reviewList.facetStore"),value:F(r,"store"),options:T(s,"store",t("reviewList.all"))},S={label:t("reviewList.facetSession"),value:F(r,"session"),options:T(s,"session",t("reviewList.all"),i=>t(i==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))};return e.jsx(oe,{notice:l,loading:o,error:d,title:t("reviewList.issuesTitle"),action:k,search:{value:String(c.q??"").trim()?c.q:A,onSubmit:b,placeholder:t("reviewList.searchIssues"),label:t("reviewList.search"),keys:ge,suggest:{author:T(s,"author",t("reviewList.all")).filter(i=>i.value),node:T(s,"node",t("reviewList.all")).filter(i=>i.value)}},sections:[{key:"open",label:t("reviewList.open"),count:j,active:h===""||h==="open",onSelect:()=>m("state","open")},{key:"closed",label:t("reviewList.closed"),count:f,active:h!==""&&h!=="open",onSelect:()=>m("state","closed")}],facets:e.jsx(ue,{label:N.label,value:N.value,options:N.options,clearLabel:t("reviewList.all"),onChange:i=>m("store",i),mobile:!0}),secondaryFilters:e.jsx(ce,{label:t("reviewList.filters"),clearLabel:t("reviewList.all"),groups:[{label:S.label,value:S.value,active:!!S.value,options:S.options,onChange:i=>m("session",i)}]}),rows:L,pagination:s?{page:s.page,pageCount:s.pageCount,prev:s.prev,next:s.next,hrefFor:i=>R("issues",null,G(r,A,i))}:null,empty:{hasData:((s==null?void 0:s.sourceTotal)??0)>0,dataset:t("session.issuesEmpty"),filtered:t("session.issuesNoMatch")}})}function ye({issue:s,specs:o,sessions:d,onFocusNode:c,onOpenSession:l,onWrite:t,notice:u}){const r=D(),b=s.store==="local",m=xe(s),[p,w]=v.useState(""),[j,f]=v.useState(""),h=Array.isArray(s.nodes)?s.nodes:[],L=Array.isArray(s.replies)?s.replies:[],k=s.status||"open",N=(a,y)=>async()=>{if(!p){w(a);try{const x=await y();x!=null&&x.ok?(f(""),await(t==null?void 0:t(""))):f((x==null?void 0:x.error)||`${a} failed`)}finally{w("")}}},S=(a,y,x,I)=>e.jsx("button",{type:"button",className:`fv-close-issue fv-life-${a}`,disabled:!!p,"data-tip":I,onMouseDown:i=>i.preventDefault(),onClick:N(a,x),children:p===a?r("session.issuesActing"):y});return e.jsxs(P,{title:s.concern,backHref:M("issues"),backLabel:r("detail.backToIssues"),status:e.jsx(U,{kind:"issue",state:k,showLabel:!0,className:"ds-status-pill",size:16}),side:e.jsxs(e.Fragment,{children:[e.jsx(C,{label:r("detail.sideIssue"),children:e.jsx(E,{text:s.id,mono:!0})}),e.jsxs(C,{label:r("detail.sideStore"),children:[e.jsx(E,{text:s.store,className:`fv-store fv-store-${b?"local":"forge"}`}),s.url&&e.jsx(E,{text:r("session.issuesOpenOnStore",{store:Se(s.store)}),href:s.url,external:!0})]}),s.by&&e.jsx(C,{label:r("detail.sideOriginator"),children:b?e.jsx(le,{originator:s.by,sessions:d,kind:"issue",onOpenSession:l}):e.jsx(E,{text:s.by,dim:!0})}),h.length>0&&e.jsx(C,{label:r("detail.sideNodes"),children:h.map(a=>e.jsx(E,{text:a,mono:!0,tip:r("session.issuesFocusNode"),onClick:()=>c==null?void 0:c(a)},a))})]}),composer:e.jsx(ie,{onSend:(a,y)=>Z(s.id,a,y),specs:o,sessions:d,focusId:h[0]||null,onDone:t,actionsEnd:!m&&e.jsxs(e.Fragment,{children:[j&&e.jsx("span",{className:"fv-error",children:j}),b&&S("promote",r("session.issuesPromote"),()=>J(s.id),r("session.issuesPromoteTitle")),S("close",r("session.issuesCloseIssue"),()=>X(s.id),r("session.issuesCloseIssueTitle"))]})},s.id),children:[u&&e.jsx("div",{className:"fv-notice",children:u}),s.body&&e.jsx("div",{className:"fvd-body",children:e.jsx(_,{body:s.body})}),e.jsx(ne,{replies:L,threadId:b?s.id:null,onRemarkChange:()=>t==null?void 0:t("")})]})}function we(s,o){const[d,c]=v.useState(null),[l,t]=v.useState(null),u=v.useRef(0),r=v.useCallback(async()=>{if(!s)return null;const m=++u.current;t(null);try{const p=await W(s);return m===u.current&&c(p),p}catch(p){return m===u.current&&(c(!1),t(p instanceof Error?p.message:String(p))),null}},[s]),b=v.useRef(null);return v.useEffect(()=>{s!==b.current&&(b.current=s,c(null),t(null)),s&&r()},[s,o,r]),{issue:d,error:l,reload:r}}function Ae({onFocusNode:s,onOpenSession:o,specs:d=[],sessions:c=[],issuesStamp:l=null}){var S;const t=D(),{param:u,query:r}=Y(),b=u===z,m=String(r.q??"").trim()||A,p=se(r.page),w=v.useMemo(()=>c.map(a=>a.id).join(","),[c]),j=te("issues",m,p,{enabled:!u||b,refreshKey:`${l??""}|${w}`}),f=we(b?null:u,l),[h,L]=v.useState(""),k=a=>{a&&(L(a),setTimeout(()=>L(""),6e3))},N=async a=>{k(a),await(u?f.reload():j.reload())};if(b){if(j.data&&!j.data.enabled)return e.jsx("div",{className:"fv-note",children:t("session.issuesOff")});const a=Array.isArray((S=j.data)==null?void 0:S.stores)&&j.data.stores.length?j.data.stores:[{id:"local",label:"local",kind:"local"}];return e.jsx(Le,{specs:d,sessions:c,stores:a,onCreated:(y,x)=>{k(x),K("issues",y,{replace:!0})}})}return u?f.issue==null?e.jsx("div",{className:"fv-note",children:t("session.issuesLoading")}):f.error?e.jsx(P,{failure:f.error,listHref:R("issues"),listLabel:t("reviewShell.backToIssues")}):f.issue===!1?e.jsx(P,{missing:t("reviewShell.issueNotFound",{id:u}),listHref:R("issues"),listLabel:t("reviewShell.backToIssues")}):e.jsx(ye,{issue:f.issue,specs:d,sessions:c,onFocusNode:s,onOpenSession:o,onWrite:N,notice:h}):e.jsx(he,{data:j.data,loading:j.loading,error:j.error,query:r,notice:h})}const Ne={github:"GitHub",gitlab:"GitLab"},Se=s=>Ne[s]||s;function Le({specs:s,sessions:o,stores:d,onCreated:c}){var i;const l=D(),[t,u]=v.useState(((i=d[0])==null?void 0:i.id)||"local"),[r,b]=v.useState(""),[m,p]=v.useState(""),[w,j]=v.useState(!1),[f,h]=v.useState(!1),[L,k]=v.useState(""),N=v.useRef(null),{launchers:S}=de(),a=fe({inputRef:N,value:m,setValue:p,specs:s,sessions:o,launchers:S});v.useEffect(()=>{var n;d.some(g=>g.id===t)||u(((n=d[0])==null?void 0:n.id)||"local")},[d,t]);const y=[...new Set([...m.matchAll(pe)].map(n=>n[1]))],x=async()=>{const n=r.trim();if(!(!n||f)){h(!0),k("");try{const g=await ee({concern:n,body:m.trim()||void 0,store:t});g!=null&&g.ok&&g.id?c==null||c(g.id,g.outcomes||""):k((g==null?void 0:g.error)||l("session.issuesPostFailed"))}finally{h(!1)}}},I=(n,g)=>e.jsx("button",{type:"button",role:"tab","aria-selected":w===n,className:`fv-tab ${w===n?"on":""}`,onClick:()=>j(n),children:g});return e.jsx(P,{title:l("session.issuesNewTitle"),backHref:M("issues"),backLabel:l("detail.backToIssues"),side:e.jsxs(e.Fragment,{children:[e.jsx(C,{label:l("session.issuesStoreLabel"),children:e.jsxs("label",{className:"fv-store-pick",children:[e.jsx("span",{className:"sr-only",children:l("session.issuesStoreLabel")}),e.jsx("select",{value:t,disabled:f,onChange:n=>u(n.target.value),children:d.map(n=>e.jsx("option",{value:n.id,children:n.label||n.id},n.id))})]})}),e.jsx(C,{label:l("detail.sideNodes"),children:y.length>0?y.map(n=>e.jsx(E,{text:n,mono:!0},n)):e.jsx(E,{text:l("session.issuesNodesHint"),dim:!0})})]}),children:e.jsxs("div",{className:"fv-new-page",children:[e.jsxs("label",{className:"fv-field",children:[e.jsx("span",{className:"fv-field-label",children:l("session.issuesTitleLabel")}),e.jsx("input",{className:"fv-input fv-new-title",value:r,placeholder:l("session.issuesConcernPlaceholder"),disabled:f,autoFocus:!0,onChange:n=>b(n.target.value),onKeyDown:n=>{O(n)||n.key==="Enter"&&(n.preventDefault(),x())}})]}),e.jsxs("div",{className:"fv-field",children:[e.jsxs("div",{className:"fv-field-head",children:[e.jsx("span",{className:"fv-field-label",children:l("session.issuesBodyLabel")}),e.jsxs("div",{className:"fv-tabs",role:"tablist","aria-label":l("session.issuesBodyLabel"),children:[I(!1,l("session.issuesWrite")),I(!0,l("session.issuesPreview"))]})]}),e.jsx(me,{className:"fv-new-compose",editor:w?e.jsx("div",{className:"fv-new-preview",role:"tabpanel",children:m.trim()?e.jsx(_,{body:m}):e.jsx("span",{className:"fv-new-hint",children:l("session.issuesPreviewEmpty")})}):e.jsxs("div",{className:"fv-tawrap",role:"tabpanel",children:[e.jsx(ve,{ref:N,className:"fv-textarea",rows:1,value:m,placeholder:l("session.issuesBodyPlaceholder"),disabled:f,onChange:n=>{p(n.target.value),a.sync(n.target)},onSelect:n=>a.sync(n.target),onBlur:a.close,onKeyDown:n=>{O(n)||a.onKeyDown(n)||n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),x())}}),a.menuEl]}),footer:e.jsxs("div",{className:"fv-actions",children:[e.jsx(q,{label:l("thread.mentionActor"),disabled:f||w,onClick:()=>H(N.current,"@",p,a.sync),children:"@"}),e.jsx(q,{label:l("thread.mentionNode"),disabled:f||w,onClick:()=>H(N.current,"[[",p,a.sync),children:"[["})]})})]}),e.jsxs("div",{className:"fv-new-actions",children:[L&&e.jsx("span",{className:"fv-error",children:L}),e.jsx("a",{className:"fv-cancel",href:M("issues"),children:l("session.issuesCancel")}),e.jsx("button",{type:"button",className:"fv-post",disabled:f||!r.trim(),onClick:x,children:l(f?"session.issuesSending":"session.issuesPost")})]})]})})}export{ge as ISSUE_QUERY_KEYS,ye as IssueDetailPage,he as IssuesListPage,z as NEW_PARAM,Ae as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EvalsPage-BTvJIW8Q.js","assets/index-BUKLPN_4.js","assets/index-CzutlTDf.css","assets/Thread-Dg35J-Pu.js","assets/PageScroll-B2kxcqJJ.js","assets/data-SNi0AmVT.js","assets/IssuesPage-Bn94h_HQ.js","assets/Settings-J3aibcXo.js","assets/bindings-BC9vqpYU.js","assets/terminalFont-C6oGNKrf.js"])))=>i.map(i=>d[i]);
2
- import{u as E,r as o,f as D,j as s,n as y,_ as O}from"./index-BUKLPN_4.js";import{A as z,u as H,S as $,R as B,a as U,F as Q,b as A}from"./SessionWindow-Dag_GiJB.js";import{I as Z,J,K as L,N as K,P as W,Q as X,U as Y,V as q,W as G,X as ss,z as es,H as as,s as ns,Y as ls,o as ts,t as is,Z as cs}from"./Thread-Dg35J-Pu.js";import{T as os}from"./TimelineChat-f0UF9fXq.js";import"./PageScroll-B2kxcqJJ.js";import"./data-SNi0AmVT.js";const rs=o.lazy(()=>O(()=>import("./EvalsPage-BTvJIW8Q.js"),__vite__mapDeps([0,1,2,3,4,5]))),ms=o.lazy(()=>O(()=>import("./IssuesPage-Bn94h_HQ.js"),__vite__mapDeps([6,1,2,5,3,4]))),ds=o.lazy(()=>O(()=>import("./Settings-J3aibcXo.js"),__vite__mapDeps([7,1,2,8,4,9]))),us={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"},R=(e,l)=>l.filter(r=>{var m;return(m=r.ops)==null?void 0:m.some(t=>t.nodeId===e.id)});function M({status:e}){const l=A[e]||A.pending;return s.jsx("span",{className:"m-dot",style:{background:l.color}})}function hs({node:e,kids:l,editors:r,onTap:m}){return s.jsxs("button",{className:"m-row",onClick:m,children:[s.jsx(M,{status:e.status}),s.jsx("span",{className:"m-row-title",children:e.title}),r.length>0&&s.jsx("span",{className:"m-row-faces",children:r.slice(0,3).map(t=>s.jsx(z,{seed:t.id,status:t.status,title:L(t)},t.id))}),e.version?s.jsxs("span",{className:"m-row-ver",children:["v",e.version]}):null,l>0&&s.jsxs("span",{className:"m-row-kids",children:["▸",l]}),s.jsx("span",{className:"m-row-chev",children:"›"})]})}function bs({node:e,childrenOf:l,sessions:r,onOpenChild:m}){const t=E(),d=l(e.id),h=Z(e),f=[...d.length?[{key:"children",label:t("mobile.childrenTab",{n:d.length})}]:[],...h.map(a=>({key:a.key,label:t(us[a.key])}))],[x,b]=o.useState(null),[N,j]=o.useState({issues:{},eval:{}});o.useEffect(()=>{b(null),j({issues:{},eval:{}})},[e.id]);const g=(a,w)=>j(p=>({...p,[a]:ss(p[a],w)})),i=x&&f.some(a=>a.key===x)?x:f[0].key,k=J(e.id,i==="history"),c=R(e,r);return s.jsxs("div",{className:"m-node",children:[s.jsxs("div",{className:"m-node-head",children:[s.jsx(M,{status:e.status}),s.jsx("span",{className:"m-node-title",children:e.title}),e.version?s.jsxs("span",{className:"m-node-ver",children:["v",e.version]}):null,s.jsx("span",{className:"m-node-status",children:t(`status.${e.status}`)}),c.length>0&&s.jsx("span",{className:"m-node-faces",title:t("mobile.liveEditors",{n:c.length}),children:c.map(a=>s.jsx(z,{seed:a.id,status:a.status,title:L(a)},a.id))})]}),e.desc&&s.jsx("div",{className:"m-node-desc",children:e.desc}),s.jsx("div",{className:"m-tabs",children:f.map(a=>s.jsx("button",{className:a.key===i?"m-tab on":"m-tab",onClick:()=>b(a.key),children:a.label},a.key))}),s.jsxs("div",{className:i==="history"?"m-pane-host fixed":"m-pane-host",children:[i==="children"&&s.jsx("div",{className:"m-children",children:d.map(a=>s.jsx(hs,{node:a,kids:l(a.id).length,editors:R(a,r),onTap:()=>m(a.id)},a.id))}),i==="spec"&&s.jsx(K,{node:e}),i==="history"&&s.jsx(W,{node:e,rows:k}),i==="issues"&&s.jsx(X,{node:e,sessions:r,filter:N.issues,onFilter:a=>g("issues",a)}),i==="eval"&&s.jsx(Y,{node:e,sessions:r,filter:N.eval,onFilter:a=>g("eval",a)}),i==="edit"&&s.jsx(q,{node:e})]})]})}function ps({s:e,sessions:l,onBack:r}){const m=E();return s.jsxs("div",{className:"m-sessdetail chat",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":m("mobile.back"),children:"‹"}),s.jsxs("div",{className:"m-sess-meta",children:[s.jsx("span",{className:"m-sess-name",children:ns(e)}),s.jsxs("span",{className:"m-sess-status",style:{color:ls[e.status]},children:[m(`status.${e.status}`),e.merges?` · ×${e.merges}`:""," · ",s.jsx("span",{className:"m-sess-id8",children:e.id.slice(0,8)})]})]}),s.jsx("a",{className:"m-sess-evalbtn",href:ts(is(e.id)),title:m("sessionEval.btnTitle"),children:m("sessionEval.btn")})]}),s.jsx(os,{s:e,sessions:l})]})}function xs({draft:e,setDraft:l,onBack:r,onLaunched:m}){const t=E(),{launchers:d,launcher:h,pickLauncher:f}=es(),[x,b]=o.useState(!1),[N,j]=o.useState(null),g=async()=>{const i=e.trim();if(!i||x)return;b(!0),j(null);const k=await cs(i,h);b(!1),k.ok?(l(""),m()):j(k.error||t("mobile.launchFailed"))};return s.jsxs("div",{className:"m-sessdetail m-new",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":t("mobile.back"),children:"‹"}),s.jsx("div",{className:"m-sess-meta",children:s.jsx("span",{className:"m-sess-name",children:t("mobile.newSession")})})]}),s.jsxs("div",{className:"m-new-body",children:[s.jsx(as,{className:"m-input m-new-input",rows:5,placeholder:t("mobile.newPlaceholder"),value:e,onChange:i=>l(i.target.value)}),d.length>0&&s.jsxs("label",{className:"m-new-launcher",children:[s.jsx("span",{className:"m-new-launcher-label",children:t("session.launcherLabel")}),s.jsx("select",{className:"m-new-launcher-select",value:h,onChange:i=>f(i.target.value),children:d.map(i=>s.jsx("option",{value:i.name,children:i.name},i.name))})]}),N&&s.jsx("div",{className:"m-senderr",children:N}),s.jsx("button",{className:"m-send m-new-go",disabled:!e.trim()||x,onClick:g,children:t(x?"mobile.launching":"mobile.launch")})]})]})}function js({specs:e,sessions:l,openId:r,setOpenId:m,creating:t,setCreating:d,newDraft:h,setNewDraft:f}){const x=E(),b=r?l.find(c=>c.id===r):null,{expanded:N,toggle:j}=H(),[g,i]=o.useState(!1),k=o.useMemo(()=>G(l,c=>N.has(c),{zoneFolded:c=>c==="offline"&&!g}),[l,N,g]);return t?s.jsx(xs,{draft:h,setDraft:f,onBack:()=>d(!1),onLaunched:()=>d(!1)}):b?s.jsx(ps,{s:b,sessions:l,onBack:()=>m(null)}):s.jsxs("div",{className:"m-sesslist",children:[s.jsxs("button",{className:"m-new-btn",onClick:()=>d(!0),children:[s.jsx("span",{className:"m-new-btn-plus",children:"+"}),x("mobile.newSession")]}),!l.length&&s.jsx("div",{className:"m-empty big",children:x("mobile.noSessions")}),k.map(c=>{if(c.type==="zone")return s.jsx($,{item:c,baseClass:"m-zone",onToggle:()=>i(p=>!p)},`z-${c.zone}`);const a=c.s,w=c.expandable||c.depth?s.jsx(B,{guides:c.guides,expandable:c.expandable,kin:c.kin}):null;return s.jsxs("div",{className:"sess-tree-row m-sess-tree-row",style:{"--sess-fold-indent":`${c.depth*14}px`},children:[s.jsx("button",{type:"button",className:"m-sess-row",onClick:()=>m(a.id),children:s.jsx(U,{s:a,locked:!1,showAvatar:!1,lead:w})}),c.expandable&&s.jsx(Q,{expanded:c.expanded,rollup:c.rollup,kin:c.kin,onToggle:()=>j(a.id)})]},a.id)})]})}function Ss({specs:e,sessions:l,issuesStamp:r,reloadBoard:m}){const t=E(),d=o.useMemo(()=>Object.fromEntries(e.map(n=>[n.id,n])),[e]),h=o.useMemo(()=>e.find(n=>!n.parent)||e[0],[e]),f=o.useMemo(()=>{const n={};return e.forEach(u=>{var _;u.parent&&(n[_=u.parent]??(n[_]=[])).push(u)}),u=>n[u]||[]},[e]),[x,b]=o.useState("specs"),[N,j]=o.useState(()=>h?[h.id]:[]),[g,i]=o.useState(null),[k,c]=o.useState(!1),[a,w]=o.useState(""),{page:p,param:C}=D(),v=p==="evals"||p==="issues"||p==="settings"?p:x;o.useEffect(()=>{p==="sessions"&&C&&(b("sessions"),i(C))},[p,C]);const T=n=>{if(n==="evals"||n==="issues"){y(n);return}b(n),(p==="evals"||p==="issues"||p==="settings")&&y(n==="specs"?"graph":"sessions")},F=n=>{b("sessions"),i(n),y("sessions",n)},S=N.filter(n=>d[n]),I=S[S.length-1]||(h==null?void 0:h.id),P=I?d[I]:null,V=n=>j(u=>[...u.filter(_=>d[_]),n]);return s.jsxs("div",{className:"m-app",children:[s.jsx("main",{className:"m-main",children:v==="evals"||v==="issues"||v==="settings"?s.jsx("div",{className:"m-review",children:s.jsx(o.Suspense,{fallback:s.jsx("div",{className:"m-empty",children:t("common.loading")}),children:v==="settings"?s.jsx(ds,{}):v==="evals"?s.jsx(rs,{specs:e,sessions:l,issuesStamp:r,reloadBoard:m,onOpenSession:F,onFocusNode:n=>{b("specs"),j([h.id,n].filter(u=>d[u])),y("graph")}}):s.jsx(ms,{specs:e,sessions:l,issuesStamp:r,onOpenSession:F,onFocusNode:n=>{b("specs"),j([h.id,n].filter(u=>d[u])),y("graph")}})})}):v==="specs"?s.jsxs("div",{className:"m-specs",children:[s.jsx("nav",{className:"m-crumbs",children:S.map((n,u)=>s.jsxs("span",{className:"m-crumb",children:[u>0&&s.jsx("span",{className:"m-crumb-sep",children:"›"}),s.jsx("button",{className:u===S.length-1?"m-crumb-btn cur":"m-crumb-btn",onClick:()=>j(S.slice(0,u+1)),children:d[n].title})]},n))}),P&&s.jsx(bs,{node:P,childrenOf:f,sessions:l,onOpenChild:V},P.id)]}):s.jsx(js,{specs:e,sessions:l,openId:g,setOpenId:i,creating:k,setCreating:c,newDraft:a,setNewDraft:w})}),s.jsxs("nav",{className:"m-tabbar",children:[s.jsxs("button",{className:v==="specs"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("specs"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"❯_"}),t("mobile.specsTab")]}),s.jsxs("button",{className:v==="sessions"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("sessions"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◐"}),t("mobile.sessionsTab"),l.length>0&&s.jsx("span",{className:"m-tabbar-badge",children:l.length})]}),s.jsxs("button",{className:v==="evals"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("evals"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"✓"}),t("mobile.evalsTab")]}),s.jsxs("button",{className:v==="issues"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("issues"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◎"}),t("mobile.issuesTab")]})]})]})}export{Ss as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EvalsPage-Bq1Tkb8y.js","assets/index-Di1ch5dd.js","assets/index-CixSnz1H.css","assets/Thread-BpL3N3kw.js","assets/PageScroll-px_rUZVJ.js","assets/data-CQFbQEMH.js","assets/IssuesPage-BlkPSkmv.js","assets/Settings-bpAbfnmS.js","assets/bindings-BC9vqpYU.js","assets/terminalFont-C6oGNKrf.js"])))=>i.map(i=>d[i]);
2
+ import{u as E,r as o,f as D,j as s,n as y,_ as O}from"./index-Di1ch5dd.js";import{A as z,u as H,S as $,R as B,a as U,F as Q,b as A}from"./SessionWindow-IspcLjFA.js";import{I as Z,J,K as L,N as K,P as W,Q as X,U as Y,V as q,W as G,X as ss,z as es,H as as,s as ns,Y as ls,o as ts,t as is,Z as cs}from"./Thread-BpL3N3kw.js";import{T as os}from"./TimelineChat-Ckmb1Ez2.js";import"./PageScroll-px_rUZVJ.js";import"./data-CQFbQEMH.js";const rs=o.lazy(()=>O(()=>import("./EvalsPage-Bq1Tkb8y.js"),__vite__mapDeps([0,1,2,3,4,5]))),ms=o.lazy(()=>O(()=>import("./IssuesPage-BlkPSkmv.js"),__vite__mapDeps([6,1,2,5,3,4]))),ds=o.lazy(()=>O(()=>import("./Settings-bpAbfnmS.js"),__vite__mapDeps([7,1,2,8,4,9]))),us={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"},R=(e,l)=>l.filter(r=>{var m;return(m=r.ops)==null?void 0:m.some(t=>t.nodeId===e.id)});function M({status:e}){const l=A[e]||A.pending;return s.jsx("span",{className:"m-dot",style:{background:l.color}})}function hs({node:e,kids:l,editors:r,onTap:m}){return s.jsxs("button",{className:"m-row",onClick:m,children:[s.jsx(M,{status:e.status}),s.jsx("span",{className:"m-row-title",children:e.title}),r.length>0&&s.jsx("span",{className:"m-row-faces",children:r.slice(0,3).map(t=>s.jsx(z,{seed:t.id,status:t.status,title:L(t)},t.id))}),e.version?s.jsxs("span",{className:"m-row-ver",children:["v",e.version]}):null,l>0&&s.jsxs("span",{className:"m-row-kids",children:["▸",l]}),s.jsx("span",{className:"m-row-chev",children:"›"})]})}function bs({node:e,childrenOf:l,sessions:r,onOpenChild:m}){const t=E(),d=l(e.id),h=Z(e),f=[...d.length?[{key:"children",label:t("mobile.childrenTab",{n:d.length})}]:[],...h.map(a=>({key:a.key,label:t(us[a.key])}))],[x,b]=o.useState(null),[N,j]=o.useState({issues:{},eval:{}});o.useEffect(()=>{b(null),j({issues:{},eval:{}})},[e.id]);const g=(a,w)=>j(p=>({...p,[a]:ss(p[a],w)})),i=x&&f.some(a=>a.key===x)?x:f[0].key,k=J(e.id,i==="history"),c=R(e,r);return s.jsxs("div",{className:"m-node",children:[s.jsxs("div",{className:"m-node-head",children:[s.jsx(M,{status:e.status}),s.jsx("span",{className:"m-node-title",children:e.title}),e.version?s.jsxs("span",{className:"m-node-ver",children:["v",e.version]}):null,s.jsx("span",{className:"m-node-status",children:t(`status.${e.status}`)}),c.length>0&&s.jsx("span",{className:"m-node-faces",title:t("mobile.liveEditors",{n:c.length}),children:c.map(a=>s.jsx(z,{seed:a.id,status:a.status,title:L(a)},a.id))})]}),e.desc&&s.jsx("div",{className:"m-node-desc",children:e.desc}),s.jsx("div",{className:"m-tabs",children:f.map(a=>s.jsx("button",{className:a.key===i?"m-tab on":"m-tab",onClick:()=>b(a.key),children:a.label},a.key))}),s.jsxs("div",{className:i==="history"?"m-pane-host fixed":"m-pane-host",children:[i==="children"&&s.jsx("div",{className:"m-children",children:d.map(a=>s.jsx(hs,{node:a,kids:l(a.id).length,editors:R(a,r),onTap:()=>m(a.id)},a.id))}),i==="spec"&&s.jsx(K,{node:e}),i==="history"&&s.jsx(W,{node:e,rows:k}),i==="issues"&&s.jsx(X,{node:e,sessions:r,filter:N.issues,onFilter:a=>g("issues",a)}),i==="eval"&&s.jsx(Y,{node:e,sessions:r,filter:N.eval,onFilter:a=>g("eval",a)}),i==="edit"&&s.jsx(q,{node:e})]})]})}function ps({s:e,sessions:l,onBack:r}){const m=E();return s.jsxs("div",{className:"m-sessdetail chat",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":m("mobile.back"),children:"‹"}),s.jsxs("div",{className:"m-sess-meta",children:[s.jsx("span",{className:"m-sess-name",children:ns(e)}),s.jsxs("span",{className:"m-sess-status",style:{color:ls[e.status]},children:[m(`status.${e.status}`),e.merges?` · ×${e.merges}`:""," · ",s.jsx("span",{className:"m-sess-id8",children:e.id.slice(0,8)})]})]}),s.jsx("a",{className:"m-sess-evalbtn",href:ts(is(e.id)),title:m("sessionEval.btnTitle"),children:m("sessionEval.btn")})]}),s.jsx(os,{s:e,sessions:l})]})}function xs({draft:e,setDraft:l,onBack:r,onLaunched:m}){const t=E(),{launchers:d,launcher:h,pickLauncher:f}=es(),[x,b]=o.useState(!1),[N,j]=o.useState(null),g=async()=>{const i=e.trim();if(!i||x)return;b(!0),j(null);const k=await cs(i,h);b(!1),k.ok?(l(""),m()):j(k.error||t("mobile.launchFailed"))};return s.jsxs("div",{className:"m-sessdetail m-new",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":t("mobile.back"),children:"‹"}),s.jsx("div",{className:"m-sess-meta",children:s.jsx("span",{className:"m-sess-name",children:t("mobile.newSession")})})]}),s.jsxs("div",{className:"m-new-body",children:[s.jsx(as,{className:"m-input m-new-input",rows:5,placeholder:t("mobile.newPlaceholder"),value:e,onChange:i=>l(i.target.value)}),d.length>0&&s.jsxs("label",{className:"m-new-launcher",children:[s.jsx("span",{className:"m-new-launcher-label",children:t("session.launcherLabel")}),s.jsx("select",{className:"m-new-launcher-select",value:h,onChange:i=>f(i.target.value),children:d.map(i=>s.jsx("option",{value:i.name,children:i.name},i.name))})]}),N&&s.jsx("div",{className:"m-senderr",children:N}),s.jsx("button",{className:"m-send m-new-go",disabled:!e.trim()||x,onClick:g,children:t(x?"mobile.launching":"mobile.launch")})]})]})}function js({specs:e,sessions:l,openId:r,setOpenId:m,creating:t,setCreating:d,newDraft:h,setNewDraft:f}){const x=E(),b=r?l.find(c=>c.id===r):null,{expanded:N,toggle:j}=H(),[g,i]=o.useState(!1),k=o.useMemo(()=>G(l,c=>N.has(c),{zoneFolded:c=>c==="offline"&&!g}),[l,N,g]);return t?s.jsx(xs,{draft:h,setDraft:f,onBack:()=>d(!1),onLaunched:()=>d(!1)}):b?s.jsx(ps,{s:b,sessions:l,onBack:()=>m(null)}):s.jsxs("div",{className:"m-sesslist",children:[s.jsxs("button",{className:"m-new-btn",onClick:()=>d(!0),children:[s.jsx("span",{className:"m-new-btn-plus",children:"+"}),x("mobile.newSession")]}),!l.length&&s.jsx("div",{className:"m-empty big",children:x("mobile.noSessions")}),k.map(c=>{if(c.type==="zone")return s.jsx($,{item:c,baseClass:"m-zone",onToggle:()=>i(p=>!p)},`z-${c.zone}`);const a=c.s,w=c.expandable||c.depth?s.jsx(B,{guides:c.guides,expandable:c.expandable,kin:c.kin}):null;return s.jsxs("div",{className:"sess-tree-row m-sess-tree-row",style:{"--sess-fold-indent":`${c.depth*14}px`},children:[s.jsx("button",{type:"button",className:"m-sess-row",onClick:()=>m(a.id),children:s.jsx(U,{s:a,locked:!1,showAvatar:!1,lead:w})}),c.expandable&&s.jsx(Q,{expanded:c.expanded,rollup:c.rollup,kin:c.kin,onToggle:()=>j(a.id)})]},a.id)})]})}function Ss({specs:e,sessions:l,issuesStamp:r,reloadBoard:m}){const t=E(),d=o.useMemo(()=>Object.fromEntries(e.map(n=>[n.id,n])),[e]),h=o.useMemo(()=>e.find(n=>!n.parent)||e[0],[e]),f=o.useMemo(()=>{const n={};return e.forEach(u=>{var _;u.parent&&(n[_=u.parent]??(n[_]=[])).push(u)}),u=>n[u]||[]},[e]),[x,b]=o.useState("specs"),[N,j]=o.useState(()=>h?[h.id]:[]),[g,i]=o.useState(null),[k,c]=o.useState(!1),[a,w]=o.useState(""),{page:p,param:C}=D(),v=p==="evals"||p==="issues"||p==="settings"?p:x;o.useEffect(()=>{p==="sessions"&&C&&(b("sessions"),i(C))},[p,C]);const T=n=>{if(n==="evals"||n==="issues"){y(n);return}b(n),(p==="evals"||p==="issues"||p==="settings")&&y(n==="specs"?"graph":"sessions")},F=n=>{b("sessions"),i(n),y("sessions",n)},S=N.filter(n=>d[n]),I=S[S.length-1]||(h==null?void 0:h.id),P=I?d[I]:null,V=n=>j(u=>[...u.filter(_=>d[_]),n]);return s.jsxs("div",{className:"m-app",children:[s.jsx("main",{className:"m-main",children:v==="evals"||v==="issues"||v==="settings"?s.jsx("div",{className:"m-review",children:s.jsx(o.Suspense,{fallback:s.jsx("div",{className:"m-empty",children:t("common.loading")}),children:v==="settings"?s.jsx(ds,{}):v==="evals"?s.jsx(rs,{specs:e,sessions:l,issuesStamp:r,reloadBoard:m,onOpenSession:F,onFocusNode:n=>{b("specs"),j([h.id,n].filter(u=>d[u])),y("graph")}}):s.jsx(ms,{specs:e,sessions:l,issuesStamp:r,onOpenSession:F,onFocusNode:n=>{b("specs"),j([h.id,n].filter(u=>d[u])),y("graph")}})})}):v==="specs"?s.jsxs("div",{className:"m-specs",children:[s.jsx("nav",{className:"m-crumbs",children:S.map((n,u)=>s.jsxs("span",{className:"m-crumb",children:[u>0&&s.jsx("span",{className:"m-crumb-sep",children:"›"}),s.jsx("button",{className:u===S.length-1?"m-crumb-btn cur":"m-crumb-btn",onClick:()=>j(S.slice(0,u+1)),children:d[n].title})]},n))}),P&&s.jsx(bs,{node:P,childrenOf:f,sessions:l,onOpenChild:V},P.id)]}):s.jsx(js,{specs:e,sessions:l,openId:g,setOpenId:i,creating:k,setCreating:c,newDraft:a,setNewDraft:w})}),s.jsxs("nav",{className:"m-tabbar",children:[s.jsxs("button",{className:v==="specs"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("specs"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"❯_"}),t("mobile.specsTab")]}),s.jsxs("button",{className:v==="sessions"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("sessions"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◐"}),t("mobile.sessionsTab"),l.length>0&&s.jsx("span",{className:"m-tabbar-badge",children:l.length})]}),s.jsxs("button",{className:v==="evals"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("evals"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"✓"}),t("mobile.evalsTab")]}),s.jsxs("button",{className:v==="issues"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("issues"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◎"}),t("mobile.issuesTab")]})]})]})}export{Ss as default};
@@ -1 +1 @@
1
- import{r as d,o as c,j as e,e as i}from"./index-BUKLPN_4.js";function x({title:a,closeLabel:o,onClose:s,className:l,children:n}){return d.useEffect(()=>()=>c(),[]),e.jsx("div",{className:"legend-backdrop","data-focus-overlay":!0,onClick:s,children:e.jsxs("div",{className:l?`legend ${l}`:"legend",role:"dialog","aria-modal":"true","aria-label":a,onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"legend-head",children:[e.jsx("span",{className:"legend-title",children:a}),e.jsx(i,{icon:"x",size:13,className:"legend-close",label:o,onClick:s})]}),e.jsx("div",{className:"legend-body",children:n})]})})}export{x as M};
1
+ import{r as d,o as c,j as e,e as i}from"./index-Di1ch5dd.js";function x({title:a,closeLabel:o,onClose:s,className:l,children:n}){return d.useEffect(()=>()=>c(),[]),e.jsx("div",{className:"legend-backdrop","data-focus-overlay":!0,onClick:s,children:e.jsxs("div",{className:l?`legend ${l}`:"legend",role:"dialog","aria-modal":"true","aria-label":a,onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"legend-head",children:[e.jsx("span",{className:"legend-title",children:a}),e.jsx(i,{icon:"x",size:13,className:"legend-close",label:o,onClick:s})]}),e.jsx("div",{className:"legend-body",children:n})]})})}export{x as M};
@@ -1 +1 @@
1
- import{r as h,j as L}from"./index-BUKLPN_4.js";const w="spex.page-scroll:",T=()=>typeof window>"u"?"":`${window.location.pathname}${window.location.search}${window.location.hash}`,$=n=>{try{return Number(sessionStorage.getItem(`${w}${n}`))||0}catch{return 0}},p=(n,r)=>{try{sessionStorage.setItem(`${w}${n}`,String(r))}catch{}};function A({className:n="",scrollKey:r=T(),children:g,...E}){const f=h.useRef(null);return h.useLayoutEffect(()=>{const e=f.current;if(!e)return;const o=$(r);let i=o,c=o>0,u=0,t=0,a;const m=()=>{c=!1,t&&cancelAnimationFrame(t),t=0,a==null||a.disconnect()},l=()=>{if(t=0,!c)return;const v=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop=Math.min(o,v),v<o){u=0;return}if(Math.abs(e.scrollTop-o)>1){u=0,t=requestAnimationFrame(l);return}i=e.scrollTop,p(r,i),++u<2?t=requestAnimationFrame(l):m()},d=()=>{c||(i=e.scrollTop,p(r,i))},s=()=>{m(),d()};return e.scrollTop=o,c&&(a=new MutationObserver(()=>{t||(t=requestAnimationFrame(l))}),a.observe(e,{childList:!0,subtree:!0,characterData:!0}),t=requestAnimationFrame(l)),e.addEventListener("scroll",d,{passive:!0}),e.addEventListener("pointerdown",s,!0),e.addEventListener("wheel",s,{passive:!0,capture:!0}),e.addEventListener("keydown",s,!0),()=>{e.removeEventListener("scroll",d),e.removeEventListener("pointerdown",s,!0),e.removeEventListener("wheel",s,!0),e.removeEventListener("keydown",s,!0),m(),p(r,i)}},[r]),L.jsx("div",{ref:f,className:`page-scroll${n?` ${n}`:""}`,...E,children:g})}export{A as P};
1
+ import{r as h,j as L}from"./index-Di1ch5dd.js";const w="spex.page-scroll:",T=()=>typeof window>"u"?"":`${window.location.pathname}${window.location.search}${window.location.hash}`,$=n=>{try{return Number(sessionStorage.getItem(`${w}${n}`))||0}catch{return 0}},p=(n,r)=>{try{sessionStorage.setItem(`${w}${n}`,String(r))}catch{}};function A({className:n="",scrollKey:r=T(),children:g,...E}){const f=h.useRef(null);return h.useLayoutEffect(()=>{const e=f.current;if(!e)return;const o=$(r);let i=o,c=o>0,u=0,t=0,a;const m=()=>{c=!1,t&&cancelAnimationFrame(t),t=0,a==null||a.disconnect()},l=()=>{if(t=0,!c)return;const v=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop=Math.min(o,v),v<o){u=0;return}if(Math.abs(e.scrollTop-o)>1){u=0,t=requestAnimationFrame(l);return}i=e.scrollTop,p(r,i),++u<2?t=requestAnimationFrame(l):m()},d=()=>{c||(i=e.scrollTop,p(r,i))},s=()=>{m(),d()};return e.scrollTop=o,c&&(a=new MutationObserver(()=>{t||(t=requestAnimationFrame(l))}),a.observe(e,{childList:!0,subtree:!0,characterData:!0}),t=requestAnimationFrame(l)),e.addEventListener("scroll",d,{passive:!0}),e.addEventListener("pointerdown",s,!0),e.addEventListener("wheel",s,{passive:!0,capture:!0}),e.addEventListener("keydown",s,!0),()=>{e.removeEventListener("scroll",d),e.removeEventListener("pointerdown",s,!0),e.removeEventListener("wheel",s,!0),e.removeEventListener("keydown",s,!0),m(),p(r,i)}},[r]),L.jsx("div",{ref:f,className:`page-scroll${n?` ${n}`:""}`,...E,children:g})}export{A as P};
@@ -1 +1 @@
1
- import{u as T,r,j as e,I as L,e as F,y as G,P as O,z as $,A as B}from"./index-BUKLPN_4.js";import{l as M,p as _,C as J,a as q,b as K,c as U,s as V,d as Q,e as W,i as X,f as Y,g as Z,h as ee,j as se,k as ae,m as te,n as oe,o as re}from"./App-B72LuS5I.js";import{M as ne}from"./Modal-6l_QtCKF.js";import{P as ce}from"./PageScroll-B2kxcqJJ.js";import"./data-SNi0AmVT.js";const R=["claude","codex","opencode","pi"];function D({onSet:s,onClear:l,placeholder:a,busy:o,t:c}){const[t,g]=r.useState("");return e.jsxs("form",{className:"proj-drawer proj-pw",onSubmit:d=>{d.preventDefault(),t&&(s(t),g(""))},children:[e.jsx("input",{className:"proj-add-path",type:"password",value:t,onChange:d=>g(d.target.value),placeholder:a,"aria-label":a}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!t||o,children:c("projects.passwordSet")}),e.jsx("button",{className:"proj-act",type:"button",disabled:o,onClick:l,children:c("projects.passwordClear")})]})}function ie({onAdded:s,onClose:l,t:a}){const[o,c]=r.useState(""),[t,g]=r.useState(null),[d,u]=r.useState(!0),[i,b]=r.useState(!1),[k,m]=r.useState(null),[P,v]=r.useState(""),[w,f]=r.useState(!1),[S,N]=r.useState(!1),[h,E]=r.useState([]),n=r.useCallback(async p=>{if(i)return;u(!0),m(null),v("");const y=await Q(p);if(u(!1),!y.ok){m(y.error==="network"?a("projects.actionFailed"):y.error);return}g(y),c(y.path),f(!1),N(!1),E([])},[i,a]);r.useEffect(()=>{n("")},[]),r.useEffect(()=>{const p=y=>{y.key==="Escape"&&!i&&l()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[i,l]);const x=!!t&&o===t.path,I=x&&!t.gitRoot,A=x&&!t.initialized,j=x&&!d&&!i&&!t.cataloged&&(!I||w)&&(!S||!!h.length),C=p=>E(y=>y.includes(p)?y.filter(H=>H!==p):[...y,p]),z=async p=>{if(p.preventDefault(),!j)return;b(!0),m(null),v("");const y=await ee(t.path,{...I?{initGit:w}:{},...A&&S?{init:{harness:h.join(",")}}:{}});if(b(!1),y.ok){s(y.project);return}m(y.error==="network"?a("projects.actionFailed"):y.error),v(y.output||"")};return e.jsx(ne,{title:a("projects.addTitle"),closeLabel:a("common.close"),onClose:()=>{i||l()},className:"proj-add-modal",children:e.jsxs("form",{className:"proj-add-flow",onSubmit:z,children:[e.jsxs("div",{className:"proj-add-pathbar",children:[e.jsx(F,{icon:"arrow-left",size:14,className:"proj-act icon",label:a("projects.browseParent"),disabled:!(t!=null&&t.parent)||d||i,onClick:()=>n(t.parent)}),e.jsx("button",{type:"button",className:"proj-act icon proj-home-btn","data-tip":a("projects.browseHome"),"aria-label":a("projects.browseHome"),disabled:!(t!=null&&t.home)||d||i,onClick:()=>n(t.home),children:"~"}),e.jsx("input",{className:"proj-add-path",value:o,autoFocus:!0,spellCheck:!1,onChange:p=>{c(p.target.value),m(null)},onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),o.trim()&&n(o.trim()))},placeholder:a("projects.addPlaceholder"),"aria-label":a("projects.addPlaceholder"),disabled:i}),e.jsx("button",{className:"proj-act",type:"button",disabled:!o.trim()||d||i,onClick:()=>n(o.trim()),children:a(d?"projects.browseLoading":"projects.browseGo")})]}),e.jsxs("div",{className:"proj-folder-list","aria-label":a("projects.folderList"),"aria-busy":d,children:[!d&&(t==null?void 0:t.entries.map(p=>e.jsxs("button",{type:"button",className:"proj-folder-row",onClick:()=>n(p.path),disabled:i,children:[e.jsx(L,{name:"chevron-right",size:13}),e.jsx("span",{className:"proj-folder-name",children:p.name}),p.git&&e.jsx("span",{className:"proj-folder-tag",children:"Git"}),p.initialized&&e.jsx("span",{className:"proj-folder-tag spex",children:"SpexCode"})]},p.path))),!d&&t&&!t.entries.length&&e.jsx("div",{className:"proj-folder-empty",children:a("projects.folderEmpty")}),d&&e.jsx("div",{className:"proj-folder-empty",children:a("projects.browseLoading")})]}),x&&e.jsxs("div",{className:"proj-add-options",children:[e.jsx("div",{className:"proj-add-selected",title:t.path,children:t.path}),t.gitRoot?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," Git ",e.jsx("code",{children:t.gitRoot})]}):e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:p=>f(p.target.checked),disabled:i}),e.jsx("span",{children:a("projects.initGit")})]}),t.initialized?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," ",a("projects.spexInitialized")]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:p=>{N(p.target.checked),v(""),m(null)},disabled:i}),e.jsx("span",{children:a("projects.initSpex")})]}),S&&e.jsxs("fieldset",{className:"proj-add-harnesses",disabled:i,children:[e.jsx("legend",{children:a("projects.harnessTargets")}),R.map(p=>e.jsxs("label",{className:"proj-add-harness",children:[e.jsx("input",{type:"checkbox",checked:h.includes(p),onChange:()=>C(p)}),e.jsx("span",{children:p})]},p))]})]}),t.cataloged&&e.jsx("div",{className:"proj-op-status ok",children:a("projects.alreadyAdded")})]}),(k||P)&&e.jsxs("div",{className:"proj-add-result",children:[k&&e.jsx("div",{className:"proj-err",children:k}),P&&e.jsx("pre",{className:"proj-log",children:P})]}),e.jsxs("div",{className:"proj-add-actions",children:[e.jsx("button",{className:"proj-act",type:"button",disabled:i,onClick:l,children:a("common.cancel")}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!j,children:a(i?"projects.addBusy":"projects.addSubmit")})]})]})})}function le({p:s,onRefresh:l,t:a}){const[o,c]=r.useState(null),[t,g]=r.useState(""),[d,u]=r.useState(!1),[i,b]=r.useState(null),[k,m]=r.useState(!1),[P,v]=r.useState(0),[w,f]=r.useState(s.identity.icon),[S,N]=r.useState(!1),[h,E]=r.useState(null);r.useEffect(()=>{let j=!0;return c(null),b(null),m(!1),W(s.id).then(C=>{if(j){if(!C.ok){b(C.error==="network"?a("projects.actionFailed"):C.error);return}c({content:C.content,revision:C.revision}),g(C.content),f(s.identity.icon)}}),()=>{j=!1}},[s.id,s.identity.icon,P,a]);let n=!1;try{const j=JSON.parse(t);n=!j||typeof j!="object"||Array.isArray(j)}catch{n=!0}const x=!!o&&t!==o.content,I=async()=>{var C,z;if(!o||n||!x||d)return;u(!0),b(null),m(!1);const j=await se(s.id,t,o.revision);if(u(!1),!j.ok){b(j.error==="network"?a("projects.actionFailed"):j.error);return}c({content:j.content,revision:j.revision}),g(j.content),m(!0);try{f(((z=(C=JSON.parse(j.content))==null?void 0:C.dashboard)==null?void 0:z.icon)||s.identity.icon)}catch{}l()},A=async j=>{if(!o||S)return!1;const C=w;f(j),N(!0),E(null),m(!1);const z=await ae(s.id,j,o.revision);return N(!1),z.ok?(c({content:z.content,revision:z.revision}),g(z.content),f(z.identity.icon),m(!0),l(),!0):(f(C),E(z.error==="network"?a("projects.actionFailed"):z.error),!1)};return e.jsxs("div",{className:"proj-drawer proj-config",children:[e.jsxs("div",{className:"proj-config-head",children:[e.jsx("code",{children:"spexcode.json"}),k&&e.jsx("span",{className:"proj-op-status ok",children:a("projects.configSaved")})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:n?"proj-config-editor invalid":"proj-config-editor",value:t,onChange:j=>{g(j.target.value),m(!1),b(null)},"aria-label":a("projects.configEditor"),spellCheck:!1,disabled:d}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!x||n||d,onClick:I,children:a(d?"projects.configSaving":"projects.configSave")}),e.jsx("button",{className:"proj-act",type:"button",disabled:d,onClick:()=>v(j=>j+1),children:a("projects.configReload")}),n&&e.jsx("span",{className:"proj-err",children:a("projects.configInvalid")}),i&&e.jsx("span",{className:"proj-err",children:i})]}),e.jsx(B,{value:w,onChange:A,label:a("projects.projectIcon"),editLabel:a("projects.editProjectIcon"),name:`project-icon-${s.id}`,disabled:d||S}),h&&e.jsx("span",{className:"proj-err",children:h})]}):e.jsxs("div",{className:"proj-setup-row",children:[!i&&e.jsx("span",{className:"proj-dim",children:a("projects.configLoading")}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"proj-err",children:i}),e.jsx("button",{className:"proj-act",type:"button",onClick:()=>v(j=>j+1),children:a("projects.configReload")})]})]})]})}function de({p:s,busyOp:l,run:a,result:o,t:c}){const[t,g]=r.useState([]),d=u=>g(i=>i.includes(u)?i.filter(b=>b!==u):[...i,u]);return e.jsxs("div",{className:"proj-drawer proj-setup",children:[e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("span",{className:"proj-dim",children:c("projects.harnessLabel")}),R.map(u=>e.jsx("button",{type:"button",className:t.includes(u)?"proj-act on":"proj-act","aria-pressed":t.includes(u),disabled:!!l,onClick:()=>d(u),children:u},u))]}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!l||!t.length,title:t.length?void 0:c("projects.harnessRequired"),onClick:()=>a("init",()=>X(s.id,t.join(","))),children:c(l==="init"?"projects.running":"projects.init")}),e.jsx("button",{className:"proj-act",type:"button",disabled:!!l,onClick:()=>a("doctor",()=>Y(s.id)),children:c(l==="doctor"?"projects.running":"projects.doctor")})]}),o&&e.jsxs("div",{className:"proj-op-result proj-full",children:[e.jsx("div",{className:o.ok?"proj-op-status ok":"proj-op-status fail",children:o.ok?c("projects.opOk",{op:c(`projects.${o.op}`)}):c("projects.opFail",{op:c(`projects.${o.op}`),code:o.code??"?"})}),o.output?e.jsx("pre",{className:"proj-log",children:o.output}):null]})]})}function pe({p:s,health:l,onRefresh:a,t:o}){const[c,t]=r.useState(null),[g,d]=r.useState(!1),[u,i]=r.useState(null),[b,k]=r.useState(null),[m,P]=r.useState(null),v=s.id===O,w=s.online===!1,f=w?"stopped":l||"probing",S=async h=>{d(!0),k(null);const E=await h();d(!1),E.ok?t(null):k(E.error||o("projects.actionFailed")),a()},N=async(h,E)=>{i(h),k(null),P(null);const n=await E();i(null),h!=="serve"?P({op:h,ok:n.ok,code:n.code,output:n.output||(n.ok?"":n.error||"")}):n.ok||k(n.error||o("projects.actionFailed")),a()};return e.jsxs("li",{className:v?"proj-row current":"proj-row",children:[e.jsxs("div",{className:"proj-row-main",children:[e.jsx("span",{className:`proj-health h-${f}`,"data-tip":o(`projects.health.${f}`)}),e.jsx(G,{icon:s.identity.icon,size:26}),e.jsx("span",{className:"proj-name",children:s.identity.title}),s.gated&&e.jsx(L,{name:"lock",size:12,className:"proj-locked"}),v&&e.jsx("span",{className:"proj-tag",children:o("projects.current")}),e.jsx("span",{className:"proj-path",title:s.id,children:s.root||s.id}),e.jsxs("span",{className:"proj-actions",children:[e.jsx(F,{icon:"settings",label:o("projects.configTitle"),className:c==="config"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="config"?null:"config"),k(null)}}),e.jsx(F,{icon:"terminal",label:o("projects.setupTitle"),className:c==="setup"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="setup"?null:"setup"),k(null)}}),e.jsx(F,{icon:"lock",label:o("projects.passwordTitle"),className:c==="pw"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="pw"?null:"pw"),k(null)}}),w?e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!u,onClick:()=>N("serve",()=>te(s.id)),children:o(u==="serve"?"projects.startBusy":"projects.start")}):e.jsx("a",{className:"proj-act primary",href:$(s.id),children:o("projects.open")})]})]}),b&&e.jsx("div",{className:"proj-err",children:b}),c==="pw"&&e.jsx(D,{t:o,busy:g,placeholder:o("projects.passwordPlaceholder"),onSet:h=>S(()=>re(s.id,h)),onClear:()=>S(()=>oe(s.id))}),c==="config"&&e.jsx(le,{p:s,onRefresh:a,t:o}),c==="setup"&&e.jsx(de,{p:s,busyOp:u,run:N,result:m,t:o})]})}function je({gateway:s,onRefresh:l,t:a}){const[o,c]=r.useState(s.identity.icon),[t,g]=r.useState(!1),[d,u]=r.useState(null);r.useEffect(()=>{c(s.identity.icon)},[s.identity.icon]);const i=async b=>{if(t||!s.revision)return!1;const k=o;c(b),g(!0),u(null);const m=await Z(b,s.revision);return g(!1),m.ok?(c(m.gateway.identity.icon),l(),!0):(c(k),u(m.error==="network"?a("projects.actionFailed"):m.error),!1)};return e.jsxs("div",{className:"proj-gateway-identity",children:[e.jsx(B,{value:o,onChange:i,label:a("projects.gatewayIcon"),editLabel:a("projects.editGatewayIcon"),name:"gateway-icon",fallback:"gateway",disabled:t||!s.revision}),d&&e.jsx("span",{className:"proj-err",children:d})]})}function ge(){const s=T(),[l,a]=r.useState({kind:"loading"}),[o,c]=r.useState({}),[t,g]=r.useState(null),[d,u]=r.useState(!1),[i,b]=r.useState(!1),[k,m]=r.useState(null),[P,v]=r.useState(1),w=r.useRef(0),f=r.useCallback(async()=>{const n=++w.current,x=await M();n===w.current&&(x.state==="ok"?(a({kind:"ok",adminGated:x.adminGated,gateway:x.gateway,projects:x.projects}),x.projects.filter(I=>I.online!==!1).forEach(I=>{_(I.id).then(A=>{n===w.current&&c(j=>({...j,[I.id]:A}))})})):x.state==="denied"?a({kind:"denied",reason:x.reason}):a(I=>I.kind==="ok"?I:{kind:"absent"}))},[]);r.useEffect(()=>{f();const n=setInterval(f,J),x=()=>{document.hidden||f()};return document.addEventListener("visibilitychange",x),()=>{clearInterval(n),document.removeEventListener("visibilitychange",x)}},[f]);const S=async n=>{b(!0),m(null);const x=await n();b(!1),x.ok?g(null):m(x.error||s("projects.actionFailed")),f()},N=q(l.kind==="ok"?l.projects:[],P);r.useEffect(()=>{N.page!==P&&v(N.page)},[N.page,P]);const h=l.kind==="loading"?e.jsx("div",{className:"loading",children:s("hud.loading")}):l.kind==="denied"?e.jsx(K,{scope:"admin",locked:l.reason==="locked",onUnlocked:f}):l.kind==="absent"?e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:s("projects.absent")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"proj-head",children:[e.jsx("span",{className:"proj-count",children:s("projects.count",{n:l.projects.length})}),e.jsxs("button",{className:d?"proj-act on":"proj-act",onClick:()=>u(!0),children:[e.jsx(L,{name:"plus",size:12})," ",s("projects.add")]}),e.jsxs("button",{className:t==="admin"?"proj-act on":"proj-act",onClick:()=>{g(n=>n==="admin"?null:"admin"),m(null)},children:[e.jsx(L,{name:"lock",size:12})," ",s("projects.adminPassword")]})]}),!l.adminGated&&e.jsx("div",{className:"proj-hint",children:s("projects.adminUngated")}),t==="admin"&&e.jsxs("div",{className:"proj-admin-pw",children:[e.jsx(D,{t:s,busy:i,placeholder:s("projects.adminPasswordPlaceholder"),onSet:n=>S(()=>V(n)),onClear:()=>S(()=>U())}),k&&e.jsx("div",{className:"proj-err",children:k})]}),l.projects.length?e.jsx("ul",{className:"proj-list",children:N.items.map(n=>e.jsx(pe,{p:n,health:o[n.id],onRefresh:f,t:s},n.id))}):e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:s("projects.empty")})}),N.pageCount>1&&e.jsxs("nav",{className:"proj-pagination","aria-label":s("projects.pagination"),children:[e.jsx(F,{icon:"arrow-left",label:s("projects.previousPage"),className:"proj-act icon",size:14,disabled:N.page===1,onClick:()=>v(n=>n-1)}),e.jsx("span",{className:"proj-page-label",children:s("projects.pageOf",{page:N.page,pages:N.pageCount})}),e.jsx(F,{icon:"chevron-right",label:s("projects.nextPage"),className:"proj-act icon",size:14,disabled:N.page===N.pageCount,onClick:()=>v(n=>n+1)})]}),e.jsx("div",{className:"proj-page-details","aria-label":s("projects.gatewaySettings"),children:e.jsx(je,{gateway:l.gateway,onRefresh:f,t:s})})]}),E=l.kind==="ok"?l.gateway.identity:{icon:"gateway"};return e.jsxs("div",{className:"page-pane page-projects",children:[e.jsx(ce,{className:"page-projects-scroll",children:e.jsxs("div",{className:"proj-body",children:[e.jsxs("div",{className:"cred-brand proj-brand",children:[e.jsx(G,{icon:E.icon,fallback:"gateway",size:30}),e.jsx("span",{children:"$ spexcode"})]}),e.jsx("h1",{className:"page-title",children:s("projects.title")}),h]})}),d&&e.jsx(ie,{t:s,onClose:()=>u(!1),onAdded:()=>{u(!1),f()}})]})}export{ge as default};
1
+ import{u as T,r,j as e,I as L,e as F,y as G,P as O,z as $,A as B}from"./index-Di1ch5dd.js";import{l as M,p as _,C as J,a as q,b as K,c as U,s as V,d as Q,e as W,i as X,f as Y,g as Z,h as ee,j as se,k as ae,m as te,n as oe,o as re}from"./App-u2P7KdSg.js";import{M as ne}from"./Modal-bAkq9IIT.js";import{P as ce}from"./PageScroll-px_rUZVJ.js";import"./data-CQFbQEMH.js";const R=["claude","codex","opencode","pi"];function D({onSet:s,onClear:l,placeholder:a,busy:o,t:c}){const[t,g]=r.useState("");return e.jsxs("form",{className:"proj-drawer proj-pw",onSubmit:d=>{d.preventDefault(),t&&(s(t),g(""))},children:[e.jsx("input",{className:"proj-add-path",type:"password",value:t,onChange:d=>g(d.target.value),placeholder:a,"aria-label":a}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!t||o,children:c("projects.passwordSet")}),e.jsx("button",{className:"proj-act",type:"button",disabled:o,onClick:l,children:c("projects.passwordClear")})]})}function ie({onAdded:s,onClose:l,t:a}){const[o,c]=r.useState(""),[t,g]=r.useState(null),[d,u]=r.useState(!0),[i,b]=r.useState(!1),[k,m]=r.useState(null),[P,v]=r.useState(""),[w,f]=r.useState(!1),[S,N]=r.useState(!1),[h,E]=r.useState([]),n=r.useCallback(async p=>{if(i)return;u(!0),m(null),v("");const y=await Q(p);if(u(!1),!y.ok){m(y.error==="network"?a("projects.actionFailed"):y.error);return}g(y),c(y.path),f(!1),N(!1),E([])},[i,a]);r.useEffect(()=>{n("")},[]),r.useEffect(()=>{const p=y=>{y.key==="Escape"&&!i&&l()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[i,l]);const x=!!t&&o===t.path,I=x&&!t.gitRoot,A=x&&!t.initialized,j=x&&!d&&!i&&!t.cataloged&&(!I||w)&&(!S||!!h.length),C=p=>E(y=>y.includes(p)?y.filter(H=>H!==p):[...y,p]),z=async p=>{if(p.preventDefault(),!j)return;b(!0),m(null),v("");const y=await ee(t.path,{...I?{initGit:w}:{},...A&&S?{init:{harness:h.join(",")}}:{}});if(b(!1),y.ok){s(y.project);return}m(y.error==="network"?a("projects.actionFailed"):y.error),v(y.output||"")};return e.jsx(ne,{title:a("projects.addTitle"),closeLabel:a("common.close"),onClose:()=>{i||l()},className:"proj-add-modal",children:e.jsxs("form",{className:"proj-add-flow",onSubmit:z,children:[e.jsxs("div",{className:"proj-add-pathbar",children:[e.jsx(F,{icon:"arrow-left",size:14,className:"proj-act icon",label:a("projects.browseParent"),disabled:!(t!=null&&t.parent)||d||i,onClick:()=>n(t.parent)}),e.jsx("button",{type:"button",className:"proj-act icon proj-home-btn","data-tip":a("projects.browseHome"),"aria-label":a("projects.browseHome"),disabled:!(t!=null&&t.home)||d||i,onClick:()=>n(t.home),children:"~"}),e.jsx("input",{className:"proj-add-path",value:o,autoFocus:!0,spellCheck:!1,onChange:p=>{c(p.target.value),m(null)},onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),o.trim()&&n(o.trim()))},placeholder:a("projects.addPlaceholder"),"aria-label":a("projects.addPlaceholder"),disabled:i}),e.jsx("button",{className:"proj-act",type:"button",disabled:!o.trim()||d||i,onClick:()=>n(o.trim()),children:a(d?"projects.browseLoading":"projects.browseGo")})]}),e.jsxs("div",{className:"proj-folder-list","aria-label":a("projects.folderList"),"aria-busy":d,children:[!d&&(t==null?void 0:t.entries.map(p=>e.jsxs("button",{type:"button",className:"proj-folder-row",onClick:()=>n(p.path),disabled:i,children:[e.jsx(L,{name:"chevron-right",size:13}),e.jsx("span",{className:"proj-folder-name",children:p.name}),p.git&&e.jsx("span",{className:"proj-folder-tag",children:"Git"}),p.initialized&&e.jsx("span",{className:"proj-folder-tag spex",children:"SpexCode"})]},p.path))),!d&&t&&!t.entries.length&&e.jsx("div",{className:"proj-folder-empty",children:a("projects.folderEmpty")}),d&&e.jsx("div",{className:"proj-folder-empty",children:a("projects.browseLoading")})]}),x&&e.jsxs("div",{className:"proj-add-options",children:[e.jsx("div",{className:"proj-add-selected",title:t.path,children:t.path}),t.gitRoot?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," Git ",e.jsx("code",{children:t.gitRoot})]}):e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:p=>f(p.target.checked),disabled:i}),e.jsx("span",{children:a("projects.initGit")})]}),t.initialized?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," ",a("projects.spexInitialized")]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:p=>{N(p.target.checked),v(""),m(null)},disabled:i}),e.jsx("span",{children:a("projects.initSpex")})]}),S&&e.jsxs("fieldset",{className:"proj-add-harnesses",disabled:i,children:[e.jsx("legend",{children:a("projects.harnessTargets")}),R.map(p=>e.jsxs("label",{className:"proj-add-harness",children:[e.jsx("input",{type:"checkbox",checked:h.includes(p),onChange:()=>C(p)}),e.jsx("span",{children:p})]},p))]})]}),t.cataloged&&e.jsx("div",{className:"proj-op-status ok",children:a("projects.alreadyAdded")})]}),(k||P)&&e.jsxs("div",{className:"proj-add-result",children:[k&&e.jsx("div",{className:"proj-err",children:k}),P&&e.jsx("pre",{className:"proj-log",children:P})]}),e.jsxs("div",{className:"proj-add-actions",children:[e.jsx("button",{className:"proj-act",type:"button",disabled:i,onClick:l,children:a("common.cancel")}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!j,children:a(i?"projects.addBusy":"projects.addSubmit")})]})]})})}function le({p:s,onRefresh:l,t:a}){const[o,c]=r.useState(null),[t,g]=r.useState(""),[d,u]=r.useState(!1),[i,b]=r.useState(null),[k,m]=r.useState(!1),[P,v]=r.useState(0),[w,f]=r.useState(s.identity.icon),[S,N]=r.useState(!1),[h,E]=r.useState(null);r.useEffect(()=>{let j=!0;return c(null),b(null),m(!1),W(s.id).then(C=>{if(j){if(!C.ok){b(C.error==="network"?a("projects.actionFailed"):C.error);return}c({content:C.content,revision:C.revision}),g(C.content),f(s.identity.icon)}}),()=>{j=!1}},[s.id,s.identity.icon,P,a]);let n=!1;try{const j=JSON.parse(t);n=!j||typeof j!="object"||Array.isArray(j)}catch{n=!0}const x=!!o&&t!==o.content,I=async()=>{var C,z;if(!o||n||!x||d)return;u(!0),b(null),m(!1);const j=await se(s.id,t,o.revision);if(u(!1),!j.ok){b(j.error==="network"?a("projects.actionFailed"):j.error);return}c({content:j.content,revision:j.revision}),g(j.content),m(!0);try{f(((z=(C=JSON.parse(j.content))==null?void 0:C.dashboard)==null?void 0:z.icon)||s.identity.icon)}catch{}l()},A=async j=>{if(!o||S)return!1;const C=w;f(j),N(!0),E(null),m(!1);const z=await ae(s.id,j,o.revision);return N(!1),z.ok?(c({content:z.content,revision:z.revision}),g(z.content),f(z.identity.icon),m(!0),l(),!0):(f(C),E(z.error==="network"?a("projects.actionFailed"):z.error),!1)};return e.jsxs("div",{className:"proj-drawer proj-config",children:[e.jsxs("div",{className:"proj-config-head",children:[e.jsx("code",{children:"spexcode.json"}),k&&e.jsx("span",{className:"proj-op-status ok",children:a("projects.configSaved")})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:n?"proj-config-editor invalid":"proj-config-editor",value:t,onChange:j=>{g(j.target.value),m(!1),b(null)},"aria-label":a("projects.configEditor"),spellCheck:!1,disabled:d}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!x||n||d,onClick:I,children:a(d?"projects.configSaving":"projects.configSave")}),e.jsx("button",{className:"proj-act",type:"button",disabled:d,onClick:()=>v(j=>j+1),children:a("projects.configReload")}),n&&e.jsx("span",{className:"proj-err",children:a("projects.configInvalid")}),i&&e.jsx("span",{className:"proj-err",children:i})]}),e.jsx(B,{value:w,onChange:A,label:a("projects.projectIcon"),editLabel:a("projects.editProjectIcon"),name:`project-icon-${s.id}`,disabled:d||S}),h&&e.jsx("span",{className:"proj-err",children:h})]}):e.jsxs("div",{className:"proj-setup-row",children:[!i&&e.jsx("span",{className:"proj-dim",children:a("projects.configLoading")}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"proj-err",children:i}),e.jsx("button",{className:"proj-act",type:"button",onClick:()=>v(j=>j+1),children:a("projects.configReload")})]})]})]})}function de({p:s,busyOp:l,run:a,result:o,t:c}){const[t,g]=r.useState([]),d=u=>g(i=>i.includes(u)?i.filter(b=>b!==u):[...i,u]);return e.jsxs("div",{className:"proj-drawer proj-setup",children:[e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("span",{className:"proj-dim",children:c("projects.harnessLabel")}),R.map(u=>e.jsx("button",{type:"button",className:t.includes(u)?"proj-act on":"proj-act","aria-pressed":t.includes(u),disabled:!!l,onClick:()=>d(u),children:u},u))]}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!l||!t.length,title:t.length?void 0:c("projects.harnessRequired"),onClick:()=>a("init",()=>X(s.id,t.join(","))),children:c(l==="init"?"projects.running":"projects.init")}),e.jsx("button",{className:"proj-act",type:"button",disabled:!!l,onClick:()=>a("doctor",()=>Y(s.id)),children:c(l==="doctor"?"projects.running":"projects.doctor")})]}),o&&e.jsxs("div",{className:"proj-op-result proj-full",children:[e.jsx("div",{className:o.ok?"proj-op-status ok":"proj-op-status fail",children:o.ok?c("projects.opOk",{op:c(`projects.${o.op}`)}):c("projects.opFail",{op:c(`projects.${o.op}`),code:o.code??"?"})}),o.output?e.jsx("pre",{className:"proj-log",children:o.output}):null]})]})}function pe({p:s,health:l,onRefresh:a,t:o}){const[c,t]=r.useState(null),[g,d]=r.useState(!1),[u,i]=r.useState(null),[b,k]=r.useState(null),[m,P]=r.useState(null),v=s.id===O,w=s.online===!1,f=w?"stopped":l||"probing",S=async h=>{d(!0),k(null);const E=await h();d(!1),E.ok?t(null):k(E.error||o("projects.actionFailed")),a()},N=async(h,E)=>{i(h),k(null),P(null);const n=await E();i(null),h!=="serve"?P({op:h,ok:n.ok,code:n.code,output:n.output||(n.ok?"":n.error||"")}):n.ok||k(n.error||o("projects.actionFailed")),a()};return e.jsxs("li",{className:v?"proj-row current":"proj-row",children:[e.jsxs("div",{className:"proj-row-main",children:[e.jsx("span",{className:`proj-health h-${f}`,"data-tip":o(`projects.health.${f}`)}),e.jsx(G,{icon:s.identity.icon,size:26}),e.jsx("span",{className:"proj-name",children:s.identity.title}),s.gated&&e.jsx(L,{name:"lock",size:12,className:"proj-locked"}),v&&e.jsx("span",{className:"proj-tag",children:o("projects.current")}),e.jsx("span",{className:"proj-path",title:s.id,children:s.root||s.id}),e.jsxs("span",{className:"proj-actions",children:[e.jsx(F,{icon:"settings",label:o("projects.configTitle"),className:c==="config"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="config"?null:"config"),k(null)}}),e.jsx(F,{icon:"terminal",label:o("projects.setupTitle"),className:c==="setup"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="setup"?null:"setup"),k(null)}}),e.jsx(F,{icon:"lock",label:o("projects.passwordTitle"),className:c==="pw"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{t(h=>h==="pw"?null:"pw"),k(null)}}),w?e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!u,onClick:()=>N("serve",()=>te(s.id)),children:o(u==="serve"?"projects.startBusy":"projects.start")}):e.jsx("a",{className:"proj-act primary",href:$(s.id),children:o("projects.open")})]})]}),b&&e.jsx("div",{className:"proj-err",children:b}),c==="pw"&&e.jsx(D,{t:o,busy:g,placeholder:o("projects.passwordPlaceholder"),onSet:h=>S(()=>re(s.id,h)),onClear:()=>S(()=>oe(s.id))}),c==="config"&&e.jsx(le,{p:s,onRefresh:a,t:o}),c==="setup"&&e.jsx(de,{p:s,busyOp:u,run:N,result:m,t:o})]})}function je({gateway:s,onRefresh:l,t:a}){const[o,c]=r.useState(s.identity.icon),[t,g]=r.useState(!1),[d,u]=r.useState(null);r.useEffect(()=>{c(s.identity.icon)},[s.identity.icon]);const i=async b=>{if(t||!s.revision)return!1;const k=o;c(b),g(!0),u(null);const m=await Z(b,s.revision);return g(!1),m.ok?(c(m.gateway.identity.icon),l(),!0):(c(k),u(m.error==="network"?a("projects.actionFailed"):m.error),!1)};return e.jsxs("div",{className:"proj-gateway-identity",children:[e.jsx(B,{value:o,onChange:i,label:a("projects.gatewayIcon"),editLabel:a("projects.editGatewayIcon"),name:"gateway-icon",fallback:"gateway",disabled:t||!s.revision}),d&&e.jsx("span",{className:"proj-err",children:d})]})}function ge(){const s=T(),[l,a]=r.useState({kind:"loading"}),[o,c]=r.useState({}),[t,g]=r.useState(null),[d,u]=r.useState(!1),[i,b]=r.useState(!1),[k,m]=r.useState(null),[P,v]=r.useState(1),w=r.useRef(0),f=r.useCallback(async()=>{const n=++w.current,x=await M();n===w.current&&(x.state==="ok"?(a({kind:"ok",adminGated:x.adminGated,gateway:x.gateway,projects:x.projects}),x.projects.filter(I=>I.online!==!1).forEach(I=>{_(I.id).then(A=>{n===w.current&&c(j=>({...j,[I.id]:A}))})})):x.state==="denied"?a({kind:"denied",reason:x.reason}):a(I=>I.kind==="ok"?I:{kind:"absent"}))},[]);r.useEffect(()=>{f();const n=setInterval(f,J),x=()=>{document.hidden||f()};return document.addEventListener("visibilitychange",x),()=>{clearInterval(n),document.removeEventListener("visibilitychange",x)}},[f]);const S=async n=>{b(!0),m(null);const x=await n();b(!1),x.ok?g(null):m(x.error||s("projects.actionFailed")),f()},N=q(l.kind==="ok"?l.projects:[],P);r.useEffect(()=>{N.page!==P&&v(N.page)},[N.page,P]);const h=l.kind==="loading"?e.jsx("div",{className:"loading",children:s("hud.loading")}):l.kind==="denied"?e.jsx(K,{scope:"admin",locked:l.reason==="locked",onUnlocked:f}):l.kind==="absent"?e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:s("projects.absent")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"proj-head",children:[e.jsx("span",{className:"proj-count",children:s("projects.count",{n:l.projects.length})}),e.jsxs("button",{className:d?"proj-act on":"proj-act",onClick:()=>u(!0),children:[e.jsx(L,{name:"plus",size:12})," ",s("projects.add")]}),e.jsxs("button",{className:t==="admin"?"proj-act on":"proj-act",onClick:()=>{g(n=>n==="admin"?null:"admin"),m(null)},children:[e.jsx(L,{name:"lock",size:12})," ",s("projects.adminPassword")]})]}),!l.adminGated&&e.jsx("div",{className:"proj-hint",children:s("projects.adminUngated")}),t==="admin"&&e.jsxs("div",{className:"proj-admin-pw",children:[e.jsx(D,{t:s,busy:i,placeholder:s("projects.adminPasswordPlaceholder"),onSet:n=>S(()=>V(n)),onClear:()=>S(()=>U())}),k&&e.jsx("div",{className:"proj-err",children:k})]}),l.projects.length?e.jsx("ul",{className:"proj-list",children:N.items.map(n=>e.jsx(pe,{p:n,health:o[n.id],onRefresh:f,t:s},n.id))}):e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:s("projects.empty")})}),N.pageCount>1&&e.jsxs("nav",{className:"proj-pagination","aria-label":s("projects.pagination"),children:[e.jsx(F,{icon:"arrow-left",label:s("projects.previousPage"),className:"proj-act icon",size:14,disabled:N.page===1,onClick:()=>v(n=>n-1)}),e.jsx("span",{className:"proj-page-label",children:s("projects.pageOf",{page:N.page,pages:N.pageCount})}),e.jsx(F,{icon:"chevron-right",label:s("projects.nextPage"),className:"proj-act icon",size:14,disabled:N.page===N.pageCount,onClick:()=>v(n=>n+1)})]}),e.jsx("div",{className:"proj-page-details","aria-label":s("projects.gatewaySettings"),children:e.jsx(je,{gateway:l.gateway,onRefresh:f,t:s})})]}),E=l.kind==="ok"?l.gateway.identity:{icon:"gateway"};return e.jsxs("div",{className:"page-pane page-projects",children:[e.jsx(ce,{className:"page-projects-scroll",children:e.jsxs("div",{className:"proj-body",children:[e.jsxs("div",{className:"cred-brand proj-brand",children:[e.jsx(G,{icon:E.icon,fallback:"gateway",size:30}),e.jsx("span",{children:"$ spexcode"})]}),e.jsx("h1",{className:"page-title",children:s("projects.title")}),h]})}),d&&e.jsx(ie,{t:s,onClose:()=>u(!1),onAdded:()=>{u(!1),f()}})]})}export{ge as default};