spexcode 0.4.3 → 0.5.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/README.md +1 -1
- package/package.json +2 -2
- package/spec-cli/src/claude-headless.ts +271 -0
- package/spec-cli/src/cli.ts +24 -1
- package/spec-cli/src/client.ts +8 -0
- package/spec-cli/src/codex-headless.ts +13 -0
- package/spec-cli/src/guide.ts +18 -8
- package/spec-cli/src/harness.ts +150 -14
- package/spec-cli/src/help.ts +4 -1
- package/spec-cli/src/index.ts +19 -7
- package/spec-cli/src/layout.ts +1 -0
- package/spec-cli/src/message-stream.ts +147 -0
- package/spec-cli/src/opencode-headless.ts +95 -0
- package/spec-cli/src/pi-headless.ts +195 -0
- package/spec-cli/src/session-timeline.ts +6 -4
- package/spec-cli/src/sessions.ts +72 -39
- package/spec-cli/templates/spexcode.json +8 -1
- package/spec-dashboard/dist/assets/Dashboard-C_w_wdk5.js +27 -0
- package/spec-dashboard/dist/assets/{EvalsPage-DmiX3rdU.js → EvalsPage-5_nfIYll.js} +2 -2
- package/spec-dashboard/dist/assets/IssuesPage-By-u--95.js +1 -0
- package/spec-dashboard/dist/assets/MobileApp-CVEwjHr9.js +2 -0
- package/spec-dashboard/dist/assets/Modal-BqgvzMJD.js +1 -0
- package/spec-dashboard/dist/assets/{PageScroll-C15adEYI.js → PageScroll-B_dKCuXx.js} +1 -1
- package/spec-dashboard/dist/assets/ProjectsPage-RVP8AqK4.js +1 -0
- package/spec-dashboard/dist/assets/SessionInterface-Bh3vq8SU.js +39 -0
- package/spec-dashboard/dist/assets/{SessionWindow-CuDO_67z.js → SessionWindow-BuJ5mzjC.js} +1 -1
- package/spec-dashboard/dist/assets/{Settings-C_N1wX1f.js → Settings-B8KFocsz.js} +1 -1
- package/spec-dashboard/dist/assets/TimelineChat-K0wdlweB.js +1 -0
- package/spec-dashboard/dist/assets/index-BKaTHjmU.js +41 -0
- package/spec-dashboard/dist/assets/index-DcnCaBAC.css +1 -0
- package/spec-dashboard/dist/index.html +2 -2
- package/spec-dashboard/dist/assets/Dashboard-CiHh-gLD.js +0 -27
- package/spec-dashboard/dist/assets/IssuesPage-CIbVGRUJ.js +0 -1
- package/spec-dashboard/dist/assets/MobileApp-D-N9_eh0.js +0 -2
- package/spec-dashboard/dist/assets/Modal-DHMzSFJ4.js +0 -1
- package/spec-dashboard/dist/assets/ProjectsPage-sQpzglp5.js +0 -1
- package/spec-dashboard/dist/assets/SessionInterface-B8pGU7Rg.js +0 -39
- package/spec-dashboard/dist/assets/index-DmWbmvCq.js +0 -41
- package/spec-dashboard/dist/assets/index-GGIVdKwH.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as P,r as v,j as s,Z as Y,$ as z,a0 as Q,I as U,a1 as G,a2 as V}from"./index-DmWbmvCq.js";import{k as X,at as I,ap as Z,d as J,aj as D,r as T,au as W,ao as ee,ai as se,af as R,ag as C,ah as te,X as _,aq as ne,u as ie,a3 as M,a4 as oe,av as le,a5 as ae,as as re,a6 as ce,a7 as ue,n as de,ar as fe,C as pe,aw as me,O as ve,U as xe,a8 as be}from"./SessionWindow-CuDO_67z.js";import{M as ge}from"./Modal-DHMzSFJ4.js";import"./PageScroll-C15adEYI.js";const ye=e=>e.status!=="open",je=e=>{const r=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return Number.isFinite(r)?r<3600?`${Math.max(1,Math.floor(r/60))}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`:""},we=e=>{const r=String(e||"").split("#"),l=r.length>1?r.at(-1):r[0];return`#${l.length>16?`${l.slice(0,13)}…`:l}`},he=["is","state","store","author","node","session"],A=(e,r,l,f=u=>u)=>{var u,o;return(((o=(u=e==null?void 0:e.facets)==null?void 0:u[r])==null?void 0:o.options)??[]).map(a=>({value:a.value,label:a.value===""?l:f(a.value)}))};function Se({data:e,loading:r,error:l,reload:f,specs:u,sessions:o,query:a,notice:c,flash:d}){var $,B,q,O;const i=P(),[p,x]=v.useState(!1);if(ie(p,()=>x(!1)),e&&!e.enabled)return s.jsx("div",{className:"fv-note",children:i("session.issuesOff")});const b=Array.isArray(e==null?void 0:e.items)?e.items:[],g=String(a.q??"").trim()||I,w=n=>de("issues",null,{query:fe(n,I)}),y=(n,F)=>w(be(g,n,F)),L=(((B=($=e==null?void 0:e.facets)==null?void 0:$.store)==null?void 0:B.options)??[]).map(n=>n.value).filter(Boolean),N=Array.isArray(e==null?void 0:e.stores)&&e.stores.length?e.stores:[{id:"local",label:"local",kind:"local"}],h=b,m=((q=e==null?void 0:e.counts)==null?void 0:q.open)||0,S=((O=e==null?void 0:e.counts)==null?void 0:O.closed)||0,t=M(g,"state"),j=h.map(n=>{var K,H;const F=n.status||"open";return{key:n.id,href:T("issues",n.id),content:s.jsx(s.Fragment,{children:s.jsx(oe,{state:s.jsx(_,{kind:"issue",state:F}),title:n.concern,meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-tip":n.id,children:we(n.id)}),n.by&&s.jsx("span",{"data-tip":n.by,children:i("reviewList.openedBy",{by:le(n.by)})}),n.created&&s.jsx("span",{children:i("reviewList.openedAt",{at:je(n.created)})})]}),aside:s.jsxs(s.Fragment,{children:[(((K=n.replies)==null?void 0:K.length)??0)>0&&s.jsxs("span",{className:"rl-comments","data-tip":i("session.issuesReplies",{n:n.replies.length}),children:[s.jsx(U,{name:"message-square",size:14}),n.replies.length]}),L.length>1&&s.jsx("span",{className:`rl-tag fv-store-${n.store==="local"?"local":"forge"}`,children:n.store}),((H=n.nodes)==null?void 0:H[0])&&s.jsx("span",{className:"rl-tag node",children:n.nodes[0]})]})})})}}),k={label:i("reviewList.facetStore"),value:M(g,"store"),options:A(e,"store",i("reviewList.all"))},E={label:i("reviewList.facetSession"),value:M(g,"session"),options:A(e,"session",i("reviewList.all"),n=>i(n==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))};return s.jsx(ae,{notice:c,loading:r,error:l,title:i("reviewList.issuesTitle"),action:s.jsxs("button",{type:"button",className:"rl-new",onClick:()=>x(!0),children:[s.jsx(U,{name:"plus",size:14}),i("session.issuesNew")]}),search:{value:String(a.q??"").trim()?a.q:I,onSubmit:w,placeholder:i("reviewList.searchIssues"),label:i("reviewList.search"),keys:he,suggest:{author:A(e,"author",i("reviewList.all")).filter(n=>n.value),node:A(e,"node",i("reviewList.all")).filter(n=>n.value)}},sections:[{key:"open",label:i("reviewList.open"),count:m,active:t===""||t==="open",onSelect:()=>y("state","open")},{key:"closed",label:i("reviewList.closed"),count:S,active:t!==""&&t!=="open",onSelect:()=>y("state","closed")}],facets:s.jsx(ue,{label:k.label,value:k.value,options:k.options,clearLabel:i("reviewList.all"),onChange:n=>y("store",n),mobile:!0}),secondaryFilters:s.jsx(ce,{label:i("reviewList.filters"),clearLabel:i("reviewList.all"),groups:[{label:E.label,value:E.value,active:!!E.value,options:E.options,onChange:n=>y("session",n)}]}),rows:j,pagination:e?{page:e.page,pageCount:e.pageCount,prev:e.prev,next:e.next,hrefFor:n=>T("issues",null,re(g,I,n))}:null,empty:{hasData:((e==null?void 0:e.sourceTotal)??0)>0,dataset:i("session.issuesEmpty"),filtered:i("session.issuesNoMatch")},children:p&&s.jsx(ge,{title:i("session.issuesNew"),closeLabel:i("common.close"),onClose:()=>x(!1),className:"fv-new-modal",children:s.jsx(Ie,{specs:u,sessions:o,stores:N,onCancel:()=>x(!1),onDone:async n=>{x(!1),d(n),await(f==null?void 0:f())}})})})}function Le({issue:e,specs:r,sessions:l,onFocusNode:f,onOpenSession:u,onWrite:o,notice:a}){const c=P(),d=e.store==="local",i=ye(e),[p,x]=v.useState(""),[b,g]=v.useState(""),w=Array.isArray(e.nodes)?e.nodes:[],y=Array.isArray(e.replies)?e.replies:[],L=e.status||"open",N=(m,S)=>async()=>{if(!p){x(m);try{const t=await S();t!=null&&t.ok?(g(""),await(o==null?void 0:o(""))):g((t==null?void 0:t.error)||`${m} failed`)}finally{x("")}}},h=(m,S,t,j)=>s.jsx("button",{type:"button",className:`fv-close-issue fv-life-${m}`,disabled:!!p,"data-tip":j,onMouseDown:k=>k.preventDefault(),onClick:N(m,t),children:p===m?c("session.issuesActing"):S});return s.jsxs(D,{title:e.concern,backHref:ne("issues"),backLabel:c("detail.backToIssues"),status:s.jsx(_,{kind:"issue",state:L,showLabel:!0,className:"ds-status-pill",size:16}),side:s.jsxs(s.Fragment,{children:[s.jsx(R,{label:c("detail.sideIssue"),children:s.jsx(C,{text:e.id,mono:!0})}),s.jsxs(R,{label:c("detail.sideStore"),children:[s.jsx(C,{text:e.store,className:`fv-store fv-store-${d?"local":"forge"}`}),e.url&&s.jsx(C,{text:c("session.issuesOpenOnStore",{store:Ce(e.store)}),href:e.url,external:!0})]}),e.by&&s.jsx(R,{label:c("detail.sideOriginator"),children:d?s.jsx(te,{originator:e.by,sessions:l,kind:"issue",onOpenSession:u}):s.jsx(C,{text:e.by,dim:!0})}),w.length>0&&s.jsx(R,{label:c("detail.sideNodes"),children:w.map(m=>s.jsx(C,{text:m,mono:!0,tip:c("session.issuesFocusNode"),onClick:()=>f==null?void 0:f(m)},m))})]}),composer:s.jsx(se,{onSend:(m,S)=>Q(e.id,m,S),specs:r,sessions:l,focusId:w[0]||null,onDone:o,actionsEnd:!i&&s.jsxs(s.Fragment,{children:[b&&s.jsx("span",{className:"fv-error",children:b}),d&&h("promote",c("session.issuesPromote"),()=>Y(e.id),c("session.issuesPromoteTitle")),h("close",c("session.issuesCloseIssue"),()=>z(e.id),c("session.issuesCloseIssueTitle"))]})},e.id),children:[a&&s.jsx("div",{className:"fv-notice",children:a}),e.body&&s.jsx("div",{className:"fvd-body",children:s.jsx(W,{body:e.body})}),s.jsx(ee,{replies:y,threadId:d?e.id:null,onRemarkChange:()=>o==null?void 0:o("")})]})}function Ne(e){const[r,l]=v.useState(null),[f,u]=v.useState(null),o=v.useRef(0),a=v.useCallback(async()=>{if(!e)return null;const c=++o.current;u(null);try{const d=await G(e);return c===o.current&&l(d),d}catch(d){return c===o.current&&(l(!1),u(d instanceof Error?d.message:String(d))),null}},[e]);return v.useEffect(()=>{l(null),u(null),e&&a()},[e,a]),{issue:r,error:f,reload:a}}function Pe({onFocusNode:e,onOpenSession:r,specs:l=[],sessions:f=[]}){const u=P(),{param:o,query:a}=X(),c=String(a.q??"").trim()||I,d=Z(a.page),i=J("issues",c,d,{enabled:!o,refreshKey:f}),p=Ne(o),[x,b]=v.useState(""),g=y=>{y&&(b(y),setTimeout(()=>b(""),6e3))},w=async y=>{g(y),await(o?p.reload():i.reload())};return o?p.issue==null?s.jsx("div",{className:"fv-note",children:u("session.issuesLoading")}):p.error?s.jsx(D,{failure:p.error,listHref:T("issues"),listLabel:u("reviewShell.backToIssues")}):p.issue===!1?s.jsx(D,{missing:u("reviewShell.issueNotFound",{id:o}),listHref:T("issues"),listLabel:u("reviewShell.backToIssues")}):s.jsx(Le,{issue:p.issue,specs:l,sessions:f,onFocusNode:e,onOpenSession:r,onWrite:w,notice:x}):s.jsx(Se,{data:i.data,loading:i.loading,error:i.error,reload:i.reload,specs:l,sessions:f,query:a,notice:x,flash:g})}const ke={github:"GitHub",gitlab:"GitLab"},Ce=e=>ke[e]||e;function Ie({specs:e,sessions:r,stores:l,onCancel:f,onDone:u}){var S;const o=P(),[a,c]=v.useState(((S=l[0])==null?void 0:S.id)||"local"),[d,i]=v.useState(""),[p,x]=v.useState(""),[b,g]=v.useState(!1),[w,y]=v.useState(""),L=v.useRef(null),{launchers:N}=pe(),h=me({inputRef:L,value:p,setValue:x,specs:e,sessions:r,launchers:N,up:!0,fixedAbove:".fv-new-modal"});v.useEffect(()=>{var t;l.some(j=>j.id===a)||c(((t=l[0])==null?void 0:t.id)||"local")},[l,a]);const m=async()=>{const t=d.trim();if(!(!t||b)){g(!0),y("");try{const j=await V({concern:t,body:p.trim()||void 0,store:a});j!=null&&j.ok?(i(""),x(""),await(u==null?void 0:u(j.outcomes||""))):y((j==null?void 0:j.error)||o("session.issuesPostFailed"))}finally{g(!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:a,disabled:b,onChange:t=>c(t.target.value),children:l.map(t=>s.jsx("option",{value:t.id,children:t.label||t.id},t.id))})]}),s.jsx("input",{className:"fv-input",value:d,placeholder:o("session.issuesConcernPlaceholder"),disabled:b,onChange:t=>i(t.target.value)}),s.jsxs("div",{className:"fv-tawrap",children:[s.jsx(ve,{ref:L,className:"fv-textarea",rows:3,value:p,placeholder:o("session.issuesBodyPlaceholder"),disabled:b,onChange:t=>{x(t.target.value),h.sync(t.target)},onSelect:t=>h.sync(t.target),onBlur:h.close,onKeyDown:t=>{xe(t)||h.onKeyDown(t)||t.key==="Enter"&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),m())}}),h.menuEl]}),s.jsxs("div",{className:"fv-actions",children:[w&&s.jsx("span",{className:"fv-error",children:w}),s.jsx("button",{type:"button",className:"fv-cancel",disabled:b,onClick:f,children:o("common.cancel")}),s.jsx("button",{type:"button",className:"fv-post",disabled:b||!d.trim(),onClick:m,children:o(b?"session.issuesSending":"session.issuesPost")})]})]})}export{he as ISSUE_QUERY_KEYS,Le as IssueDetailPage,Se as IssuesListPage,Pe as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EvalsPage-DmiX3rdU.js","assets/index-DmWbmvCq.js","assets/index-GGIVdKwH.css","assets/SessionWindow-CuDO_67z.js","assets/PageScroll-C15adEYI.js","assets/IssuesPage-CIbVGRUJ.js","assets/Modal-DHMzSFJ4.js","assets/Settings-C_N1wX1f.js","assets/bindings-BC9vqpYU.js","assets/terminalFont-DmTPNdbU.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as _,r as c,d as J,e as U,j as s,s as q,_ as R}from"./index-DmWbmvCq.js";import{b as G,c as I,s as z,k as K,n as C,p as Q,q as Y,A as M,f as V,t as Z,H as W,I as X,v as ss,w as es,x as as,y as ns,R as ts,z as ls,S as L,B as is,C as cs,D as rs,F as os,J as ms}from"./SessionWindow-CuDO_67z.js";import"./PageScroll-C15adEYI.js";const O=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),A=e=>new Date(e).toLocaleDateString([],{month:"short",day:"numeric"}),F=e=>new Date(e).toDateString(),ds=(e,t)=>e!=null&&e.length===t.length&&(e.length===0||JSON.stringify(e[e.length-1])===JSON.stringify(t[t.length-1]));function us({s:e,sessions:t}){const o=_(),[m,l]=c.useState(null),[u,w]=c.useState(null),[f,h]=c.useState(""),[N,x]=c.useState(!1),[y,g]=c.useState(null),a=c.useRef(null),p=c.useRef(!0),j=c.useCallback(()=>J(e.id).then(n=>{n&&l(d=>ds(d,n.events)?d:n.events)}),[e.id]);c.useEffect(()=>{l(null),w(null),p.current=!0,j(),U(e.id).then(n=>{n&&w(n)})},[e.id,j]),c.useEffect(()=>{const n=setInterval(j,8e3);return()=>clearInterval(n)},[j]),c.useEffect(()=>{j()},[e.status,e.note,j]);const i=()=>{const n=a.current;n&&(p.current=n.scrollHeight-n.scrollTop-n.clientHeight<48)};c.useEffect(()=>{const n=a.current;n&&p.current&&(n.scrollTop=n.scrollHeight)},[m]);const S=async()=>{const n=f.trim();if(!n||N)return;x(!0),g(null);const d=await q(e.id,n,{replyVia:"note"});x(!1),d.ok?(h(""),j()):g(d.error||o("mobile.sendFailed"))},E=n=>{if(!n)return o("mobile.you");const d=t.find(k=>k.id===n);return d?z(d):n.slice(0,8)},b=[];let T=null;for(const[n,d]of(m||[]).entries())if(F(d.ts)!==T&&(T=F(d.ts),b.push(s.jsx("div",{className:"m-day",children:A(d.ts)},`d${n}`))),d.kind==="status"){const k=d.display||d.status;b.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:I[k]},children:G[k]||"·"}),s.jsx("span",{className:"m-ev-word",style:{color:I[k]},children:o(`status.${k}`)}),s.jsx("span",{className:"m-ev-time",children:O(d.ts)})]}),d.note&&s.jsx("div",{className:"m-ev-note",children:d.note})]},n))}else b.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:E(d.from)}),s.jsx("span",{className:"m-ev-time",children:O(d.ts)})]}),s.jsx("div",{className:"m-ev-text",children:d.text})]},n));const P=e.liveness==="offline"||e.status==="offline";return s.jsxs("div",{className:"tl-chat",children:[s.jsxs("div",{className:"m-timeline",ref:a,onScroll:i,children:[(u==null?void 0:u.prompt)&&s.jsxs("details",{className:"m-ev m-ev-prompt",children:[s.jsxs("summary",{children:[o("mobile.asked"),e.created?` · ${A(e.created)} ${O(e.created)}`:""]}),s.jsx("div",{className:"m-ev-text",children:u.prompt})]}),m===null?s.jsx("div",{className:"m-empty",children:o("common.loading")}):b.length===0?s.jsx("div",{className:"m-empty",children:o("mobile.noEvents")}):b]}),P&&s.jsx("div",{className:"m-offline",children:o("mobile.offlineHint")}),y&&s.jsx("div",{className:"m-senderr",children:y}),s.jsx("div",{className:"m-composer",children:s.jsxs("div",{className:"m-composer-line",children:[s.jsx("textarea",{className:"m-input",rows:1,placeholder:o("mobile.inputPlaceholder"),value:f,onChange:n=>h(n.target.value)}),s.jsx("button",{className:"m-send",disabled:!f.trim()||N,onClick:S,children:o("mobile.send")})]})})]})}const hs=c.lazy(()=>R(()=>import("./EvalsPage-DmiX3rdU.js"),__vite__mapDeps([0,1,2,3,4]))),xs=c.lazy(()=>R(()=>import("./IssuesPage-CIbVGRUJ.js"),__vite__mapDeps([5,1,2,3,4,6]))),bs=c.lazy(()=>R(()=>import("./Settings-C_N1wX1f.js"),__vite__mapDeps([7,1,2,8,4,9]))),ps={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"},H=(e,t)=>t.filter(o=>{var m;return(m=o.ops)==null?void 0:m.some(l=>l.nodeId===e.id)});function $({status:e}){const t=L[e]||L.pending;return s.jsx("span",{className:"m-dot",style:{background:t.color}})}function js({node:e,kids:t,editors:o,onTap:m}){return s.jsxs("button",{className:"m-row",onClick:m,children:[s.jsx($,{status:e.status}),s.jsx("span",{className:"m-row-title",children:e.title}),o.length>0&&s.jsx("span",{className:"m-row-faces",children:o.slice(0,3).map(l=>s.jsx(M,{seed:l.id,status:l.status,title:V(l)},l.id))}),e.version?s.jsxs("span",{className:"m-row-ver",children:["v",e.version]}):null,t>0&&s.jsxs("span",{className:"m-row-kids",children:["▸",t]}),s.jsx("span",{className:"m-row-chev",children:"›"})]})}function vs({node:e,childrenOf:t,sessions:o,onOpenChild:m}){const l=_(),u=t(e.id),w=Q(e),f=[...u.length?[{key:"children",label:l("mobile.childrenTab",{n:u.length})}]:[],...w.map(i=>({key:i.key,label:l(ps[i.key])}))],[h,N]=c.useState(null),[x,y]=c.useState({issues:{},eval:{}});c.useEffect(()=>{N(null),y({issues:{},eval:{}})},[e.id]);const g=(i,S)=>y(E=>({...E,[i]:is(E[i],S)})),a=h&&f.some(i=>i.key===h)?h:f[0].key,p=Y(e.id,a==="history"),j=H(e,o);return s.jsxs("div",{className:"m-node",children:[s.jsxs("div",{className:"m-node-head",children:[s.jsx($,{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:l(`status.${e.status}`)}),j.length>0&&s.jsx("span",{className:"m-node-faces",title:l("mobile.liveEditors",{n:j.length}),children:j.map(i=>s.jsx(M,{seed:i.id,status:i.status,title:V(i)},i.id))})]}),e.desc&&s.jsx("div",{className:"m-node-desc",children:e.desc}),s.jsx("div",{className:"m-tabs",children:f.map(i=>s.jsx("button",{className:i.key===a?"m-tab on":"m-tab",onClick:()=>N(i.key),children:i.label},i.key))}),s.jsxs("div",{className:a==="history"?"m-pane-host fixed":"m-pane-host",children:[a==="children"&&s.jsx("div",{className:"m-children",children:u.map(i=>s.jsx(js,{node:i,kids:t(i.id).length,editors:H(i,o),onTap:()=>m(i.id)},i.id))}),a==="spec"&&s.jsx(Z,{node:e}),a==="history"&&s.jsx(W,{node:e,rows:p}),a==="issues"&&s.jsx(X,{node:e,sessions:o,filter:x.issues,onFilter:i=>g("issues",i)}),a==="eval"&&s.jsx(ss,{node:e,sessions:o,filter:x.eval,onFilter:i=>g("eval",i)}),a==="edit"&&s.jsx(es,{node:e})]})]})}function fs({s:e,sessions:t,onBack:o}){const m=_();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:o,"aria-label":m("mobile.back"),children:"‹"}),s.jsxs("div",{className:"m-sess-meta",children:[s.jsx("span",{className:"m-sess-name",children:z(e)}),s.jsxs("span",{className:"m-sess-status",style:{color:I[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:rs(os(e.id)),title:m("sessionEval.btnTitle"),children:m("sessionEval.btn")})]}),s.jsx(us,{s:e,sessions:t})]})}function Ns({draft:e,setDraft:t,onBack:o,onLaunched:m}){const l=_(),{launchers:u,launcher:w,pickLauncher:f}=cs(),[h,N]=c.useState(!1),[x,y]=c.useState(null),g=async()=>{const a=e.trim();if(!a||h)return;N(!0),y(null);const p=await ms(a,w);N(!1),p.ok?(t(""),m()):y(p.error||l("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:o,"aria-label":l("mobile.back"),children:"‹"}),s.jsx("div",{className:"m-sess-meta",children:s.jsx("span",{className:"m-sess-name",children:l("mobile.newSession")})})]}),s.jsxs("div",{className:"m-new-body",children:[s.jsx("textarea",{className:"m-input m-new-input",rows:5,placeholder:l("mobile.newPlaceholder"),value:e,onChange:a=>t(a.target.value)}),u.length>0&&s.jsxs("label",{className:"m-new-launcher",children:[s.jsx("span",{className:"m-new-launcher-label",children:l("session.launcherLabel")}),s.jsx("select",{className:"m-new-launcher-select",value:w,onChange:a=>f(a.target.value),children:u.map(a=>s.jsx("option",{value:a.name,children:a.name},a.name))})]}),x&&s.jsx("div",{className:"m-senderr",children:x}),s.jsx("button",{className:"m-send m-new-go",disabled:!e.trim()||h,onClick:g,children:l(h?"mobile.launching":"mobile.launch")})]})]})}function gs({specs:e,sessions:t,openId:o,setOpenId:m,creating:l,setCreating:u,newDraft:w,setNewDraft:f}){const h=_(),N=o?t.find(a=>a.id===o):null,{expanded:x,toggle:y}=as(),g=c.useMemo(()=>ns(t,a=>x.has(a)),[t,x]);return l?s.jsx(Ns,{draft:w,setDraft:f,onBack:()=>u(!1),onLaunched:()=>u(!1)}):N?s.jsx(fs,{s:N,sessions:t,onBack:()=>m(null)}):s.jsxs("div",{className:"m-sesslist",children:[s.jsxs("button",{className:"m-new-btn",onClick:()=>u(!0),children:[s.jsx("span",{className:"m-new-btn-plus",children:"+"}),h("mobile.newSession")]}),!t.length&&s.jsx("div",{className:"m-empty big",children:h("mobile.noSessions")}),g.map(a=>{if(a.type==="zone")return s.jsx("div",{className:"m-zone",children:h(`sessionZone.${a.zone}`)},`z-${a.zone}`);const p=a.s,j=a.expandable||a.depth?s.jsx(ts,{guides:a.guides,expandable:a.expandable,expanded:a.expanded,rollup:a.rollup,kin:a.kin,onToggle:()=>y(p.id)}):null;return s.jsx("button",{className:"m-sess-row",onClick:()=>m(p.id),children:s.jsx(ls,{s:p,locked:!1,showAvatar:!1,lead:j})},p.id)})]})}function ks({specs:e,sessions:t,reloadBoard:o}){const m=_(),l=c.useMemo(()=>Object.fromEntries(e.map(r=>[r.id,r])),[e]),u=c.useMemo(()=>e.find(r=>!r.parent)||e[0],[e]),w=c.useMemo(()=>{const r={};return e.forEach(v=>{var D;v.parent&&(r[D=v.parent]??(r[D]=[])).push(v)}),v=>r[v]||[]},[e]),[f,h]=c.useState("specs"),[N,x]=c.useState(()=>u?[u.id]:[]),[y,g]=c.useState(null),[a,p]=c.useState(!1),[j,i]=c.useState(""),{page:S,param:E}=K(),b=S==="evals"||S==="issues"||S==="settings"?S:f;c.useEffect(()=>{S==="sessions"&&E&&(h("sessions"),g(E))},[S,E]);const T=r=>{if(r==="evals"||r==="issues"){C(r);return}h(r),(S==="evals"||S==="issues"||S==="settings")&&C(r==="specs"?"graph":"sessions")},P=r=>{h("sessions"),g(r),C("sessions",r)},n=N.filter(r=>l[r]),d=n[n.length-1]||(u==null?void 0:u.id),k=d?l[d]:null,B=r=>x(v=>[...v.filter(D=>l[D]),r]);return s.jsxs("div",{className:"m-app",children:[s.jsx("main",{className:"m-main",children:b==="evals"||b==="issues"||b==="settings"?s.jsx("div",{className:"m-review",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"m-empty",children:m("common.loading")}),children:b==="settings"?s.jsx(bs,{}):b==="evals"?s.jsx(hs,{specs:e,sessions:t,reloadBoard:o,onOpenSession:P,onFocusNode:r=>{h("specs"),x([u.id,r].filter(v=>l[v])),C("graph")}}):s.jsx(xs,{specs:e,sessions:t,onOpenSession:P,onFocusNode:r=>{h("specs"),x([u.id,r].filter(v=>l[v])),C("graph")}})})}):b==="specs"?s.jsxs("div",{className:"m-specs",children:[s.jsx("nav",{className:"m-crumbs",children:n.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===n.length-1?"m-crumb-btn cur":"m-crumb-btn",onClick:()=>x(n.slice(0,v+1)),children:l[r].title})]},r))}),k&&s.jsx(vs,{node:k,childrenOf:w,sessions:t,onOpenChild:B},k.id)]}):s.jsx(gs,{specs:e,sessions:t,openId:y,setOpenId:g,creating:a,setCreating:p,newDraft:j,setNewDraft:i})}),s.jsxs("nav",{className:"m-tabbar",children:[s.jsxs("button",{className:b==="specs"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("specs"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"❯_"}),m("mobile.specsTab")]}),s.jsxs("button",{className:b==="sessions"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("sessions"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◐"}),m("mobile.sessionsTab"),t.length>0&&s.jsx("span",{className:"m-tabbar-badge",children:t.length})]}),s.jsxs("button",{className:b==="evals"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("evals"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"✓"}),m("mobile.evalsTab")]}),s.jsxs("button",{className:b==="issues"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("issues"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◎"}),m("mobile.issuesTab")]})]})]})}export{ks as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,i as o}from"./index-DmWbmvCq.js";function r({title:a,closeLabel:d,onClose:l,className:s,children:n}){return e.jsx("div",{className:"legend-backdrop","data-focus-overlay":!0,onClick:l,children:e.jsxs("div",{className:s?`legend ${s}`:"legend",role:"dialog","aria-modal":"true","aria-label":a,onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"legend-head",children:[e.jsx("span",{className:"legend-title",children:a}),e.jsx(o,{icon:"x",size:13,className:"legend-close",label:d,onClick:l})]}),e.jsx("div",{className:"legend-body",children:n})]})})}export{r as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as T,r,q as O,t as $,C as J,j as e,v as M,I as L,b as A,w as _,x as q,P as K,i as F,p as U,y as B,z as V,A as Q,B as W,D as X,E as Y,F as Z,G as ee,H as se,J as te,K as ae,L as oe}from"./index-DmWbmvCq.js";import{M as re}from"./Modal-DHMzSFJ4.js";import{P as ne}from"./PageScroll-C15adEYI.js";const R=["claude","codex","opencode","pi"];function D({onSet:t,onClear:l,placeholder:s,busy:o,t:n}){const[a,b]=r.useState("");return e.jsxs("form",{className:"proj-drawer proj-pw",onSubmit:d=>{d.preventDefault(),a&&(t(a),b(""))},children:[e.jsx("input",{className:"proj-add-path",type:"password",value:a,onChange:d=>b(d.target.value),placeholder:s,"aria-label":s}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!a||o,children:n("projects.passwordSet")}),e.jsx("button",{className:"proj-act",type:"button",disabled:o,onClick:l,children:n("projects.passwordClear")})]})}function ce({onAdded:t,onClose:l,t:s}){const[o,n]=r.useState(""),[a,b]=r.useState(null),[d,p]=r.useState(!0),[i,y]=r.useState(!1),[g,m]=r.useState(null),[S,f]=r.useState(""),[C,v]=r.useState(!1),[P,h]=r.useState(!1),[c,N]=r.useState([]),x=r.useCallback(async j=>{if(i)return;p(!0),m(null),f("");const k=await V(j);if(p(!1),!k.ok){m(k.error==="network"?s("projects.actionFailed"):k.error);return}b(k),n(k.path),v(!1),h(!1),N([])},[i,s]);r.useEffect(()=>{x("")},[]),r.useEffect(()=>{const j=k=>{k.key==="Escape"&&!i&&l()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[i,l]);const I=!!a&&o===a.path,z=I&&!a.gitRoot,G=I&&!a.initialized,u=I&&!d&&!i&&!a.cataloged&&(!z||C)&&(!P||!!c.length),w=j=>N(k=>k.includes(j)?k.filter(H=>H!==j):[...k,j]),E=async j=>{if(j.preventDefault(),!u)return;y(!0),m(null),f("");const k=await Z(a.path,{...z?{initGit:C}:{},...G&&P?{init:{harness:c.join(",")}}:{}});if(y(!1),k.ok){t(k.project);return}m(k.error==="network"?s("projects.actionFailed"):k.error),f(k.output||"")};return e.jsx(re,{title:s("projects.addTitle"),closeLabel:s("common.close"),onClose:()=>{i||l()},className:"proj-add-modal",children:e.jsxs("form",{className:"proj-add-flow",onSubmit:E,children:[e.jsxs("div",{className:"proj-add-pathbar",children:[e.jsx(F,{icon:"arrow-left",size:14,className:"proj-act icon",label:s("projects.browseParent"),disabled:!(a!=null&&a.parent)||d||i,onClick:()=>x(a.parent)}),e.jsx("button",{type:"button",className:"proj-act icon proj-home-btn","data-tip":s("projects.browseHome"),"aria-label":s("projects.browseHome"),disabled:!(a!=null&&a.home)||d||i,onClick:()=>x(a.home),children:"~"}),e.jsx("input",{className:"proj-add-path",value:o,autoFocus:!0,spellCheck:!1,onChange:j=>{n(j.target.value),m(null)},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),o.trim()&&x(o.trim()))},placeholder:s("projects.addPlaceholder"),"aria-label":s("projects.addPlaceholder"),disabled:i}),e.jsx("button",{className:"proj-act",type:"button",disabled:!o.trim()||d||i,onClick:()=>x(o.trim()),children:s(d?"projects.browseLoading":"projects.browseGo")})]}),e.jsxs("div",{className:"proj-folder-list","aria-label":s("projects.folderList"),"aria-busy":d,children:[!d&&(a==null?void 0:a.entries.map(j=>e.jsxs("button",{type:"button",className:"proj-folder-row",onClick:()=>x(j.path),disabled:i,children:[e.jsx(L,{name:"chevron-right",size:13}),e.jsx("span",{className:"proj-folder-name",children:j.name}),j.git&&e.jsx("span",{className:"proj-folder-tag",children:"Git"}),j.initialized&&e.jsx("span",{className:"proj-folder-tag spex",children:"SpexCode"})]},j.path))),!d&&a&&!a.entries.length&&e.jsx("div",{className:"proj-folder-empty",children:s("projects.folderEmpty")}),d&&e.jsx("div",{className:"proj-folder-empty",children:s("projects.browseLoading")})]}),I&&e.jsxs("div",{className:"proj-add-options",children:[e.jsx("div",{className:"proj-add-selected",title:a.path,children:a.path}),a.gitRoot?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," Git ",e.jsx("code",{children:a.gitRoot})]}):e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:j=>v(j.target.checked),disabled:i}),e.jsx("span",{children:s("projects.initGit")})]}),a.initialized?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(L,{name:"check",size:13})," ",s("projects.spexInitialized")]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:P,onChange:j=>{h(j.target.checked),f(""),m(null)},disabled:i}),e.jsx("span",{children:s("projects.initSpex")})]}),P&&e.jsxs("fieldset",{className:"proj-add-harnesses",disabled:i,children:[e.jsx("legend",{children:s("projects.harnessTargets")}),R.map(j=>e.jsxs("label",{className:"proj-add-harness",children:[e.jsx("input",{type:"checkbox",checked:c.includes(j),onChange:()=>w(j)}),e.jsx("span",{children:j})]},j))]})]}),a.cataloged&&e.jsx("div",{className:"proj-op-status ok",children:s("projects.alreadyAdded")})]}),(g||S)&&e.jsxs("div",{className:"proj-add-result",children:[g&&e.jsx("div",{className:"proj-err",children:g}),S&&e.jsx("pre",{className:"proj-log",children:S})]}),e.jsxs("div",{className:"proj-add-actions",children:[e.jsx("button",{className:"proj-act",type:"button",disabled:i,onClick:l,children:s("common.cancel")}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!u,children:s(i?"projects.addBusy":"projects.addSubmit")})]})]})})}function ie({p:t,onRefresh:l,t:s}){const[o,n]=r.useState(null),[a,b]=r.useState(""),[d,p]=r.useState(!1),[i,y]=r.useState(null),[g,m]=r.useState(!1),[S,f]=r.useState(0),[C,v]=r.useState(t.identity.icon),[P,h]=r.useState(!1),[c,N]=r.useState(null);r.useEffect(()=>{let u=!0;return n(null),y(null),m(!1),Q(t.id).then(w=>{if(u){if(!w.ok){y(w.error==="network"?s("projects.actionFailed"):w.error);return}n({content:w.content,revision:w.revision}),b(w.content),v(t.identity.icon)}}),()=>{u=!1}},[t.id,t.identity.icon,S,s]);let x=!1;try{const u=JSON.parse(a);x=!u||typeof u!="object"||Array.isArray(u)}catch{x=!0}const I=!!o&&a!==o.content,z=async()=>{var w,E;if(!o||x||!I||d)return;p(!0),y(null),m(!1);const u=await ee(t.id,a,o.revision);if(p(!1),!u.ok){y(u.error==="network"?s("projects.actionFailed"):u.error);return}n({content:u.content,revision:u.revision}),b(u.content),m(!0);try{v(((E=(w=JSON.parse(u.content))==null?void 0:w.dashboard)==null?void 0:E.icon)||t.identity.icon)}catch{}l()},G=async u=>{if(!o||P)return!1;const w=C;v(u),h(!0),N(null),m(!1);const E=await se(t.id,u,o.revision);return h(!1),E.ok?(n({content:E.content,revision:E.revision}),b(E.content),v(E.identity.icon),m(!0),l(),!0):(v(w),N(E.error==="network"?s("projects.actionFailed"):E.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"}),g&&e.jsx("span",{className:"proj-op-status ok",children:s("projects.configSaved")})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:x?"proj-config-editor invalid":"proj-config-editor",value:a,onChange:u=>{b(u.target.value),m(!1),y(null)},"aria-label":s("projects.configEditor"),spellCheck:!1,disabled:d}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!I||x||d,onClick:z,children:s(d?"projects.configSaving":"projects.configSave")}),e.jsx("button",{className:"proj-act",type:"button",disabled:d,onClick:()=>f(u=>u+1),children:s("projects.configReload")}),x&&e.jsx("span",{className:"proj-err",children:s("projects.configInvalid")}),i&&e.jsx("span",{className:"proj-err",children:i})]}),e.jsx(B,{value:C,onChange:G,label:s("projects.projectIcon"),editLabel:s("projects.editProjectIcon"),name:`project-icon-${t.id}`,disabled:d||P}),c&&e.jsx("span",{className:"proj-err",children:c})]}):e.jsxs("div",{className:"proj-setup-row",children:[!i&&e.jsx("span",{className:"proj-dim",children:s("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:()=>f(u=>u+1),children:s("projects.configReload")})]})]})]})}function le({p:t,busyOp:l,run:s,result:o,t:n}){const[a,b]=r.useState([]),d=p=>b(i=>i.includes(p)?i.filter(y=>y!==p):[...i,p]);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:n("projects.harnessLabel")}),R.map(p=>e.jsx("button",{type:"button",className:a.includes(p)?"proj-act on":"proj-act","aria-pressed":a.includes(p),disabled:!!l,onClick:()=>d(p),children:p},p))]}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!l||!a.length,title:a.length?void 0:n("projects.harnessRequired"),onClick:()=>s("init",()=>W(t.id,a.join(","))),children:n(l==="init"?"projects.running":"projects.init")}),e.jsx("button",{className:"proj-act",type:"button",disabled:!!l,onClick:()=>s("doctor",()=>X(t.id)),children:n(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?n("projects.opOk",{op:n(`projects.${o.op}`)}):n("projects.opFail",{op:n(`projects.${o.op}`),code:o.code??"?"})}),o.output?e.jsx("pre",{className:"proj-log",children:o.output}):null]})]})}function de({p:t,health:l,onRefresh:s,t:o}){const[n,a]=r.useState(null),[b,d]=r.useState(!1),[p,i]=r.useState(null),[y,g]=r.useState(null),[m,S]=r.useState(null),f=t.id===K,C=t.online===!1,v=C?"stopped":l||"probing",P=async c=>{d(!0),g(null);const N=await c();d(!1),N.ok?a(null):g(N.error||o("projects.actionFailed")),s()},h=async(c,N)=>{i(c),g(null),S(null);const x=await N();i(null),c!=="serve"?S({op:c,ok:x.ok,code:x.code,output:x.output||(x.ok?"":x.error||"")}):x.ok||g(x.error||o("projects.actionFailed")),s()};return e.jsxs("li",{className:f?"proj-row current":"proj-row",children:[e.jsxs("div",{className:"proj-row-main",children:[e.jsx("span",{className:`proj-health h-${v}`,"data-tip":o(`projects.health.${v}`)}),e.jsx(A,{icon:t.identity.icon,size:26}),e.jsx("span",{className:"proj-name",children:t.identity.title}),t.gated&&e.jsx(L,{name:"lock",size:12,className:"proj-locked"}),f&&e.jsx("span",{className:"proj-tag",children:o("projects.current")}),e.jsx("span",{className:"proj-path",title:t.id,children:t.root||t.id}),e.jsxs("span",{className:"proj-actions",children:[e.jsx(F,{icon:"settings",label:o("projects.configTitle"),className:n==="config"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{a(c=>c==="config"?null:"config"),g(null)}}),e.jsx(F,{icon:"terminal",label:o("projects.setupTitle"),className:n==="setup"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{a(c=>c==="setup"?null:"setup"),g(null)}}),e.jsx(F,{icon:"lock",label:o("projects.passwordTitle"),className:n==="pw"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{a(c=>c==="pw"?null:"pw"),g(null)}}),C?e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!p,onClick:()=>h("serve",()=>te(t.id)),children:o(p==="serve"?"projects.startBusy":"projects.start")}):e.jsx("a",{className:"proj-act primary",href:U(t.id),children:o("projects.open")})]})]}),y&&e.jsx("div",{className:"proj-err",children:y}),n==="pw"&&e.jsx(D,{t:o,busy:b,placeholder:o("projects.passwordPlaceholder"),onSet:c=>P(()=>oe(t.id,c)),onClear:()=>P(()=>ae(t.id))}),n==="config"&&e.jsx(ie,{p:t,onRefresh:s,t:o}),n==="setup"&&e.jsx(le,{p:t,busyOp:p,run:h,result:m,t:o})]})}function je({gateway:t,onRefresh:l,t:s}){const[o,n]=r.useState(t.identity.icon),[a,b]=r.useState(!1),[d,p]=r.useState(null);r.useEffect(()=>{n(t.identity.icon)},[t.identity.icon]);const i=async y=>{if(a||!t.revision)return!1;const g=o;n(y),b(!0),p(null);const m=await Y(y,t.revision);return b(!1),m.ok?(n(m.gateway.identity.icon),l(),!0):(n(g),p(m.error==="network"?s("projects.actionFailed"):m.error),!1)};return e.jsxs("div",{className:"proj-gateway-identity",children:[e.jsx(B,{value:o,onChange:i,label:s("projects.gatewayIcon"),editLabel:s("projects.editGatewayIcon"),name:"gateway-icon",fallback:"gateway",disabled:a||!t.revision}),d&&e.jsx("span",{className:"proj-err",children:d})]})}function he(){const t=T(),[l,s]=r.useState({kind:"loading"}),[o,n]=r.useState({}),[a,b]=r.useState(null),[d,p]=r.useState(!1),[i,y]=r.useState(!1),[g,m]=r.useState(null),S=r.useRef(0),f=r.useCallback(async()=>{const h=++S.current,c=await O();h===S.current&&(c.state==="ok"?(s({kind:"ok",adminGated:c.adminGated,gateway:c.gateway,projects:c.projects}),c.projects.filter(N=>N.online!==!1).forEach(N=>{$(N.id).then(x=>{h===S.current&&n(I=>({...I,[N.id]:x}))})})):c.state==="denied"?s({kind:"denied",reason:c.reason}):s(N=>N.kind==="ok"?N:{kind:"absent"}))},[]);r.useEffect(()=>{f();const h=setInterval(f,J),c=()=>{document.hidden||f()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(h),document.removeEventListener("visibilitychange",c)}},[f]);const C=async h=>{y(!0),m(null);const c=await h();y(!1),c.ok?b(null):m(c.error||t("projects.actionFailed")),f()},v=l.kind==="loading"?e.jsx("div",{className:"loading",children:t("hud.loading")}):l.kind==="denied"?e.jsx(M,{scope:"admin",locked:l.reason==="locked",onUnlocked:f}):l.kind==="absent"?e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:t("projects.absent")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"proj-head",children:[e.jsx("span",{className:"proj-count",children:t("projects.count",{n:l.projects.length})}),e.jsxs("button",{className:d?"proj-act on":"proj-act",onClick:()=>p(!0),children:[e.jsx(L,{name:"plus",size:12})," ",t("projects.add")]}),e.jsxs("button",{className:a==="admin"?"proj-act on":"proj-act",onClick:()=>{b(h=>h==="admin"?null:"admin"),m(null)},children:[e.jsx(L,{name:"lock",size:12})," ",t("projects.adminPassword")]})]}),!l.adminGated&&e.jsx("div",{className:"proj-hint",children:t("projects.adminUngated")}),a==="admin"&&e.jsxs("div",{className:"proj-admin-pw",children:[e.jsx(D,{t,busy:i,placeholder:t("projects.adminPasswordPlaceholder"),onSet:h=>C(()=>q(h)),onClear:()=>C(()=>_())}),g&&e.jsx("div",{className:"proj-err",children:g})]}),l.projects.length?e.jsx("ul",{className:"proj-list",children:l.projects.map(h=>e.jsx(de,{p:h,health:o[h.id],onRefresh:f,t},h.id))}):e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:t("projects.empty")})}),e.jsx("div",{className:"proj-page-details","aria-label":t("projects.gatewaySettings"),children:e.jsx(je,{gateway:l.gateway,onRefresh:f,t})})]}),P=l.kind==="ok"?l.gateway.identity:{icon:"gateway"};return e.jsxs("div",{className:"page-pane page-projects",children:[e.jsx(ne,{className:"page-projects-scroll",children:e.jsxs("div",{className:"proj-body",children:[e.jsxs("div",{className:"cred-brand proj-brand",children:[e.jsx(A,{icon:P.icon,fallback:"gateway",size:30}),e.jsx("span",{children:"$ spexcode"})]}),e.jsx("h1",{className:"page-title",children:t("projects.title")}),v]})}),d&&e.jsx(ce,{t,onClose:()=>p(!1),onAdded:()=>{p(!1),f()}})]})}export{he as default};
|