spexcode 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/spec-cli/src/anchors.ts +341 -0
- package/spec-cli/src/cli.ts +20 -20
- package/spec-cli/src/gateway.ts +8 -1
- package/spec-cli/src/git.ts +21 -13
- package/spec-cli/src/graph.ts +13 -7
- package/spec-cli/src/guide.ts +63 -15
- package/spec-cli/src/harness.ts +85 -34
- package/spec-cli/src/help.ts +33 -17
- package/spec-cli/src/index.ts +39 -7
- package/spec-cli/src/init.ts +5 -4
- package/spec-cli/src/lint.ts +103 -28
- package/spec-cli/src/localIssues.ts +19 -0
- package/spec-cli/src/migrate-table.ts +27 -16
- package/spec-cli/src/search.bench.mjs +2 -2
- package/spec-cli/src/session-timeline.ts +148 -0
- package/spec-cli/src/sessions.ts +29 -4
- package/spec-cli/src/specs.ts +44 -21
- package/spec-cli/templates/hooks/prepare-commit-msg +6 -1
- package/spec-cli/templates/spec/project/.plugins/{extract → commands/extract}/spec.md +1 -1
- package/spec-cli/templates/spec/project/.plugins/commands/spec.md +16 -0
- package/spec-cli/templates/spec/project/.plugins/commands/supervisor/spec.md +8 -0
- package/spec-cli/templates/spec/project/.plugins/core/spec.md +1 -1
- package/spec-cli/templates/spec/project/.plugins/prompts/spec.md +20 -0
- package/spec-cli/templates/spec/project/.plugins/skills/spec.md +17 -0
- package/spec-cli/templates/spec/project/.plugins/spec.md +5 -2
- package/spec-cli/templates/spec/project/spec.md +1 -1
- package/spec-dashboard/dist/assets/{Dashboard-C7Bzsv86.js → Dashboard-C_fGmOKK.js} +3 -3
- package/spec-dashboard/dist/assets/EvalsPage-Cnr1s3bq.js +2 -0
- package/spec-dashboard/dist/assets/{FoldToggle-D5iB4Ac2.js → FoldToggle-x9gtO1OQ.js} +1 -1
- package/spec-dashboard/dist/assets/{IssuesPage-CMFTsQhg.js → IssuesPage-5f_vL-JV.js} +1 -1
- package/spec-dashboard/dist/assets/MobileApp-DEO1jgGM.js +1 -0
- package/spec-dashboard/dist/assets/SessionInterface-CAlbMOFR.js +66 -0
- package/spec-dashboard/dist/assets/SessionWindow-JYbpPwNB.js +13 -0
- package/spec-dashboard/dist/assets/{Settings-BW5f0OaW.js → Settings-DKb5Ji_X.js} +1 -1
- package/spec-dashboard/dist/assets/index-BQu-oJ8J.js +41 -0
- package/spec-dashboard/dist/assets/index-BbMkwuix.css +1 -0
- package/spec-dashboard/dist/assets/launch-BM9GgvkX.js +6 -0
- package/spec-dashboard/dist/index.html +2 -2
- package/spec-eval/src/cli.ts +82 -21
- package/spec-eval/src/evaltab.ts +15 -6
- package/spec-eval/src/humanok.ts +43 -0
- package/spec-eval/src/scenarios.ts +116 -4
- package/spec-eval/src/sidecar.ts +35 -9
- package/spec-cli/templates/presets/careful/.plugins/clarify-before-code/spec.md +0 -11
- package/spec-cli/templates/spec/project/.plugins/supervisor/spec.md +0 -8
- package/spec-dashboard/dist/assets/EvalsPage-DKZZIdHq.js +0 -2
- package/spec-dashboard/dist/assets/MobileApp-DwuTKgdP.js +0 -1
- package/spec-dashboard/dist/assets/SessionInterface-CBS5_cmK.js +0 -71
- package/spec-dashboard/dist/assets/SessionWindow-CqAnjWfI.js +0 -9
- package/spec-dashboard/dist/assets/index-Cc26X4ce.css +0 -1
- package/spec-dashboard/dist/assets/index-Ce0wDyQS.js +0 -41
- /package/spec-cli/templates/spec/project/.plugins/{regroup → commands/regroup}/spec.md +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{tidy → commands/tidy}/spec.md +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{forge-link → prompts/forge-link}/spec.md +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{memory-hygiene → prompts/memory-hygiene}/spec.md +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{reproduce-before-fix → prompts/reproduce-before-fix}/spec.md +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{distill → skills/distill}/digest.mjs +0 -0
- /package/spec-cli/templates/spec/project/.plugins/{distill → skills/distill}/spec.md +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as ke,r as o,i as st,d as at,k as ot,j as n,m as ze,n as lt}from"./index-BQu-oJ8J.js";import{X as it,Y as rt,Z as ct,_ as ut,$ as dt,g as ve,n as ft,a0 as se,a1 as mt,a2 as Oe,a3 as ht,a4 as vt,u as pt,D as pe,a5 as xt,o as gt,a6 as kt}from"./SessionWindow-JYbpPwNB.js";import{F as xe}from"./FoldToggle-x9gtO1OQ.js";const yt=[{name:"ok",color:"green",when:s=>!s.okd&&s.isLatest,labelKey:"annotator.ok",titleKey:"annotator.okTitle",descKey:"annotator.cmd.okDesc"}];function wt(s,r){return yt.filter(i=>i.when(s)).map(i=>({...i,run:r[i.name]}))}function bt(s,r){return(s||"").replace(/\{(\w+)\}/g,(i,v)=>r[v]!=null?String(r[v]):i)}const Fe=(s,r)=>{let i=null;for(const v of s)if(v.at<=r)i=v;else break;return i},jt=s=>{if(!s||!Array.isArray(s.events))return null;const r=s.v===1?"time":typeof s.axis=="string"?s.axis:"time",i=s.v===1?v=>v.tMs:v=>v.at;return{axis:r,events:s.events.map(v=>({at:i(v),step:v.step,...v.node?{node:v.node}:{}}))}},Mt=(s,r,i)=>s==="time"?se(r):s==="frame"?`#${r}`:s==="line"?`L${r}`:s==="index"?i?`${r}/${i}`:`${r}`:String(r);function Ve({events:s,axis:r,extent:i,activeStepIdx:v,onSeek:y}){return n.jsx("div",{className:"an-ruler",children:s.map((x,c)=>n.jsxs("button",{className:`an-step ${v===c?"on":""}`,onClick:()=>y(x.at),"data-tip":x.node?`→ ${x.node}`:void 0,children:[Mt(r,x.at,i)," ",x.step]},c))})}const ge=s=>{var r,i;return((r=s.verdict)==null?void 0:r.status)==="pass"?"✓":((i=s.verdict)==null?void 0:i.status)==="fail"?"✗":"·"},Xe=s=>{var r,i;return((r=s.verdict)==null?void 0:r.status)==="pass"?"pass":((i=s.verdict)==null?void 0:i.status)==="fail"?"fail":"legacy"};function Nt({entry:s,history:r,specs:i=[],sessions:v=[],onWrite:y,onOpenSession:x}){var Te,De,Ae,Ie,Pe,Ke;const c=ke(),f=o.useRef(null),E=o.useRef(null),w=o.useRef(null),k=o.useRef(null),S=o.useRef(0),[m,$]=o.useState([]),[g,b]=o.useState("time"),[u,j]=o.useState(null),[A,R]=o.useState(""),[B,q]=o.useState(!1),[H,X]=o.useState(null),I=o.useRef(null),d=o.useRef(null),L=o.useRef(null),z=o.useRef(0),[_e,ye]=o.useState(0),[ae,we]=o.useState(-1),[be,je]=o.useState(null),[Y,oe]=o.useState(!1),[Me,le]=o.useState(!1),[ie,re]=o.useState(null),[G,ce]=o.useState(null),[M,ue]=o.useState(null),[T,Z]=o.useState(0),h=M&&M[T]||s,[Be,qe]=o.useState([]);o.useEffect(()=>{let e=!0;return st().then(t=>{e&&Array.isArray(t)&&qe(t)}).catch(()=>{}),()=>{e=!1}},[]),o.useEffect(()=>{if(j(null),R(""),$([]),X(null),Z(0),ue(null),r){ue(r);return}let e=!0;return fetch(at(s.node,"evals")).then(t=>t.ok?t.json():null).then(t=>{e&&Array.isArray(t==null?void 0:t.readings)&&ue(t.readings.filter(a=>a.scenario===s.scenario))}).catch(()=>{}),()=>{e=!1}},[s.node,s.scenario,s.ts,s.blob,(Te=s.humanOk)==null?void 0:Te.ts,r]),o.useEffect(()=>{j(null),X(null)},[T]);const U=it(h),P=U.find(e=>e.kind==="video"&&e.state==="present"),de=U.filter(e=>e.kind==="image"),He=U.filter(e=>e.kind!=="video"&&e.kind!=="image"),O=!!P,F=s.thread??null,fe=o.useMemo(()=>F?[{by:F.by,at:F.created,body:F.body},...F.replies||[]]:[],[F]),Ye=M&&((De=M[0])==null?void 0:De.by)||s.by||null,C=o.useMemo(()=>fe.map((e,t)=>{const a=rt(ct(e.body),m);return a&&a.seekable?{i:t,tMs:a.tMs,step:a.step,label:a.label}:null}).filter(Boolean).sort((e,t)=>e.tMs-t.tMs),[fe,m]),Ne=o.useRef(m);Ne.current=m;const Ee=o.useRef(C);Ee.current=C;const J=o.useCallback(()=>{const e=z.current,t=Ne.current;let a=-1;for(let p=0;p<t.length&&t[p].at<=e;p++)a=p;we(p=>p===a?p:a);let l=null;for(const p of Ee.current)if(p.tMs<=e)l=p.i;else break;je(p=>p===l?p:l)},[]);o.useEffect(()=>{J()},[C,m,J]),o.useEffect(()=>{z.current=0,I.current&&(I.current.style.width="0%"),d.current&&(d.current.style.left="0%"),L.current&&(L.current.textContent=""),we(-1),je(null),ye(0),oe(!1),le(!1),re(null),ce(null)},[s.blob,s.scenario,s.node]),o.useEffect(()=>{if($([]),b("time"),!h.timelineBlob)return;let e=!0;return fetch(`/api/evidence/${h.timelineBlob}`).then(t=>t.ok?t.json():null).then(t=>{const a=e&&jt(t);a&&($(a.events),b(a.axis))}).catch(()=>{}),()=>{e=!1}},[h.timelineBlob]),o.useEffect(()=>{const e=f.current;if(!e)return;const t=()=>{const N=Math.round((e.currentTime||0)*1e3),D=Math.round((e.duration||0)*1e3);z.current=N;const ne=D?N/D*100:0;I.current&&(I.current.style.width=`${ne}%`),d.current&&(d.current.style.left=`${ne}%`),L.current&&(L.current.textContent=`${se(N)} / ${se(D)}`),J()},a=()=>{ye(e.duration||0),t()},l=()=>oe(!0),p=()=>oe(!1);return e.addEventListener("timeupdate",t),e.addEventListener("seeked",t),e.addEventListener("loadedmetadata",a),e.addEventListener("durationchange",a),e.addEventListener("play",l),e.addEventListener("pause",p),a(),()=>{e.removeEventListener("timeupdate",t),e.removeEventListener("seeked",t),e.removeEventListener("loadedmetadata",a),e.removeEventListener("durationchange",a),e.removeEventListener("play",l),e.removeEventListener("pause",p)}},[P==null?void 0:P.hash,s.node,s.scenario,T,J]);const K=Math.round(_e*1e3),Q=m[ae]||null,Se=g==="time"?K:g==="frame"?de.length:g==="index"?m.length:0,V=o.useCallback(e=>{const t=f.current;t&&(t.currentTime=e/1e3)},[]),W=o.useCallback(()=>{const e=f.current;e&&(e.paused?e.play():e.pause())},[]),$e=(e,t)=>{ce(e),t!=null&&V(t)},ee=o.useCallback(async e=>{const t=f.current;if(!(t!=null&&t.videoWidth))return null;q(!0),R(c("annotator.capturing"));try{t.seeking&&await new Promise(D=>t.addEventListener("seeked",D,{once:!0}));const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;const l=a.getContext("2d");l.drawImage(t,0,0,a.width,a.height),e&&(l.strokeStyle="#ff9a3c",l.lineWidth=Math.max(2,a.width/300),l.strokeRect(e.x/100*a.width,e.y/100*a.height,e.w/100*a.width,e.h/100*a.height));const p=await new Promise(D=>a.toBlob(D,"image/png")),{hash:N}=await ot(p);if(!N)throw new Error("no hash");return R(""),N}catch{return R(c("annotator.failed")),null}finally{q(!1)}},[c]),Ge=o.useCallback(async()=>{var a;const e=f.current;if(!e)return null;e.pause();const t=Math.round((e.currentTime??0)*1e3);return{tMs:t,step:((a=Fe(m,t))==null?void 0:a.step)??null,frame:await ee(null)}},[m,ee]),me=o.useCallback(async e=>{const t=f.current;if(!t)return;t.pause();const a=Math.round((t.currentTime||0)*1e3),l=Fe(m,a),p=await ee(e),N=[ut(a,l==null?void 0:l.step)];p&&N.push(``),l!=null&&l.node&&l.node!==s.node&&N.push(`re: [[${l.node}]]`),N.push(""),X({seq:++S.current,body:N.join(`
|
|
2
|
+
`)})},[m,s.node,ee]),he=o.useCallback(e=>{var l;if(!C.length)return;let t=C.findIndex(p=>p.i===G);if(t<0){const p=Math.round((((l=f.current)==null?void 0:l.currentTime)||0)*1e3);t=C.reduce((N,D,ne)=>D.tMs<=p?ne:N,-1)}t=Math.min(C.length-1,Math.max(0,t+e));const a=C[t];ce(a.i),V(a.tMs)},[C,G,V]);o.useEffect(()=>{if(!O)return;const e=t=>{const a=document.activeElement;if(a&&(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable))return;const l=f.current;l&&(t.key===" "?(t.preventDefault(),W()):t.key==="ArrowRight"?(t.preventDefault(),l.currentTime=Math.min(l.duration||l.currentTime,l.currentTime+(t.shiftKey?1:5))):t.key==="ArrowLeft"?(t.preventDefault(),l.currentTime=Math.max(0,l.currentTime-(t.shiftKey?1:5))):t.key===","?(t.preventDefault(),l.currentTime=Math.max(0,l.currentTime-1/30)):t.key==="."?(t.preventDefault(),l.duration&&(l.currentTime=Math.min(l.duration,l.currentTime+1/30))):t.key==="ArrowDown"?(t.preventDefault(),he(1)):t.key==="ArrowUp"?(t.preventDefault(),he(-1)):(t.key==="a"||t.key==="A")&&(t.preventDefault(),me(null)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[O,W,he,me]);const Re=e=>{var l;const t=(l=w.current)==null?void 0:l.getBoundingClientRect(),a=f.current;!t||!t.width||!a||!a.duration||(a.currentTime=Math.min(1,Math.max(0,(e-t.left)/t.width))*a.duration)},Ze=e=>{e.preventDefault(),le(!0),Re(e.clientX)},Je=e=>{var a;const t=(a=w.current)==null?void 0:a.getBoundingClientRect();t!=null&&t.width&&re(Math.min(100,Math.max(0,(e.clientX-t.left)/t.width*100)))};o.useEffect(()=>{if(!Me)return;const e=a=>Re(a.clientX),t=()=>le(!1);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[Me]);const Le=e=>{const t=E.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100}},Qe=e=>{if(e.button!==0||B)return;const t=Le(e);j({x0:t.x,y0:t.y,x:t.x,y:t.y})},We=e=>{var a,l;if(!u)return;const t=Le(e);!((a=f.current)!=null&&a.paused)&&(Math.abs(t.x-u.x0)>1||Math.abs(t.y-u.y0)>1)&&((l=f.current)==null||l.pause()),j({...u,x:t.x,y:t.y})},et=()=>{if(!u)return;const e={x:Math.min(u.x0,u.x),y:Math.min(u.y0,u.y),w:Math.abs(u.x-u.x0),h:Math.abs(u.y-u.y0)};if(j(null),e.w<1&&e.h<1){W();return}me(e)},_=u&&{x:Math.min(u.x0,u.x),y:Math.min(u.y0,u.y),w:Math.abs(u.x-u.x0),h:Math.abs(u.y-u.y0)},tt=async()=>{const e=await ze(s.node,s.scenario).catch(t=>({error:String(t)}));y==null||y((e==null?void 0:e.error)||"")},Ce=wt({okd:!!h.humanOk,isLatest:!M||T===0},{ok:tt}),te=Ce.find(e=>e.name==="ok")||null,nt=[...Ce.map(e=>({name:e.name,description:c(e.descKey),ui:!0,color:e.color,run:e.run})),...Be.map(e=>({name:e.name,description:e.desc||e.title,source:"review",prefill:()=>bt(e.body,{node:s.node,scenario:s.scenario,expected:h.expected||""})}))];return n.jsxs("div",{className:"an-detail",children:[n.jsxs("header",{className:"an-head",children:[n.jsx("span",{className:"an-title",children:s.scenario}),n.jsx("span",{className:"an-node",children:s.node}),n.jsx("span",{className:`an-verdict-badge ${Xe(h)}`,children:ge(h)}),h.evaluator&&n.jsx("span",{className:"an-meta",children:h.evaluator}),n.jsx("span",{className:"an-meta",children:new Date(h.ts).toLocaleString()}),n.jsx(dt,{originator:Ye,sessions:v,kind:"eval",onOpenSession:x}),h.humanOk?n.jsxs("span",{className:"an-okd","data-tip":c("annotator.okBy",{by:h.humanOk.by,at:new Date(h.humanOk.ts).toLocaleString()}),children:["☑ ",c("annotator.okd")]}):te&&n.jsxs("button",{type:"button",className:"an-okbtn","data-tip":c(te.titleKey),onClick:te.run,children:["☑ ",c(te.labelKey)]}),M&&M.length>1&&n.jsxs("div",{className:"an-ab",children:[n.jsx(ve,{icon:"chevron-left",size:13,className:"an-ab-nav",disabled:T>=M.length-1,onClick:()=>Z(e=>Math.min(M.length-1,e+1)),label:c("annotator.abOlder")}),n.jsx("div",{className:"an-ab-track",children:M.slice().reverse().map((e,t)=>{const a=M.length-1-t;return n.jsx("button",{type:"button",className:`an-ab-pip ${Xe(e)} ${a===T?"on":""}`,onClick:()=>Z(a),"data-tip":`${ge(e)} ${new Date(e.ts).toLocaleString()}`,children:ge(e)},`${e.ts}-${a}`)})}),n.jsx(ve,{icon:"chevron-right",size:13,className:"an-ab-nav",disabled:T<=0,onClick:()=>Z(e=>Math.max(0,e-1)),label:c("annotator.abNewer")}),n.jsx("span",{className:"an-ab-pos",children:T===0?c("annotator.abLatest"):c("annotator.abPos",{i:M.length-T,n:M.length})})]})]}),n.jsxs("div",{className:"an-work",children:[n.jsxs("div",{className:"an-stage-col",children:[h.expected&&n.jsxs("div",{className:"an-expected",children:[n.jsx("b",{children:c("nodeView.eval.expected")})," ",h.expected]}),U.length>0&&((Ae=h.verdict)==null?void 0:Ae.note)&&n.jsxs("div",{className:"an-expected an-prior-note",children:[n.jsx("b",{children:c("nodeView.eval.noteLabel")})," ",h.verdict.note]}),!h.fresh&&(((Ie=h.staleAxes)==null?void 0:Ie.length)??0)>0&&n.jsxs("div",{className:"an-expected an-stale","data-tip":c("nodeView.eval.staleReadoutTitle"),children:[n.jsx("b",{children:c("nodeView.eval.staleLabel")})," ",h.staleAxes.join(" · "),(((Pe=h.codeDrift)==null?void 0:Pe.length)??0)>0&&n.jsxs("span",{className:"an-stale-files",children:[" — ",h.codeDrift.map(e=>`${e.file.split("/").pop()} +${e.behind}`).join(", ")]})]}),P&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"an-player",ref:k,children:[n.jsxs("div",{className:`an-stage ${Y?"playing":"paused"}`,ref:E,onMouseDown:Qe,onMouseMove:We,onMouseUp:et,children:[n.jsx("video",{className:"an-video",ref:f,src:`/api/evidence/${P.hash}`,preload:"metadata",playsInline:!0}),_&&n.jsx("div",{className:"an-rect live",style:{left:`${_.x}%`,top:`${_.y}%`,width:`${_.w}%`,height:`${_.h}%`}}),!Y&&!u&&n.jsx("div",{className:"an-bigplay","aria-hidden":!0,children:n.jsx(ft,{name:"play",size:22})})]}),n.jsxs("div",{className:"an-bar",children:[n.jsx(ve,{icon:Y?"pause":"play",size:14,className:"an-play",label:c(Y?"annotator.pause":"annotator.play"),onClick:W}),n.jsxs("div",{className:"an-seek",ref:w,onMouseDown:Ze,onMouseMove:Je,onMouseLeave:()=>re(null),children:[n.jsx("div",{className:"an-seek-trk"}),K>0&&g==="time"&&m.map((e,t)=>n.jsx("div",{className:"an-band",style:{left:`${e.at/K*100}%`},"data-tip":e.step},`band-${t}`)),n.jsx("div",{className:"an-seek-play",ref:I}),K>0&&C.map(e=>n.jsx("button",{type:"button",className:`an-mk ${G===e.i?"on":""} ${be===e.i?"active":""}`,style:{left:`${e.tMs/K*100}%`},"data-tip":e.label,onMouseDown:t=>t.stopPropagation(),onClick:t=>{t.stopPropagation(),$e(e.i,e.tMs)}},`mk-${e.i}`)),n.jsx("div",{className:"an-knob",ref:d}),ie!=null&&K>0&&n.jsx("div",{className:"an-seek-hov",style:{left:`${ie}%`},children:se(ie/100*K)})]}),n.jsx("span",{className:"an-time",ref:L}),Q&&n.jsx("span",{className:"an-curstep","data-tip":Q.node?`→ ${Q.node}`:void 0,children:Q.step}),n.jsx(mt,{target:k})]})]}),m.length>0&&n.jsx(Ve,{events:m,axis:g,extent:Se,activeStepIdx:ae,onSeek:V}),n.jsx("div",{className:"an-hint",children:c("annotator.hint")}),n.jsx("div",{className:"an-keys",children:c("annotator.keys")}),A&&n.jsx("div",{className:"an-flash",children:A})]}),!P&&m.length>0&&n.jsx(Ve,{events:m,axis:g,extent:Se,activeStepIdx:ae,onSeek:V}),de.length>0&&n.jsx("div",{className:"an-gallery",children:de.map((e,t)=>n.jsx(Oe,{e,alt:s.scenario},`${e.hash}-${t}`))}),He.map((e,t)=>n.jsx(Oe,{e,alt:s.scenario},`${e.hash}-${t}`)),U.length===0&&((Ke=h.verdict)!=null&&Ke.note?n.jsx("pre",{className:"eval-transcript",children:h.verdict.note}):n.jsx("div",{className:"an-hint",children:c("nodeView.eval.noImage")}))]}),n.jsx(Et,{entry:s,comments:fe,specs:i,sessions:v,onWrite:y,codeSha:h.codeSha,seekMs:O?V:null,anchorNow:O?Ge:null,draft:H,selIdx:G,activeIdx:be,onSelect:O?$e:null,events:O?m:null,commands:nt})]})]})}function Et({entry:s,comments:r,codeSha:i,specs:v,sessions:y,onWrite:x,seekMs:c,anchorNow:f,draft:E,selIdx:w,activeIdx:k,onSelect:S,events:m,commands:$=null}){var u;const g=ke(),b=(j,A)=>lt({node:s.node,scenario:s.scenario,body:j,codeSha:i,evidence:A});return n.jsxs("aside",{className:"an-rail",children:[n.jsx("div",{className:"an-comments-head",children:g("annotator.comments",{n:r.length})}),n.jsx("div",{className:"an-rail-list",children:n.jsx(ht,{replies:r,onSeek:c,selIdx:w,activeIdx:k,onSelect:S,events:m,threadId:((u=s.thread)==null?void 0:u.id)??null,onRemarkChange:()=>x==null?void 0:x("")})}),n.jsx("div",{className:"an-rail-compose",children:n.jsx(vt,{onSend:b,specs:v,sessions:y,focusId:s.node,onDone:x,anchorNow:f,draft:E,commands:$},`${s.node}·${s.scenario}`)})]})}function Ue({rowKeys:s,sel:r,onSel:i,detail:v,children:y}){const[x,c]=o.useState(!1),f=o.useRef({});f.current={rowKeys:s,sel:r},o.useEffect(()=>{const w=k=>{var u;const S=(u=k.target)==null?void 0:u.tagName;if(S==="INPUT"||S==="TEXTAREA"||k.metaKey||k.ctrlKey||k.altKey||k.key!=="j"&&k.key!=="k")return;k.preventDefault(),k.stopPropagation();const{rowKeys:m,sel:$}=f.current;if(!m.length)return;const g=m.indexOf($),b=g<0?k.key==="j"?0:m.length-1:Math.max(0,Math.min(m.length-1,g+(k.key==="j"?1:-1)));i(m[b])};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[i]),o.useEffect(()=>{var w;(w=document.querySelector(".fv-list-col .sel"))==null||w.scrollIntoView({block:"nearest"})},[r]);const E=n.jsx(xe,{className:"fv-fold-inline",onToggle:()=>c(!0)});return n.jsxs("div",{className:`fv-master ${x?"folded":""}`,children:[x&&n.jsx(xe,{className:"fv-unfold",folded:!0,onToggle:()=>c(!1)}),n.jsx("div",{className:"fv-list-col",style:x?{display:"none"}:void 0,children:typeof y=="function"?y(E):n.jsxs(n.Fragment,{children:[n.jsx(xe,{className:"fv-fold",onToggle:()=>c(!0)}),y]})}),n.jsx("div",{className:"fv-detail",children:v})]})}function St({specs:s=[],sessions:r=[],reloadBoard:i,onOpenSession:v}){const y=ke(),{page:x,param:c}=pt(),[f,E]=o.useState(null),[w,k]=o.useState(""),[S,m]=o.useState([]),$=o.useRef([]),g=o.useMemo(()=>new Map(S.map(d=>[pe(d),d])),[S]);$.current=S.map(pe);const b=f&&g.has(f)?f:$.current[0]??null,u=o.useMemo(()=>{if(!c)return null;const d=c.indexOf("/");return d>0?`eval:${c.slice(0,d)}·${c.slice(d+1)}`:null},[c]),[j,A]=o.useState(null);o.useEffect(()=>{x==="evals"&&u&&(E(u),A(u))},[x,u]),o.useEffect(()=>{j&&g.has(j)&&A(null)},[j,g]);const R=f&&!g.has(f),B=o.useMemo(()=>!R||xt(s).some(d=>pe(d)===f),[R,s,f]);o.useEffect(()=>{R&&!B&&(E(null),A(null))},[R,B]),o.useEffect(()=>{f&&!j&&S.length&&!g.has(f)&&E(null)},[f,j,S,g]),o.useEffect(()=>{if(x!=="evals"||!b||R)return;const d=/^eval:([^·]+)·(.+)$/.exec(b);d&>("evals",`${d[1]}/${d[2]}`,{replace:!0})},[x,b,R]);const q=o.useCallback(d=>m(d),[]),H=d=>{d&&(k(d),setTimeout(()=>k(""),6e3))},X=o.useCallback(async d=>{const L=await ze(d.node,d.scenario).catch(z=>({error:String(z)}));H((L==null?void 0:L.error)||""),await(i==null?void 0:i())},[i]),I=b?g.get(b):null;return n.jsx(Ue,{rowKeys:$.current,sel:b,onSel:E,detail:I?n.jsx(Nt,{entry:I,specs:s,sessions:r,onOpenSession:v,onWrite:async d=>{H(d),await(i==null?void 0:i())}}):n.jsx("div",{className:"fv-note",children:y("evalsFeed.empty")}),children:d=>n.jsxs(n.Fragment,{children:[w&&n.jsx("div",{className:"fv-notice",children:w}),n.jsx(kt,{nodes:s,sessions:r,sel:b,onSel:L=>E(L),onRows:q,onOk:X,mustShow:j,lead:d})]})})}const Ct=Object.freeze(Object.defineProperty({__proto__:null,EvalMasterDetail:Ue,default:St},Symbol.toStringTag,{value:"Module"}));export{Nt as E,Ue as a,Ct as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as l,j as t}from"./index-
|
|
1
|
+
import{u as l,j as t}from"./index-BQu-oJ8J.js";import{n as a}from"./SessionWindow-JYbpPwNB.js";function r(){return t.jsx(a,{name:"panel-left",className:"fold-toggle-icon"})}function m({className:n,folded:e,onToggle:s}){const o=l()(e?"masterList.unfold":"masterList.fold");return t.jsx("button",{type:"button",className:n,"data-tip":o,"aria-label":o,onClick:s,children:t.jsx(r,{})})}export{m as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as D,r as a,j as s,
|
|
1
|
+
import{u as D,r as a,j as s,o as Z,q as W,t as ss,v as es}from"./index-BQu-oJ8J.js";import{a7 as _,a8 as ts,g as ns,$ as ls,a9 as as,a3 as os,a4 as is,aa as cs}from"./SessionWindow-JYbpPwNB.js";import{F as J}from"./FoldToggle-x9gtO1OQ.js";import{u as rs,M as ds}from"./Dashboard-C_fGmOKK.js";function js({onFocusNode:t,onOpenSession:k,specs:p=[],sessions:x=[],issuesData:w=null,reloadIssues:o,issueId:d=null}){const i=D(),c=w,[h,v]=a.useState(!1),[j,m]=a.useState(!1),[b,S]=a.useState(!1),[g,N]=a.useState(!1),[l,y]=a.useState("all"),[f,n]=a.useState(""),[u,L]=a.useState(null),T=a.useRef([]),G=a.useCallback(()=>o==null?void 0:o(!0),[o]),V=e=>{e&&(n(e),setTimeout(()=>n(""),6e3))},C=Array.isArray(c==null?void 0:c.issues)?c.issues:[],P=e=>e.status!=="open",B=[...new Set(C.map(e=>e.store).filter(Boolean))],Q=Array.isArray(c==null?void 0:c.stores)&&c.stores.length?c.stores:[{id:"local",label:"local",kind:"local"}];a.useEffect(()=>{if(!d||!C.length)return;const e=C.find(r=>r.id===d);e&&(l!=="all"&&e.store!==l&&y("all"),P(e)&&S(!0),M(e)||N(!1),L(`issue:${e.id}`))},[d,C,l]);const K=l==="all"?C:C.filter(e=>e.store===l),M=e=>!!_(x,e.by)||Array.isArray(e.replies)&&e.replies.some(r=>_(x,r.by)),I=b?K:K.filter(e=>!P(e)),E=g?I.filter(M):I,F=I.filter(M).length,O=K.filter(P).length,q=a.useMemo(()=>new Map(E.map(e=>[`issue:${e.id}`,e])),[E]);T.current=E.map(e=>`issue:${e.id}`);const A=u&&q.has(u)?u:T.current[0]??null,H=a.useRef({});if(H.current={effSel:A},rs(h,()=>v(!1)),a.useEffect(()=>{const e=r=>{var X;const $=(X=r.target)==null?void 0:X.tagName;if($==="INPUT"||$==="TEXTAREA"||r.metaKey||r.ctrlKey||r.altKey||r.key!=="j"&&r.key!=="k")return;r.preventDefault(),r.stopPropagation();const R=T.current;if(!R.length)return;const z=R.indexOf(H.current.effSel),Y=z<0?r.key==="j"?0:R.length-1:Math.max(0,Math.min(R.length-1,z+(r.key==="j"?1:-1)));L(R[Y])};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),a.useEffect(()=>{var e;(e=document.querySelector(".fv-list-col .sel"))==null||e.scrollIntoView({block:"nearest"})},[A]),c==null)return s.jsx("div",{className:"fv-note",children:i("session.issuesLoading")});if(!c.enabled)return s.jsx("div",{className:"fv-note",children:i("session.issuesOff")});const U=A?q.get(A):null;return s.jsxs("div",{className:`fv-master ${j?"folded":""}`,children:[j&&s.jsx(J,{className:"fv-unfold",folded:!0,onToggle:()=>m(!1)}),s.jsxs("div",{className:"fv-list-col",style:j?{display:"none"}:void 0,children:[f&&s.jsx("div",{className:"fv-notice",children:f}),s.jsxs("section",{className:"fv-group",children:[s.jsxs("header",{className:"fv-group-head",children:[s.jsxs("span",{className:"fv-head-row",children:[s.jsx(J,{className:"fv-fold-inline",onToggle:()=>m(!0)}),B.length>1&&s.jsx(ts,{value:l,onChange:y,options:[{value:"all",label:i("session.issuesStoreAll")},...B.map(e=>({value:e,label:e}))]}),s.jsx(ns,{icon:"plus",size:12,className:"fv-new-btn",label:i("session.issuesNew"),onClick:()=>v(!0)})]}),(g||F>0||O>0)&&s.jsxs("span",{className:"ef-chipbar",children:[(g||F>0)&&s.jsx("button",{type:"button",className:`ef-chip fv-live ${g?"on":""}`,onClick:()=>N(e=>!e),"data-tip":i("masterList.liveChipTitle"),children:i("masterList.liveChip",{n:F})}),O>0&&s.jsx("button",{type:"button",className:`ef-chip fv-concluded ${b?"on":""}`,onClick:()=>S(e=>!e),children:i("nodeView.closedIssues",{n:O})})]})]}),!E.length&&s.jsx("div",{className:"fv-note",children:i("session.issuesEmpty")}),E.map(e=>{var $;const r=`issue:${e.id}`;return s.jsxs("button",{className:`fv-row ${A===r?"sel":""}`,onClick:()=>L(r),children:[s.jsx("span",{className:`fv-dot st-${e.status||"open"}`,"data-tip":e.status}),s.jsx("span",{className:"fv-concern","data-tip":e.concern,children:e.concern}),((($=e.replies)==null?void 0:$.length)??0)>0&&s.jsx("span",{className:"fv-replies","data-tip":i("session.issuesReplies",{n:e.replies.length}),children:e.replies.length}),B.length>1&&s.jsx("span",{className:`fv-store fv-store-${e.store==="local"?"local":"forge"}`,children:e.store})]},e.id)})]})]}),s.jsx("div",{className:"fv-detail",children:U?s.jsx(us,{issue:U,specs:p,sessions:x,onFocusNode:t,onOpenSession:k,onWrite:async e=>{V(e),await G()}}):s.jsx("div",{className:"fv-note",children:i("session.issuesEmpty")})}),h&&s.jsx(ds,{title:i("session.issuesNew"),closeLabel:i("common.close"),onClose:()=>v(!1),className:"fv-new-modal",children:s.jsx(ms,{specs:p,sessions:x,stores:Q,onCancel:()=>v(!1),onDone:async e=>{v(!1),V(e),await G()}})})]})}function us({issue:t,specs:k,sessions:p,onFocusNode:x,onOpenSession:w,onWrite:o}){const d=D(),i=t.store==="local",c=t.status!=="open",[h,v]=a.useState(""),[j,m]=a.useState(""),b=Array.isArray(t.nodes)?t.nodes:[],S=Array.isArray(t.replies)?t.replies:[],g=(l,y)=>async()=>{if(!h){v(l);try{const f=await y();f!=null&&f.ok?(m(""),await(o==null?void 0:o(""))):m((f==null?void 0:f.error)||`${l} failed`)}finally{v("")}}},N=(l,y,f,n)=>s.jsx("button",{type:"button",className:`fv-close-issue fv-life-${l}`,disabled:!!h,"data-tip":n,onMouseDown:u=>u.preventDefault(),onClick:g(l,f),children:h===l?d("session.issuesActing"):y});return s.jsxs("div",{className:"fvd",children:[s.jsxs("div",{className:"fvd-scroll",children:[s.jsx("header",{className:"fvd-head",children:s.jsx("span",{className:"fvd-concern",children:t.concern})}),s.jsxs("div",{className:"fvd-meta",children:[t.status&&s.jsx("span",{className:`fv-status fv-st-${t.status}`,children:t.status}),s.jsx("span",{className:`fv-store fv-store-${i?"local":"forge"}`,children:t.store}),i?s.jsx(ls,{originator:t.by,sessions:p,kind:"issue",onOpenSession:w}):t.by&&s.jsx("span",{className:"fv-by",children:t.by}),b.map(l=>s.jsx("button",{type:"button",className:"fv-chip",onClick:()=>x==null?void 0:x(l),"data-tip":d("session.issuesFocusNode"),children:l},l)),t.url&&s.jsx("a",{className:"fv-link",href:t.url,target:"_blank",rel:"noreferrer",children:d("session.issuesOpenOnForge")})]}),t.body&&s.jsx("div",{className:"fvd-body",children:s.jsx(as,{body:t.body})}),s.jsx(os,{replies:S,threadId:i?t.id:null,onRemarkChange:()=>o==null?void 0:o("")})]}),s.jsx("div",{className:"fvd-compose",children:s.jsx(is,{onSend:(l,y)=>ss(t.id,l,y),specs:k,sessions:p,focusId:b[0]||null,onDone:o,actionsEnd:!c&&s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:"fv-error",children:j}),i&&N("promote",d("session.issuesPromote"),()=>Z(t.id),d("session.issuesPromoteTitle")),N("close",d("session.issuesCloseIssue"),()=>W(t.id),d("session.issuesCloseIssueTitle"))]})},t.id)})]})}const fs=t=>t.id==="local"?"L":t.id==="github"?"GH":t.id==="gitlab"?"GL":(t.id||"?").slice(0,2).toUpperCase();function ms({specs:t,sessions:k,stores:p,onCancel:x,onDone:w}){var f;const o=D(),[d,i]=a.useState(((f=p[0])==null?void 0:f.id)||"local"),[c,h]=a.useState(""),[v,j]=a.useState(""),[m,b]=a.useState(!1),[S,g]=a.useState(""),N=a.useRef(null),l=cs({inputRef:N,value:v,setValue:j,specs:t,sessions:k,up:!0,fixedAbove:".fv-new-modal"});a.useEffect(()=>{var n;p.some(u=>u.id===d)||i(((n=p[0])==null?void 0:n.id)||"local")},[p,d]);const y=async()=>{const n=c.trim();if(!(!n||m)){b(!0),g("");try{const u=await es({concern:n,body:v.trim()||void 0,store:d});u!=null&&u.ok?(h(""),j(""),await(w==null?void 0:w(u.outcomes||""))):g((u==null?void 0:u.error)||o("session.issuesPostFailed"))}finally{b(!1)}}};return s.jsxs("div",{className:"fv-new-form",children:[s.jsxs("label",{className:"fv-store-pick",children:[s.jsx("span",{children:o("session.issuesStoreLabel")}),s.jsx("select",{value:d,disabled:m,onChange:n=>i(n.target.value),children:p.map(n=>s.jsxs("option",{value:n.id,children:[fs(n)," · ",n.label||n.id]},n.id))})]}),s.jsx("input",{className:"fv-input",value:c,placeholder:o("session.issuesConcernPlaceholder"),disabled:m,onChange:n=>h(n.target.value)}),s.jsxs("div",{className:"fv-tawrap",children:[s.jsx("textarea",{ref:N,className:"fv-textarea",rows:3,value:v,placeholder:o("session.issuesBodyPlaceholder"),disabled:m,onChange:n=>{j(n.target.value),l.sync(n.target)},onSelect:n=>l.sync(n.target),onBlur:l.close,onKeyDown:n=>{l.onKeyDown(n)||n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),y())}}),l.menuEl]}),s.jsxs("div",{className:"fv-actions",children:[s.jsx("span",{className:S?"fv-error":"fv-hint",children:S||o("session.issuesMentionHint")}),s.jsx("button",{type:"button",className:"fv-cancel",disabled:m,onClick:x,children:o("common.cancel")}),s.jsx("button",{type:"button",className:"fv-send",disabled:m||!c.trim(),onClick:y,children:o(m?"session.issuesSending":"session.issuesPost")})]})]})}export{js as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as E,r as i,j as s,b as z,c as V,s as F}from"./index-BQu-oJ8J.js";import{q as B,t as _,A as M,j as $,v as U,H as J,w as q,E as G,x as K,y as Y,z as Z,R as Q,B as W,S as H,b as X,c as D,s as L}from"./SessionWindow-JYbpPwNB.js";import{u as ss,a as es,c as as,b as ns}from"./launch-BM9GgvkX.js";const ts={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"},O=(e,n)=>n.filter(u=>{var l;return(l=u.ops)==null?void 0:l.some(c=>c.nodeId===e.id)});function A({status:e}){const n=H[e]||H.pending;return s.jsx("span",{className:"m-dot",style:{background:n.color}})}function ls({node:e,kids:n,editors:u,onTap:l}){return s.jsxs("button",{className:"m-row",onClick:l,children:[s.jsx(A,{status:e.status}),s.jsx("span",{className:"m-row-title",children:e.title}),u.length>0&&s.jsx("span",{className:"m-row-faces",children:u.slice(0,3).map(c=>s.jsx(M,{seed:c.id,status:c.status,title:$(c)},c.id))}),e.version?s.jsxs("span",{className:"m-row-ver",children:["v",e.version]}):null,n>0&&s.jsxs("span",{className:"m-row-kids",children:["▸",n]}),s.jsx("span",{className:"m-row-chev",children:"›"})]})}function cs({node:e,childrenOf:n,sessions:u,onOpenChild:l}){const c=E(),d=n(e.id),p=B(e),j=[...d.length?[{key:"children",label:c("mobile.childrenTab",{n:d.length})}]:[],...p.map(a=>({key:a.key,label:c(ts[a.key])}))],[b,N]=i.useState(null);i.useEffect(()=>{N(null)},[e.id]);const o=b&&j.some(a=>a.key===b)?b:j[0].key,y=_(e.id,o==="history"),f=O(e,u);return s.jsxs("div",{className:"m-node",children:[s.jsxs("div",{className:"m-node-head",children:[s.jsx(A,{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:c(`status.${e.status}`)}),f.length>0&&s.jsx("span",{className:"m-node-faces",title:c("mobile.liveEditors",{n:f.length}),children:f.map(a=>s.jsx(M,{seed:a.id,status:a.status,title:$(a)},a.id))})]}),e.desc&&s.jsx("div",{className:"m-node-desc",children:e.desc}),s.jsx("div",{className:"m-tabs",children:j.map(a=>s.jsx("button",{className:a.key===o?"m-tab on":"m-tab",onClick:()=>N(a.key),children:a.label},a.key))}),s.jsxs("div",{className:o==="history"?"m-pane-host fixed":"m-pane-host",children:[o==="children"&&s.jsx("div",{className:"m-children",children:d.map(a=>s.jsx(ls,{node:a,kids:n(a.id).length,editors:O(a,u),onTap:()=>l(a.id)},a.id))}),o==="spec"&&s.jsx(U,{node:e}),o==="history"&&s.jsx(J,{node:e,rows:y}),o==="issues"&&s.jsx(q,{node:e}),o==="eval"&&s.jsx(G,{node:e}),o==="edit"&&s.jsx(K,{node:e})]})]})}const P=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),R=e=>new Date(e).toLocaleDateString([],{month:"short",day:"numeric"}),I=e=>new Date(e).toDateString(),is=(e,n)=>e!=null&&e.length===n.length&&(e.length===0||JSON.stringify(e[e.length-1])===JSON.stringify(n[n.length-1]));function rs({s:e,sessions:n,onBack:u}){const l=E(),[c,d]=i.useState(null),[p,j]=i.useState(null),[b,N]=i.useState(""),[o,y]=i.useState(!1),[f,a]=i.useState(null),g=i.useRef(null),h=i.useRef(!0),x=i.useCallback(()=>z(e.id).then(t=>{t&&d(m=>is(m,t.events)?m:t.events)}),[e.id]);i.useEffect(()=>{d(null),j(null),h.current=!0,x(),V(e.id).then(t=>{t&&j(t)})},[e.id,x]),i.useEffect(()=>{const t=setInterval(x,8e3);return()=>clearInterval(t)},[x]),i.useEffect(()=>{x()},[e.status,e.note,x]);const T=()=>{const t=g.current;t&&(h.current=t.scrollHeight-t.scrollTop-t.clientHeight<48)};i.useEffect(()=>{const t=g.current;t&&h.current&&(t.scrollTop=t.scrollHeight)},[c]);const k=async()=>{const t=b.trim();if(!t||o)return;y(!0),a(null);const m=await F(e.id,t,{replyVia:"note"});y(!1),m.ok?(N(""),x()):a(m.error||l("mobile.sendFailed"))},C=t=>{if(!t)return l("mobile.you");const m=n.find(w=>w.id===t);return m?L(m):t.slice(0,8)},r=[];let v=null;for(const[t,m]of(c||[]).entries())if(I(m.ts)!==v&&(v=I(m.ts),r.push(s.jsx("div",{className:"m-day",children:R(m.ts)},`d${t}`))),m.kind==="status"){const w=m.display||m.status;r.push(s.jsxs("div",{className:"m-ev",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-glyph",style:{color:D[w]},children:X[w]||"·"}),s.jsx("span",{className:"m-ev-word",style:{color:D[w]},children:l(`status.${w}`)}),s.jsx("span",{className:"m-ev-time",children:P(m.ts)})]}),m.note&&s.jsx("div",{className:"m-ev-note",children:m.note})]},t))}else r.push(s.jsxs("div",{className:"m-ev m-ev-sent",children:[s.jsxs("div",{className:"m-ev-head",children:[s.jsx("span",{className:"m-ev-from",children:C(m.from)}),s.jsx("span",{className:"m-ev-time",children:P(m.ts)})]}),s.jsx("div",{className:"m-ev-text",children:m.text})]},t));const S=e.liveness==="offline"||e.status==="offline";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:u,"aria-label":l("mobile.back"),children:"‹"}),s.jsxs("div",{className:"m-sess-meta",children:[s.jsx("span",{className:"m-sess-name",children:L(e)}),s.jsxs("span",{className:"m-sess-status",style:{color:D[e.status]},children:[l(`status.${e.status}`),e.merges?` · ×${e.merges}`:""," · ",s.jsx("span",{className:"m-sess-id8",children:e.id.slice(0,8)})]})]})]}),s.jsxs("div",{className:"m-timeline",ref:g,onScroll:T,children:[(p==null?void 0:p.prompt)&&s.jsxs("details",{className:"m-ev m-ev-prompt",children:[s.jsxs("summary",{children:[l("mobile.asked"),e.created?` · ${R(e.created)} ${P(e.created)}`:""]}),s.jsx("div",{className:"m-ev-text",children:p.prompt})]}),c===null?s.jsx("div",{className:"m-empty",children:l("hud.loading")}):r.length===0?s.jsx("div",{className:"m-empty",children:l("mobile.noEvents")}):r]}),S&&s.jsx("div",{className:"m-offline",children:l("mobile.offlineHint")}),f&&s.jsx("div",{className:"m-senderr",children:f}),s.jsx("div",{className:"m-composer",children:s.jsxs("div",{className:"m-composer-line",children:[s.jsx("textarea",{className:"m-input",rows:1,placeholder:l("mobile.inputPlaceholder"),value:b,onChange:t=>N(t.target.value)}),s.jsx("button",{className:"m-send",disabled:!b.trim()||o,onClick:k,children:l("mobile.send")})]})})]})}function os({specs:e,draft:n,setDraft:u,onBack:l,onLaunched:c}){const d=E(),{launchers:p,launcher:j,pickLauncher:b}=ss(),N=es(),[o,y]=i.useState(!1),[f,a]=i.useState(null),g=async()=>{const h=n.trim();if(!h||o)return;y(!0),a(null);const x=await as(ns(h,N,e),j);y(!1),x.ok?(u(""),c()):a(x.error||d("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:l,"aria-label":d("mobile.back"),children:"‹"}),s.jsx("div",{className:"m-sess-meta",children:s.jsx("span",{className:"m-sess-name",children:d("mobile.newSession")})})]}),s.jsxs("div",{className:"m-new-body",children:[s.jsx("textarea",{className:"m-input m-new-input",rows:5,placeholder:d("mobile.newPlaceholder"),value:n,onChange:h=>u(h.target.value)}),p.length>0&&s.jsxs("label",{className:"m-new-launcher",children:[s.jsx("span",{className:"m-new-launcher-label",children:d("session.launcherLabel")}),s.jsx("select",{className:"m-new-launcher-select",value:j,onChange:h=>b(h.target.value),children:p.map(h=>s.jsx("option",{value:h.name,children:h.name},h.name))})]}),f&&s.jsx("div",{className:"m-senderr",children:f}),s.jsx("button",{className:"m-send m-new-go",disabled:!n.trim()||o,onClick:g,children:d(o?"mobile.launching":"mobile.launch")})]})]})}function ms({specs:e,sessions:n,openId:u,setOpenId:l,creating:c,setCreating:d,newDraft:p,setNewDraft:j}){const b=E(),N=u?n.find(a=>a.id===u):null,{expanded:o,toggle:y}=Y(),f=i.useMemo(()=>Z(n,a=>o.has(a)),[n,o]);return c?s.jsx(os,{specs:e,draft:p,setDraft:j,onBack:()=>d(!1),onLaunched:()=>d(!1)}):N?s.jsx(rs,{s:N,sessions:n,onBack:()=>l(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:"+"}),b("mobile.newSession")]}),!n.length&&s.jsx("div",{className:"m-empty big",children:b("mobile.noSessions")}),f.map(a=>{if(a.type==="zone")return s.jsx("div",{className:"m-zone",children:b(`sessionZone.${a.zone}`)},`z-${a.zone}`);const g=a.s,h=a.expandable||a.depth?s.jsx(Q,{guides:a.guides,expandable:a.expandable,expanded:a.expanded,rollup:a.rollup,kin:a.kin,onToggle:()=>y(g.id)}):null;return s.jsx("button",{className:"m-sess-row",onClick:()=>l(g.id),children:s.jsx(W,{s:g,locked:!1,showAvatar:!1,lead:h})},g.id)})]})}function xs({specs:e,sessions:n}){const u=E(),l=i.useMemo(()=>Object.fromEntries(e.map(r=>[r.id,r])),[e]),c=i.useMemo(()=>e.find(r=>!r.parent)||e[0],[e]),d=i.useMemo(()=>{const r={};return e.forEach(v=>{var S;v.parent&&(r[S=v.parent]??(r[S]=[])).push(v)}),v=>r[v]||[]},[e]),[p,j]=i.useState("specs"),[b,N]=i.useState(()=>c?[c.id]:[]),[o,y]=i.useState(null),[f,a]=i.useState(!1),[g,h]=i.useState(""),x=b.filter(r=>l[r]),T=x[x.length-1]||(c==null?void 0:c.id),k=T?l[T]:null,C=r=>N(v=>[...v.filter(S=>l[S]),r]);return s.jsxs("div",{className:"m-app",children:[s.jsx("main",{className:"m-main",children:p==="specs"?s.jsxs("div",{className:"m-specs",children:[s.jsx("nav",{className:"m-crumbs",children:x.map((r,v)=>s.jsxs("span",{className:"m-crumb",children:[v>0&&s.jsx("span",{className:"m-crumb-sep",children:"›"}),s.jsx("button",{className:v===x.length-1?"m-crumb-btn cur":"m-crumb-btn",onClick:()=>N(x.slice(0,v+1)),children:l[r].title})]},r))}),k&&s.jsx(cs,{node:k,childrenOf:d,sessions:n,onOpenChild:C},k.id)]}):s.jsx(ms,{specs:e,sessions:n,openId:o,setOpenId:y,creating:f,setCreating:a,newDraft:g,setNewDraft:h})}),s.jsxs("nav",{className:"m-tabbar",children:[s.jsxs("button",{className:p==="specs"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>j("specs"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"❯_"}),u("mobile.specsTab")]}),s.jsxs("button",{className:p==="sessions"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>j("sessions"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◐"}),u("mobile.sessionsTab"),n.length>0&&s.jsx("span",{className:"m-tabbar-badge",children:n.length})]})]})]})}export{xs as default};
|