claude-code-session-manager 0.107.0 → 0.108.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.
Files changed (38) hide show
  1. package/dist/assets/{AgentLibrary-Bjeq2-kp.js → AgentLibrary-Co54GThg.js} +1 -1
  2. package/dist/assets/{Button-CRLhoI2K.js → Button-DC6VzovQ.js} +1 -1
  3. package/dist/assets/{DataModel-iPJw5jcG.js → DataModel-DZ0vyJau.js} +1 -1
  4. package/dist/assets/{History-DfPR3_6N.js → History-Df3YwpPe.js} +1 -1
  5. package/dist/assets/{Hooks-Bw7H_DmC.js → Hooks-DplG6roH.js} +1 -1
  6. package/dist/assets/{Library-rqaJJJ1b.js → Library-DLmnlfQt.js} +1 -1
  7. package/dist/assets/{ListDetail-qI27OYfy.js → ListDetail-YylbvUj_.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-BEFuHVNz.js → MarkdownEditor-DMPKWHTF.js} +1 -1
  9. package/dist/assets/{McpServers-Bz9O79rz.js → McpServers-Da-Ty5nc.js} +1 -1
  10. package/dist/assets/{Memory-DobxIoZ-.js → Memory-C3rUQ_cg.js} +1 -1
  11. package/dist/assets/{Panel-Cyt1wpUf.js → Panel-CC3JTnOI.js} +1 -1
  12. package/dist/assets/{Permissions-ChSNRUJJ.js → Permissions-XvBiMj1-.js} +1 -1
  13. package/dist/assets/{Plugins-CII221R2.js → Plugins-CzHY1mgS.js} +2 -2
  14. package/dist/assets/{ProvenanceBadge-C_sk5-v3.js → ProvenanceBadge-DaJIWVcg.js} +1 -1
  15. package/dist/assets/{SaveBar-BuYrg5E9.js → SaveBar-C06rFT34.js} +1 -1
  16. package/dist/assets/{Scheduler-eixbMGEk.js → Scheduler-BehadU-0.js} +1 -1
  17. package/dist/assets/{ScopeSwitcher-BM0gLPhd.js → ScopeSwitcher-Cp5mxblN.js} +1 -1
  18. package/dist/assets/{Settings-qD-0W-Ut.js → Settings-Cg9LIni0.js} +1 -1
  19. package/dist/assets/{SkillReferenceGraph-D0Hgdfxq.js → SkillReferenceGraph-DuWRmT_f.js} +1 -1
  20. package/dist/assets/{Skills-C3T_2_2o.js → Skills-CMmCZfIv.js} +1 -1
  21. package/dist/assets/{SystemPrompt-B-xTy9Qn.js → SystemPrompt-D_-MV025.js} +1 -1
  22. package/dist/assets/{TagLibrary-BH67tR5z.js → TagLibrary-D9Tv3yOJ.js} +1 -1
  23. package/dist/assets/{TiptapBody-CP_F_mwb.js → TiptapBody-1r4ODLJ7.js} +1 -1
  24. package/dist/assets/{Toggle-haRPHS5N.js → Toggle-BGT68XHP.js} +1 -1
  25. package/dist/assets/{ViewTabs-BHV3MA5u.js → ViewTabs-T0NBc8uv.js} +1 -1
  26. package/dist/assets/{index-v_3LvhMx.js → index-3_AtCAyd.js} +3 -3
  27. package/dist/assets/{settingsSchema-CE46TA3V.js → settingsSchema-CvoNk3Ye.js} +1 -1
  28. package/dist/assets/useAgentsDirWatch-1C2CBBya.js +1 -0
  29. package/dist/assets/{useConfigDirWatch-CjcswsWR.js → useConfigDirWatch-Cd5PnTkB.js} +1 -1
  30. package/dist/index.html +1 -1
  31. package/package.json +1 -1
  32. package/scripts/scheduler-mcp-server.cjs +38 -5
  33. package/src/main/build-info.json +4 -4
  34. package/src/main/lib/builtinMacros.cjs +2 -2
  35. package/src/main/lib/mcpToolCatalog.cjs +3 -1
  36. package/src/main/lib/shippedPersonaSeeds.cjs +11 -0
  37. package/src/seed/agents/demo-video-builder.md +69 -48
  38. package/dist/assets/useAgentsDirWatch-BZTi2K2e.js +0 -1
