claude-code-session-manager 0.113.0 → 0.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentLibrary-wvrcLGGS.js → AgentLibrary-DZFM7Lto.js} +1 -1
- package/dist/assets/{Button-B6h0F0XT.js → Button-BJVFKdGH.js} +1 -1
- package/dist/assets/{DataModel-C5pW9E3u.js → DataModel-CebvcP_y.js} +1 -1
- package/dist/assets/{History-BV4e8YOM.js → History-BwISEUhR.js} +1 -1
- package/dist/assets/{Hooks-CrFSv4x1.js → Hooks-Dac3smYP.js} +1 -1
- package/dist/assets/{Library-D-GIt3EY.js → Library-DTjsUr9W.js} +1 -1
- package/dist/assets/{ListDetail-Bco_wfs6.js → ListDetail-B1L5TbjS.js} +1 -1
- package/dist/assets/{MarkdownEditor-C-yHSXNV.js → MarkdownEditor-BFRhWZD4.js} +1 -1
- package/dist/assets/{McpServers-CfDekadG.js → McpServers-CBjGCMg0.js} +1 -1
- package/dist/assets/Memory-DdLi5fqe.js +8 -0
- package/dist/assets/{Panel-DGMEuYYG.js → Panel-BQkkkjex.js} +1 -1
- package/dist/assets/{Permissions-Cx2zjtYZ.js → Permissions-CaACwY0B.js} +1 -1
- package/dist/assets/{Plugins-Bc_W3IyR.js → Plugins-DJeBwVoh.js} +2 -2
- package/dist/assets/{ProvenanceBadge-DiKAUR1u.js → ProvenanceBadge--N5j8xiK.js} +1 -1
- package/dist/assets/{RemoteMachines-8_77-WPD.js → RemoteMachines-WjWaDHEA.js} +1 -1
- package/dist/assets/{SaveBar-Blpzdq1R.js → SaveBar-DFmOjb4_.js} +1 -1
- package/dist/assets/{Scheduler-Bd70AM4X.js → Scheduler-Miap6_aY.js} +1 -1
- package/dist/assets/{ScopeSwitcher-wxN0h4YW.js → ScopeSwitcher-CiEujp4L.js} +1 -1
- package/dist/assets/{Settings-CQ7DA3zW.js → Settings-UGpW4P0j.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-DH1NLOiS.js → SkillReferenceGraph-BgyAnxGW.js} +1 -1
- package/dist/assets/{Skills-CmyRyu4_.js → Skills-BQUpnNfx.js} +1 -1
- package/dist/assets/{SystemPrompt-KAc3UMCd.js → SystemPrompt-CQjOgHGT.js} +1 -1
- package/dist/assets/{TagLibrary-C8EvHnpg.js → TagLibrary-CTVpoLl0.js} +1 -1
- package/dist/assets/{TiptapBody-d423mH6D.js → TiptapBody-BtOcrdRR.js} +1 -1
- package/dist/assets/{Toggle-D1wsGE9S.js → Toggle-Chri4G19.js} +1 -1
- package/dist/assets/{ViewTabs-CjHw3kGY.js → ViewTabs-BIenDGVv.js} +1 -1
- package/dist/assets/{historyTotals-DFHzqLt7.js → historyTotals-CX8mUxJY.js} +1 -1
- package/dist/assets/{index-Ci1u018F.js → index-AVrhGmUO.js} +86 -86
- package/dist/assets/{index-Dutcsly-.css → index-HpEbvDiE.css} +1 -1
- package/dist/assets/{settingsSchema-Ctf3pZVI.js → settingsSchema-uqwlznbH.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-B1NBmOAe.js → useAgentsDirWatch-BaezRtWw.js} +1 -1
- package/dist/assets/{useRemotePeers-BHjSJs9D.js → useRemotePeers-BuFbBqDt.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/main/build-info.json +4 -4
- package/src/main/index.cjs +0 -2
- package/src/main/ipcSchemas.cjs +24 -34
- package/src/main/lib/memoryDirResolve.cjs +139 -0
- package/src/main/lib/memoryIndex.cjs +98 -0
- package/src/main/memoryAggregate.cjs +15 -8
- package/src/main/memoryTool.cjs +151 -22
- package/src/preload/api.d.ts +41 -52
- package/src/preload/index.cjs +19 -21
- package/dist/assets/Memory-CGGLexkR.js +0 -8
- package/src/main/agentMemory.cjs +0 -246
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{b3 as ne,aX as G,aF as a,aW as $,ap as e,n as A,Z as xe,ad as X,ah as Z}from"./index-AVrhGmUO.js";import{V as ae}from"./ViewTabs-BIenDGVv.js";import{P as ue}from"./Panel-BQkkkjex.js";import{L as fe}from"./ListDetail-B1L5TbjS.js";import{M as he}from"./MarkdownEditor-BFRhWZD4.js";import"./monaco-editor-BsIlgG7c.js";function pe(t){return!t||!t.trim()?"default":t.replace(/[^a-zA-Z0-9]/g,"-")}const oe=/^[a-z0-9-_]+$/;function ge(t,n,s,l){return t.filter(p=>!n||p.name.toLowerCase().includes(n.toLowerCase())).filter(p=>{var b;return!s||((b=l[p.name])==null?void 0:b.stale)===!0})}const be=["Commands:"," list — show all memory entries"," show <slug> — read one entry"," search <text> — find entries containing <text>"," forget <slug> — delete an entry (with confirm)"," remember <free-form> — ask Claude to save this"," help — this message","","Anything else: I will offer to send it to Claude in the terminal,","or add it as a new memory entry directly."].join(`
|
|
2
|
+
`);function ye(t){const n=t.trim();if(!n)return{kind:"freeform",arg:"",raw:t};const s=n.toLowerCase();if(s==="help"||s==="?")return{kind:"help",arg:"",raw:t};if(s==="list"||s==="ls"||s==="list memories"||s==="list all"||s==="what do you remember"||s==="what do you remember?")return{kind:"list",arg:"",raw:t};const l=n.match(/^(?:show|read|open)\s+(.+)$/i);if(l)return{kind:"show",arg:l[1].trim(),raw:t};const p=n.match(/^(?:forget|delete|remove)\s+(.+)$/i);if(p)return{kind:"forget",arg:p[1].trim(),raw:t};const b=n.match(/^(?:search|find)\s+(.+)$/i)||n.match(/^what (?:do )?you know about\s+(.+?)\??$/i);if(b)return{kind:"search",arg:b[1].trim(),raw:t};const d=n.match(/^remember(?:\s+that)?\s+(.+)$/i)||n.match(/^note(?:\s+that)?\s+(.+)$/i)||n.match(/^save(?:\s+that)?\s+(.+)$/i);return d?{kind:"remember",arg:d[1].trim(),raw:t}:{kind:"freeform",arg:n,raw:t}}function q(t,n){const s=t.toLowerCase().replace(/\.md$/,""),l=n.find(d=>d.name.replace(/\.md$/,"").toLowerCase()===s);if(l)return l;const p=n.filter(d=>d.name.replace(/\.md$/,"").toLowerCase().startsWith(s));if(p.length===1)return p[0];const b=n.filter(d=>d.name.replace(/\.md$/,"").toLowerCase().includes(s));return b.length===1?b[0]:null}function ee(t){const n=new Set(["the","a","an","is","are","to","of","in","for","and","or"]);return t.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/\s+/).filter(p=>p&&!n.has(p)).slice(0,4).join("-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`note-${Date.now().toString(36).slice(-4)}`}function te(t,n){return[`Please save this to my workspace memory (workspace: ${t}).`,`Use the memory tool (or write a markdown file under ~/.claude/projects/${t}/memory/).`,"Pick a short kebab-case filename and add a one-line title at the top.","","Memory to save:",n].join(`
|
|
3
|
+
`)}function se(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function je({workspace:t,cwd:n,entries:s,onChanged:l}){const p=ne(),b=G(),d=(b==null?void 0:b.id)??null,[v,h]=a.useState(""),[j,x]=a.useState(()=>[{id:se(),role:"system",text:"Hi — I am the memory assistant for this workspace. Type `help` for what I understand, or just talk to me."}]),[f,i]=a.useState(!1),N=a.useRef(null),w=a.useRef(null);a.useEffect(()=>{const r=N.current;r&&(r.scrollTop=r.scrollHeight)},[j]);const c=a.useCallback(r=>{x(u=>[...u,{...r,id:se()}])},[]),k=a.useCallback(()=>{if(s.length===0){c({role:"result",text:"No memories saved for this workspace yet."});return}c({role:"result",text:`Found ${s.length} ${s.length===1?"memory":"memories"}:`,payload:{kind:"entries",entries:s}})},[s,c]),B=a.useCallback(async r=>{const u=q(r,s);if(!u){c({role:"result",text:`No memory matches "${r}". Try \`list\` to see what is here.`});return}const g=await window.api.memory.read(u.name,{workspace:t,cwd:n});if(g.error){$.error(`Memory read failed: ${g.error}`),c({role:"result",text:`Read failed: ${g.error}`});return}c({role:"result",text:`${u.name}`,payload:{kind:"entry",entry:u,content:g.content}})},[s,t,n,c]),F=a.useCallback(async r=>{const u=r.toLowerCase(),g=s.filter(S=>S.name.toLowerCase().includes(u)),M=[];for(const S of s){if(g.includes(S))continue;const C=await window.api.memory.read(S.name,{workspace:t,cwd:n});if(C.error)continue;const T=C.content.split(`
|
|
4
|
+
`),I=T.findIndex(L=>L.toLowerCase().includes(u));I>=0&&M.push({entry:S,snippet:T[I].trim().slice(0,200)})}const E=[...g.map(S=>({entry:S,snippet:"(filename match)"})),...M];if(E.length===0){c({role:"result",text:`No matches for "${r}".`});return}c({role:"result",text:`Found ${E.length} ${E.length===1?"match":"matches"} for "${r}":`,payload:{kind:"search",query:r,hits:E}})},[s,t,n,c]),W=a.useCallback(async r=>{const u=q(r,s);if(!u){c({role:"result",text:`No memory matches "${r}". Try \`list\` to see what is here.`});return}if(!window.confirm(`Delete memory "${u.name}"? This cannot be undone.`))return;const g=await window.api.memory.delete(u.name,{workspace:t,cwd:n});if(!g.ok){$.error(`Memory delete failed: ${g.error??"unknown error"}`),c({role:"result",text:`Delete failed: ${g.error??"unknown error"}`});return}c({role:"result",text:`Deleted ${u.name}.`}),l()},[s,t,n,c,l]),D=a.useCallback(r=>{const u=ee(r),g=te(t,r);c({role:"result",text:"I do not write to memory from this panel. Send the request to Claude in the active terminal, or add it directly as a new memory entry below.",payload:{kind:"suggest-send",prompt:g,original:r}}),c({role:"result",text:`Add it directly as \`${u}.md\` instead?`,payload:{kind:"suggest-add",slug:u,content:r}})},[t,c]),H=a.useCallback(r=>{const u=ee(r),g=te(t,r);c({role:"result",text:"Not a recognised command. Options:",payload:{kind:"suggest-send",prompt:g,original:r}}),c({role:"result",text:`…or save it directly as \`${u}.md\`.`,payload:{kind:"suggest-add",slug:u,content:r}})},[t,c]),z=a.useCallback(async r=>{i(!0);try{switch(r.kind){case"list":k();break;case"show":await B(r.arg);break;case"search":await F(r.arg);break;case"forget":await W(r.arg);break;case"help":c({role:"result",text:be});break;case"remember":D(r.arg);break;case"freeform":H(r.arg);break}}finally{i(!1)}},[k,B,F,W,D,H,c]),K=a.useCallback(async()=>{const r=v.trim();!r||f||(h(""),c({role:"user",text:r}),await z(ye(r)))},[v,f,z,c]),R=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),K())},V=a.useCallback(r=>{if(!d){$.error("No active terminal session — open or focus a tab first.");return}window.api.pty.write({tabId:d,data:r}),$.info("Prompt sent to active terminal (not submitted)")},[d]),Y=a.useCallback(async(r,u)=>{if(!oe.test(r)){$.error(`Invalid slug "${r}" — must be [a-z0-9-_]+`);return}const g=`${r}.md`,M=await window.api.memory.create(g,void 0,{workspace:t,cwd:n});if(!M.ok){$.error(`Create failed: ${M.error??"unknown error"}`);return}const E=await window.api.memory.read(g,{workspace:t,cwd:n}),S=E.error?u:`${E.content.trimEnd()}
|
|
5
|
+
|
|
6
|
+
${u}
|
|
7
|
+
`,C=await window.api.memory.write(g,S,{workspace:t,cwd:n});if(!C.ok){$.error(`Write failed: ${C.error??"unknown error"}`);return}c({role:"result",text:`Saved as ${g}.`}),l()},[t,n,c,l]),O=a.useMemo(()=>[{label:"List memories",value:"list"},{label:"Help",value:"help"},{label:"Search…",value:"search "},{label:"Remember…",value:"remember "}],[]);return p?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:N,className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-2",children:[j.map(r=>e.jsx(ve,{message:r,entries:s,onShow:u=>{var g;h(`show ${u.replace(/\.md$/,"")}`),(g=w.current)==null||g.focus()},onSendToClaude:V,onAddDirect:Y},r.id)),f&&e.jsx("div",{className:"text-xs text-fg-faint italic",children:"working…"})]}),e.jsxs("div",{className:"shrink-0 border-t border-line px-3 py-2 space-y-2",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:O.map(r=>e.jsx("button",{onClick:()=>{var u;h(r.value),(u=w.current)==null||u.focus()},className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:r.label},r.label))}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx(xe,{}),e.jsx("textarea",{ref:w,value:v,onChange:r=>h(r.target.value),onKeyDown:R,placeholder:"Type `list`, `show <slug>`, `search <text>`, `remember …`, or talk freely. Enter to send, Shift+Enter for newline.",rows:2,className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-xs text-fg resize-none focus:outline-none focus:border-fg-faint"}),e.jsx("button",{onClick:K,disabled:!v.trim()||f,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Send"})]}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Workspace: ",e.jsx("span",{className:"font-mono",children:t}),!d&&e.jsx("span",{className:"ml-2 text-amber-400",children:"(no active terminal — Send-to-Claude disabled)"})]})]})]}):e.jsx(A,{title:"loading…"})}function ve({message:t,entries:n,onShow:s,onSendToClaude:l,onAddDirect:p}){var d,v,h,j,x;const b=t.role==="user"?"bg-bg-hi text-fg ml-8":t.role==="system"?"bg-bg text-fg-dim italic":"bg-bg text-fg-dim";return e.jsxs("div",{className:`text-xs rounded border border-line px-3 py-2 ${b}`,children:[e.jsx("div",{className:"whitespace-pre-wrap font-mono text-[11px] leading-relaxed",children:t.text}),((d=t.payload)==null?void 0:d.kind)==="entries"&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.payload.entries.map(f=>e.jsxs("button",{onClick:()=>s(f.name),className:"block w-full text-left px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg hover:bg-bg-hi rounded font-mono",children:[f.name," ",e.jsxs("span",{className:"text-fg-faint",children:["(",X(f.bytes),")"]})]},f.name))}),((v=t.payload)==null?void 0:v.kind)==="entry"&&e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto px-2 py-1 bg-bg-hi rounded text-[11px] whitespace-pre-wrap text-fg",children:t.payload.content}),((h=t.payload)==null?void 0:h.kind)==="search"&&e.jsx("div",{className:"mt-2 space-y-1",children:t.payload.hits.map((f,i)=>e.jsxs("button",{onClick:()=>s(f.entry.name),className:"block w-full text-left px-2 py-1 hover:bg-bg-hi rounded",children:[e.jsx("div",{className:"font-mono text-[11px] text-fg-dim",children:f.entry.name}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",children:f.snippet})]},`${f.entry.name}-${i}`))}),((j=t.payload)==null?void 0:j.kind)==="suggest-send"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>l(t.payload.kind==="suggest-send"?t.payload.prompt:""),className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Send to Claude in terminal"}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"paste-only — you press Enter"})]}),((x=t.payload)==null?void 0:x.kind)==="suggest-add"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>{var f;return((f=t.payload)==null?void 0:f.kind)==="suggest-add"&&p(t.payload.slug,t.payload.content)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Add as new memory"}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:[t.payload.slug,".md"]})]})]})}function we({workspace:t,cwd:n,onOpenMember:s}){const[l,p]=a.useState(null),[b,d]=a.useState(!1),[v,h]=a.useState(!1),j=a.useRef(0),x=a.useCallback(async w=>{const c=++j.current;d(!0);try{const k=await window.api.memory.aggregate(t,w,n??void 0);if(j.current!==c)return;p(k)}catch(k){if(j.current!==c)return;$.error(`Memory aggregate failed: ${k instanceof Error?k.message:String(k)}`)}finally{j.current===c&&(d(!1),h(!0))}},[t,n]);a.useEffect(()=>{p(null),h(!1),x(!1)},[x]);const f=(l==null?void 0:l.clusters)??[],i=(l==null?void 0:l.orphans)??[],N=f.length>0||i.length>0;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-2 border-b border-line text-xs",children:[e.jsx("span",{className:"text-fg-faint",children:l!=null&&l.generatedAt?`generated ${Z(l.generatedAt)} ago`:"not yet aggregated"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>x(!0),disabled:b,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:b?"Aggregating…":l!=null&&l.generatedAt?"Refresh":"Aggregate"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:v?N?e.jsxs("div",{className:"space-y-4",children:[f.length>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:f.map(w=>e.jsx(Ne,{cluster:w,onOpenMember:s},w.id))}),i.length>0&&e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-xs text-fg mb-2",children:"Unclustered"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.map(w=>e.jsx("button",{onClick:()=>s(w),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:w},w))})]})]}):e.jsx(A,{title:"no clusters yet",hint:"Click Aggregate to organize this workspace's memories into named clusters."}):e.jsx(A,{title:"loading…"})})]})}function Ne({cluster:t,onOpenMember:n}){return e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-sm text-fg",children:t.name}),t.summary&&e.jsx("div",{className:"text-xs text-fg-faint mt-0.5",children:t.summary}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.memberSlugs.map(s=>e.jsx("button",{onClick:()=>n(s),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:s},s))}),t.links.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.links.map((s,l)=>e.jsxs("div",{className:"text-[10px] text-fg-faint font-mono",children:[s.from," → ",s.to,s.label?` (${s.label})`:""]},`${s.from}-${s.to}-${l}`))})]})}function ke({index:t,autoMemoryEnabled:n}){const s=t!=null&&t.overBudget?"text-red-400 border-red-400/40 bg-red-400/10":t!=null&&t.nearBudget?"text-amber-400 border-amber-400/40 bg-amber-400/10":"text-fg-faint border-line";return e.jsxs(e.Fragment,{children:[!n&&e.jsx("div",{"data-testid":"memory-auto-off-banner",className:"shrink-0 px-3 py-1.5 text-xs text-amber-400 border-b border-amber-400/40 bg-amber-400/10",children:"Auto memory is off — Claude Code will not read or write these memories"}),t&&e.jsxs("div",{"data-testid":"memory-index-strip",className:`shrink-0 flex items-center gap-3 px-3 py-1 text-[11px] border-b ${s}`,children:[e.jsxs("span",{children:["MEMORY.md ",t.lines,"/",t.maxLines," lines · ",(t.bytes/1024).toFixed(1),"/",Math.round(t.maxBytes/1024)," KB"]}),t.orphans.length>0&&e.jsxs("span",{children:[t.orphans.length," not in index"]}),t.dangling.length>0&&e.jsxs("span",{children:[t.dangling.length," dangling index lines"]})]})]})}function le({target:t,cwd:n,toolbarExtra:s,enableNatural:l=!1,enableClusters:p=!1}){const b=JSON.stringify(t),d=a.useMemo(()=>t,[b]),v=d.workspace??"",[h,j]=a.useState("classic"),[x,f]=a.useState([]),[i,N]=a.useState(null),[w,c]=a.useState(""),[k,B]=a.useState({}),[F,W]=a.useState(!1),[D,H]=a.useState(""),[z,K]=a.useState(!0),[R,V]=a.useState(void 0),[Y,O]=a.useState({}),[r,u]=a.useState({}),[g,M]=a.useState(!1),[E,S]=a.useState(!1),C=a.useCallback(async()=>{const o=await window.api.memory.list(d);f(o.entries),H(o.dir??""),K(o.autoMemoryEnabled!==!1),o.error&&$.error(`Memory list failed: ${o.error}`),N(m=>{var y;return m&&o.entries.some(me=>me.name===m)?m:((y=o.entries[0])==null?void 0:y.name)??null});try{const m=await window.api.memory.stale(d);B(Object.fromEntries(m.entries.map(y=>[y.name,y]))),V(m.index)}catch(m){B({}),V(void 0),$.error(`Memory staleness check failed: ${m instanceof Error?m.message:String(m)}`)}},[d]);a.useEffect(()=>{O({}),u({}),N(null),S(!1),C()},[C]),a.useEffect(()=>{if(!D)return;const o=D;window.api.config.watch([o]);const m=window.api.config.onChanged(({path:y})=>{(y===o||y.startsWith(o+"/"))&&C()});return()=>{m(),window.api.config.unwatch([o])}},[D,C]),a.useEffect(()=>{if(!i||Y[i]!==void 0)return;let o=!1;return(async()=>{const m=await window.api.memory.read(i,d);if(!o){if(m.error){$.error(`Memory read failed: ${m.error}`);return}O(y=>({...y,[i]:m.content})),u(y=>({...y,[i]:m.content}))}})(),()=>{o=!0}},[i,d]);const T=x.reduce((o,m)=>{var y;return o+((y=k[m.name])!=null&&y.stale?1:0)},0),I=ge(x,w,F,k),L=x.find(o=>o.name===i)??null,P=i?k[i]:void 0,U=i?Y[i]??"":"",ie=i?r[i]??"":"",J=i?U!==ie:!1,Q=[{key:"classic",label:"Editor"},...l?[{key:"natural",label:"Natural"}]:[],...p?[{key:"clusters",label:"Clusters"}]:[]],ce=async()=>{if(!i)return;M(!0);const o=await window.api.memory.write(i,U,d);if(M(!1),!o.ok){$.error(`Memory save failed: ${o.error??"unknown error"}`);return}u(m=>({...m,[i]:U})),C()},de=async()=>{if(!i||!window.confirm(`Delete memory "${i}"? This cannot be undone.`))return;M(!0);const o=await window.api.memory.delete(i,d);if(M(!1),!o.ok){$.error(`Memory delete failed: ${o.error??"unknown error"}`);return}O(m=>{const y={...m};return delete y[i],y}),u(m=>{const y={...m};return delete y[i],y}),N(null),C()};return e.jsxs(ue,{toolbar:e.jsxs(e.Fragment,{children:[Q.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(ae,{options:Q,active:h,onChange:j}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"})]}),s,s&&e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[x.length," ",x.length===1?"entry":"entries"]}),e.jsx("div",{className:"flex-1"}),h==="classic"&&T>0&&e.jsxs("button",{onClick:()=>W(o=>!o),className:`px-2 py-0.5 text-xs border rounded transition-colors ${F?"text-amber-400 border-amber-400/50 bg-amber-400/10":"text-fg-dim hover:text-fg border-line hover:border-fg-faint"}`,children:["Stale only (",T,")"]}),h==="classic"&&e.jsx("button",{onClick:()=>S(!0),className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"+ New memory"}),h!=="clusters"&&e.jsx("button",{onClick:C,className:"ml-2 px-2 py-0.5 text-xs text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:"Refresh"})]}),footer:h==="classic"&&L?e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsx("button",{onClick:ce,disabled:!J||g,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:g?"Saving…":"Save"}),e.jsx("button",{onClick:de,disabled:g,className:"px-2 py-0.5 text-xs text-red-400 hover:text-red-300 border border-line hover:border-red-400/50 rounded transition-colors disabled:opacity-40",children:"Delete"}),(P==null?void 0:P.stale)&&e.jsxs("span",{className:"text-amber-400/90 truncate",title:P.reasons.join("; "),children:["stale · ",P.reasons.join(", ")]}),e.jsx("span",{className:"text-fg-faint truncate flex-1",children:L.path}),J&&e.jsx("span",{className:"text-accent",children:"unsaved"})]}):null,children:[h==="classic"&&e.jsx(ke,{index:R,autoMemoryEnabled:z}),h==="natural"&&l?e.jsx(je,{workspace:v,cwd:n??void 0,entries:x,onChanged:C}):h==="clusters"&&p?e.jsx(we,{workspace:v,cwd:n,onOpenMember:o=>{N(`${o}.md`),j("classic")}}):e.jsx(fe,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:w,onChange:o=>c(o.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),I.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:x.length===0?"no memories yet":"no matches"}):I.map(o=>{const m=k[o.name],y=m!=null&&m.stale?`${o.path}
|
|
8
|
+
stale: ${m.reasons.join(", ")}`:o.path;return e.jsxs("button",{onClick:()=>N(o.name),className:`w-full text-left px-3 py-1 text-xs flex items-center justify-between ${i===o.name?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,title:y,children:[e.jsxs("span",{className:"truncate flex items-center",children:[e.jsx("span",{className:"truncate",children:o.name.replace(/\.md$/,"")}),(m==null?void 0:m.stale)&&e.jsx("span",{className:"ml-1.5 shrink-0 px-1 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30",children:"stale"}),(R==null?void 0:R.orphans.includes(o.name))&&e.jsx("span",{className:"ml-1.5 shrink-0 px-1 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30",title:"Not listed in MEMORY.md — Claude won't see it",children:"not in index"})]}),e.jsxs("span",{className:"ml-2 text-fg-faint shrink-0 text-[10px]",children:[X(o.bytes)," · ",Z(o.mtimeMs)]})]},o.name)})]}),detail:E?e.jsx(Ce,{target:d,dir:D,onCancel:()=>S(!1),onCreated:o=>{S(!1),N(o),C()}}):L&&i?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-3 py-2 border-b border-line text-xs",children:[e.jsx("div",{className:"text-fg truncate",children:L.name}),e.jsxs("div",{className:"text-fg-faint truncate",children:[X(L.bytes)," · modified ",Z(L.mtimeMs)]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(he,{path:L.path,value:U,onChange:o=>O(m=>({...m,[i]:o}))})})]}):e.jsx(A,{title:x.length===0?"no memories yet":"select a memory",hint:x.length===0?"Claude writes to memories during sessions when you ask it to remember things, or you can create one manually with the + New memory button.":void 0})})]})}function Ce({target:t,dir:n,onCancel:s,onCreated:l}){const[p,b]=a.useState(""),[d,v]=a.useState(""),[h,j]=a.useState(!1),[x,f]=a.useState(null),i=p.trim().toLowerCase(),N=oe.test(i),w=async()=>{if(!N){f("Slug must match [a-z0-9-_]+");return}j(!0),f(null);const c=`${i}.md`,k=await window.api.memory.create(c,d.trim()||void 0,t);if(j(!1),!k.ok){f(k.error??"create failed");return}l(c)};return e.jsxs("div",{className:"p-4 max-w-xl space-y-3",children:[e.jsx("div",{className:"text-sm text-fg",children:"New memory"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:p,onChange:c=>b(c.target.value),placeholder:"my-notes",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("span",{className:"text-xs text-fg-faint",children:".md"})]}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Lowercase letters, digits, dashes, underscores. The file is created at",e.jsxs("code",{className:"ml-1 font-mono text-fg-dim",children:[n||"…","/",i||"…",".md"]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Description (optional)"}),e.jsx("input",{value:d,onChange:c=>v(c.target.value),placeholder:"one-line summary",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})]}),x&&e.jsx("div",{className:"text-xs text-red-400",children:x}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:w,disabled:!N||h,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40",children:h?"Creating…":"Create"}),e.jsx("button",{onClick:s,disabled:h,className:"px-3 py-1 text-xs text-fg-faint hover:text-fg-dim rounded transition-colors",children:"Cancel"})]})]})}const Se={user:"user — all projects",project:"project — shared via git",local:"local — this machine, not committed"},_=t=>`${t.origin}:${t.name}`;function $e(){const t=G(),n=(t==null?void 0:t.cwd)??null,[s,l]=a.useState([]),[p,b]=a.useState(!1),[d,v]=a.useState(null);a.useEffect(()=>{let x=!1;return window.api.memory.agents(n??void 0).then(f=>{x||(l(f.agents),b(!0),v(i=>i&&f.agents.some(N=>_(N)===i)?i:f.agents[0]?_(f.agents[0]):null))}).catch(()=>{x||(l([]),b(!0))}),()=>{x=!0}},[n]);const h=s.find(x=>_(x)===d)??null,j=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-faint",children:"Agent"}),e.jsxs("select",{value:d??"",onChange:x=>v(x.target.value||null),className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg max-w-[16rem]",children:[s.length===0&&e.jsx("option",{value:"",children:"(no agents found)"}),s.map(x=>e.jsxs("option",{value:_(x),children:[x.name," · ",x.origin]},_(x)))]})]});return p?h?h.memoryScope?e.jsx(le,{target:{cwd:n??void 0,agent:{name:h.name,scope:h.memoryScope}},cwd:n,toolbarExtra:e.jsxs(e.Fragment,{children:[j,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-faint",children:Se[h.memoryScope]})]})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-line flex items-center gap-2 text-xs",children:j}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(A,{title:`${h.name} has no persistent memory`,hint:"Add `memory: project` (or `user` / `local`) to its frontmatter in the Agent Library to enable it."})})]}):e.jsx(A,{title:"no agents found",hint:"Create an agent in the Agent Library; add `memory: project` to its frontmatter to give it persistent memory."}):e.jsx(A,{title:"loading…"})}const Me=[{key:"workspace",label:"Workspace"},{key:"subagent",label:"Subagent"}],re="sm.memoryTab.scope";function Ee(){const[t,n]=a.useState(()=>localStorage.getItem(re)==="subagent"?"subagent":"workspace");return a.useEffect(()=>{localStorage.setItem(re,t)},[t]),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[e.jsx(ae,{options:Me,active:t,onChange:n}),e.jsx("span",{className:"text-[11px] text-fg-faint",children:t==="workspace"?"memories scoped to the active project":"long-term memory per subagent"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="workspace"?e.jsx(Le,{}):e.jsx($e,{})})]})}const Te=a.memo(Ee);function Le(){const t=ne(),n=G(),s=(n==null?void 0:n.cwd)??null,l=a.useMemo(()=>pe(s),[s]),p=a.useMemo(()=>({workspace:l,cwd:s??void 0}),[l,s]);return t?e.jsx(le,{target:p,cwd:s,enableNatural:!0,enableClusters:!0,toolbarExtra:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-faint",children:"Workspace"}),e.jsx("span",{className:"font-mono text-fg-dim truncate max-w-[24rem]",title:l,children:l})]})}):e.jsx(A,{title:"loading…"})}export{Te as Memory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ap as e}from"./index-
|
|
1
|
+
import{ap as e}from"./index-AVrhGmUO.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{aF as u,b3 as H,aX as X,b5 as Z,aZ as w,ar as q,aw as Q,al as U,ap as e,n as E,P as J,aW as O,aN as Y}from"./index-
|
|
1
|
+
import{aF as u,b3 as H,aX as X,b5 as Z,aZ as w,ar as q,aw as Q,al as U,ap as e,n as E,P as J,aW as O,aN as Y}from"./index-AVrhGmUO.js";import{P as I}from"./Panel-BQkkkjex.js";import{S as ee}from"./ScopeSwitcher-CiEujp4L.js";import{S as te}from"./SaveBar-DFmOjb4_.js";import{P as se}from"./Library-DTjsUr9W.js";import{u as re,E as ne,s as oe}from"./settingsSchema-uqwlznbH.js";import{V as ae}from"./ViewTabs-BIenDGVv.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BJVFKdGH.js";import"./listSkills-C1aWKf0T.js";import"./claude-settings-schema-COigsajx.js";const ie=["allow","deny","ask"],k="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function F(n){if(n.trim()==="")return{perms:{},full:{},err:null};try{const r=JSON.parse(n);if(r===null||typeof r!="object"||Array.isArray(r))return{perms:{},full:{},err:"settings file is not a JSON object"};const o=r;return{perms:o.permissions??{},full:o,err:null}}catch(r){return{perms:{},full:{},err:r.message}}}function le(n,r){const o={...n,permissions:r};return JSON.stringify(o,null,2)+`
|
|
2
2
|
`}function ce(){const n=H(),r=X(),o=(r==null?void 0:r.cwd)??null,s=Z(t=>t.navFace),f=u.useRef(!1),i=u.useRef(s),[c,v]=u.useState(()=>s==="project"&&o?"project":"user"),[l,b]=u.useState("effective");u.useEffect(()=>{if(i.current!==s){if(i.current=s,f.current){f.current=!1;return}v(s==="project"&&o?"project":"user")}},[s,o]),u.useEffect(()=>{s==="project"&&l==="presets"&&b("effective")},[s,l]);const M=t=>{f.current=!0,v(t)},j=re(J,n,o),x=j[c]??null,y=w(t=>t.files),C=w(t=>t.setDraft),L=w(t=>t.saveJson),T=w(t=>t.revert),[_,S]=u.useState(null),R=e.jsx(ae,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:l,onChange:b}),$=u.useMemo(()=>{const t=q(Q(y,j));return U(t,["permissions"])??{kind:"object",children:{}}},[y,j]),V=(t,d)=>{var D;const a=j[c];if(!a)return;const{full:g,err:P}=F(((D=y[a])==null?void 0:D.draftRaw)??"");if(P){O.error(k);return}S(null);const z=Y(g.permissions??{},t,d),G={...g,permissions:z};C(a,JSON.stringify(G,null,2)+`
|
|
3
3
|
`)};if(!n)return e.jsx(E,{title:"loading…"});if(l==="presets")return e.jsx(I,{toolbar:R,children:e.jsx(se,{})});const A=t=>t!=="user"&&!o,m=x?y[x]:null,{perms:p,full:B,err:h}=m?F(m.draftRaw):{perms:{},full:{},err:null},N=t=>{if(x){if(h){O.error(k);return}S(null),C(x,le(B,t))}},K=(t,d)=>{const a=d.trim();if(!a)return;const g=p[t]??[];g.includes(a)||N({...p,[t]:[...g,a]})},W=(t,d)=>{const a=p[t]??[];N({...p,[t]:a.filter((g,P)=>P!==d)})};return e.jsx(I,{toolbar:e.jsxs(e.Fragment,{children:[R,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(ee,{scopes:J.scopes,active:c,onChange:M,annotate:t=>{if(A(t))return{exists:!1};const d=j[t];if(!d)return null;const a=y[d];return{exists:(a==null?void 0:a.exists)??!1,dirty:(a==null?void 0:a.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),footer:x&&m?e.jsx(te,{dirty:m.dirty,busy:m.busy,parseError:_||h||m.parseError,lastSavedAt:m.lastSavedAt,onSave:async()=>{S(null);const t=await L(x);t.ok||S(t.error??"save failed")},onRevert:()=>{S(null),T(x)}}):null,children:A(c)?e.jsx(E,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):l==="effective"?e.jsx(ne,{node:$,targetScope:c,onOverride:V,schema:oe().rootedAt(["permissions"]),rootLabel:"permissions"}):x&&m?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[h&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[k," (",h,")"]}),e.jsx(de,{value:p.defaultMode??"default",onChange:t=>N({...p,defaultMode:t})}),ie.map(t=>e.jsx(ue,{list:t,rules:p[t]??[],disabled:!!h,onAdd:d=>K(t,d),onRemove:d=>W(t,d)},t)),e.jsx(fe,{dirs:p.additionalDirectories??[],disabled:!!h,onChange:t=>N({...p,additionalDirectories:t})})]}):e.jsx(E,{title:"resolving…"})})}const we=u.memo(ce);function de({value:n,onChange:r}){const o=["default","acceptEdits","plan","bypassPermissions"];return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:o.map(s=>e.jsx("button",{onClick:()=>r(s),className:`px-2.5 py-1 text-xs transition-colors ${n===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ue({list:n,rules:r,onAdd:o,onRemove:s,disabled:f}){const[i,c]=u.useState(""),v=n==="allow"?"text-green-400":n==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${v}`,children:n}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,disabled:f,onChange:l=>c(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(o(i),c(""))},placeholder:n==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{o(i),c("")},disabled:f||!i.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),r.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:r.map((l,b)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:l}),e.jsx("button",{onClick:()=>s(b),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${b}-${l}`))})]})}function fe({dirs:n,onChange:r,disabled:o}){const[s,f]=u.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:s,disabled:o,onChange:i=>f(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s.trim()&&(r([...n,s.trim()]),f(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:n.map((i,c)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:i}),e.jsx("button",{onClick:()=>r(n.filter((v,l)=>l!==c)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${c}-${i}`))})]})}export{we as Permissions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-
|
|
2
|
-
import{ap as t,aF as c,n as S,b3 as pe,aW as q,a_ as ae,a as xe}from"./index-Ci1u018F.js";import{P as ee}from"./Panel-DGMEuYYG.js";import{P as re}from"./ProvenanceBadge-DiKAUR1u.js";import{e as ge}from"./Library-D-GIt3EY.js";import{p as le}from"./skillFrontmatter-Dif5JIg7.js";import{l as je}from"./listSkills-C1aWKf0T.js";import{_ as be}from"./monaco-editor-BsIlgG7c.js";import{L as ye}from"./ListDetail-Bco_wfs6.js";import{M as ve}from"./MarkdownEditor-C-yHSXNV.js";import"./Button-B6h0F0XT.js";function ke({columns:e,rows:n,getKey:i,onRowClick:s,activeKey:a,empty:d}){return n.length===0?t.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:d??"no entries"}):t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:t.jsx("tr",{className:"border-b border-line",children:e.map(l=>t.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),t.jsx("tbody",{children:n.map(l=>{const h=i(l),o=a===h;return t.jsx("tr",{"data-row-key":h,onClick:()=>s==null?void 0:s(l),className:`border-b border-line/50 transition-colors ${s?"cursor-pointer":""} ${o?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:e.map(u=>t.jsx("td",{className:`px-3 py-1 ${u.className??""}`,children:u.render(l)},u.key))},h)})})]})}async function oe(e){const n=`${e}/skills`;return await window.api.config.exists(n)?n:null}async function ce(e){const{entries:n}=await je(e,{nested:!1});return n.map(i=>{const s=le(i.text);return{id:i.name,name:s.name,description:s.description,dir:i.dir,path:i.path,body:s.body}})}function Ne(e){const n=[],i=new Set;for(const s of e)for(const a of e){if(s.id===a.id)continue;const d=a.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${d}\\b`,`\`${d}\``];if(a.id.length>=4&&l.push(`\\b${d}\\b`),!l.some(u=>new RegExp(u,"i").test(s.body)))continue;const o=`${s.id}->${a.id}`;i.has(o)||(i.add(o),n.push({from:s.id,to:a.id}))}return n}const we=c.lazy(()=>be(()=>import("./SkillReferenceGraph-DH1NLOiS.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>({default:e.SkillReferenceGraph})));function Se({pluginName:e,skills:n,onBack:i,initialSelectedId:s}){var N;const[a,d]=c.useState(s??((N=n[0])==null?void 0:N.id)??null),l=a?n.find(m=>m.id===a)??null:null,h=c.useMemo(()=>Ne(n),[n]),[o,u]=c.useState("list");return t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsxs("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",e]}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),t.jsx("span",{className:"flex-1"}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[t.jsx("button",{onClick:()=>u("list"),className:`px-2 py-0.5 text-xs ${o==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),t.jsx("button",{onClick:()=>u("graph"),className:`px-2 py-0.5 text-xs ${o==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?t.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,t.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",h.length," ",h.length===1?"reference":"references"]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?t.jsx(S,{title:"no skills in this plugin"}):o==="graph"?t.jsx(c.Suspense,{fallback:t.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:t.jsx(we,{skills:n,edges:h,selectedId:a,onSelect:d})}):t.jsx(ye,{sidebar:t.jsx("div",{className:"py-1",children:n.map(m=>t.jsxs("button",{onClick:()=>d(m.id),className:`w-full px-3 py-1 text-xs text-left ${a===m.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("div",{className:"truncate",children:m.name??m.id}),m.description?t.jsx("div",{className:"truncate text-fg-faint",children:m.description}):null]},m.id))}),detail:l?t.jsx("div",{className:"h-full min-h-0",children:t.jsx(ve,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):t.jsx(S,{title:"select a skill"})})})]})}const de=e=>{var n,i;return{type:"plugin",name:e.name,repository:(n=e.manifest)==null?void 0:n.repository,homepage:(i=e.manifest)==null?void 0:i.homepage}};function $e(){const e=pe(),[n,i]=c.useState([]),[s,a]=c.useState(!0),[d,l]=c.useState(null),[h,o]=c.useState(null),[u,N]=c.useState("installed"),[m,I]=c.useState(null),[D,F]=c.useState(new Set);c.useEffect(()=>{var g,k;let r=!1;return(k=(g=window.api.app).seedStatus)==null||k.call(g).then($=>{r||I($)}).catch(()=>{}),()=>{r=!0}},[]);const E=c.useRef(0),C=c.useRef(!1),b=c.useCallback(async()=>{const r=++E.current;if(!e)return;C.current||a(!0);const g=`${e}/.claude/plugins/installed_plugins.json`;let k=[],$=null;try{const x=await window.api.config.readJson(g);if(x.exists&&x.parseError)$=`could not parse installed_plugins.json${x.error?`: ${x.error}`:""}`;else if(x.exists&&x.data&&typeof x.data=="object"){const T=x.data,J=[];for(const[W,R]of Object.entries(T.plugins??{})){if(!Array.isArray(R))continue;const[_,O]=W.split("@");for(const j of R)j!=null&&j.installPath&&J.push({name:_,marketplace:O,entry:j})}k=await De(J,Le,async({name:W,marketplace:R,entry:_})=>{var H;const O={name:W,path:_.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let j;try{j=await _e(O)}catch(B){j=Re(O,B instanceof Error?B.message:String(B))}return(H=j.manifest)!=null&&H.version||(j.manifest={...j.manifest??{},version:_.version}),j.marketplace=R,j.scope=_.scope,j})}}catch(x){$=`could not read installed_plugins.json: ${x instanceof Error?x.message:String(x)}`}E.current===r&&(l($),$?q.error(`Plugins: ${$}`):(k.sort((x,T)=>x.name.localeCompare(T.name)),C.current=k.length>0,i(k)),a(!1))},[e]);c.useEffect(()=>{b()},[b]),c.useEffect(()=>()=>{E.current+=1},[]),ae(e?[`${e}/.claude/plugins/installed_plugins.json`]:[],b);const f=[{key:"name",header:"name",render:r=>{var g;return t.jsxs("div",{style:{maxWidth:"16rem"},children:[t.jsx("div",{className:"truncate",children:r.name}),(g=r.manifest)!=null&&g.description?t.jsx("div",{className:"truncate text-fg-faint",title:r.manifest.description,children:r.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:r=>t.jsx(re,{interactive:!1,input:de(r)}),width:"7rem"},{key:"scope",header:"scope",render:r=>r.scope?t.jsx("span",{"data-testid":"plugin-scope",children:r.scope}):t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:r=>{var g;return((g=r.manifest)==null?void 0:g.version)??t.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:r=>r.hasManifest?"plugin.json":t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:r=>t.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[r.agents>0?`${r.agents} agents`:null,r.commands>0?`${r.commands} commands`:null,r.skills>0?`${r.skills} skills`:null,r.hooks>0?`${r.hooks} hooks`:null,r.monitors>0?`${r.monitors} monitors`:null,r.binCount>0?`${r.binCount} bin`:null,r.hasLsp?"lsp":null,r.hasMcp?"mcp":null,r.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:r=>t.jsx("span",{className:"font-mono text-fg-faint truncate",children:r.path})}],p=c.useMemo(()=>m?Object.keys(m).filter(r=>m[r].status==="exhausted"&&!D.has(r)):[],[m,D]),w=p.length>0?t.jsx(Pe,{seeders:p,seedStatus:m,onDismiss:r=>F(g=>new Set(g).add(r)),onOpenLibrary:()=>N("library")}):null;if(u==="library")return t.jsxs(ee,{toolbar:t.jsx(ne,{active:u,onChange:N}),children:[w,t.jsx(ge,{})]});const y=h?n.find(r=>r.path===h)??null:null;return t.jsxs(ee,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(ne,{active:u,onChange:N}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[w,d?t.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[d,n.length>0?" — showing the last known list":null]}):null,s&&n.length===0?t.jsx(S,{title:"scanning plugins…"}):d&&n.length===0?null:y?t.jsx(Ae,{row:y,home:e,onBack:()=>o(null)},y.path):t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsx(ke,{columns:f,rows:n,getKey:r=>r.path,activeKey:h,onRowClick:r=>o(r.path),empty:t.jsxs(t.Fragment,{children:["no plugins installed",t.jsxs("div",{className:"mt-2 text-fg-faint",children:["install one from the Library view or run ",t.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const Xe=c.memo($e),te={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Pe({seeders:e,seedStatus:n,onDismiss:i,onOpenLibrary:s}){return t.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:e.map(a=>t.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[te[a]," setup failed after retrying — manual fix needed"]}),a==="dev-plugin"?t.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",t.jsx("button",{onClick:s,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):t.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[a].fix})]}),t.jsx("button",{onClick:()=>i(a),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${te[a]} warning`,children:"✕"})]},a))})}function ne({active:e,onChange:n}){const i=[["installed","Installed"],["library","Library"]];return t.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:i.map(([s,a])=>t.jsx("button",{onClick:()=>n(s),role:"tab","aria-selected":e===s,className:`px-2 py-0.5 text-xs ${e===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:a},s))})}const Ee=250,Ce=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function Ae({row:e,home:n,onBack:i}){var O,j,H,B,U;const[s,a]=c.useState([]),[d,l]=c.useState([]),[h,o]=c.useState([]),[u,N]=c.useState([]),[m,I]=c.useState([]),[D,F]=c.useState("skills"),[E,C]=c.useState(null),[b,f]=c.useState(!0),[p,w]=c.useState([]),y=c.useRef(0),r=c.useRef(!1),g=c.useCallback(async()=>{if(!n)return;const v=++y.current;try{const{manifest:M}=await ue(e.path),[z,V,he]=await Promise.all([oe(e.path),me(e.path,M),K(`${e.path}/bin`,{filesOnly:!0})]),G=z?await ce(z):[],[X,Y]=await Promise.all([ie(V.agentFiles),ie(V.commandFiles)]),Q=V.mcpServers,fe=await Promise.all([...new Set([...Ce.map(A=>`${e.path}/${A}`),...V.sourcePaths])].map(async A=>await window.api.config.exists(A)?A:null));if(v!==y.current)return;a(G),l(X),o(Y),N(Q),I(he);const Z=fe.filter(A=>A!==null);w(A=>A.join("\0")===Z.join("\0")?A:Z),r.current||(r.current=!0,F(G.length>0?"skills":X.length>0?"agents":Y.length>0?"commands":Q.length>0?"mcp":e.hooks>0?"hooks":e.monitors>0?"monitors":e.hasLsp?"lsp":"files"))}catch(M){if(v!==y.current)return;q.error(`Failed to load plugin contents: ${M instanceof Error?M.message:String(M)}`)}finally{v===y.current&&f(!1)}},[e.path,e.name,e.hooks,e.monitors,e.hasLsp,n]);c.useEffect(()=>(f(!0),g(),()=>{y.current+=1}),[g]);const k=c.useRef(null),$=c.useRef(!1),x=c.useRef(!1),T=c.useCallback(async()=>{if($.current){x.current=!0;return}$.current=!0;try{do x.current=!1,await g();while(x.current)}finally{$.current=!1}},[g]),J=c.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,T()},Ee)},[T]);c.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),ae(p,J,{depth:0});const W=[{key:"skills",label:"Skills",count:s.length},{key:"agents",label:"Agents",count:d.length},{key:"commands",label:"Commands",count:h.length},{key:"mcp",label:"MCP server",count:u.length},{key:"hooks",label:"Hooks",count:e.hooks},{key:"monitors",label:"Monitors",count:e.monitors},{key:"lsp",label:"LSP",count:e.hasLsp?1:0},{key:"files",label:"Bin",count:m.length}],R=(O=e.manifest)!=null&&O.author?typeof e.manifest.author=="string"?e.manifest.author:e.manifest.author.name??null:null,_=async v=>{const M=await window.api.shell.open({as:"external",url:v});M.ok||q.error(M.error??`Failed to open ${v}`)};return E?t.jsx(Se,{pluginName:((j=e.manifest)==null?void 0:j.name)??e.name,skills:s,initialSelectedId:E.id,onBack:()=>C(null)},E.id):t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsx("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((H=e.manifest)==null?void 0:H.name)??e.name}),(B=e.manifest)!=null&&B.version?t.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",e.manifest.version]}):null,(U=e.manifest)!=null&&U.description?t.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:e.manifest.description}):t.jsx("span",{className:"flex-1"}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(re,{input:de(e)}),e.hasMcp?t.jsx(xe,{tone:"accent",children:"MCP"}):null]})]}),e.manifest?t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[R?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"Author "}),R]}):null,e.manifest.license?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"License "}),e.manifest.license]}):null,e.manifest.homepage?t.jsxs("button",{onClick:()=>_(e.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:e.manifest.homepage,children:[t.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),e.manifest.homepage]}):null,t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})]}):t.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})}),t.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[t.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:W.map(v=>t.jsxs("button",{type:"button",disabled:v.count===0,onClick:()=>F(v.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${v.count===0?"text-fg-faint opacity-50 cursor-default":D===v.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("span",{children:v.label}),v.count>0?t.jsx("span",{className:"font-mono text-fg-faint",children:v.count}):null]},v.key))}),t.jsx("div",{className:"min-h-0 overflow-auto",children:b?t.jsx(S,{title:"scanning…"}):t.jsx(Me,{active:D,row:e,skills:s,agents:d,commands:h,mcpServers:u,files:m,onOpenSkill:C})})]})]})}function Me({active:e,row:n,skills:i,agents:s,commands:a,mcpServers:d,files:l,onOpenSkill:h}){return e==="skills"?i.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:i.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description,onClick:()=>h(o)},o.id))}):e==="agents"?s.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:s.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="commands"?a.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:a.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="mcp"?d.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:d.map((o,u)=>t.jsx(L,{n:u+1,name:o.name,description:o.description},o.id))}):e==="hooks"?n.hooks===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):e==="monitors"?n.monitors===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):e==="lsp"?n.hasLsp?t.jsx("div",{children:t.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):t.jsx(S,{title:"no components"}):l.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:l.map((o,u)=>t.jsx(L,{n:u+1,name:o,description:null},o))})}function L({n:e,name:n,description:i,onClick:s}){const a=s?"button":"div";return t.jsxs(a,{onClick:s,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${s?"hover:bg-bg-hi cursor-pointer":""}`,children:[t.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(e).padStart(2,"0")}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),i?t.jsx("div",{className:"text-fg-dim text-xs truncate",children:i}):null]})]})}const Le=4;async function De(e,n,i){const s=new Array(e.length);let a=0;const d=Array.from({length:Math.min(n,e.length)},async()=>{for(;a<e.length;){const l=a++;s[l]=await i(e[l])}});return await Promise.all(d),s}function Re(e,n){return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,error:n}}async function _e(e){const{hasManifest:n,manifest:i}=await ue(e.path),[s,a]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let d=0;if(a){const m=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(m.data)?d=m.data.length:m.data&&typeof m.data=="object"&&Array.isArray(m.data.monitors)&&(d=m.data.monitors.length)}const[l,h,o]=await Promise.all([me(e.path,i),K(`${e.path}/bin`,{filesOnly:!0}),oe(e.path)]),u=h.length,N=o?(await ce(o)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:n,manifest:i,hasLsp:s,monitors:d,hooks:l.hooks,agents:l.agentFiles.length,commands:l.commandFiles.length,skills:N,binCount:u,hasMcp:l.mcpServers.length>0}}async function ue(e){let n=`${e}/.claude-plugin/plugin.json`,i=await window.api.config.exists(n);if(i||(n=`${e}/plugin.json`,i=await window.api.config.exists(n)),!i)return{hasManifest:i,manifest:null};const s=await window.api.config.readJson(n),a=s.exists&&!s.parseError&&s.data&&typeof s.data=="object"&&!Array.isArray(s.data);return{hasManifest:i,manifest:a?s.data:null}}const P=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Oe(e,n){const i=n.startsWith("/")?n.startsWith(`${e}/`)?n.slice(e.length+1):null:n;if(i===null)return se(n);const s=[];for(const a of i.split("/"))if(!(a===""||a===".")){if(a!=="..")s.push(a);else if(s.pop()===void 0)return se(n)}return s.length>0?`${e}/${s.join("/")}`:e}function se(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Fe(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Te(e){if(!P(e))return null;if(P(e.mcpServers))return e.mcpServers;const n=Object.values(e);return n.length>0&&n.every(s=>P(s)&&(typeof s.command=="string"||typeof s.url=="string"))?e:null}function Be(e){if(!P(e))return 0;const n=P(e.hooks)?e.hooks:e;return Object.values(n).reduce((i,s)=>Array.isArray(s)?i+s.reduce((a,d)=>a+(P(d)&&Array.isArray(d.hooks)?d.hooks.length:0),0):i,0)}async function me(e,n){const i=(b,f)=>{const p=new Set;for(const w of Fe(b)){const y=Oe(e,w);y&&p.add(y)}return p.add(`${e}/${f}`),[...p]},s=async b=>{const f=new Set;for(const p of b)if(p.endsWith(".md"))f.add(p);else for(const w of await K(p,{filesOnly:!0}))w.endsWith(".md")&&f.add(`${p}/${w}`);return[...f]},a=async b=>{try{const f=await window.api.config.readJson(b);return f.exists&&!f.parseError?f.data:null}catch{return null}},d=i(n==null?void 0:n.commands,"commands"),l=i(n==null?void 0:n.agents,"agents"),h=n==null?void 0:n.hooks,o=i(typeof h=="string"||Array.isArray(h)?h:void 0,"hooks/hooks.json"),u=n==null?void 0:n.mcpServers,N=i(typeof u=="string"||Array.isArray(u)?u:void 0,".mcp.json"),[m,I,D,F]=await Promise.all([s(d),s(l),Promise.all(o.map(a)),Promise.all(N.map(a))]),E=[...P(h)?[h]:[],...D].reduce((b,f)=>b+Be(f),0),C=new Map;for(const b of[...P(u)?[u]:[],...F])for(const[f,p]of Object.entries(Te(b)??{})){if(C.has(f))continue;const w=P(p)?p.command:void 0,y=P(p)?p.url:void 0;C.set(f,{id:f,name:f,description:typeof w=="string"?w:typeof y=="string"?y:null})}return{commandFiles:m,agentFiles:I,hooks:E,mcpServers:[...C.values()],sourcePaths:[...d,...l,...o,...N]}}async function ie(e){const n=await Promise.all(e.map(s=>window.api.config.readText(s))),i=[];return e.forEach((s,a)=>{if(!n[a].exists)return;const d=s.slice(s.lastIndexOf("/")+1),l=le(n[a].text);i.push({id:s,name:l.name??d.replace(/\.md$/,""),description:l.description})}),i}async function K(e,n){try{return(await window.api.config.listDir(e,n)).entries.map(s=>s.name)}catch{return[]}}export{Xe as Plugins};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-BgyAnxGW.js","./index-AVrhGmUO.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-HpEbvDiE.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ap as t,aF as c,n as S,b3 as pe,aW as q,a_ as ae,a as xe}from"./index-AVrhGmUO.js";import{P as ee}from"./Panel-BQkkkjex.js";import{P as re}from"./ProvenanceBadge--N5j8xiK.js";import{e as ge}from"./Library-DTjsUr9W.js";import{p as le}from"./skillFrontmatter-Dif5JIg7.js";import{l as je}from"./listSkills-C1aWKf0T.js";import{_ as be}from"./monaco-editor-BsIlgG7c.js";import{L as ye}from"./ListDetail-B1L5TbjS.js";import{M as ve}from"./MarkdownEditor-BFRhWZD4.js";import"./Button-BJVFKdGH.js";function ke({columns:e,rows:n,getKey:i,onRowClick:s,activeKey:a,empty:d}){return n.length===0?t.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:d??"no entries"}):t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:t.jsx("tr",{className:"border-b border-line",children:e.map(l=>t.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),t.jsx("tbody",{children:n.map(l=>{const h=i(l),o=a===h;return t.jsx("tr",{"data-row-key":h,onClick:()=>s==null?void 0:s(l),className:`border-b border-line/50 transition-colors ${s?"cursor-pointer":""} ${o?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:e.map(u=>t.jsx("td",{className:`px-3 py-1 ${u.className??""}`,children:u.render(l)},u.key))},h)})})]})}async function oe(e){const n=`${e}/skills`;return await window.api.config.exists(n)?n:null}async function ce(e){const{entries:n}=await je(e,{nested:!1});return n.map(i=>{const s=le(i.text);return{id:i.name,name:s.name,description:s.description,dir:i.dir,path:i.path,body:s.body}})}function Ne(e){const n=[],i=new Set;for(const s of e)for(const a of e){if(s.id===a.id)continue;const d=a.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${d}\\b`,`\`${d}\``];if(a.id.length>=4&&l.push(`\\b${d}\\b`),!l.some(u=>new RegExp(u,"i").test(s.body)))continue;const o=`${s.id}->${a.id}`;i.has(o)||(i.add(o),n.push({from:s.id,to:a.id}))}return n}const we=c.lazy(()=>be(()=>import("./SkillReferenceGraph-BgyAnxGW.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>({default:e.SkillReferenceGraph})));function Se({pluginName:e,skills:n,onBack:i,initialSelectedId:s}){var N;const[a,d]=c.useState(s??((N=n[0])==null?void 0:N.id)??null),l=a?n.find(m=>m.id===a)??null:null,h=c.useMemo(()=>Ne(n),[n]),[o,u]=c.useState("list");return t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsxs("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",e]}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),t.jsx("span",{className:"flex-1"}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[t.jsx("button",{onClick:()=>u("list"),className:`px-2 py-0.5 text-xs ${o==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),t.jsx("button",{onClick:()=>u("graph"),className:`px-2 py-0.5 text-xs ${o==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?t.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,t.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",h.length," ",h.length===1?"reference":"references"]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?t.jsx(S,{title:"no skills in this plugin"}):o==="graph"?t.jsx(c.Suspense,{fallback:t.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:t.jsx(we,{skills:n,edges:h,selectedId:a,onSelect:d})}):t.jsx(ye,{sidebar:t.jsx("div",{className:"py-1",children:n.map(m=>t.jsxs("button",{onClick:()=>d(m.id),className:`w-full px-3 py-1 text-xs text-left ${a===m.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("div",{className:"truncate",children:m.name??m.id}),m.description?t.jsx("div",{className:"truncate text-fg-faint",children:m.description}):null]},m.id))}),detail:l?t.jsx("div",{className:"h-full min-h-0",children:t.jsx(ve,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):t.jsx(S,{title:"select a skill"})})})]})}const de=e=>{var n,i;return{type:"plugin",name:e.name,repository:(n=e.manifest)==null?void 0:n.repository,homepage:(i=e.manifest)==null?void 0:i.homepage}};function $e(){const e=pe(),[n,i]=c.useState([]),[s,a]=c.useState(!0),[d,l]=c.useState(null),[h,o]=c.useState(null),[u,N]=c.useState("installed"),[m,I]=c.useState(null),[D,F]=c.useState(new Set);c.useEffect(()=>{var g,k;let r=!1;return(k=(g=window.api.app).seedStatus)==null||k.call(g).then($=>{r||I($)}).catch(()=>{}),()=>{r=!0}},[]);const E=c.useRef(0),C=c.useRef(!1),b=c.useCallback(async()=>{const r=++E.current;if(!e)return;C.current||a(!0);const g=`${e}/.claude/plugins/installed_plugins.json`;let k=[],$=null;try{const x=await window.api.config.readJson(g);if(x.exists&&x.parseError)$=`could not parse installed_plugins.json${x.error?`: ${x.error}`:""}`;else if(x.exists&&x.data&&typeof x.data=="object"){const T=x.data,J=[];for(const[W,R]of Object.entries(T.plugins??{})){if(!Array.isArray(R))continue;const[_,O]=W.split("@");for(const j of R)j!=null&&j.installPath&&J.push({name:_,marketplace:O,entry:j})}k=await De(J,Le,async({name:W,marketplace:R,entry:_})=>{var H;const O={name:W,path:_.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let j;try{j=await _e(O)}catch(B){j=Re(O,B instanceof Error?B.message:String(B))}return(H=j.manifest)!=null&&H.version||(j.manifest={...j.manifest??{},version:_.version}),j.marketplace=R,j.scope=_.scope,j})}}catch(x){$=`could not read installed_plugins.json: ${x instanceof Error?x.message:String(x)}`}E.current===r&&(l($),$?q.error(`Plugins: ${$}`):(k.sort((x,T)=>x.name.localeCompare(T.name)),C.current=k.length>0,i(k)),a(!1))},[e]);c.useEffect(()=>{b()},[b]),c.useEffect(()=>()=>{E.current+=1},[]),ae(e?[`${e}/.claude/plugins/installed_plugins.json`]:[],b);const f=[{key:"name",header:"name",render:r=>{var g;return t.jsxs("div",{style:{maxWidth:"16rem"},children:[t.jsx("div",{className:"truncate",children:r.name}),(g=r.manifest)!=null&&g.description?t.jsx("div",{className:"truncate text-fg-faint",title:r.manifest.description,children:r.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:r=>t.jsx(re,{interactive:!1,input:de(r)}),width:"7rem"},{key:"scope",header:"scope",render:r=>r.scope?t.jsx("span",{"data-testid":"plugin-scope",children:r.scope}):t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:r=>{var g;return((g=r.manifest)==null?void 0:g.version)??t.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:r=>r.hasManifest?"plugin.json":t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:r=>t.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[r.agents>0?`${r.agents} agents`:null,r.commands>0?`${r.commands} commands`:null,r.skills>0?`${r.skills} skills`:null,r.hooks>0?`${r.hooks} hooks`:null,r.monitors>0?`${r.monitors} monitors`:null,r.binCount>0?`${r.binCount} bin`:null,r.hasLsp?"lsp":null,r.hasMcp?"mcp":null,r.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:r=>t.jsx("span",{className:"font-mono text-fg-faint truncate",children:r.path})}],p=c.useMemo(()=>m?Object.keys(m).filter(r=>m[r].status==="exhausted"&&!D.has(r)):[],[m,D]),w=p.length>0?t.jsx(Pe,{seeders:p,seedStatus:m,onDismiss:r=>F(g=>new Set(g).add(r)),onOpenLibrary:()=>N("library")}):null;if(u==="library")return t.jsxs(ee,{toolbar:t.jsx(ne,{active:u,onChange:N}),children:[w,t.jsx(ge,{})]});const y=h?n.find(r=>r.path===h)??null:null;return t.jsxs(ee,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(ne,{active:u,onChange:N}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[w,d?t.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[d,n.length>0?" — showing the last known list":null]}):null,s&&n.length===0?t.jsx(S,{title:"scanning plugins…"}):d&&n.length===0?null:y?t.jsx(Ae,{row:y,home:e,onBack:()=>o(null)},y.path):t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsx(ke,{columns:f,rows:n,getKey:r=>r.path,activeKey:h,onRowClick:r=>o(r.path),empty:t.jsxs(t.Fragment,{children:["no plugins installed",t.jsxs("div",{className:"mt-2 text-fg-faint",children:["install one from the Library view or run ",t.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const Xe=c.memo($e),te={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Pe({seeders:e,seedStatus:n,onDismiss:i,onOpenLibrary:s}){return t.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:e.map(a=>t.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[te[a]," setup failed after retrying — manual fix needed"]}),a==="dev-plugin"?t.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",t.jsx("button",{onClick:s,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):t.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[a].fix})]}),t.jsx("button",{onClick:()=>i(a),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${te[a]} warning`,children:"✕"})]},a))})}function ne({active:e,onChange:n}){const i=[["installed","Installed"],["library","Library"]];return t.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:i.map(([s,a])=>t.jsx("button",{onClick:()=>n(s),role:"tab","aria-selected":e===s,className:`px-2 py-0.5 text-xs ${e===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:a},s))})}const Ee=250,Ce=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function Ae({row:e,home:n,onBack:i}){var O,j,H,B,U;const[s,a]=c.useState([]),[d,l]=c.useState([]),[h,o]=c.useState([]),[u,N]=c.useState([]),[m,I]=c.useState([]),[D,F]=c.useState("skills"),[E,C]=c.useState(null),[b,f]=c.useState(!0),[p,w]=c.useState([]),y=c.useRef(0),r=c.useRef(!1),g=c.useCallback(async()=>{if(!n)return;const v=++y.current;try{const{manifest:M}=await ue(e.path),[z,V,he]=await Promise.all([oe(e.path),me(e.path,M),K(`${e.path}/bin`,{filesOnly:!0})]),G=z?await ce(z):[],[X,Y]=await Promise.all([ie(V.agentFiles),ie(V.commandFiles)]),Q=V.mcpServers,fe=await Promise.all([...new Set([...Ce.map(A=>`${e.path}/${A}`),...V.sourcePaths])].map(async A=>await window.api.config.exists(A)?A:null));if(v!==y.current)return;a(G),l(X),o(Y),N(Q),I(he);const Z=fe.filter(A=>A!==null);w(A=>A.join("\0")===Z.join("\0")?A:Z),r.current||(r.current=!0,F(G.length>0?"skills":X.length>0?"agents":Y.length>0?"commands":Q.length>0?"mcp":e.hooks>0?"hooks":e.monitors>0?"monitors":e.hasLsp?"lsp":"files"))}catch(M){if(v!==y.current)return;q.error(`Failed to load plugin contents: ${M instanceof Error?M.message:String(M)}`)}finally{v===y.current&&f(!1)}},[e.path,e.name,e.hooks,e.monitors,e.hasLsp,n]);c.useEffect(()=>(f(!0),g(),()=>{y.current+=1}),[g]);const k=c.useRef(null),$=c.useRef(!1),x=c.useRef(!1),T=c.useCallback(async()=>{if($.current){x.current=!0;return}$.current=!0;try{do x.current=!1,await g();while(x.current)}finally{$.current=!1}},[g]),J=c.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,T()},Ee)},[T]);c.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),ae(p,J,{depth:0});const W=[{key:"skills",label:"Skills",count:s.length},{key:"agents",label:"Agents",count:d.length},{key:"commands",label:"Commands",count:h.length},{key:"mcp",label:"MCP server",count:u.length},{key:"hooks",label:"Hooks",count:e.hooks},{key:"monitors",label:"Monitors",count:e.monitors},{key:"lsp",label:"LSP",count:e.hasLsp?1:0},{key:"files",label:"Bin",count:m.length}],R=(O=e.manifest)!=null&&O.author?typeof e.manifest.author=="string"?e.manifest.author:e.manifest.author.name??null:null,_=async v=>{const M=await window.api.shell.open({as:"external",url:v});M.ok||q.error(M.error??`Failed to open ${v}`)};return E?t.jsx(Se,{pluginName:((j=e.manifest)==null?void 0:j.name)??e.name,skills:s,initialSelectedId:E.id,onBack:()=>C(null)},E.id):t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsx("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((H=e.manifest)==null?void 0:H.name)??e.name}),(B=e.manifest)!=null&&B.version?t.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",e.manifest.version]}):null,(U=e.manifest)!=null&&U.description?t.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:e.manifest.description}):t.jsx("span",{className:"flex-1"}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(re,{input:de(e)}),e.hasMcp?t.jsx(xe,{tone:"accent",children:"MCP"}):null]})]}),e.manifest?t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[R?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"Author "}),R]}):null,e.manifest.license?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"License "}),e.manifest.license]}):null,e.manifest.homepage?t.jsxs("button",{onClick:()=>_(e.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:e.manifest.homepage,children:[t.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),e.manifest.homepage]}):null,t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})]}):t.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})}),t.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[t.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:W.map(v=>t.jsxs("button",{type:"button",disabled:v.count===0,onClick:()=>F(v.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${v.count===0?"text-fg-faint opacity-50 cursor-default":D===v.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("span",{children:v.label}),v.count>0?t.jsx("span",{className:"font-mono text-fg-faint",children:v.count}):null]},v.key))}),t.jsx("div",{className:"min-h-0 overflow-auto",children:b?t.jsx(S,{title:"scanning…"}):t.jsx(Me,{active:D,row:e,skills:s,agents:d,commands:h,mcpServers:u,files:m,onOpenSkill:C})})]})]})}function Me({active:e,row:n,skills:i,agents:s,commands:a,mcpServers:d,files:l,onOpenSkill:h}){return e==="skills"?i.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:i.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description,onClick:()=>h(o)},o.id))}):e==="agents"?s.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:s.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="commands"?a.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:a.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="mcp"?d.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:d.map((o,u)=>t.jsx(L,{n:u+1,name:o.name,description:o.description},o.id))}):e==="hooks"?n.hooks===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):e==="monitors"?n.monitors===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):e==="lsp"?n.hasLsp?t.jsx("div",{children:t.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):t.jsx(S,{title:"no components"}):l.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:l.map((o,u)=>t.jsx(L,{n:u+1,name:o,description:null},o))})}function L({n:e,name:n,description:i,onClick:s}){const a=s?"button":"div";return t.jsxs(a,{onClick:s,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${s?"hover:bg-bg-hi cursor-pointer":""}`,children:[t.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(e).padStart(2,"0")}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),i?t.jsx("div",{className:"text-fg-dim text-xs truncate",children:i}):null]})]})}const Le=4;async function De(e,n,i){const s=new Array(e.length);let a=0;const d=Array.from({length:Math.min(n,e.length)},async()=>{for(;a<e.length;){const l=a++;s[l]=await i(e[l])}});return await Promise.all(d),s}function Re(e,n){return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,error:n}}async function _e(e){const{hasManifest:n,manifest:i}=await ue(e.path),[s,a]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let d=0;if(a){const m=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(m.data)?d=m.data.length:m.data&&typeof m.data=="object"&&Array.isArray(m.data.monitors)&&(d=m.data.monitors.length)}const[l,h,o]=await Promise.all([me(e.path,i),K(`${e.path}/bin`,{filesOnly:!0}),oe(e.path)]),u=h.length,N=o?(await ce(o)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:n,manifest:i,hasLsp:s,monitors:d,hooks:l.hooks,agents:l.agentFiles.length,commands:l.commandFiles.length,skills:N,binCount:u,hasMcp:l.mcpServers.length>0}}async function ue(e){let n=`${e}/.claude-plugin/plugin.json`,i=await window.api.config.exists(n);if(i||(n=`${e}/plugin.json`,i=await window.api.config.exists(n)),!i)return{hasManifest:i,manifest:null};const s=await window.api.config.readJson(n),a=s.exists&&!s.parseError&&s.data&&typeof s.data=="object"&&!Array.isArray(s.data);return{hasManifest:i,manifest:a?s.data:null}}const P=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Oe(e,n){const i=n.startsWith("/")?n.startsWith(`${e}/`)?n.slice(e.length+1):null:n;if(i===null)return se(n);const s=[];for(const a of i.split("/"))if(!(a===""||a===".")){if(a!=="..")s.push(a);else if(s.pop()===void 0)return se(n)}return s.length>0?`${e}/${s.join("/")}`:e}function se(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Fe(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Te(e){if(!P(e))return null;if(P(e.mcpServers))return e.mcpServers;const n=Object.values(e);return n.length>0&&n.every(s=>P(s)&&(typeof s.command=="string"||typeof s.url=="string"))?e:null}function Be(e){if(!P(e))return 0;const n=P(e.hooks)?e.hooks:e;return Object.values(n).reduce((i,s)=>Array.isArray(s)?i+s.reduce((a,d)=>a+(P(d)&&Array.isArray(d.hooks)?d.hooks.length:0),0):i,0)}async function me(e,n){const i=(b,f)=>{const p=new Set;for(const w of Fe(b)){const y=Oe(e,w);y&&p.add(y)}return p.add(`${e}/${f}`),[...p]},s=async b=>{const f=new Set;for(const p of b)if(p.endsWith(".md"))f.add(p);else for(const w of await K(p,{filesOnly:!0}))w.endsWith(".md")&&f.add(`${p}/${w}`);return[...f]},a=async b=>{try{const f=await window.api.config.readJson(b);return f.exists&&!f.parseError?f.data:null}catch{return null}},d=i(n==null?void 0:n.commands,"commands"),l=i(n==null?void 0:n.agents,"agents"),h=n==null?void 0:n.hooks,o=i(typeof h=="string"||Array.isArray(h)?h:void 0,"hooks/hooks.json"),u=n==null?void 0:n.mcpServers,N=i(typeof u=="string"||Array.isArray(u)?u:void 0,".mcp.json"),[m,I,D,F]=await Promise.all([s(d),s(l),Promise.all(o.map(a)),Promise.all(N.map(a))]),E=[...P(h)?[h]:[],...D].reduce((b,f)=>b+Be(f),0),C=new Map;for(const b of[...P(u)?[u]:[],...F])for(const[f,p]of Object.entries(Te(b)??{})){if(C.has(f))continue;const w=P(p)?p.command:void 0,y=P(p)?p.url:void 0;C.set(f,{id:f,name:f,description:typeof w=="string"?w:typeof y=="string"?y:null})}return{commandFiles:m,agentFiles:I,hooks:E,mcpServers:[...C.values()],sourcePaths:[...d,...l,...o,...N]}}async function ie(e){const n=await Promise.all(e.map(s=>window.api.config.readText(s))),i=[];return e.forEach((s,a)=>{if(!n[a].exists)return;const d=s.slice(s.lastIndexOf("/")+1),l=le(n[a].text);i.push({id:s,name:l.name??d.replace(/\.md$/,""),description:l.description})}),i}async function K(e,n){try{return(await window.api.config.listDir(e,n)).entries.map(s=>s.name)}catch{return[]}}export{Xe as Plugins};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a5 as P,b3 as G,aF as x,ap as i,_,B as R,a as T}from"./index-
|
|
1
|
+
import{a5 as P,b3 as G,aF as x,ap as i,_,B as R,a as T}from"./index-AVrhGmUO.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-DTjsUr9W.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),F=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.map(e=>e.command.trim())),q=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return F.has(t)||n&&Z.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&q.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(T,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),b&&i.jsxs("span",{className:`absolute ${_.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(w,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${R[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(w,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{be as _,aF as d,a1 as P,ap as e,a as N,bm as D,W as O,D as A,$ as H,a2 as U}from"./index-
|
|
1
|
+
import{be as _,aF as d,a1 as P,ap as e,a as N,bm as D,W as O,D as A,$ as H,a2 as U}from"./index-AVrhGmUO.js";import{b as L,P as E,E as $,R as z,u as W,S as G}from"./useRemotePeers-BuFbBqDt.js";import"./monaco-editor-BsIlgG7c.js";function M(o){return o instanceof Error?o.message:String(o)}function V({peerId:o,machineName:i,onOpenTerminal:y}){const c=_(a=>a.show),[x,m]=d.useState([]),[p,w]=d.useState("loading"),[h,k]=d.useState(null),[t,j]=d.useState(""),[C,I]=d.useState(!1),f=d.useRef(0),v=d.useCallback(async()=>{const a=++f.current;w("loading");try{let u;try{const s=await window.api.remoteClient.send(o,"cmd:sessions:list",{});u=Array.isArray(s==null?void 0:s.sessions)?s.sessions:[]}catch{if(a!==f.current)return;const s=await window.api.remoteClient.send(o,"cmd:sessions:load",{});u=(Array.isArray(s==null?void 0:s.tabs)?s.tabs:[]).map(b=>({kind:"project",tabId:b.sessionId,cwd:b.cwd,title:b.label||b.cwd,project:b.label||P(b.cwd)}))}if(a!==f.current)return;m(u),w("ready")}catch(u){if(a!==f.current)return;w("error"),c("error",`Could not load sessions from ${i}: ${M(u)}`)}},[o,i,c]);d.useEffect(()=>(v(),()=>{f.current++}),[v]);const S=d.useMemo(()=>{const a=new Map;for(const s of x){const g=s.project||P(s.cwd);(a.get(g)??a.set(g,[]).get(g)).push(s)}const u=s=>s.kind==="project"?0:1;for(const s of a.values())s.sort((g,b)=>u(g)-u(b));return[...a.entries()].sort((s,g)=>s[0].localeCompare(g[0]))},[x]),n=t.trim(),T=h!==null&&n.length>0&&!C,R=d.useCallback(async()=>{if(!(h===null||t.trim().length===0)){I(!0);try{await window.api.remoteClient.send(o,"cmd:chat:send",{tabId:h,prompt:t}),j("")}catch(a){c("error",`Could not send prompt to ${i}: ${M(a)}`)}finally{I(!1)}}},[o,i,h,t,c]);return e.jsxs("div",{"data-testid":"remote-sessions-panel",className:"flex flex-col gap-3",children:[e.jsx(L,{right:e.jsx(N,{tone:"accent",className:"",title:`Sessions on ${i}`,children:e.jsxs("span",{"data-testid":"remote-sessions-badge",children:["Remote: ",i]})}),children:"Remote sessions"}),e.jsx("div",{className:"flex justify-end",children:e.jsx(E,{icon:"history",testId:"remote-sessions-refresh",onClick:()=>{v()},disabled:p==="loading",children:"Refresh"})}),p==="loading"&&e.jsx($,{testId:"remote-sessions-loading",children:"Loading sessions…"}),p==="error"&&e.jsxs($,{testId:"remote-sessions-error",children:["Could not load sessions from ",i,"."]}),p==="ready"&&x.length===0&&e.jsxs($,{testId:"remote-sessions-empty",children:["No sessions open on ",i,"."]}),p==="ready"&&S.map(([a,u])=>e.jsx("div",{"data-testid":"remote-sessions-group",className:"flex flex-col gap-2",children:u.map(s=>e.jsx(z,{testId:`remote-session-${s.tabId}`,icon:"terminal",title:s.title||s.cwd,subtitle:s.cwd,badge:s.kind==="epic"&&s.tag?e.jsx(N,{tone:"accent",children:s.tag}):void 0,action:e.jsxs("div",{className:"flex items-center gap-2",children:[s.kind==="project"&&y&&e.jsx(E,{icon:"terminal",kind:"ghost",testId:`remote-session-terminal-${s.tabId}`,onClick:()=>y(s.cwd),children:"Terminal here"}),e.jsx(E,{kind:h===s.tabId?"soft":"ghost",testId:`remote-session-select-${s.tabId}`,onClick:()=>k(s.tabId),children:h===s.tabId?"Selected":"Select"})]})},s.tabId))},a)),p==="ready"&&x.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("textarea",{"data-testid":"remote-sessions-prompt",value:t,onChange:a=>j(a.target.value),rows:3,placeholder:h?`Prompt for the selected session on ${i}`:"Select a session first",className:"w-full rounded-lg bg-bg-hi border border-line px-3 py-2 text-[13px] text-fg placeholder:text-fg-faint"}),e.jsx("div",{className:"flex justify-end",children:e.jsx(E,{icon:"play",testId:"remote-sessions-send",onClick:()=>{R()},disabled:!T,children:"Send"})})]})]})}const q=260;function J({peerId:o,machineName:i,cwd:y,onClose:c}){const x=d.useRef(null),m=d.useRef(null),p=_(t=>t.show),[w,h]=d.useState(!1);d.useEffect(()=>{const t=x.current;if(!t)return;const j=crypto.randomUUID();let C=!0,I=!1,f=!1;const v=(r,l)=>{C&&p("error",`Remote terminal ${r} failed: ${l instanceof Error?l.message:String(l)}`)},S=(r,l)=>window.api.remoteClient.send(o,r,l),n=new D.Terminal({fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',fontSize:A.fontSize,lineHeight:1.2,cursorBlink:!0,allowProposedApi:!0,theme:O[A.theme]}),T=new H.FitAddon;n.loadAddon(T);const R=()=>{if(U(t.clientWidth,t.clientHeight))try{T.fit()}catch{}};n.open(t),R(),n.focus();const a=window.api.remoteClient.onEvent(r=>{if(r.peerId!==o)return;const l=r.payload??{};l.tabId===j&&(r.type==="event:pty:data"?typeof l.data=="string"&&n.write(l.data):r.type==="event:pty:exit"&&(I=!0,n.options.disableStdin=!0,n.write(`\r
|
|
2
2
|
\x1B[38;5;240m[remote session exited code=${l.exitCode??"?"}]\x1B[0m\r
|
|
3
3
|
`),h(!0)))}),u=n.onData(r=>{I||S("cmd:pty:write",{tabId:j,data:r}).catch(l=>v("write",l))}),s=n.onResize(({cols:r,rows:l})=>{I||S("cmd:pty:resize",{tabId:j,cols:r,rows:l}).catch(F=>v("resize",F))});S("cmd:pty:spawn",{tabId:j,cwd:y,cols:n.cols,rows:n.rows}).catch(r=>v("spawn",r)),m.current=()=>{f||(f=!0,S("cmd:pty:kill",{tabId:j}).catch(r=>v("kill",r)))};const g=()=>R();window.addEventListener("resize",g);const b=new ResizeObserver(()=>R());return b.observe(t),()=>{var r;window.removeEventListener("resize",g),b.disconnect(),a(),u.dispose(),s.dispose(),(r=m.current)==null||r.call(m),m.current=null,C=!1,n.dispose()}},[o,y,p]);const k=()=>{var t;(t=m.current)==null||t.call(m),c()};return e.jsxs("div",{"data-testid":"remote-terminal-panel",className:"bg-bg-hi border border-line rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-[18px] pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(L,{children:"Remote terminal"}),e.jsx(N,{tone:"accent",children:e.jsxs("span",{"data-testid":"remote-terminal-badge",children:["Remote: ",i]})}),w&&e.jsx(N,{tone:"dim",children:"exited"})]}),e.jsx(E,{kind:"ghost",onClick:k,testId:"remote-terminal-close",children:"Close"})]}),e.jsx("div",{ref:x,"data-testid":"remote-terminal-host",className:"w-full bg-bg",style:{height:q}})]})}const X="relay_client_auth_unavailable",K="device_offline",Q={win32:"Windows",darwin:"macOS",linux:"Linux"},B=o=>o?Q[o]??o:"OS unknown";function Y({peers:o,selectedId:i,onSelect:y}){return e.jsxs("div",{className:"w-[240px] shrink-0 border-r border-line p-3 space-y-2 overflow-y-auto","data-testid":"remote-view-switcher",children:[e.jsx(L,{children:"Machines"}),o.map(c=>{const x=c.status==="authenticated";return e.jsxs("button",{type:"button","data-testid":"remote-view-machine","aria-pressed":c.peerId===i,onClick:()=>y(c.peerId),className:`w-full text-left rounded-lg border px-3 py-2 transition-colors ${c.peerId===i?"bg-bg-hi border-accent/40":"bg-bg border-line hover:bg-bg-hi"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:c.machineName}),x?e.jsx(N,{tone:"good",children:"online"}):e.jsx(N,{tone:"dim",children:"offline"})]}),e.jsx("div",{className:"text-[11.5px] text-fg-faint",children:B(c.os)})]},c.peerId)})]})}function se({onOpenSettings:o}){const{peers:i,connect:y,confirmSas:c}=W(),[x,m]=d.useState(null),[p,w]=d.useState("sessions"),[h,k]=d.useState("");if(i.length===0)return e.jsxs("div",{className:"p-6 space-y-3","data-testid":"remote-view",children:[e.jsx($,{testId:"remote-view-empty",children:"No machines paired yet. Pair a machine in Settings → Phone remote."}),e.jsx(E,{testId:"remote-view-open-settings",onClick:o,children:"Open Settings"})]});const t=i.find(n=>n.peerId===x)??i[0],j=t.status==="authenticated",C=t.status==="failed"&&t.reason===X,I=t.status==="connecting",f=`Remote: ${t.machineName}`,v=n=>{m(n),w("sessions"),k("")},S=n=>{k(n),w("terminal")};return e.jsxs("div",{className:"flex h-full min-h-0","data-testid":"remote-view",children:[e.jsx(Y,{peers:i,selectedId:t.peerId,onSelect:v}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col p-4 gap-3 overflow-y-auto",children:[e.jsxs("div",{"data-testid":"remote-view-header",className:"flex items-center gap-2.5",children:[e.jsx(N,{tone:"accent",className:"",title:t.peerId,children:e.jsx("span",{"data-testid":"remote-view-header-badge",children:f})}),e.jsx("span",{className:"text-[12.5px] text-fg-faint",children:B(t.os)})]}),t.status==="pending_sas"&&t.sas&&e.jsx(G,{peer:"other machine",testId:"remote-view-sas",code:t.sas,onConfirm:()=>{c(t.peerId)}}),j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-2 border-b border-line pb-2",children:["sessions","terminal"].map(n=>e.jsxs("button",{type:"button","data-testid":`remote-view-tab-${n}`,onClick:()=>w(n),className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-[13px] font-semibold ${p===n?"bg-bg-hi text-fg border border-line":"text-fg-dim hover:text-fg"}`,children:[n==="sessions"?"Sessions":"Terminal",e.jsx(N,{tone:"accent",children:f})]},n))}),p==="sessions"?e.jsx(V,{peerId:t.peerId,machineName:t.machineName,onOpenTerminal:S},t.peerId):e.jsx(J,{peerId:t.peerId,machineName:t.machineName,cwd:h,onClose:()=>w("sessions")},t.peerId)]}):e.jsxs("div",{className:"space-y-2","data-testid":"remote-view-offline",children:[e.jsx($,{children:C?"The bilko.run relay does not support desktop clients yet":t.reason===K?`${t.machineName} is offline.`:`Not connected to ${t.machineName}.`}),!C&&t.status!=="pending_sas"&&e.jsx(z,{icon:"terminal",title:t.machineName,subtitle:t.peerId,action:e.jsx(E,{testId:"remote-view-connect",disabled:I,onClick:()=>{y(t.peerId)},children:I?"Connecting…":"Connect"})})]})]})]})}export{se as RemoteMachines};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ap as e,aj as x}from"./index-
|
|
1
|
+
import{ap as e,aj as x}from"./index-AVrhGmUO.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:l,leading:d}){const s=a&&!n&&!t;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:d}),t&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:t,children:t}),!a&&!t&&c&&e.jsx("span",{className:"text-fg-faint",children:x(c)}),a&&!t&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:l,disabled:!a||n,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:i,disabled:!s,className:`px-2.5 py-0.5 rounded border ${s?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:n?"Saving…":"Save"})]})}export{m as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aL as Pe,ax as ie,af as Te,aR as gs,ak as Ce,ae as le,ai as ee,aW as q,ba as Fe,b8 as pe,aF as f,ac as xe,bh as xs,ap as t,b as Ue,I as me,L as bt,q as ms,K as ge,u as bs,Q as ws,d as vs,U as js,aQ as ys,b7 as st,b0 as Ns,a7 as wt,av as Tt,bg as $e,G as qe,aC as _e,A as nt,aP as at,N as _t,w as Ot,p as Lt,r as ks,o as rt,y as it,O as Ss,f as re,g as H,ag as Ft,bb as Cs,aE as $s,aH as qt,bk as Bt,V as Ps,ay as vt,b1 as jt,n as ke,x as yt,aM as Nt,m as Ds,aU as As,Y as Ms,v as Ht,b3 as Rs,aZ as ye,H as Is,C as Es,bc as Ts,aG as _s,T as Os,bj as Ls,bd as kt,aO as Fs}from"./index-Ci1u018F.js";import{f as qs,a as Bs,s as Hs}from"./historyTotals-DFHzqLt7.js";import{l as Gs}from"./listSkills-C1aWKf0T.js";import{T as Vs}from"./Toggle-D1wsGE9S.js";import"./monaco-editor-BsIlgG7c.js";function Ws(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,c=[];function l(i){n.set(i,1),c.push(i);const r=s.get(i);for(const d of(r==null?void 0:r.dependsOn)??[]){if(!s.has(d))continue;const o=n.get(d);if(o===1){const p=c.indexOf(d);for(let u=p;u<c.length;u++)a.add(c[u])}else o===void 0&&l(d)}c.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||l(i.slug);return a}function Us(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function Qs(e,s,n){const a=new Set(e.map(o=>o.slug)),c=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&c.add(p);const l=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(l.has(p)||l.set(p,[]),l.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of l.values())o.sort(r);function d(o,p,u){const h=Us(o,s),g=n.has(o.slug);u.add(o.slug);const x=g?[]:(l.get(o.slug)??[]).filter(w=>!u.has(w.slug)).map(w=>d(w,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:x,blockers:h,blocked:h.some(w=>!w.missing&&w.status!=="completed"),hasNeedsReviewBlocker:h.some(w=>w.needsReview),hasMissingDep:h.some(w=>w.missing),cycle:g,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Gt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Ws(e),l=[],i=new Map,r=new Map;for(const o of e){const p=Pe(o,s),u=p.epicId??"__none__";i.has(u)||(l.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const d=l.map(o=>{const p=r.get(o),u=i.get(o),h=Qs(u,a,c),g={};for(const x of u){const w=x.status??"unknown";g[w]=(g[w]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:g,total:u.length}});return d.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),d}function Be(e){const s=[],n=a=>{s.push(a);for(const c of a.children)n(c)};for(const a of e)n(a);return s}function Ke(e){return String(e??"").replace(/^\d+-/,"")}function Oe(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Ke(a.slug),l=n.get(c);l?l.push(a.slug):n.set(c,[a.slug])}return e.map(a=>{const c=a.dependsOn;if(!c||c.length===0)return a;let l=!1;const i=c.map(r=>{if(s.has(r))return r;const d=n.get(Ke(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Ys=15e4,Xe=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Vt=e=>e==="failed"||e==="needs_review"||e==="quarantined",zs=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Wt(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function Ut(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Te(s)}function Js(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const c=Date.parse(a.finishedAt)-Date.parse(a.startedAt);c>0&&(s+=c,n++)}return n===0?Ys:s/n}function Le(e){const s=ie(e);return s===null?1/0:Number(s)}function Ze(e,s){const n=Le(e.slug)-Le(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ks(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Xs(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Xe(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Zs(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function en(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function tn(e,s){const n=new Map(e.map(l=>[l.row.slug,l.row.slug])),a=l=>{for(;n.get(l)!==l;)n.set(l,n.get(n.get(l))),l=n.get(l);return l};for(const l of e)for(const i of l.row.dependsOn??[])s.has(i)&&n.set(a(l.row.slug),a(i));const c=new Map;for(const l of e){const i=a(l.row.slug),r=c.get(i);r?r.push(l):c.set(i,[l])}return[...c.values()]}function sn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const c=n.get(a.row.planId);c?c.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return tn(e,s)}function nn(e,s,n,a){const c=[],l=[e];for(a.add(e.row.slug);l.length>0;){const i=l.pop();c.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const d=s.get(r);d&&l.push(d)}}return c}function an(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Ke(r.row.slug).startsWith("validate-")).sort((r,d)=>Ze({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:nn(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(d=>d.row.slug));for(const d of sn(i,r))c.push({nodes:d,validateSlug:null})}return c}function rn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function lt(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),c=s.avgDurationMs??Js(n),l=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(h=>i.get(h)===void 0||i.get(h).status==="completed"),d=new Map;n.filter(r).sort(Ze).forEach((u,h)=>d.set(u.slug,h));const o=Gt(n,s.sessions,n),p=[];for(const u of o){const h=Be(u.nodes),g=new Set(h.map(D=>D.row.slug)),x=new Map(h.map(D=>[D.row.slug,D])),w=[];for(const D of an(h,g)){const k=D.nodes,E=new Set(k.map(N=>N.row.slug)),m=new Map,T=new Set,$=N=>{const S=x.get(N);return(S.row.dependsOn??[]).filter(G=>E.has(G)&&!(S.cycle&&x.get(G).cycle))},P=N=>{const S=m.get(N);if(S!==void 0)return S;if(T.has(N))return 0;T.add(N);let G=0;for(const F of $(N))G=Math.max(G,P(F));return T.delete(N),m.set(N,G+1),G+1};for(const N of k)P(N.row.slug);const O=k.map(N=>{const S=N.row,G=(S.dependsOn??[]).filter(F=>g.has(F));return{slug:S.slug,title:S.title,status:S.status,stage:m.get(S.slug),prdNumber:ie(S.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:S.estimateMinutes??null,deps:G,crossEpicDeps:(S.dependsOn??[]).filter(F=>!g.has(F)),blockers:N.blockers,job:S}});O.sort(Ze);const J=O.reduce((N,S)=>Math.max(N,S.stage),0),W=new Map;for(const N of O){const S=N.job,G=x.get(N.slug),F=S.status;let U;if(Xe(F)){const b=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;U={kind:"done",trailing:b>0?Te(b):"",held:!1,blocked:!1}}else if(Se(F)){const b=S.startedAt?Math.max(0,a-Date.parse(S.startedAt)):null;U={kind:"running",trailing:b===null?"":Ut(S,b),held:!1,blocked:!1}}else if(F==="failed")U={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(F==="needs_review")U={kind:"review",trailing:"review",held:!1,blocked:!1};else if(F==="quarantined")U={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const b=G.blockers.filter(y=>!y.missing&&y.status!=="completed");if(b.length>0){const y=b.some(C=>zs(C.status)),A=b[0].slug;U={kind:"dep",trailing:`←${ie(A)??A}`,held:!y,blocked:y}}else if(S.heldReason)U={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const y=Ks(S),A=d.get(S.slug)??0;U=y>0?{kind:"retry",trailing:`${y} ${y===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Wt(A*c/l),held:!1,blocked:!1}}}W.set(N.slug,U)}const Q=[];for(let N=1;N<=J;N++){const S=O.filter(_=>_.stage===N),G=S.find(_=>{const X=W.get(_.slug).kind;return _.status==="pending"&&(X==="eta"||X==="retry")});if(G){const _=W.get(G.slug);_.kind="next",_.trailing="next"}let F=0,U=0,b=0,y=0,A=0,C=0;for(const _ of S){const X=W.get(_.slug);_.rowKind=X.kind,_.rowTrailing=X.trailing,Xe(_.status)?F++:Se(_.status)?U++:_.status==="pending"?(A++,X.held&&b++,X.blocked&&y++):Vt(_.status)&&C++}const R=F===S.length?"done":U>0?"running":y+C>0?"blocked":b>0?"held":"pending",L={n:N,rows:S,doneCount:F,runningCount:U,heldCount:b,blockedCount:y};Q.push({...L,state:R,summary:Zs(R,L,A,C)})}let K=0;for(const N of O){const S=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")K+=S;else if(Se(N.status)){const G=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;K+=Math.max(0,S-G)}}const te=O.reduce((N,S)=>Math.min(N,Le(S.slug)),1/0),se=O.reduce((N,S)=>Math.max(N,Le(S.slug)),-1/0),Y=u.known?gs(u.label).title:u.label,M=D.validateSlug?O.find(N=>N.slug===D.validateSlug):void 0,B=M&&rn(M.title)||Y;w.push({epicId:u.epicId,waveIndex:0,index:0,label:B,epicLabel:Y,validateSlug:D.validateSlug,width:Q.reduce((N,S)=>Math.max(N,S.rows.length),0),status:Xs(O),prdCount:O.length,stageCount:J,doneCount:Q.reduce((N,S)=>N+S.doneCount,0),runningCount:Q.reduce((N,S)=>N+S.runningCount,0),heldCount:Q.reduce((N,S)=>N+S.heldCount,0),blockedCount:Q.reduce((N,S)=>N+S.blockedCount,0),etaMs:K/l,stages:Q,_firstNum:te,_lastNum:se,_firstSlug:O[0].slug})}w.sort(en),w.forEach((D,k)=>{D.waveIndex=k+1});const j=w.filter(D=>D.validateSlug===null);j.forEach((D,k)=>{j.length>1&&(D.label=`${D.label} · plan ${k+1}/${j.length}`)});for(const D of w)p.push(D)}return p.sort((u,h)=>{if(u._lastNum!==h._lastNum)return u._lastNum>h._lastNum?-1:1;const g=(u.epicId??"").localeCompare(h.epicId??"");return g!==0?g:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:g,...x},w)=>({...x,index:w+1}))}function ln(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(g=>[g.slug,g])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const g of n)g.status==="pending"?(i++,(g.dependsOn??[]).every(w=>a.get(w)===void 0||a.get(w).status==="completed")&&l++):Se(g.status)?u++:g.status==="failed"?r++:g.status==="needs_review"?d++:g.status==="quarantined"?o++:g.status==="completed"&&g.finishedAt&&new Date(Date.parse(g.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const g of lt(n,{sessions:{},now:s}))for(const x of g.stages)if(x.rows.some(w=>Vt(w.status))){(h===null||x.n<h)&&(h=x.n);break}}return{readyNow:l,totalQueued:i,heldByDeps:i-l,needsYou:r+d+o,needsYouStage:h,failedCount:r,needsReviewCount:d,doneToday:p,inFlight:u}}function on(e){const s=new Map;for(const d of e.stages)for(const o of d.rows)s.set(o.slug,o);const n=d=>{var o;return((o=s.get(d))==null?void 0:o.cycle)===!0},a=new Map,c=new Set,l=(d,o)=>d.chain.length!==o.chain.length?d.chain.length>o.chain.length:d.est!==o.est?d.est>o.est:d.chain.join("\0")<o.chain.join("\0"),i=d=>{const o=a.get(d);if(o)return o;const p=s.get(d),u=p.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let h=null;for(const x of p.deps){if(!s.has(x)||p.cycle&&n(x))continue;const w=i(x);(!h||l(w,h))&&(h=w)}c.delete(d);const g=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,g),g};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const dn=300*6e4,cn={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function un(e){return cn[e]??e.replace(/_/g," ")}function Qt({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:l,paused:i,nextReset:r,utilization:d,utilizationWindow:o,effectiveConcurrency:p}=e;let u=0,h=0;for(const k of l)k.status==="pending"?u++:k.status==="completed"&&h++;const g=a.length,x=u+g,w=(p==null?void 0:p.cap)??5;if(g>0){const k=a.reduce((P,O)=>(P.startedAt??"")<(O.startedAt??"")?P:O),E=k.startedAt?s-Date.parse(k.startedAt):0,m=h+g,T=h+x,$=g>1?` · ${g}/${w} parallel`:"";return{kind:"running",line1:`Running ${m}/${T}${$} · ${Ce(E)}`,line2:g===1?k.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(i){const k=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":k!==null&&k>0?`auto-resume ${le(Date.parse(i.resumeAt))} (in ${ee(k)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};const j=c.firePolicy??"when-available";if(j==="manual")return{kind:"manual",line1:`Manual · ${u} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(j==="on-reset"){if(!r)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const k=Date.parse(r)+c.offsetMinutes*6e4,E=k-s;return{kind:"on-reset",line1:`On-reset · ${u} pending`,line2:E>0?`fires ${le(k)} (in ${ee(E)})`:"firing now…"}}const D=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${u} pending`,line2:"checking token availability…"};if(d>=D){const k=r?Date.parse(r)-s:null,E=o?un(o):null,m=k===null||Number.isNaN(k)||k>dn,T=k&&k>0?`resets ${le(Date.parse(r))} (in ${ee(k)})`:null;let $;return m?$=`${E??"binding"} window — long hold${T?`, ${T}`:", reset time unknown"}`:$=T?`${E?`${E} window `:""}next ${T}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${D}%)`,line2:$}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const pn=15e3,fn=new Set(["failed","needs_review","quarantined"]);function St(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>fn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function hn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${ee(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?ee(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function gn(e){const[s,n]=f.useState(null),a=st(),c=Ns(),l=a&&c;return f.useEffect(()=>{if(!l)return;let i=!0,r=!1,d=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,d=!1,i&&n(u)},u=>{r=!1,!d&&(d=!0,q.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,pn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const xn={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function mn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}const Qe="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function bn(e,s,n,a){var c;if(e==="agent"){const l=((c=a==null?void 0:a.cwd)==null?void 0:c.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,d=r==null?"":r>0?` — auto-resumes in ${ee(r)}`:" — auto-resume pending";return`Paused by an agent in ${l}${i}${d}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const l=new Date(s).getTime()-n;return l>0?`Paused for rate limit — resumes in ${ee(l)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function wn({now:e}){const s=Fe(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),l=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${l?r:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:bn(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${ee(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),c.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${d}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([h,g])=>`${h}=${g}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function vn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Fe(C=>C.snapshot),o=pe(C=>C.sessions),p=gn(e),[u,h]=f.useState(()=>Date.now()),[g,x]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return qs(30).then(R=>{if(!C||!R.ok||!R.data)return;const L=new Date,_=He=>String(He).padStart(2,"0"),X=`${L.getFullYear()}-${_(L.getMonth()+1)}-${_(L.getDate())}`;x(Bs(Hs(R.data,{day:X})))}),()=>{C=!1}},[]);const w=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(C=>!e||C.cwd===e),[d,e]),j=f.useMemo(()=>ln(w,u),[w,u]),D=f.useMemo(()=>{const C=lt(w,{sessions:o,now:u}),R=L=>C.filter(_=>_.status===L).length;return{active:R("active"),queued:R("queued"),draft:R("draft")}},[w,o,u]),k=f.useMemo(()=>{const C=new Date(u).toDateString(),R=[];for(const L of w)if(L.status==="completed"&&L.startedAt&&L.finishedAt&&new Date(Date.parse(L.finishedAt)).toDateString()===C){const _=Date.parse(L.finishedAt)-Date.parse(L.startedAt);_>0&&R.push(_)}return R.length?Math.round(R.reduce((L,_)=>L+_,0)/R.length/6e4):null},[w,u]);if(!d)return null;const E=p&&!p.unknown?p.verdict??null:null,m=p&&!p.unknown?p.slots??null:null,T=d.paused,$=mn((E==null?void 0:E.kind)??null,!!T,j.inFlight),P=xn[$],O=w.filter(C=>C.status==="pending").length,J=w.filter(C=>C.status==="running").length,W=Qt({snap:{...d,jobs:w},now:u,avgDurationMs:0,runningJobs:w.filter(C=>C.status==="running")}),Q=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:E?hn(E,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",K=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,u),te=p!=null&&p.lastDispatchAttemptAt?xe(Date.parse(p.lastDispatchAttemptAt),u):"never",se=[Q,W.line1,E?`dispatchable ${E.dispatchable} · needs_review ${E.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${ee(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${K} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${te} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
1
|
+
import{aL as Pe,ax as ie,af as Te,aR as gs,ak as Ce,ae as le,ai as ee,aW as q,ba as Fe,b8 as pe,aF as f,ac as xe,bh as xs,ap as t,b as Ue,I as me,L as bt,q as ms,K as ge,u as bs,Q as ws,d as vs,U as js,aQ as ys,b7 as st,b0 as Ns,a7 as wt,av as Tt,bg as $e,G as qe,aC as _e,A as nt,aP as at,N as _t,w as Ot,p as Lt,r as ks,o as rt,y as it,O as Ss,f as re,g as H,ag as Ft,bb as Cs,aE as $s,aH as qt,bk as Bt,V as Ps,ay as vt,b1 as jt,n as ke,x as yt,aM as Nt,m as Ds,aU as As,Y as Ms,v as Ht,b3 as Rs,aZ as ye,H as Is,C as Es,bc as Ts,aG as _s,T as Os,bj as Ls,bd as kt,aO as Fs}from"./index-AVrhGmUO.js";import{f as qs,a as Bs,s as Hs}from"./historyTotals-CX8mUxJY.js";import{l as Gs}from"./listSkills-C1aWKf0T.js";import{T as Vs}from"./Toggle-Chri4G19.js";import"./monaco-editor-BsIlgG7c.js";function Ws(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,c=[];function l(i){n.set(i,1),c.push(i);const r=s.get(i);for(const d of(r==null?void 0:r.dependsOn)??[]){if(!s.has(d))continue;const o=n.get(d);if(o===1){const p=c.indexOf(d);for(let u=p;u<c.length;u++)a.add(c[u])}else o===void 0&&l(d)}c.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||l(i.slug);return a}function Us(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function Qs(e,s,n){const a=new Set(e.map(o=>o.slug)),c=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&c.add(p);const l=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(l.has(p)||l.set(p,[]),l.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of l.values())o.sort(r);function d(o,p,u){const h=Us(o,s),g=n.has(o.slug);u.add(o.slug);const x=g?[]:(l.get(o.slug)??[]).filter(w=>!u.has(w.slug)).map(w=>d(w,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:x,blockers:h,blocked:h.some(w=>!w.missing&&w.status!=="completed"),hasNeedsReviewBlocker:h.some(w=>w.needsReview),hasMissingDep:h.some(w=>w.missing),cycle:g,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Gt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Ws(e),l=[],i=new Map,r=new Map;for(const o of e){const p=Pe(o,s),u=p.epicId??"__none__";i.has(u)||(l.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const d=l.map(o=>{const p=r.get(o),u=i.get(o),h=Qs(u,a,c),g={};for(const x of u){const w=x.status??"unknown";g[w]=(g[w]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:g,total:u.length}});return d.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),d}function Be(e){const s=[],n=a=>{s.push(a);for(const c of a.children)n(c)};for(const a of e)n(a);return s}function Ke(e){return String(e??"").replace(/^\d+-/,"")}function Oe(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Ke(a.slug),l=n.get(c);l?l.push(a.slug):n.set(c,[a.slug])}return e.map(a=>{const c=a.dependsOn;if(!c||c.length===0)return a;let l=!1;const i=c.map(r=>{if(s.has(r))return r;const d=n.get(Ke(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Ys=15e4,Xe=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Vt=e=>e==="failed"||e==="needs_review"||e==="quarantined",zs=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Wt(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function Ut(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Te(s)}function Js(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const c=Date.parse(a.finishedAt)-Date.parse(a.startedAt);c>0&&(s+=c,n++)}return n===0?Ys:s/n}function Le(e){const s=ie(e);return s===null?1/0:Number(s)}function Ze(e,s){const n=Le(e.slug)-Le(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ks(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Xs(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Xe(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Zs(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function en(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function tn(e,s){const n=new Map(e.map(l=>[l.row.slug,l.row.slug])),a=l=>{for(;n.get(l)!==l;)n.set(l,n.get(n.get(l))),l=n.get(l);return l};for(const l of e)for(const i of l.row.dependsOn??[])s.has(i)&&n.set(a(l.row.slug),a(i));const c=new Map;for(const l of e){const i=a(l.row.slug),r=c.get(i);r?r.push(l):c.set(i,[l])}return[...c.values()]}function sn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const c=n.get(a.row.planId);c?c.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return tn(e,s)}function nn(e,s,n,a){const c=[],l=[e];for(a.add(e.row.slug);l.length>0;){const i=l.pop();c.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const d=s.get(r);d&&l.push(d)}}return c}function an(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Ke(r.row.slug).startsWith("validate-")).sort((r,d)=>Ze({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:nn(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(d=>d.row.slug));for(const d of sn(i,r))c.push({nodes:d,validateSlug:null})}return c}function rn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function lt(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),c=s.avgDurationMs??Js(n),l=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(h=>i.get(h)===void 0||i.get(h).status==="completed"),d=new Map;n.filter(r).sort(Ze).forEach((u,h)=>d.set(u.slug,h));const o=Gt(n,s.sessions,n),p=[];for(const u of o){const h=Be(u.nodes),g=new Set(h.map(D=>D.row.slug)),x=new Map(h.map(D=>[D.row.slug,D])),w=[];for(const D of an(h,g)){const k=D.nodes,E=new Set(k.map(N=>N.row.slug)),m=new Map,T=new Set,$=N=>{const S=x.get(N);return(S.row.dependsOn??[]).filter(G=>E.has(G)&&!(S.cycle&&x.get(G).cycle))},P=N=>{const S=m.get(N);if(S!==void 0)return S;if(T.has(N))return 0;T.add(N);let G=0;for(const F of $(N))G=Math.max(G,P(F));return T.delete(N),m.set(N,G+1),G+1};for(const N of k)P(N.row.slug);const O=k.map(N=>{const S=N.row,G=(S.dependsOn??[]).filter(F=>g.has(F));return{slug:S.slug,title:S.title,status:S.status,stage:m.get(S.slug),prdNumber:ie(S.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:S.estimateMinutes??null,deps:G,crossEpicDeps:(S.dependsOn??[]).filter(F=>!g.has(F)),blockers:N.blockers,job:S}});O.sort(Ze);const J=O.reduce((N,S)=>Math.max(N,S.stage),0),W=new Map;for(const N of O){const S=N.job,G=x.get(N.slug),F=S.status;let U;if(Xe(F)){const b=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;U={kind:"done",trailing:b>0?Te(b):"",held:!1,blocked:!1}}else if(Se(F)){const b=S.startedAt?Math.max(0,a-Date.parse(S.startedAt)):null;U={kind:"running",trailing:b===null?"":Ut(S,b),held:!1,blocked:!1}}else if(F==="failed")U={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(F==="needs_review")U={kind:"review",trailing:"review",held:!1,blocked:!1};else if(F==="quarantined")U={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const b=G.blockers.filter(y=>!y.missing&&y.status!=="completed");if(b.length>0){const y=b.some(C=>zs(C.status)),A=b[0].slug;U={kind:"dep",trailing:`←${ie(A)??A}`,held:!y,blocked:y}}else if(S.heldReason)U={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const y=Ks(S),A=d.get(S.slug)??0;U=y>0?{kind:"retry",trailing:`${y} ${y===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Wt(A*c/l),held:!1,blocked:!1}}}W.set(N.slug,U)}const Q=[];for(let N=1;N<=J;N++){const S=O.filter(_=>_.stage===N),G=S.find(_=>{const X=W.get(_.slug).kind;return _.status==="pending"&&(X==="eta"||X==="retry")});if(G){const _=W.get(G.slug);_.kind="next",_.trailing="next"}let F=0,U=0,b=0,y=0,A=0,C=0;for(const _ of S){const X=W.get(_.slug);_.rowKind=X.kind,_.rowTrailing=X.trailing,Xe(_.status)?F++:Se(_.status)?U++:_.status==="pending"?(A++,X.held&&b++,X.blocked&&y++):Vt(_.status)&&C++}const R=F===S.length?"done":U>0?"running":y+C>0?"blocked":b>0?"held":"pending",L={n:N,rows:S,doneCount:F,runningCount:U,heldCount:b,blockedCount:y};Q.push({...L,state:R,summary:Zs(R,L,A,C)})}let K=0;for(const N of O){const S=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")K+=S;else if(Se(N.status)){const G=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;K+=Math.max(0,S-G)}}const te=O.reduce((N,S)=>Math.min(N,Le(S.slug)),1/0),se=O.reduce((N,S)=>Math.max(N,Le(S.slug)),-1/0),Y=u.known?gs(u.label).title:u.label,M=D.validateSlug?O.find(N=>N.slug===D.validateSlug):void 0,B=M&&rn(M.title)||Y;w.push({epicId:u.epicId,waveIndex:0,index:0,label:B,epicLabel:Y,validateSlug:D.validateSlug,width:Q.reduce((N,S)=>Math.max(N,S.rows.length),0),status:Xs(O),prdCount:O.length,stageCount:J,doneCount:Q.reduce((N,S)=>N+S.doneCount,0),runningCount:Q.reduce((N,S)=>N+S.runningCount,0),heldCount:Q.reduce((N,S)=>N+S.heldCount,0),blockedCount:Q.reduce((N,S)=>N+S.blockedCount,0),etaMs:K/l,stages:Q,_firstNum:te,_lastNum:se,_firstSlug:O[0].slug})}w.sort(en),w.forEach((D,k)=>{D.waveIndex=k+1});const j=w.filter(D=>D.validateSlug===null);j.forEach((D,k)=>{j.length>1&&(D.label=`${D.label} · plan ${k+1}/${j.length}`)});for(const D of w)p.push(D)}return p.sort((u,h)=>{if(u._lastNum!==h._lastNum)return u._lastNum>h._lastNum?-1:1;const g=(u.epicId??"").localeCompare(h.epicId??"");return g!==0?g:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:g,...x},w)=>({...x,index:w+1}))}function ln(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(g=>[g.slug,g])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const g of n)g.status==="pending"?(i++,(g.dependsOn??[]).every(w=>a.get(w)===void 0||a.get(w).status==="completed")&&l++):Se(g.status)?u++:g.status==="failed"?r++:g.status==="needs_review"?d++:g.status==="quarantined"?o++:g.status==="completed"&&g.finishedAt&&new Date(Date.parse(g.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const g of lt(n,{sessions:{},now:s}))for(const x of g.stages)if(x.rows.some(w=>Vt(w.status))){(h===null||x.n<h)&&(h=x.n);break}}return{readyNow:l,totalQueued:i,heldByDeps:i-l,needsYou:r+d+o,needsYouStage:h,failedCount:r,needsReviewCount:d,doneToday:p,inFlight:u}}function on(e){const s=new Map;for(const d of e.stages)for(const o of d.rows)s.set(o.slug,o);const n=d=>{var o;return((o=s.get(d))==null?void 0:o.cycle)===!0},a=new Map,c=new Set,l=(d,o)=>d.chain.length!==o.chain.length?d.chain.length>o.chain.length:d.est!==o.est?d.est>o.est:d.chain.join("\0")<o.chain.join("\0"),i=d=>{const o=a.get(d);if(o)return o;const p=s.get(d),u=p.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let h=null;for(const x of p.deps){if(!s.has(x)||p.cycle&&n(x))continue;const w=i(x);(!h||l(w,h))&&(h=w)}c.delete(d);const g=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,g),g};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const dn=300*6e4,cn={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function un(e){return cn[e]??e.replace(/_/g," ")}function Qt({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:l,paused:i,nextReset:r,utilization:d,utilizationWindow:o,effectiveConcurrency:p}=e;let u=0,h=0;for(const k of l)k.status==="pending"?u++:k.status==="completed"&&h++;const g=a.length,x=u+g,w=(p==null?void 0:p.cap)??5;if(g>0){const k=a.reduce((P,O)=>(P.startedAt??"")<(O.startedAt??"")?P:O),E=k.startedAt?s-Date.parse(k.startedAt):0,m=h+g,T=h+x,$=g>1?` · ${g}/${w} parallel`:"";return{kind:"running",line1:`Running ${m}/${T}${$} · ${Ce(E)}`,line2:g===1?k.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(i){const k=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":k!==null&&k>0?`auto-resume ${le(Date.parse(i.resumeAt))} (in ${ee(k)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};const j=c.firePolicy??"when-available";if(j==="manual")return{kind:"manual",line1:`Manual · ${u} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(j==="on-reset"){if(!r)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const k=Date.parse(r)+c.offsetMinutes*6e4,E=k-s;return{kind:"on-reset",line1:`On-reset · ${u} pending`,line2:E>0?`fires ${le(k)} (in ${ee(E)})`:"firing now…"}}const D=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${u} pending`,line2:"checking token availability…"};if(d>=D){const k=r?Date.parse(r)-s:null,E=o?un(o):null,m=k===null||Number.isNaN(k)||k>dn,T=k&&k>0?`resets ${le(Date.parse(r))} (in ${ee(k)})`:null;let $;return m?$=`${E??"binding"} window — long hold${T?`, ${T}`:", reset time unknown"}`:$=T?`${E?`${E} window `:""}next ${T}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${D}%)`,line2:$}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const pn=15e3,fn=new Set(["failed","needs_review","quarantined"]);function St(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>fn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function hn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${ee(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?ee(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function gn(e){const[s,n]=f.useState(null),a=st(),c=Ns(),l=a&&c;return f.useEffect(()=>{if(!l)return;let i=!0,r=!1,d=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,d=!1,i&&n(u)},u=>{r=!1,!d&&(d=!0,q.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,pn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const xn={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function mn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}const Qe="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function bn(e,s,n,a){var c;if(e==="agent"){const l=((c=a==null?void 0:a.cwd)==null?void 0:c.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,d=r==null?"":r>0?` — auto-resumes in ${ee(r)}`:" — auto-resume pending";return`Paused by an agent in ${l}${i}${d}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const l=new Date(s).getTime()-n;return l>0?`Paused for rate limit — resumes in ${ee(l)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function wn({now:e}){const s=Fe(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),l=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${l?r:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:bn(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${ee(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),c.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${d}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([h,g])=>`${h}=${g}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function vn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Fe(C=>C.snapshot),o=pe(C=>C.sessions),p=gn(e),[u,h]=f.useState(()=>Date.now()),[g,x]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return qs(30).then(R=>{if(!C||!R.ok||!R.data)return;const L=new Date,_=He=>String(He).padStart(2,"0"),X=`${L.getFullYear()}-${_(L.getMonth()+1)}-${_(L.getDate())}`;x(Bs(Hs(R.data,{day:X})))}),()=>{C=!1}},[]);const w=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(C=>!e||C.cwd===e),[d,e]),j=f.useMemo(()=>ln(w,u),[w,u]),D=f.useMemo(()=>{const C=lt(w,{sessions:o,now:u}),R=L=>C.filter(_=>_.status===L).length;return{active:R("active"),queued:R("queued"),draft:R("draft")}},[w,o,u]),k=f.useMemo(()=>{const C=new Date(u).toDateString(),R=[];for(const L of w)if(L.status==="completed"&&L.startedAt&&L.finishedAt&&new Date(Date.parse(L.finishedAt)).toDateString()===C){const _=Date.parse(L.finishedAt)-Date.parse(L.startedAt);_>0&&R.push(_)}return R.length?Math.round(R.reduce((L,_)=>L+_,0)/R.length/6e4):null},[w,u]);if(!d)return null;const E=p&&!p.unknown?p.verdict??null:null,m=p&&!p.unknown?p.slots??null:null,T=d.paused,$=mn((E==null?void 0:E.kind)??null,!!T,j.inFlight),P=xn[$],O=w.filter(C=>C.status==="pending").length,J=w.filter(C=>C.status==="running").length,W=Qt({snap:{...d,jobs:w},now:u,avgDurationMs:0,runningJobs:w.filter(C=>C.status==="running")}),Q=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:E?hn(E,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",K=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,u),te=p!=null&&p.lastDispatchAttemptAt?xe(Date.parse(p.lastDispatchAttemptAt),u):"never",se=[Q,W.line1,E?`dispatchable ${E.dispatchable} · needs_review ${E.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${ee(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${K} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${te} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
2
2
|
`),Y=d.utilization,M=d.pollHealth,B=M!=null&&!M.lastPollOk,N=xs(d.utilizationWindow),S=d.nextReset?Date.parse(d.nextReset):null,G=S?S>u?ee(S-u):"soon":"—",F=d.effectiveConcurrency,U=(F==null?void 0:F.cap)??5,b=(F==null?void 0:F.source)==="env",y=d.config.firePolicy??"when-available",A=O===0&&J===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Ue,{height:40,testId:"queue-health-header",className:"gap-3",children:[t.jsx("h1",{className:"m-0 font-serif text-[21px] font-semibold leading-none tracking-tight text-fg",children:"Scheduler"}),t.jsx("span",{className:"w-px h-[20px] bg-rule-structural","aria-hidden":"true"}),t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-[12.5px] font-medium ${P.text}`,"data-testid":"scheduler-state-word","data-state":$,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${P.dot}`,"aria-hidden":"true"}),$]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[j.inFlight," in flight · ",j.heldByDeps," held · last batch ",K]}),t.jsxs(me,{title:se,testId:"scheduler-verdict-info",popoverTestId:"scheduler-info-popover",children:[t.jsx("pre",{className:"m-0 mb-2 whitespace-pre-wrap font-mono text-[11.5px] text-fg-dim",children:se}),bt.scheduler&&t.jsx(ms,{content:bt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(q.fromOutcome).catch(()=>q.error("Failed to rescan")),title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",className:Qe,children:"Refresh"}),T?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:Qe,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:Qe,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),disabled:A,title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",className:"px-3 py-1.5 rounded bg-accent text-white text-[12.5px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",children:"Fire next batch"})]})]}),t.jsx(wn,{now:u}),t.jsxs(Ue,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(ge,{testId:"kpi-window",label:N?`${N} used`:"Window used",info:B?`Billing poll failing — this reading may be outdated (last good reading ${xe(M.lastPollAt,u)}). Machine-wide ${N??"binding"} window.`:`Share of the machine-wide ${N??"binding"} billing window consumed — the window closest to its limit.`,value:Y==null?"—":`${Math.round(Y)}%`,sub:`resets in ${G}`,third:t.jsx(bs,{pct:Y??0,tone:B?"bg-amber-500":"bg-accent"})}),t.jsx(ge,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(m==null?void 0:m.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:m?`${m.inUse}/${m.total}`:"—",sub:"in use",third:m?t.jsx(ws,{filled:m.inUse,total:m.total}):null}),t.jsx(ge,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:j.readyNow,sub:`of ${j.totalQueued} queued`,third:`${j.heldByDeps} held by deps`}),j.needsYou>0?t.jsx(ge,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:St,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / needs-review / quarantined row",children:j.needsYou}),sub:t.jsx("button",{type:"button",onClick:St,className:"hover:underline",children:j.needsYouStage!=null?`blocking stage ${j.needsYouStage}`:"need attention"}),third:[j.failedCount>0&&`${j.failedCount} failed`,j.needsReviewCount>0&&`${j.needsReviewCount} needs review`,j.needsYou-j.failedCount-j.needsReviewCount>0&&`${j.needsYou-j.failedCount-j.needsReviewCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(ge,{testId:"kpi-needs-you",label:"Needs you",value:t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[15px]",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-sage","aria-hidden":"true"}),"all clear"]}),third:"0 failed · 0 needs review"}),t.jsx(ge,{testId:"kpi-done",label:"Done today",value:j.doneToday,sub:k!=null?`avg ${k}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:g})}),t.jsx(ge,{testId:"kpi-concurrency",label:"Concurrency",info:"Start-jobs policy, concurrency cap and utilization threshold",infoTestId:"kpi-concurrency-info",infoAlignRight:!0,infoContent:t.jsxs("label",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg",children:"Start jobs"}),t.jsxs("select",{"data-testid":"kpi-fire-policy",value:y,onChange:C=>window.api.schedule.setConfig({firePolicy:C.target.value}),className:"border border-line bg-bg-hi rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.","aria-label":"Start jobs policy",children:[t.jsx("option",{value:"when-available",children:"when available"}),t.jsx("option",{value:"on-reset",children:"only on reset"}),t.jsx("option",{value:"manual",children:"manually"})]})]}),value:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(js,{value:U,min:0,max:10,disabled:b,onChange:C=>{ys(C).catch(R=>{q.error(`Could not set session slots: ${R instanceof Error?R.message:String(R)}`)})},title:b?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),b&&t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-600 bg-amber-400/10 border border-amber-400/30 rounded px-1 py-0",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"})]}),sub:"at once",third:y==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(vs,{value:d.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Holds new dispatches when the highest of the 5-hour and weekly usage windows is at/above this percent (when-available policy only). Not the executor rate-limit pause — click to edit",onCommit:C=>window.api.schedule.setConfig({utilizationThreshold:C})})]}):null})]}),t.jsxs(Ue,{height:30,testId:"scheduler-plans-toolbar",className:"gap-3",children:[t.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:"Plans"}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-plans-meta",children:[D.active," active · ",D.queued," queued · ",D.draft," draft · ",w.length," PRDs"]}),t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[t.jsx("span",{ref:r,className:"contents","data-testid":"scheduler-plan-tools"}),t.jsx("input",{type:"text",value:a,onChange:C=>c(C.target.value),placeholder:"filter PRDs…","aria-label":"Filter PRDs by title, slug, or project","data-testid":"scheduler-filter-input",className:"w-[180px] bg-bg-hi border border-line rounded px-2 py-0.5 text-[12px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),t.jsx("span",{className:"inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Plan view mode",children:[["graph","Graph"],["list","List"],["critical","Critical path"]].map(([C,R])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${C}`,"aria-pressed":l===C&&s==="queue",onClick:()=>{i(C),n("queue")},className:`px-2 py-0.5 text-[12px] ${l===C&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:R},C))}),t.jsx("span",{className:"w-px h-[16px] bg-rule-structural","aria-hidden":"true"}),[["prds","PRDs","Authored PRD source files on disk — edit, lint, archive, or queue them."],["history","History","The last 50 completed and failed jobs."],["machine","Machine","Machine-wide config that applies to every project — not this project’s live queue."]].map(([C,R,L])=>t.jsx("button",{type:"button",onClick:()=>n(C),"aria-pressed":s===C,title:L,className:`text-[12.5px] ${s===C?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:R},C))]})]})]})}function Yt({options:e,value:s,onChange:n,pillPadding:a="px-3 py-1.5"}){return t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:e.map(c=>{const l=c.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(c.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${l?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[c.label,c.count!==void 0&&t.jsxs("span",{children:[" ",c.count]})]},c.value)})})}function zt(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function jn(e){return Be([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Jt(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:jn(s)}))}function yn(e){const s=new Map;for(const n of e){const a=Jt(n);n.nodes.forEach((c,l)=>{const i=a.filter((r,d)=>d!==l);for(const r of Be([c]))s.set(r.row.slug,i)})}return s}function Kt({job:e,headChoices:s}){const[n,a]=f.useState(!1),c=f.useCallback((l,i)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:l,dependsOn:i}).then(q.fromOutcome).catch(()=>q.error("Failed to change disposition")).finally(()=>a(!1))},[e.slug,e.cwd]);return e.disposition!=="append"&&s.length===0?null:t.jsxs("select",{"data-testid":"job-row-disposition-control",disabled:n,value:"",onChange:l=>{const i=l.target.value;if(i==="__new-head__")c("new-head");else if(i){const r=s.find(d=>d.rootSlug===i);r&&c("append",r.terminals)}},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border border-line/60 rounded px-1.5 py-0.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:"Change this wave's relationship to the rest of the Epic's plan",children:[t.jsx("option",{value:"",disabled:!0,children:"change disposition…"}),e.disposition==="append"&&t.jsx("option",{value:"__new-head__",children:"promote to new head"}),s.map(l=>t.jsxs("option",{value:l.rootSlug,children:["attach behind: ",zt(l.label,40)]},l.rootSlug))]})}function Nn(e,s,n=null){if(s.length===0||e.length===0)return e;const a=new Set,c=new Set;for(const i of e){a.add(i.slug);for(const r of wt(i))c.add(r)}const l=[];for(const i of s)i.archived!==!0||a.has(i.slug)||n&&i.cwd!==n||wt(i).some(r=>c.has(r))&&(a.add(i.slug),l.push({slug:i.slug,title:i.title,cwd:i.cwd,parallelGroup:i.parallelGroup,estimateMinutes:i.estimateMinutes,bodyPreview:"",status:i.archivedStatus??"completed",runId:null,startedAt:null,finishedAt:null,exitCode:null,error:null,dependsOn:i.dependsOn??void 0,sourcePromptId:i.sourcePromptId??null,epicId:i.epicId??null,synthetic:!0}));return l.length===0?e:[...e,...l]}const kn=[],Sn=new Set(["failed","needs_review","quarantined"]);function Cn(e){switch(e.status){case"completed":case"skipped":return"bg-sage";case"running":case"investigating":return"bg-accent";case"failed":return"bg-accent";case"needs_review":return"bg-butter";case"quarantined":return"bg-butter/60";default:return e.rowKind==="eta"||e.rowKind==="next"||e.rowKind==="retry"?"border border-fg-faint bg-transparent":"bg-fg-faint/40"}}function $n(e){switch(e.status){case"running":case"investigating":return"bg-butter/10";case"failed":return"bg-accent/10";case"needs_review":return"bg-butter/25";default:return""}}function Pn(e){switch(e.rowKind){case"running":case"dep":case"failed":return"text-accent";case"review":return"text-butter font-semibold";default:return"text-fg-faint"}}function Dn({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:c=kn}){const[l,i]=f.useState(!1),r=e.job,d=s!==null&&e.rowKind==="running"?Ut(r,s):e.rowTrailing,o=e.status==="completed"||e.status==="skipped",p=e.rowKind==="dep"&&e.blockers.some(h=>!h.missing&&h.status!==null&&Sn.has(h.status)),u=o||p;return t.jsxs("div",{role:"listitem","data-testid":"prd-row","data-slug":e.slug,className:"border-t border-rule-inner first:border-t-0",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":r.status,"data-job-index":n,onClick:()=>i(h=>!h),onFocus:()=>a(n),"aria-expanded":l,"aria-label":`${e.prdNumber?`PRD ${e.prdNumber}, `:""}${r.title}, ${r.status}${d?`, ${d}`:""}`,title:r.title,className:`w-full h-[31px] py-1 px-2 text-left flex items-center gap-1.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${$n(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${Cn(e)}`}),t.jsx("span",{className:"shrink-0 font-mono text-[10.5px] text-fg-faint w-[30px]",children:e.prdNumber?`#${e.prdNumber}`:""}),t.jsx("span",{className:`flex-1 min-w-0 truncate text-[12.5px] leading-tight ${u?"text-fg-faint":"text-fg font-medium"}`,children:r.title}),t.jsx("span",{"data-testid":"prd-row-trailing",className:`shrink-0 font-mono text-[10.5px] ${Pn(e)}`,children:d})]}),l&&t.jsx(An,{row:e,elapsedMs:s,headChoices:c})]})}const Xt=f.memo(Dn);function An({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[c,l]=f.useState(!1),i=pe(g=>g.sessions),r=f.useMemo(()=>Pe(a,i),[a,i]),d=r.known&&r.epicId?i[r.epicId]:null,o=f.useCallback(g=>Tt(g),[]),p="font-mono text-[11.5px] text-fg-dim leading-snug break-words",u="text-[12px] font-semibold bg-transparent border-0 cursor-pointer p-0",h=a.error?a.error.split(`
|
|
3
3
|
`)[0]:null;return t.jsxs("div",{"data-testid":"prd-row-detail",className:"px-3 py-2 bg-bg-elev/50 border-t border-rule-inner flex flex-col gap-1",children:[t.jsxs("div",{className:p,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${$e(a.verifierVerdict)}`,a.startedAt&&` · started ${le(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${le(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${p} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(g=>g.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:p,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(g=>`${g.slug} (${g.missing?"missing":(g.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${p} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),h&&t.jsx("div",{className:`${p} text-accent/80`,children:h}),!a.synthetic&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 pt-0.5",children:[d&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:d.goalText,onClick:()=>o(d.id),className:`${u} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>l(!0),className:`${u} text-fg-dim hover:text-fg`,children:"view log →"}),a.status==="quarantined"&&t.jsx("button",{type:"button","data-testid":"job-row-adopt-prd",title:"Stamp this PRD's provenance so the scheduler will run it — no unstamped PRD runs automatically.",onClick:()=>{window.api.schedule.adoptPrd(a.slug).then(q.fromOutcome).catch(()=>q.error("Failed to adopt PRD"))},className:`${u} text-accent hover:text-accent/80`,children:"adopt PRD →"}),a.status!=="pending"&&a.status!=="running"&&a.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(a.slug,a.cwd??void 0),className:`${u} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(Kt,{job:a,headChoices:n})]}),c&&a.runId&&t.jsx(qe,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>l(!1)})]})}const ue=190,Mn=7,Rn=5,In=[],Zt=e=>e==="completed"||e==="skipped",es=e=>e==="running"||e==="investigating",ts=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Me(e){return es(e.status)?0:ts(e.status)?1:Zt(e.status)?3:2}const En={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},Tn={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function _n(e,s){return e.every(n=>Zt(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&ts(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function On({stage:e,epicId:s,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i}){const[r,d]=f.useState(!1),o=f.useMemo(()=>e.rows.filter(m=>!(a.has(m.slug)&&(m.status==="completed"||m.status==="failed"))).map((m,T)=>({r:m,i:T})).sort((m,T)=>Me(m.r)-Me(T.r)||m.i-T.i).map(m=>m.r),[e.rows,a]),p=f.useMemo(()=>o.filter(m=>Me(m)<=1).length,[o]),u=Math.max(e.state==="done"?Rn:Mn,p),h=r?o:o.slice(0,u),g=r?[]:o.slice(u),x=o.find(m=>m.status==="failed"),w=o.find(m=>m.status==="needs_review"),j=p>0&&(x!==void 0||w!==void 0),D=h.reduce((m,T,$)=>Me(T)<=1?$:m,-1),k=m=>t.jsx(Xt,{row:m,elapsedMs:es(m.status)&&m.job.startedAt?n-Date.parse(m.job.startedAt):null,listIndex:c.get(m.slug)??0,onFocused:i,headChoices:l.get(m.slug)??In},m.slug),E="flex-1 min-w-0 truncate h-[24px] text-[11.5px] font-medium text-fg-dim hover:text-fg border border-rule-structural rounded-sm bg-transparent cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"stage-column","data-stage":e.n,style:{width:ue},className:"shrink-0 border-l border-rule-structural first:border-l-0 flex flex-col self-stretch",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center gap-1.5 px-2 border-b border-rule-inner","data-testid":"stage-header",children:[t.jsx("span",{"aria-hidden":"true",className:`w-[7px] h-[7px] rounded-full shrink-0 ${Tn[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${En[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(me,{title:"Rows in this stage are failed / need review / are quarantined, or wait on one that is."}),t.jsx("span",{"data-testid":"stage-summary",className:"ml-auto font-mono text-[10.5px] text-fg-dim truncate",children:e.summary})]}),t.jsx("div",{role:"presentation",children:h.map((m,T)=>t.jsxs("div",{children:[k(m),j&&T===D&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[x&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${x.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(x.slug,x.job.cwd??void 0).then($=>{$.ok||q.error($.error??`Failed to reset ${x.slug}`)}).catch(()=>q.error(`Failed to reset ${x.slug}`))},className:E,children:["Retry ",x.prdNumber?`#${x.prdNumber}`:x.slug]}),w&&t.jsxs("button",{type:"button","data-testid":"stage-review",disabled:!s,title:s?"Open the authoring Epic — a needs_review PRD is a question routed back to it":"No authoring Epic recorded for this plan",onClick:()=>{s&&Tt(s)},className:E,children:["Review ",w.prdNumber?`#${w.prdNumber}`:w.slug]})]})]},m.slug))}),(g.length>0||r&&o.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":r,onClick:()=>d(m=>!m),className:"mt-auto h-[26px] border-t border-rule-inner font-mono text-[11px] text-fg-faint hover:text-fg-dim bg-transparent cursor-pointer",children:r?"show less ▴":`${_n(g,e.n)} ▾`})]})}const we=6,Ye=4,Ee=4,Ct=12,$t=5,ss=2,Pt=4,Ln={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function Fn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function qn(e){const s=[],n=[],a=[];let c=$t;for(const l of e){const i=Math.max(1,Math.ceil(l.rows.length/Ee));n.push(c),a.push(i*we),l.rows.forEach((r,d)=>{s.push({x:c+Math.floor(d/Ee)*we,y:ss+d%Ee*we,tone:Fn(r.status),title:`${r.prdNumber?`#${r.prdNumber}`:r.slug} ${r.title} — ${r.status}`})}),c+=i*we+Ct}return{dots:s,stageX:n,stageW:a,width:Math.max(0,c-Ct)+$t}}function ve(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const et=e=>e==="running"||e==="investigating",tt=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Bn({stages:e,first:s,perView:n,onSeek:a}){const c=f.useMemo(()=>qn(e),[e]),l=f.useMemo(()=>ve(e,et)>=0,[e]),i=f.useMemo(()=>ve(e,tt)>=0,[e]),r=f.useRef(!1),d=e.length,o=Math.min(d-1,s+n-1),p=c.stageX[Math.min(s,d-1)]??0,u=(c.stageX[o]??0)+(c.stageW[o]??0),h=x=>{const w=x.currentTarget.getBoundingClientRect(),j=x.clientX-w.left;let D=0;for(let k=0;k<d;k++)c.stageX[k]<=j&&(D=k);a(Math.max(0,Math.min(d-1,D-Math.floor(n/2))))},g="px-2 h-[20px] text-[11.5px] disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"plan-minimap",className:"h-[28px] flex items-center gap-3 px-3 border-t border-rule-inner",children:[t.jsxs("span",{className:"shrink-0 flex items-center gap-1 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Whole graph",t.jsx(me,{title:"Every PRD in this plan as one dot, grouped by stage. The rust box is the range of stages shown below — drag it to scroll."})]}),t.jsxs("div",{"data-testid":"plan-minimap-dots",role:"presentation",className:"relative shrink min-w-0 overflow-hidden cursor-ew-resize touch-none",style:{width:c.width,height:Ee*we-(we-Ye)+2*ss},onPointerDown:x=>{var w,j;r.current=!0,(j=(w=x.currentTarget).setPointerCapture)==null||j.call(w,x.pointerId),h(x)},onPointerMove:x=>{r.current&&h(x)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},children:[c.dots.map((x,w)=>t.jsx("span",{title:x.title,"data-tone":x.tone,className:`absolute rounded-[1px] ${Ln[x.tone]}`,style:{left:x.x,top:x.y,width:Ye,height:Ye}},w)),t.jsx("span",{"data-testid":"plan-minimap-brush","aria-hidden":"true",className:"absolute top-0 bottom-0 border border-accent bg-accent/10 rounded-[2px] pointer-events-none",style:{left:p-Pt,width:u-p+2*Pt}})]}),t.jsxs("span",{className:"ml-auto shrink-0 font-mono text-[11.5px] text-fg-faint","data-testid":"plan-minimap-range",children:["stages ",Math.min(s+1,d),"–",o+1," of ",d]}),t.jsxs("span",{className:"shrink-0 inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Jump the stage window",children:[t.jsx("button",{type:"button","data-testid":"minimap-running",disabled:!l,title:l?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(ve(e,et)),className:`${g} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!i,title:i?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(ve(e,tt)),className:`${g} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const Hn=148;function Gn({stages:e,onSeek:s}){if(e.length===0)return null;const n=e[0].n,a=e[e.length-1].n;return t.jsxs("div",{"data-testid":"further-stages",style:{width:Hn},className:"shrink-0 border-l border-rule-structural flex flex-col",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center px-2 border-b border-rule-inner text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Stage ",n,"–",a]}),t.jsxs("div",{className:"h-[22px] shrink-0 flex items-center gap-1 px-2 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Further stages",t.jsx(me,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(c=>{const l=c.rows.length===0?0:c.doneCount/c.rows.length*100;return t.jsxs("button",{type:"button","data-testid":"further-stage-row","data-stage":c.n,title:`${c.summary} — scroll to stage ${c.n}`,onClick:()=>s(c.n-1),className:"h-[26px] px-2 flex items-center gap-2 border-t border-rule-inner bg-transparent hover:bg-bg-hi cursor-pointer text-left",children:[t.jsxs("span",{className:"font-mono text-[10.5px] text-fg-dim w-[50px] whitespace-nowrap shrink-0",children:["stage ",c.n]}),t.jsx("span",{role:"progressbar","aria-valuenow":c.doneCount,"aria-valuemin":0,"aria-valuemax":c.rows.length,className:"flex-1 h-[4px] rounded-sm bg-rule-inner overflow-hidden",children:t.jsx("span",{className:"block h-full bg-sage",style:{width:`${l}%`}})})]},c.n)})]})}const Vn=[],Wn=e=>e==="running"||e==="investigating";function Un(e){const s=on(e),n=new Map,a=new Map;for(const r of e.stages){a.set(r.n,r.rows.length);for(const d of r.rows)n.set(d.slug,d)}const c=new Map;let l=0;const i=[];for(const r of s){const d=n.get(r);l+=d.estimateMinutes??0,c.set(d.stage,(c.get(d.stage)??0)+1),i.push({row:d,totalMinutes:l,othersInStage:0})}for(const r of i)r.othersInStage=(a.get(r.row.stage)??0)-(c.get(r.row.stage)??0);return i}function Qn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:c}){const l=f.useMemo(()=>Un(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:l.map(({row:i,totalMinutes:r,othersInStage:d})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":i.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(Xt,{row:i,elapsedMs:Wn(i.status)&&i.job.startedAt?s-Date.parse(i.job.startedAt):null,listIndex:n.get(i.slug)??0,onFocused:c,headChoices:a.get(i.slug)??Vn})}),t.jsxs("span",{"data-testid":"critical-est",className:"shrink-0 h-[31px] px-3 flex items-center gap-2 font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:[t.jsx("span",{title:"estimateMinutes",children:i.estimateMinutes?`${i.estimateMinutes}m`:"—"}),t.jsxs("span",{className:"text-fg-dim",title:"Running total along the chain",children:["Σ ",r,"m"]})]})]}),d>0&&t.jsxs("div",{"data-testid":"critical-others",className:"h-[22px] px-3 flex items-center font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:["stage ",i.stage," · +",d," not on the critical path"]})]},i.slug))})}const Dt=1,At=1350,Yn={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},zn={active:{label:"ACTIVE",cls:"bg-accent text-white border border-accent"},queued:{label:"QUEUED",cls:"text-fg-dim border border-fg-faint"},done:{label:"DONE",cls:"text-sage-dark border border-sage"},draft:{label:"DRAFT",cls:"text-fg-faint border border-dashed border-fg-faint"}},Jn=e=>String(e).padStart(2,"0");function Kn({plan:e}){const s=Math.max(1,e.prdCount),n=e.doneCount/s*100,a=e.runningCount/s*100;return t.jsxs("span",{"data-testid":"plan-progress",role:"progressbar","aria-valuenow":e.doneCount,"aria-valuemin":0,"aria-valuemax":e.prdCount,className:"flex w-[160px] h-[5px] rounded-sm overflow-hidden bg-rule-inner shrink-0",children:[t.jsx("span",{className:"h-full bg-sage",style:{width:`${n}%`}}),t.jsx("span",{className:"h-full bg-accent",style:{width:`${a}%`}})]})}function Xn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i,onOpenPrds:r}){var se,Y;const[d,o]=f.useState(e.status==="active"||e.status==="queued"),[p,u]=f.useState(!1),h=f.useRef(null),[g,x]=f.useState(0),[w,j]=f.useState(At),D=f.useMemo(()=>{const M=ve(e.stages,et);return M>=0?M:Math.max(0,ve(e.stages,tt))},[e.stages]);f.useLayoutEffect(()=>{if(!d)return;const M=h.current,B=(M==null?void 0:M.clientWidth)||At,N=Math.max(0,Math.min(D,e.stageCount-Math.max(1,Math.ceil(B/ue))));M!=null&&M.clientWidth&&j(M.clientWidth),M&&(M.scrollLeft=N*ue),x(N)},[d]);const k=f.useMemo(()=>{let M=null;for(const B of e.stages)for(const N of B.rows){if(!N.job.runId)continue;const S=N.job.finishedAt?Date.parse(N.job.finishedAt):0;(!M||S>M.at)&&(M={runId:N.job.runId,slug:N.slug,title:N.title,at:S})}return M},[e.stages]),E=_e((Y=(se=e.stages[0])==null?void 0:se.rows[0])==null?void 0:Y.job.cwd)??"—",m=zn[e.status],T=Math.max(1,Math.ceil(w/ue)),$=Math.max(0,Math.min(g-Dt,e.stageCount)),P=Math.min(e.stageCount,g+T+Dt),O=M=>{const B=Math.max(0,Math.min(e.stageCount-1,M));h.current&&(h.current.scrollLeft=B*ue),x(B)},J=Math.min(e.stageCount,g+T),W=M=>{const B=M.currentTarget,N=Math.floor(B.scrollLeft/ue);N!==g&&x(N),B.clientWidth&&B.clientWidth!==w&&j(B.clientWidth)},Q="h-[24px] px-3 text-[12px] font-medium text-fg border border-rule-structural rounded-sm bg-transparent hover:bg-bg-hi cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shrink-0",K=(()=>{switch(e.status){case"active":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Pauses the WHOLE scheduler (machine-wide) — there is no per-plan pause.",onClick:()=>{window.api.schedule.pause().catch(()=>q.error("Failed to pause the scheduler"))},className:Q,children:"Pause plan"});case"queued":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Fires the next scheduler batch machine-wide (force tick) — it does not target this plan.",onClick:()=>{window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire the next batch"))},className:Q,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!k,title:k?`Open the run log of ${k.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>u(!0),className:Q,children:"View run"});case"draft":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Open the PRDs sub-view on this plan's first PRD (the PRDs view has no per-Epic filter).",onClick:()=>{var M,B;return r==null?void 0:r(((B=(M=e.stages[0])==null?void 0:M.rows[0])==null?void 0:B.slug)??null)},className:Q,children:"Schedule…"})}})(),te=e.etaMs>0?` · ${Wt(e.etaMs)} left`:"";return t.jsxs("section",{"data-testid":"plan-band","data-epic-id":e.epicId??"","data-plan-status":e.status,className:`border-l-[3px] ${Yn[e.status]} border-b border-rule-structural`,children:[t.jsxs("div",{className:"h-[32px] flex items-center gap-2.5 px-3","data-testid":"plan-header",children:[t.jsx("button",{type:"button","aria-expanded":d,"aria-label":d?"Collapse plan":"Expand plan","data-testid":"plan-toggle",onClick:()=>o(M=>!M),className:"shrink-0 w-[14px] text-[11px] text-fg-faint hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:d?"▾":"▸"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint shrink-0",children:Jn(e.index)}),t.jsx("span",{className:"font-serif text-[15px] font-bold text-fg truncate shrink-0 max-w-[320px]",title:e.epicLabel!==e.label?`${e.label} — ${e.epicLabel}`:e.label,"data-testid":"plan-label",children:e.label}),t.jsx("span",{"data-testid":"plan-chip",className:`shrink-0 rounded-sm px-1.5 py-[1px] text-[10px] font-bold tracking-wide ${m.cls}`,children:m.label}),t.jsx("span",{"aria-hidden":"true",className:"shrink-0 w-px h-[16px] bg-rule-structural"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint truncate min-w-0","data-testid":"plan-meta",children:e.validateSlug!=null&&e.epicLabel!==e.label?t.jsxs(t.Fragment,{children:[E," · ",e.epicLabel," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.width," wide · ",e.stageCount," stage",e.stageCount===1?"":"s"]}):t.jsxs(t.Fragment,{children:[E," · ",e.prdCount," PRD",e.prdCount===1?"":"s",e.width>1?` · ${e.width} wide`:""," · ",e.stageCount," stage",e.stageCount===1?"":"s"]})}),t.jsx(me,{title:`${e.doneCount} done · ${e.runningCount} running · ${e.heldCount} held · ${e.blockedCount} blocked`}),t.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-dim shrink-0","data-testid":"plan-progress-label",children:[e.doneCount,"/",e.prdCount,te]}),t.jsx(Kn,{plan:e}),K]}),d&&s==="critical"&&t.jsx(Qn,{plan:e,now:n,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i}),d&&s!=="critical"&&e.status==="active"&&t.jsx(Bn,{stages:e.stages,first:g,perView:T,onSeek:O}),d&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:h,"data-testid":"plan-stages",onScroll:W,className:"flex flex-1 min-w-0 overflow-x-auto",children:[$>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:$*ue}}),e.stages.slice($,P).map(M=>t.jsx(On,{stage:M,epicId:e.epicId,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i},M.n)),P<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-P)*ue}})]}),t.jsx(Gn,{stages:e.stages.slice(J),onSeek:O})]}),p&&k&&t.jsx(qe,{runId:k.runId,slug:k.slug,title:k.title||k.slug,onClose:()=>u(!1)})]})}function Zn({page:e,pageSize:s,totalItems:n,onPageChange:a}){if(n<=s)return null;const c=Math.max(1,Math.ceil(n/s)),l=(e-1)*s+1,i=Math.min(e*s,n);return t.jsxs("div",{"data-testid":"plan-pager",className:"flex items-center justify-center gap-3 px-[18px] py-3 font-mono text-[12px] text-fg-faint",children:[t.jsx("button",{type:"button","data-testid":"plan-pager-prev",onClick:()=>a(e-1),disabled:e<=1,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Prev"}),t.jsxs("span",{"data-testid":"plan-pager-range",children:[l,"–",i," of ",n]}),t.jsx("button",{type:"button","data-testid":"plan-pager-next",onClick:()=>a(e+1),disabled:e>=c,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Next"})]})}function ea({section:e,children:s}){const[n,a]=f.useState(!0),c=Object.entries(e.counts).map(([l,i])=>`${i} ${l.replace(/_/g," ")}`).join(" · ");return t.jsxs("div",{className:"border-t border-line","data-testid":"backlog-epic-section","data-epic-id":e.epicId??"",children:[t.jsxs("button",{type:"button",onClick:()=>a(l=>!l),className:"w-full flex items-center gap-2.5 px-[18px] py-2.5 bg-bg-elev/60 hover:bg-bg-elev text-left","aria-expanded":n,title:e.label,children:[t.jsx("span",{className:`text-fg-faint inline-flex shrink-0 transition-transform duration-150 ${n?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(nt,{name:"chevron",size:12})}),t.jsx("span",{className:"font-serif text-[14.5px] font-semibold text-fg truncate","data-testid":"backlog-epic-label",children:e.label}),t.jsxs("span",{className:"font-mono text-[11px] text-fg-faint shrink-0",children:[e.total," PRD",e.total===1?"":"s"]}),t.jsx("span",{className:"font-mono text-[11px] text-fg-faint truncate",children:c})]}),n&&s]})}const ta=[],sa=[],na={depth:0,blockers:ta,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function aa(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function ra(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function ia({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:l,hold:i,backlog:r=na,headChoices:d=sa}){const[o,p]=f.useState(!1),[u,h]=f.useState(!1),g=pe(P=>P.sessions),x=f.useMemo(()=>Pe(e,g),[e,g]),w=x.known&&x.epicId?g[x.epicId]:null,j=f.useCallback(P=>{at(P),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),D=e.status==="running",k=e.status==="failed";let E=null;D&&n!==null?E=`${Te(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?E=`took ${Ce(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(E=s);const m=e.error??null,T=k&&m?m.split(`
|
|
4
4
|
`)[0]:e.status==="needs_review"&&e.verifierVerdict?$e(e.verifierVerdict):null,$=D&&n!==null?Math.min(.99,n/a):0;return t.jsxs("div",{role:"listitem",className:"border-t border-line",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":e.status,"data-job-index":c,"data-depth":r.depth,onClick:()=>p(P=>!P),onFocus:()=>l(c),style:r.depth>0?{paddingLeft:18+r.depth*20}:void 0,className:`w-full text-left grid grid-cols-[116px_1fr_auto_auto] items-center gap-4 px-[18px] py-3.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${o?"bg-bg-elev/40":""}`,"aria-expanded":o,"aria-label":`${ie(e.slug)?`PRD ${ie(e.slug)}, `:""}${e.title}, ${e.status}${E?`, ${E}`:""}`,title:e.title,children:[t.jsx(_t,{status:e.status}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug",children:[ie(e.slug)&&t.jsx(Ot,{n:ie(e.slug)}),e.title,t.jsx(Lt,{leaked:e.leakedDescendants}),t.jsx(ks,{count:e.leftoverCount,truncated:e.leftoverPathsTruncated,salvagePatch:e.salvagePatch}),r.parallelEligible&&t.jsx("span",{"data-testid":"job-row-parallel-eligible",title:"No dependsOn, and nothing in this Epic depends on it — can run any time a slot is free",className:"text-[10px] font-semibold uppercase tracking-wide text-sage/90 bg-sage/10 border border-sage/30 rounded px-1.5 py-0.5",children:"parallel"})]}),r.cycle&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",r.blockers.map(P=>P.slug).join(" ↔ ")||"self-referencing"]}),!r.cycle&&r.blockers.length>0&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 font-mono","data-testid":"job-row-blockers",children:[t.jsx("span",{className:r.blocked||r.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:r.blocked||r.hasMissingDep?"blocked by ":"depends on "}),r.blockers.map((P,O)=>t.jsxs("span",{className:ra(P),children:[O>0&&", ",aa(P)]},P.slug))]}),T&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${k?"text-accent/80":"text-fg-faint"}`,children:T}),i&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:i.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",i.dep," (",i.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",i.reason??"launch blocked"]})}),!i&&e.status==="pending"&&e.heldReason&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-held-reason",children:["held · ",e.heldReason]}),t.jsx(rt,{epicId:x.epicId,label:x.label?zt(x.label):null,onOpen:j,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(it,{cwd:e.cwd}),t.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint shrink-0",children:[t.jsx(Ss,{status:e.status,overrun:e.overrun}),E,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${o?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(nt,{name:"chevron",size:14})})]})]}),D&&!o&&t.jsx("div",{className:"h-1 bg-line mx-[18px] mb-3 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-accent transition-all duration-1000",style:{width:`${Math.max(4,$*100)}%`}})}),o&&t.jsxs("div",{className:"px-[18px] py-5 grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-5 bg-bg-elev/50 border-t border-line",children:[t.jsxs(re,{label:"Status",children:[t.jsx(H,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(H,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(H,{k:"verdict",v:$e(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(H,{k:"leaked",v:Ft(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(H,{k:"uncommitted",v:`${e.leftoverCount} file${e.leftoverCount===1?"":"s"}${e.leftoverPathsTruncated?"+":""}: ${(e.leftoverPaths??[]).join(", ")}${e.salvagePatch?` — salvaged to ${e.salvagePatch}`:""}`,wrap:!0}),m&&t.jsx(H,{k:"error",v:m.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ap as i,S as d}from"./index-
|
|
1
|
+
import{ap as i,S as d}from"./index-AVrhGmUO.js";function a({scopes:l,active:n,onChange:o,annotate:s}){return i.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:l.map(t=>{const r=d[t],e=s==null?void 0:s(t),c=t===n;return i.jsxs("button",{title:r.hint,onClick:()=>o(t),className:`px-2.5 py-1 text-xs flex items-center gap-1.5 transition-colors ${c?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[i.jsx("span",{children:r.label}),(e==null?void 0:e.dirty)&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent",title:"unsaved edits"}),e&&e.exists===!1&&!e.dirty&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-fg-faint",title:"not yet created"})]},t)})})}export{a as S};
|