@@ -1,3 +1,3 @@
1
- import{aw as d,aS as z,aM as H,aU as U,aN as N,aj as W,ao as q,ad as G,ah as e,m as w,P as D,aD as Q}from"./index-v_3LvhMx.js";import{P as A}from"./Panel-Cyt1wpUf.js";import{S as X}from"./ScopeSwitcher-BM0gLPhd.js";import{S as Y}from"./SaveBar-BuYrg5E9.js";import{P as Z}from"./Library-rqaJJJ1b.js";import{u as ee,E as te,s as se}from"./settingsSchema-CE46TA3V.js";import{V as re}from"./ViewTabs-BHV3MA5u.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-CRLhoI2K.js";import"./claude-settings-schema-COigsajx.js";const ne=["allow","deny","ask"];function oe(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function ae(r,n){const o={...r,permissions:n};return JSON.stringify(o,null,2)+`
1
+ import{aw as d,aS as z,aM as H,aU as U,aN as N,aj as W,ao as q,ad as G,ah as e,m as w,P as D,aD as Q}from"./index-3_AtCAyd.js";import{P as A}from"./Panel-CC3JTnOI.js";import{S as X}from"./ScopeSwitcher-Cp5mxblN.js";import{S as Y}from"./SaveBar-C06rFT34.js";import{P as Z}from"./Library-DLmnlfQt.js";import{u as ee,E as te,s as se}from"./settingsSchema-CvoNk3Ye.js";import{V as re}from"./ViewTabs-T0NBc8uv.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-DC6VzovQ.js";import"./claude-settings-schema-COigsajx.js";const ne=["allow","deny","ask"];function oe(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function ae(r,n){const o={...r,permissions:n};return JSON.stringify(o,null,2)+`
2
2
  `}function ie(){const r=z(),n=H(),o=(n==null?void 0:n.cwd)??null,s=U(t=>t.navFace),i=d.useRef(!1),u=d.useRef(s),[x,c]=d.useState(()=>s==="project"&&o?"project":"user"),[m,P]=d.useState("effective");d.useEffect(()=>{if(u.current!==s){if(u.current=s,i.current){i.current=!1;return}c(s==="project"&&o?"project":"user")}},[s,o]),d.useEffect(()=>{s==="project"&&m==="presets"&&P("effective")},[s,m]);const J=t=>{i.current=!0,c(t)},b=ee(D,r,o),f=b[x]??null,j=N(t=>t.files),E=N(t=>t.setDraft),M=N(t=>t.saveJson),O=N(t=>t.revert),[I,y]=d.useState(null),k=e.jsx(re,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:m,onChange:P}),$=d.useMemo(()=>{const t=W(q(j,b));return G(t,["permissions"])??{kind:"object",children:{}}},[j,b]),F=(t,l)=>{var R;const a=b[x];if(!a)return;y(null);const g=((R=j[a])==null?void 0:R.draftRaw)??"";let v={};if(g.trim())try{v=JSON.parse(g)}catch{v={}}const B=Q(v.permissions??{},t,l),K={...v,permissions:B};E(a,JSON.stringify(K,null,2)+`
3
3
  `)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(A,{toolbar:k,children:e.jsx(Z,{})});const C=t=>t!=="user"&&!o,h=f?j[f]:null,{perms:p,full:L,err:T}=h?oe(h.draftRaw):{perms:{},full:{},err:null},S=t=>{f&&(y(null),E(f,ae(L,t)))},_=(t,l)=>{const a=l.trim();if(!a)return;const g=p[t]??[];g.includes(a)||S({...p,[t]:[...g,a]})},V=(t,l)=>{const a=p[t]??[];S({...p,[t]:a.filter((g,v)=>v!==l)})};return e.jsx(A,{toolbar:e.jsxs(e.Fragment,{children:[k,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(X,{scopes:D.scopes,active:x,onChange:J,annotate:t=>{if(C(t))return{exists:!1};const l=b[t];if(!l)return null;const a=j[l];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:f??"—"}),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:f&&h?e.jsx(Y,{dirty:h.dirty,busy:h.busy,parseError:I||T||h.parseError,lastSavedAt:h.lastSavedAt,onSave:async()=>{y(null);const t=await M(f);t.ok||y(t.error??"save failed")},onRevert:()=>{y(null),O(f)}}):null,children:C(x)?e.jsx(w,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):m==="effective"?e.jsx(te,{node:$,targetScope:x,onOverride:F,schema:se().rootedAt(["permissions"]),rootLabel:"permissions"}):f&&h?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[e.jsx(le,{value:p.defaultMode??"default",onChange:t=>S({...p,defaultMode:t})}),ne.map(t=>e.jsx(ce,{list:t,rules:p[t]??[],onAdd:l=>_(t,l),onRemove:l=>V(t,l)},t)),e.jsx(de,{dirs:p.additionalDirectories??[],onChange:t=>S({...p,additionalDirectories:t})})]}):e.jsx(w,{title:"resolving…"})})}const ye=d.memo(ie);function le({value:r,onChange:n}){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:()=>n(s),className:`px-2.5 py-1 text-xs transition-colors ${r===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ce({list:r,rules:n,onAdd:o,onRemove:s}){const[i,u]=d.useState(""),x=r==="allow"?"text-green-400":r==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${x}`,children:r}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,onChange:c=>u(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(o(i),u(""))},placeholder:r==="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),u("")},disabled:!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"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((c,m)=>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:c}),e.jsx("button",{onClick:()=>s(m),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${m}-${c}`))})]})}function de({dirs:r,onChange:n}){const[o,s]=d.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:o,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&o.trim()&&(n([...r,o.trim()]),s(""))},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:r.map((i,u)=>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:()=>n(r.filter((x,c)=>c!==u)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${u}-${i}`))})]})}export{ye as Permissions};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-D0Hgdfxq.js","./index-v_3LvhMx.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-tr1w3hHB.css"])))=>i.map(i=>d[i]);
2
- import{ah as e,aw as h,m as k,aS as X,aL as V,a as Y}from"./index-v_3LvhMx.js";import{P as W}from"./Panel-Cyt1wpUf.js";import{P as z}from"./ProvenanceBadge-C_sk5-v3.js";import{u as Z}from"./useConfigDirWatch-CjcswsWR.js";import{e as ee}from"./Library-rqaJJJ1b.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as te}from"./monaco-editor-BsIlgG7c.js";import{L as ne}from"./ListDetail-qI27OYfy.js";import{M as se}from"./MarkdownEditor-BEFuHVNz.js";import"./Button-CRLhoI2K.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.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))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(g=(p=i.plugins[m])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=h.lazy(()=>te(()=>import("./SkillReferenceGraph-D0Hgdfxq.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,m]=h.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=h.useMemo(()=>re(n),[n]),[d,p]=h.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.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"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.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?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const Q=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=X(),[n,o]=h.useState([]),[a,i]=h.useState(!0),[m,l]=h.useState(null),[r,d]=h.useState("installed"),[p,g]=h.useState(null),[c,E]=h.useState(new Set);h.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=h.useRef(0),$=h.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);h.useEffect(()=>{$()},[$]),h.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(z,{interactive:!1,input:Q(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=h.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(me,{seeders:f,seedStatus:p,onDismiss:s=>E(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(W,{toolbar:e.jsx(q,{active:r,onChange:d}),children:[C,e.jsx(ee,{})]});const S=m?n.find(s=>s.path===m)??null:null;return e.jsxs(W,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(q,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(he,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:m,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const Se=h.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function me({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function q({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function he({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=h.useState([]),[m,l]=h.useState([]),[r,d]=h.useState([]),[p,g]=h.useState([]),[c,E]=h.useState("skills"),[w,$]=h.useState(null),[D,f]=h.useState(!0);h.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=U[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),E(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;V.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||V.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(z,{input:Q(t)}),t.hasMcp?e.jsx(Y,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.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:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.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:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>E(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(L,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):m.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(L,{n:d+1,name:r,description:null},r))})}function L({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,m,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,E]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=E.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:m}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{Se as Plugins};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-DuWRmT_f.js","./index-3_AtCAyd.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-tr1w3hHB.css"])))=>i.map(i=>d[i]);
2
+ import{ah as e,aw as h,m as k,aS as X,aL as V,a as Y}from"./index-3_AtCAyd.js";import{P as W}from"./Panel-CC3JTnOI.js";import{P as z}from"./ProvenanceBadge-DaJIWVcg.js";import{u as Z}from"./useConfigDirWatch-Cd5PnTkB.js";import{e as ee}from"./Library-DLmnlfQt.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as te}from"./monaco-editor-BsIlgG7c.js";import{L as ne}from"./ListDetail-YylbvUj_.js";import{M as se}from"./MarkdownEditor-DMPKWHTF.js";import"./Button-DC6VzovQ.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.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))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(g=(p=i.plugins[m])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=h.lazy(()=>te(()=>import("./SkillReferenceGraph-DuWRmT_f.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,m]=h.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=h.useMemo(()=>re(n),[n]),[d,p]=h.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.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"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.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?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const Q=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=X(),[n,o]=h.useState([]),[a,i]=h.useState(!0),[m,l]=h.useState(null),[r,d]=h.useState("installed"),[p,g]=h.useState(null),[c,E]=h.useState(new Set);h.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=h.useRef(0),$=h.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);h.useEffect(()=>{$()},[$]),h.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(z,{interactive:!1,input:Q(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=h.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(me,{seeders:f,seedStatus:p,onDismiss:s=>E(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(W,{toolbar:e.jsx(q,{active:r,onChange:d}),children:[C,e.jsx(ee,{})]});const S=m?n.find(s=>s.path===m)??null:null;return e.jsxs(W,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(q,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(he,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:m,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const Se=h.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function me({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function q({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function he({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=h.useState([]),[m,l]=h.useState([]),[r,d]=h.useState([]),[p,g]=h.useState([]),[c,E]=h.useState("skills"),[w,$]=h.useState(null),[D,f]=h.useState(!0);h.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=U[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),E(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;V.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||V.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(z,{input:Q(t)}),t.hasMcp?e.jsx(Y,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.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:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.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:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>E(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(L,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):m.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(L,{n:d+1,name:r,description:null},r))})}function L({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,m,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,E]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=E.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:m}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{Se as Plugins};
@@ -1 +1 @@
1
- import{_ as P,aS as G,aw as x,ah as i,Z as _,B as R,a as T}from"./index-v_3LvhMx.js";import{a as S,C as B,c as E,d as L,b as I}from"./Library-rqaJJJ1b.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(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(E.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(E.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(S.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(S.map(e=>e.command.trim())),F=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}),w=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)?w("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?w("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?w("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.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")&&F.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?w(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(),[y,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!y)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)}},[y]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],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}),y&&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(b,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(b,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
+ import{_ as P,aS as G,aw as x,ah as i,Z as _,B as R,a as T}from"./index-3_AtCAyd.js";import{a as S,C as B,c as E,d as L,b as I}from"./Library-DLmnlfQt.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(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(E.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(E.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(S.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(S.map(e=>e.command.trim())),F=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}),w=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)?w("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?w("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?w("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.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")&&F.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?w(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(),[y,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!y)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)}},[y]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],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}),y&&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(b,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(b,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 +1 @@
1
- import{ah as e,ab as x}from"./index-v_3LvhMx.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
+ import{ah as e,ab as x}from"./index-3_AtCAyd.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{aC as Pe,ap as ie,aG as xs,ac as $e,a6 as le,aa as Z,aL as H,aZ as Le,aX as pe,aw as f,b4 as gs,a4 as ge,b3 as ms,ah as t,b as Ve,I as me,L as gt,p as bs,K as xe,t as ws,N as vs,d as js,T as ys,aW as et,aP as Ns,a0 as mt,an as It,b2 as Ce,z as Fe,at as Te,A as tt,aF as st,a7 as bt,H as Et,v as Tt,o as _t,q as ks,n as nt,x as at,O as Ss,D as re,f as B,a8 as Ot,a_ as $s,av as Cs,ay as Lt,b6 as Ft,U as Ps,aq as wt,aQ as vt,m as ke,w as jt,l as Ds,aJ as Ms,V as As,u as qt,aS as Rs,aN as ye,G as Is,C as Es,a$ as Ts,ax as _s,Q as Os,b5 as Ls,b0 as yt,aE as Fs}from"./index-v_3LvhMx.js";import{l as qs}from"./listSkills-QORduPIk.js";import{T as Bs}from"./Toggle-haRPHS5N.js";import"./monaco-editor-BsIlgG7c.js";function Hs(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 Gs(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 Vs(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=Gs(o,s),x=n.has(o.slug);u.add(o.slug);const g=x?[]:(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:g,blockers:h,blocked:h.some(w=>!w.missing&&w.status!=="completed"),hasNeedsReviewBlocker:h.some(w=>w.needsReview),hasMissingDep:h.some(w=>w.missing),cycle:x,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Bt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Hs(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=Vs(u,a,c),x={};for(const g of u){const w=g.status??"unknown";x[w]=(x[w]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:x,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 qe(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 Je(e){return String(e??"").replace(/^\d+-/,"")}function _e(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Je(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(Je(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Ws=15e4,Ke=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Ht=e=>e==="failed"||e==="needs_review"||e==="quarantined",Us=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Gt(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),c=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(c).padStart(2,"0")}s`:`${c}s`}function Vt(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 Wt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Gt(s)}function Qs(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?Ws:s/n}function Oe(e){const s=ie(e);return s===null?1/0:Number(s)}function Ye(e,s){const n=Oe(e.slug)-Oe(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function zs(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Js(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Ke(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Ks(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 Ys(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function Xs(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 Zs(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 Xs(e,s)}function en(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 tn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Je(r.row.slug).startsWith("validate-")).sort((r,d)=>Ye({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:en(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 Zs(i,r))c.push({nodes:d,validateSlug:null})}return c}function sn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function rt(e,s){if(e.length===0)return[];const n=_e(e),a=s.now??Date.now(),c=s.avgDurationMs??Qs(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(Ye).forEach((u,h)=>d.set(u.slug,h));const o=Bt(n,s.sessions,n),p=[];for(const u of o){const h=qe(u.nodes),x=new Set(h.map(D=>D.row.slug)),g=new Map(h.map(D=>[D.row.slug,D])),w=[];for(const D of tn(h,x)){const k=D.nodes,I=new Set(k.map(N=>N.row.slug)),m=new Map,E=new Set,C=N=>{const S=g.get(N);return(S.row.dependsOn??[]).filter(G=>I.has(G)&&!(S.cycle&&g.get(G).cycle))},P=N=>{const S=m.get(N);if(S!==void 0)return S;if(E.has(N))return 0;E.add(N);let G=0;for(const F of C(N))G=Math.max(G,P(F));return E.delete(N),m.set(N,G+1),G+1};for(const N of k)P(N.row.slug);const L=k.map(N=>{const S=N.row,G=(S.dependsOn??[]).filter(F=>x.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=>!x.has(F)),blockers:N.blockers,job:S}});L.sort(Ye);const K=L.reduce((N,S)=>Math.max(N,S.stage),0),W=new Map;for(const N of L){const S=N.job,G=g.get(N.slug),F=S.status;let U;if(Ke(F)){const b=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;U={kind:"done",trailing:b>0?Gt(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?"":Wt(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($=>Us($.status)),M=b[0].slug;U={kind:"dep",trailing:`←${ie(M)??M}`,held:!y,blocked:y}}else if(S.heldReason)U={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const y=zs(S),M=d.get(S.slug)??0;U=y>0?{kind:"retry",trailing:`${y} ${y===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Vt(M*c/l),held:!1,blocked:!1}}}W.set(N.slug,U)}const Q=[];for(let N=1;N<=K;N++){const S=L.filter(O=>O.stage===N),G=S.find(O=>{const se=W.get(O.slug).kind;return O.status==="pending"&&(se==="eta"||se==="retry")});if(G){const O=W.get(G.slug);O.kind="next",O.trailing="next"}let F=0,U=0,b=0,y=0,M=0,$=0;for(const O of S){const se=W.get(O.slug);O.rowKind=se.kind,O.rowTrailing=se.trailing,Ke(O.status)?F++:Se(O.status)?U++:O.status==="pending"?(M++,se.held&&b++,se.blocked&&y++):Ht(O.status)&&$++}const T=F===S.length?"done":U>0?"running":y+$>0?"blocked":b>0?"held":"pending",_={n:N,rows:S,doneCount:F,runningCount:U,heldCount:b,blockedCount:y};Q.push({..._,state:T,summary:Ks(T,_,M,$)})}let Y=0;for(const N of L){const S=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")Y+=S;else if(Se(N.status)){const G=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;Y+=Math.max(0,S-G)}}const ee=L.reduce((N,S)=>Math.min(N,Oe(S.slug)),1/0),te=L.reduce((N,S)=>Math.max(N,Oe(S.slug)),-1/0),z=u.known?xs(u.label).title:u.label,A=D.validateSlug?L.find(N=>N.slug===D.validateSlug):void 0,q=A&&sn(A.title)||z;w.push({epicId:u.epicId,waveIndex:0,index:0,label:q,epicLabel:z,validateSlug:D.validateSlug,width:Q.reduce((N,S)=>Math.max(N,S.rows.length),0),status:Js(L),prdCount:L.length,stageCount:K,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:Y/l,stages:Q,_firstNum:ee,_lastNum:te,_firstSlug:L[0].slug})}w.sort(Ys),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 x=(u.epicId??"").localeCompare(h.epicId??"");return x!==0?x:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:x,...g},w)=>({...g,index:w+1}))}function nn(e,s=Date.now()){const n=_e(e),a=new Map(n.map(x=>[x.slug,x])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const x of n)x.status==="pending"?(i++,(x.dependsOn??[]).every(w=>a.get(w)===void 0||a.get(w).status==="completed")&&l++):Se(x.status)?u++:x.status==="failed"?r++:x.status==="needs_review"?d++:x.status==="quarantined"?o++:x.status==="completed"&&x.finishedAt&&new Date(Date.parse(x.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const x of rt(n,{sessions:{},now:s}))for(const g of x.stages)if(g.rows.some(w=>Ht(w.status))){(h===null||g.n<h)&&(h=g.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 an(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 g of p.deps){if(!s.has(g)||p.cycle&&n(g))continue;const w=i(g);(!h||l(w,h))&&(h=w)}c.delete(d);const x=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,x),x};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const rn=300*6e4,ln={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function on(e){return ln[e]??e.replace(/_/g," ")}function Ut({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 x=a.length,g=u+x,w=(p==null?void 0:p.cap)??5;if(x>0){const k=a.reduce((P,L)=>(P.startedAt??"")<(L.startedAt??"")?P:L),I=k.startedAt?s-Date.parse(k.startedAt):0,m=h+x,E=h+g,C=x>1?` · ${x}/${w} parallel`:"";return{kind:"running",line1:`Running ${m}/${E}${C} · ${$e(I)}`,line2:x===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 ${Z(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(g===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(H.fromOutcome).catch(()=>H.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,I=k-s;return{kind:"on-reset",line1:`On-reset · ${u} pending`,line2:I>0?`fires ${le(k)} (in ${Z(I)})`:"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,I=o?on(o):null,m=k===null||Number.isNaN(k)||k>rn,E=k&&k>0?`resets ${le(Date.parse(r))} (in ${Z(k)})`:null;let C;return m?C=`${I??"binding"} window — long hold${E?`, ${E}`:", reset time unknown"}`:C=E?`${I?`${I} window `:""}next ${E}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${D}%)`,line2:C}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const dn=15e3,cn=new Set(["failed","needs_review","quarantined"]);function Nt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>cn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function un(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 ${Z(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?Z(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function pn(e){const[s,n]=f.useState(null),a=et(),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,H.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,dn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const fn={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 hn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function xn(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}const We="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 gn(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 ${Z(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 ${Z(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 mn({now:e}){const s=Le(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:gn(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 ${Z(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,x])=>`${h}=${x}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function bn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Le($=>$.snapshot),o=pe($=>$.sessions),p=pn(e),[u,h]=f.useState(()=>Date.now()),[x,g]=f.useState("—");f.useEffect(()=>{const $=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval($)},[]),f.useEffect(()=>{let $=!0;return gs(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(T=>{if(!$)return;const _=T.totals,O=_.inputTokens+_.outputTokens+_.cacheReadTokens+_.cacheCreationTokens;g(`$${_.estimatedCostUsd.toFixed(2)} · ${xn(O)} tok`)}).catch(()=>{}),()=>{$=!1}},[]);const w=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter($=>!e||$.cwd===e),[d,e]),j=f.useMemo(()=>nn(w,u),[w,u]),D=f.useMemo(()=>{const $=rt(w,{sessions:o,now:u}),T=_=>$.filter(O=>O.status===_).length;return{active:T("active"),queued:T("queued"),draft:T("draft")}},[w,o,u]),k=f.useMemo(()=>{const $=new Date(u).toDateString(),T=[];for(const _ of w)if(_.status==="completed"&&_.startedAt&&_.finishedAt&&new Date(Date.parse(_.finishedAt)).toDateString()===$){const O=Date.parse(_.finishedAt)-Date.parse(_.startedAt);O>0&&T.push(O)}return T.length?Math.round(T.reduce((_,O)=>_+O,0)/T.length/6e4):null},[w,u]);if(!d)return null;const I=p&&!p.unknown?p.verdict??null:null,m=p&&!p.unknown?p.slots??null:null,E=d.paused,C=hn((I==null?void 0:I.kind)??null,!!E,j.inFlight),P=fn[C],L=w.filter($=>$.status==="pending").length,K=w.filter($=>$.status==="running").length,W=Ut({snap:{...d,jobs:w},now:u,avgDurationMs:0,runningJobs:w.filter($=>$.status==="running")}),Q=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:I?un(I,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",Y=ge(d.lastRunAt?Date.parse(d.lastRunAt):null,u),ee=p!=null&&p.lastDispatchAttemptAt?ge(Date.parse(p.lastDispatchAttemptAt),u):"never",te=[Q,W.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${Z(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${Y} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${ee} (advances on every driver evaluation)`].filter(Boolean).join(`
1
+ import{aC as Pe,ap as ie,aG as xs,ac as $e,a6 as le,aa as Z,aL as H,aZ as Le,aX as pe,aw as f,b4 as gs,a4 as ge,b3 as ms,ah as t,b as Ve,I as me,L as gt,p as bs,K as xe,t as ws,N as vs,d as js,T as ys,aW as et,aP as Ns,a0 as mt,an as It,b2 as Ce,z as Fe,at as Te,A as tt,aF as st,a7 as bt,H as Et,v as Tt,o as _t,q as ks,n as nt,x as at,O as Ss,D as re,f as B,a8 as Ot,a_ as $s,av as Cs,ay as Lt,b6 as Ft,U as Ps,aq as wt,aQ as vt,m as ke,w as jt,l as Ds,aJ as Ms,V as As,u as qt,aS as Rs,aN as ye,G as Is,C as Es,a$ as Ts,ax as _s,Q as Os,b5 as Ls,b0 as yt,aE as Fs}from"./index-3_AtCAyd.js";import{l as qs}from"./listSkills-QORduPIk.js";import{T as Bs}from"./Toggle-BGT68XHP.js";import"./monaco-editor-BsIlgG7c.js";function Hs(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 Gs(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 Vs(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=Gs(o,s),x=n.has(o.slug);u.add(o.slug);const g=x?[]:(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:g,blockers:h,blocked:h.some(w=>!w.missing&&w.status!=="completed"),hasNeedsReviewBlocker:h.some(w=>w.needsReview),hasMissingDep:h.some(w=>w.missing),cycle:x,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Bt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Hs(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=Vs(u,a,c),x={};for(const g of u){const w=g.status??"unknown";x[w]=(x[w]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:x,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 qe(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 Je(e){return String(e??"").replace(/^\d+-/,"")}function _e(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Je(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(Je(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Ws=15e4,Ke=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Ht=e=>e==="failed"||e==="needs_review"||e==="quarantined",Us=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Gt(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),c=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(c).padStart(2,"0")}s`:`${c}s`}function Vt(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 Wt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Gt(s)}function Qs(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?Ws:s/n}function Oe(e){const s=ie(e);return s===null?1/0:Number(s)}function Ye(e,s){const n=Oe(e.slug)-Oe(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function zs(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Js(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Ke(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Ks(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 Ys(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function Xs(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 Zs(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 Xs(e,s)}function en(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 tn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Je(r.row.slug).startsWith("validate-")).sort((r,d)=>Ye({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:en(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 Zs(i,r))c.push({nodes:d,validateSlug:null})}return c}function sn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function rt(e,s){if(e.length===0)return[];const n=_e(e),a=s.now??Date.now(),c=s.avgDurationMs??Qs(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(Ye).forEach((u,h)=>d.set(u.slug,h));const o=Bt(n,s.sessions,n),p=[];for(const u of o){const h=qe(u.nodes),x=new Set(h.map(D=>D.row.slug)),g=new Map(h.map(D=>[D.row.slug,D])),w=[];for(const D of tn(h,x)){const k=D.nodes,I=new Set(k.map(N=>N.row.slug)),m=new Map,E=new Set,C=N=>{const S=g.get(N);return(S.row.dependsOn??[]).filter(G=>I.has(G)&&!(S.cycle&&g.get(G).cycle))},P=N=>{const S=m.get(N);if(S!==void 0)return S;if(E.has(N))return 0;E.add(N);let G=0;for(const F of C(N))G=Math.max(G,P(F));return E.delete(N),m.set(N,G+1),G+1};for(const N of k)P(N.row.slug);const L=k.map(N=>{const S=N.row,G=(S.dependsOn??[]).filter(F=>x.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=>!x.has(F)),blockers:N.blockers,job:S}});L.sort(Ye);const K=L.reduce((N,S)=>Math.max(N,S.stage),0),W=new Map;for(const N of L){const S=N.job,G=g.get(N.slug),F=S.status;let U;if(Ke(F)){const b=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;U={kind:"done",trailing:b>0?Gt(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?"":Wt(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($=>Us($.status)),M=b[0].slug;U={kind:"dep",trailing:`←${ie(M)??M}`,held:!y,blocked:y}}else if(S.heldReason)U={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const y=zs(S),M=d.get(S.slug)??0;U=y>0?{kind:"retry",trailing:`${y} ${y===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Vt(M*c/l),held:!1,blocked:!1}}}W.set(N.slug,U)}const Q=[];for(let N=1;N<=K;N++){const S=L.filter(O=>O.stage===N),G=S.find(O=>{const se=W.get(O.slug).kind;return O.status==="pending"&&(se==="eta"||se==="retry")});if(G){const O=W.get(G.slug);O.kind="next",O.trailing="next"}let F=0,U=0,b=0,y=0,M=0,$=0;for(const O of S){const se=W.get(O.slug);O.rowKind=se.kind,O.rowTrailing=se.trailing,Ke(O.status)?F++:Se(O.status)?U++:O.status==="pending"?(M++,se.held&&b++,se.blocked&&y++):Ht(O.status)&&$++}const T=F===S.length?"done":U>0?"running":y+$>0?"blocked":b>0?"held":"pending",_={n:N,rows:S,doneCount:F,runningCount:U,heldCount:b,blockedCount:y};Q.push({..._,state:T,summary:Ks(T,_,M,$)})}let Y=0;for(const N of L){const S=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")Y+=S;else if(Se(N.status)){const G=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;Y+=Math.max(0,S-G)}}const ee=L.reduce((N,S)=>Math.min(N,Oe(S.slug)),1/0),te=L.reduce((N,S)=>Math.max(N,Oe(S.slug)),-1/0),z=u.known?xs(u.label).title:u.label,A=D.validateSlug?L.find(N=>N.slug===D.validateSlug):void 0,q=A&&sn(A.title)||z;w.push({epicId:u.epicId,waveIndex:0,index:0,label:q,epicLabel:z,validateSlug:D.validateSlug,width:Q.reduce((N,S)=>Math.max(N,S.rows.length),0),status:Js(L),prdCount:L.length,stageCount:K,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:Y/l,stages:Q,_firstNum:ee,_lastNum:te,_firstSlug:L[0].slug})}w.sort(Ys),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 x=(u.epicId??"").localeCompare(h.epicId??"");return x!==0?x:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:x,...g},w)=>({...g,index:w+1}))}function nn(e,s=Date.now()){const n=_e(e),a=new Map(n.map(x=>[x.slug,x])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const x of n)x.status==="pending"?(i++,(x.dependsOn??[]).every(w=>a.get(w)===void 0||a.get(w).status==="completed")&&l++):Se(x.status)?u++:x.status==="failed"?r++:x.status==="needs_review"?d++:x.status==="quarantined"?o++:x.status==="completed"&&x.finishedAt&&new Date(Date.parse(x.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const x of rt(n,{sessions:{},now:s}))for(const g of x.stages)if(g.rows.some(w=>Ht(w.status))){(h===null||g.n<h)&&(h=g.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 an(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 g of p.deps){if(!s.has(g)||p.cycle&&n(g))continue;const w=i(g);(!h||l(w,h))&&(h=w)}c.delete(d);const x=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,x),x};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const rn=300*6e4,ln={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function on(e){return ln[e]??e.replace(/_/g," ")}function Ut({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 x=a.length,g=u+x,w=(p==null?void 0:p.cap)??5;if(x>0){const k=a.reduce((P,L)=>(P.startedAt??"")<(L.startedAt??"")?P:L),I=k.startedAt?s-Date.parse(k.startedAt):0,m=h+x,E=h+g,C=x>1?` · ${x}/${w} parallel`:"";return{kind:"running",line1:`Running ${m}/${E}${C} · ${$e(I)}`,line2:x===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 ${Z(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(g===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(H.fromOutcome).catch(()=>H.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,I=k-s;return{kind:"on-reset",line1:`On-reset · ${u} pending`,line2:I>0?`fires ${le(k)} (in ${Z(I)})`:"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,I=o?on(o):null,m=k===null||Number.isNaN(k)||k>rn,E=k&&k>0?`resets ${le(Date.parse(r))} (in ${Z(k)})`:null;let C;return m?C=`${I??"binding"} window — long hold${E?`, ${E}`:", reset time unknown"}`:C=E?`${I?`${I} window `:""}next ${E}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${D}%)`,line2:C}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const dn=15e3,cn=new Set(["failed","needs_review","quarantined"]);function Nt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>cn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function un(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 ${Z(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?Z(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function pn(e){const[s,n]=f.useState(null),a=et(),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,H.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,dn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const fn={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 hn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function xn(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}const We="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 gn(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 ${Z(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 ${Z(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 mn({now:e}){const s=Le(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:gn(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 ${Z(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,x])=>`${h}=${x}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function bn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Le($=>$.snapshot),o=pe($=>$.sessions),p=pn(e),[u,h]=f.useState(()=>Date.now()),[x,g]=f.useState("—");f.useEffect(()=>{const $=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval($)},[]),f.useEffect(()=>{let $=!0;return gs(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(T=>{if(!$)return;const _=T.totals,O=_.inputTokens+_.outputTokens+_.cacheReadTokens+_.cacheCreationTokens;g(`$${_.estimatedCostUsd.toFixed(2)} · ${xn(O)} tok`)}).catch(()=>{}),()=>{$=!1}},[]);const w=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter($=>!e||$.cwd===e),[d,e]),j=f.useMemo(()=>nn(w,u),[w,u]),D=f.useMemo(()=>{const $=rt(w,{sessions:o,now:u}),T=_=>$.filter(O=>O.status===_).length;return{active:T("active"),queued:T("queued"),draft:T("draft")}},[w,o,u]),k=f.useMemo(()=>{const $=new Date(u).toDateString(),T=[];for(const _ of w)if(_.status==="completed"&&_.startedAt&&_.finishedAt&&new Date(Date.parse(_.finishedAt)).toDateString()===$){const O=Date.parse(_.finishedAt)-Date.parse(_.startedAt);O>0&&T.push(O)}return T.length?Math.round(T.reduce((_,O)=>_+O,0)/T.length/6e4):null},[w,u]);if(!d)return null;const I=p&&!p.unknown?p.verdict??null:null,m=p&&!p.unknown?p.slots??null:null,E=d.paused,C=hn((I==null?void 0:I.kind)??null,!!E,j.inFlight),P=fn[C],L=w.filter($=>$.status==="pending").length,K=w.filter($=>$.status==="running").length,W=Ut({snap:{...d,jobs:w},now:u,avgDurationMs:0,runningJobs:w.filter($=>$.status==="running")}),Q=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:I?un(I,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",Y=ge(d.lastRunAt?Date.parse(d.lastRunAt):null,u),ee=p!=null&&p.lastDispatchAttemptAt?ge(Date.parse(p.lastDispatchAttemptAt),u):"never",te=[Q,W.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${Z(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${Y} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${ee} (advances on every driver evaluation)`].filter(Boolean).join(`
2
2
  `),z=d.utilization,A=d.pollHealth,q=A!=null&&!A.lastPollOk,N=ms(d.utilizationWindow),S=d.nextReset?Date.parse(d.nextReset):null,G=S?S>u?Z(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",M=L===0&&K===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Ve,{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":C,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${P.dot}`,"aria-hidden":"true"}),C]}),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 ",Y]}),t.jsxs(me,{title:te,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:te}),gt.scheduler&&t.jsx(bs,{content:gt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(H.fromOutcome).catch(()=>H.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:We,children:"Refresh"}),E?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:We,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:We,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(H.fromOutcome).catch(()=>H.error("Failed to fire batch")),disabled:M,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(mn,{now:u}),t.jsxs(Ve,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(xe,{testId:"kpi-window",label:N?`${N} used`:"Window used",info:q?`Billing poll failing — this reading may be outdated (last good reading ${ge(A.lastPollAt,u)}). Machine-wide ${N??"binding"} window.`:`Share of the machine-wide ${N??"binding"} billing window consumed — the window closest to its limit.`,value:z==null?"—":`${Math.round(z)}%`,sub:`resets in ${G}`,third:t.jsx(ws,{pct:z??0,tone:q?"bg-amber-500":"bg-accent"})}),t.jsx(xe,{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(vs,{filled:m.inUse,total:m.total}):null}),t.jsx(xe,{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(xe,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:Nt,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:Nt,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(xe,{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(xe,{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:x})}),t.jsx(xe,{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:$=>window.api.schedule.setConfig({firePolicy:$.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(ys,{value:U,min:0,max:10,disabled:b,onChange:$=>{window.api.schedule.setSessionSlots(Math.max(0,Math.min(10,$)))},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(js,{value:d.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Fire only when 5h utilization is below this percent — click to edit",onCommit:$=>window.api.schedule.setConfig({utilizationThreshold:$})})]}):null})]}),t.jsxs(Ve,{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($.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(([$,T])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${$}`,"aria-pressed":l===$&&s==="queue",onClick:()=>{i($),n("queue")},className:`px-2 py-0.5 text-[12px] ${l===$&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:T},$))}),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(([$,T,_])=>t.jsx("button",{type:"button",onClick:()=>n($),"aria-pressed":s===$,title:_,className:`text-[12.5px] ${s===$?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:T},$))]})]})]})}function Qt({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 wn(e){return qe([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:wn(s)}))}function vn(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 qe([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(H.fromOutcome).catch(()=>H.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 jn(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 mt(i))c.add(r)}const l=[];for(const i of s)i.archived!==!0||a.has(i.slug)||n&&i.cwd!==n||mt(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 yn=[],Nn=new Set(["failed","needs_review","quarantined"]);function kn(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 Sn(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 $n(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 Cn({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:c=yn}){const[l,i]=f.useState(!1),r=e.job,d=s!==null&&e.rowKind==="running"?Wt(r,s):e.rowTrailing,o=e.status==="completed"||e.status==="skipped",p=e.rowKind==="dep"&&e.blockers.some(h=>!h.missing&&h.status!==null&&Nn.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 ${Sn(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${kn(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] ${$n(e)}`,children:d})]}),l&&t.jsx(Pn,{row:e,elapsedMs:s,headChoices:c})]})}const Yt=f.memo(Cn);function Pn({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[c,l]=f.useState(!1),i=pe(x=>x.sessions),r=f.useMemo(()=>Pe(a,i),[a,i]),d=r.known&&r.epicId?i[r.epicId]:null,o=f.useCallback(x=>It(x),[]),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&&` · ${Ce(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(x=>x.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(x=>`${x.slug} (${x.missing?"missing":(x.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(H.fromOutcome).catch(()=>H.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(Fe,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>l(!1)})]})}const ue=190,Dn=7,Mn=5,An=[],Xt=e=>e==="completed"||e==="skipped",Zt=e=>e==="running"||e==="investigating",es=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Ae(e){return Zt(e.status)?0:es(e.status)?1:Xt(e.status)?3:2}const Rn={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},In={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function En(e,s){return e.every(n=>Xt(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&es(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function Tn({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,E)=>({r:m,i:E})).sort((m,E)=>Ae(m.r)-Ae(E.r)||m.i-E.i).map(m=>m.r),[e.rows,a]),p=f.useMemo(()=>o.filter(m=>Ae(m)<=1).length,[o]),u=Math.max(e.state==="done"?Mn:Dn,p),h=r?o:o.slice(0,u),x=r?[]:o.slice(u),g=o.find(m=>m.status==="failed"),w=o.find(m=>m.status==="needs_review"),j=p>0&&(g!==void 0||w!==void 0),D=h.reduce((m,E,C)=>Ae(E)<=1?C:m,-1),k=m=>t.jsx(Yt,{row:m,elapsedMs:Zt(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)??An},m.slug),I="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 ${In[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${Rn[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,E)=>t.jsxs("div",{children:[k(m),j&&E===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:[g&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${g.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(g.slug,g.job.cwd??void 0).then(C=>{C.ok||H.error(C.error??`Failed to reset ${g.slug}`)}).catch(()=>H.error(`Failed to reset ${g.slug}`))},className:I,children:["Retry ",g.prdNumber?`#${g.prdNumber}`:g.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&&It(s)},className:I,children:["Review ",w.prdNumber?`#${w.prdNumber}`:w.slug]})]})]},m.slug))}),(x.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 ▴":`${En(x,e.n)} ▾`})]})}const we=6,Ue=4,Ee=4,kt=12,St=5,ts=2,$t=4,_n={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function On(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function Ln(e){const s=[],n=[],a=[];let c=St;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:ts+d%Ee*we,tone:On(r.status),title:`${r.prdNumber?`#${r.prdNumber}`:r.slug} ${r.title} — ${r.status}`})}),c+=i*we+kt}return{dots:s,stageX:n,stageW:a,width:Math.max(0,c-kt)+St}}function ve(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const Xe=e=>e==="running"||e==="investigating",Ze=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Fn({stages:e,first:s,perView:n,onSeek:a}){const c=f.useMemo(()=>Ln(e),[e]),l=f.useMemo(()=>ve(e,Xe)>=0,[e]),i=f.useMemo(()=>ve(e,Ze)>=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=g=>{const w=g.currentTarget.getBoundingClientRect(),j=g.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))))},x="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-Ue)+2*ts},onPointerDown:g=>{var w,j;r.current=!0,(j=(w=g.currentTarget).setPointerCapture)==null||j.call(w,g.pointerId),h(g)},onPointerMove:g=>{r.current&&h(g)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},children:[c.dots.map((g,w)=>t.jsx("span",{title:g.title,"data-tone":g.tone,className:`absolute rounded-[1px] ${_n[g.tone]}`,style:{left:g.x,top:g.y,width:Ue,height:Ue}},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-$t,width:u-p+2*$t}})]}),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,Xe)),className:`${x} 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,Ze)),className:`${x} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const qn=148;function Bn({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:qn},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 Hn=[],Gn=e=>e==="running"||e==="investigating";function Vn(e){const s=an(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 Wn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:c}){const l=f.useMemo(()=>Vn(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(Yt,{row:i,elapsedMs:Gn(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)??Hn})}),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 Ct=1,Pt=1350,Un={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},Qn={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"}},zn=e=>String(e).padStart(2,"0");function Jn({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 Kn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i,onOpenPrds:r}){var te,z;const[d,o]=f.useState(e.status==="active"||e.status==="queued"),[p,u]=f.useState(!1),h=f.useRef(null),[x,g]=f.useState(0),[w,j]=f.useState(Pt),D=f.useMemo(()=>{const A=ve(e.stages,Xe);return A>=0?A:Math.max(0,ve(e.stages,Ze))},[e.stages]);f.useLayoutEffect(()=>{if(!d)return;const A=h.current,q=(A==null?void 0:A.clientWidth)||Pt,N=Math.max(0,Math.min(D,e.stageCount-Math.max(1,Math.ceil(q/ue))));A!=null&&A.clientWidth&&j(A.clientWidth),A&&(A.scrollLeft=N*ue),g(N)},[d]);const k=f.useMemo(()=>{let A=null;for(const q of e.stages)for(const N of q.rows){if(!N.job.runId)continue;const S=N.job.finishedAt?Date.parse(N.job.finishedAt):0;(!A||S>A.at)&&(A={runId:N.job.runId,slug:N.slug,title:N.title,at:S})}return A},[e.stages]),I=Te((z=(te=e.stages[0])==null?void 0:te.rows[0])==null?void 0:z.job.cwd)??"—",m=Qn[e.status],E=Math.max(1,Math.ceil(w/ue)),C=Math.max(0,Math.min(x-Ct,e.stageCount)),P=Math.min(e.stageCount,x+E+Ct),L=A=>{const q=Math.max(0,Math.min(e.stageCount-1,A));h.current&&(h.current.scrollLeft=q*ue),g(q)},K=Math.min(e.stageCount,x+E),W=A=>{const q=A.currentTarget,N=Math.floor(q.scrollLeft/ue);N!==x&&g(N),q.clientWidth&&q.clientWidth!==w&&j(q.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",Y=(()=>{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(()=>H.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(H.fromOutcome).catch(()=>H.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 A,q;return r==null?void 0:r(((q=(A=e.stages[0])==null?void 0:A.rows[0])==null?void 0:q.slug)??null)},className:Q,children:"Schedule…"})}})(),ee=e.etaMs>0?` · ${Vt(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] ${Un[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(A=>!A),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:zn(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:[I," · ",e.epicLabel," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.width," wide · ",e.stageCount," stage",e.stageCount===1?"":"s"]}):t.jsxs(t.Fragment,{children:[I," · ",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,ee]}),t.jsx(Jn,{plan:e}),Y]}),d&&s==="critical"&&t.jsx(Wn,{plan:e,now:n,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i}),d&&s!=="critical"&&e.status==="active"&&t.jsx(Fn,{stages:e.stages,first:x,perView:E,onSeek:L}),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:[C>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:C*ue}}),e.stages.slice(C,P).map(A=>t.jsx(Tn,{stage:A,epicId:e.epicId,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i},A.n)),P<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-P)*ue}})]}),t.jsx(Bn,{stages:e.stages.slice(K),onSeek:L})]}),p&&k&&t.jsx(Fe,{runId:k.runId,slug:k.slug,title:k.title||k.slug,onClose:()=>u(!1)})]})}function Yn({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 Xn({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(tt,{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 Zn=[],ea=[],ta={depth:0,blockers:Zn,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function sa(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function na(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function aa({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:l,hold:i,backlog:r=ta,headChoices:d=ea}){const[o,p]=f.useState(!1),[u,h]=f.useState(!1),x=pe(P=>P.sessions),g=f.useMemo(()=>Pe(e,x),[e,x]),w=g.known&&g.epicId?x[g.epicId]:null,j=f.useCallback(P=>{st(P),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),D=e.status==="running",k=e.status==="failed";let I=null;D&&n!==null?I=`${bt(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?I=`took ${$e(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(I=s);const m=e.error??null,E=k&&m?m.split(`
4
4
  `)[0]:e.status==="needs_review"&&e.verifierVerdict?Ce(e.verifierVerdict):null,C=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}${I?`, ${I}`:""}`,title:e.title,children:[t.jsx(Et,{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(Tt,{n:ie(e.slug)}),e.title,t.jsx(_t,{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,L)=>t.jsxs("span",{className:na(P),children:[L>0&&", ",sa(P)]},P.slug))]}),E&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${k?"text-accent/80":"text-fg-faint"}`,children:E}),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(nt,{epicId:g.epicId,label:g.label?zt(g.label):null,onOpen:j,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(at,{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}),I,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${o?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(tt,{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,C*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(B,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(B,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(B,{k:"verdict",v:Ce(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Ot(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(B,{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(B,{k:"error",v:m.split(`
@@ -1 +1 @@
1
- import{ah as i,S as d}from"./index-v_3LvhMx.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};
1
+ import{ah as i,S as d}from"./index-3_AtCAyd.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};